From 0f5b4276488b962fc2facb2c6ea8d2faa070b9c2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 12 Jul 2014 11:45:24 +0800 Subject: [PATCH 1/6] Always shows window frame except for maximized window on Unity. --- brightray/browser/views/views_delegate.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/brightray/browser/views/views_delegate.cc b/brightray/browser/views/views_delegate.cc index 6ade87e338..8da35dea80 100644 --- a/brightray/browser/views/views_delegate.cc +++ b/brightray/browser/views/views_delegate.cc @@ -6,6 +6,10 @@ #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" +#if defined(OS_LINUX) +#include "ui/views/linux_ui/linux_ui.h" +#endif + namespace brightray { ViewsDelegate::ViewsDelegate() { @@ -95,7 +99,14 @@ base::TimeDelta ViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() { } bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { - return maximized; +#if defined(OS_LINUX) + // On Ubuntu Unity, the system always provides a title bar for maximized + // windows. + views::LinuxUI* ui = views::LinuxUI::instance(); + return maximized && ui && ui->UnityIsRunning(); +#else + return false; +#endif } } // namespace brightray From 8d3f615e61b519c2a1c738a212dd0e3b75b24edc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 12 Jul 2014 19:46:26 +0800 Subject: [PATCH 2/6] win: Setup font. --- brightray/browser/browser_main_parts.cc | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index 8518066456..0dd21b4f66 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -24,8 +24,29 @@ #include "browser/views/views_delegate.h" #endif +#if defined(OS_WIN) +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/l10n/l10n_util_win.h" +#include "ui/gfx/platform_font_win.h" +#endif + namespace brightray { +#if defined(OS_WIN) +namespace { + +// gfx::Font callbacks +void AdjustUIFont(LOGFONT* logfont) { + l10n_util::AdjustUIFont(logfont); +} + +int GetMinimumFontSize() { + return 10; +} + +} // namespace +#endif + BrowserMainParts::BrowserMainParts() { } @@ -51,6 +72,11 @@ void BrowserMainParts::ToolkitInitialized() { #if defined(TOOLKIT_VIEWS) views_delegate_.reset(new ViewsDelegate); #endif + +#if defined(OS_WIN) + gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont; + gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize; +#endif } void BrowserMainParts::PreMainMessageLoopStart() { From cf1009ab3019a7119aefbd3b5b65d3be57735efe Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 12 Jul 2014 21:16:13 +0800 Subject: [PATCH 3/6] Refactor the AddPakPaths to make it possible to set pak's scale factor. This is needed when adding high DPI resources. --- brightray/common/main_delegate.cc | 8 +------- brightray/common/main_delegate.h | 9 ++++++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/brightray/common/main_delegate.cc b/brightray/common/main_delegate.cc index ea0cbdddb5..cf0a16fb27 100644 --- a/brightray/common/main_delegate.cc +++ b/brightray/common/main_delegate.cc @@ -49,13 +49,7 @@ void MainDelegate::InitializeResourceBundle() { #endif ui::ResourceBundle::InitSharedInstanceWithPakPath(path); - - std::vector pak_paths; - AddPakPaths(&pak_paths); - for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it) { - ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( - *it, ui::SCALE_FACTOR_NONE); - } + AddDataPackFromPath(&ui::ResourceBundle::GetSharedInstance(), path.DirName()); } content::ContentBrowserClient* MainDelegate::CreateContentBrowserClient() { diff --git a/brightray/common/main_delegate.h b/brightray/common/main_delegate.h index 1a6b243a40..7cfd7758d9 100644 --- a/brightray/common/main_delegate.h +++ b/brightray/common/main_delegate.h @@ -5,8 +5,6 @@ #ifndef BRIGHTRAY_COMMON_MAIN_DELEGATE_H_ #define BRIGHTRAY_COMMON_MAIN_DELEGATE_H_ -#include - #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "content/public/app/content_main_delegate.h" @@ -15,6 +13,10 @@ namespace base { class FilePath; } +namespace ui { +class ResourceBundle; +} + namespace brightray { class BrowserClient; @@ -36,7 +38,8 @@ class MainDelegate : public content::ContentMainDelegate { // Subclasses can override this to provide additional .pak files to be // included in the ui::ResourceBundle. - virtual void AddPakPaths(std::vector* pak_paths) {} + virtual void AddDataPackFromPath( + ui::ResourceBundle* bundle, const base::FilePath& pak_dir) {} #if defined(OS_MACOSX) // Subclasses can override this to custom the paths of child process and From 9d4e977c014840d9f2ba33803ddc0f2921e0066b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 12 Jul 2014 21:26:29 +0800 Subject: [PATCH 4/6] win: Fix window frame on detached window. --- .../browser/views/inspectable_web_contents_view_views.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/brightray/browser/views/inspectable_web_contents_view_views.cc b/brightray/browser/views/inspectable_web_contents_view_views.cc index 46c337515c..4032ef08ec 100644 --- a/brightray/browser/views/inspectable_web_contents_view_views.cc +++ b/brightray/browser/views/inspectable_web_contents_view_views.cc @@ -140,7 +140,11 @@ void InspectableWebContentsViewViews::SetIsDocked(bool docked) { devtools_window_web_view_, devtools_window_.get()); params.top_level = true; + params.bounds = inspectable_web_contents()->GetDevToolsBounds(); +#if defined(USE_X11) + // In X11 the window frame is drawn by the application. params.remove_standard_frame = true; +#endif devtools_window_->Init(params); } From 46e765f79b208d2d5fbf561ba8abbb28d8de9802 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 13 Jul 2014 10:08:28 +0800 Subject: [PATCH 5/6] Fix crash when closing docked devtools by clicking close button. We need to send ack for the close message, so we should destroy web contents after the beforeunload event has fired. --- brightray/browser/inspectable_web_contents_impl.cc | 6 +++++- brightray/browser/inspectable_web_contents_impl.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index e7a1518110..69eda18494 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -176,7 +176,7 @@ void InspectableWebContentsImpl::ActivateWindow() { } void InspectableWebContentsImpl::CloseWindow() { - CloseDevTools(); + devtools_web_contents()->GetMainFrame()->DispatchBeforeUnload(false); } void InspectableWebContentsImpl::SetContentsResizingStrategy( @@ -305,4 +305,8 @@ void InspectableWebContentsImpl::HandleKeyboardEvent( delegate->HandleKeyboardEvent(source, event); } +void InspectableWebContentsImpl::CloseContents(content::WebContents* source) { + CloseDevTools(); +} + } // namespace brightray diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 1fcfff5537..dd115cdd1e 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -109,6 +109,7 @@ class InspectableWebContentsImpl : virtual void HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE; + virtual void CloseContents(content::WebContents* source) OVERRIDE; scoped_ptr web_contents_; scoped_ptr frontend_host_; From a318b1c5d1da651d6da71b85dbfb3f55f676e6da Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 14 Jul 2014 15:56:04 +0800 Subject: [PATCH 6/6] views: Use DesktopNativeWidgetAura for menu view. --- brightray/browser/views/views_delegate.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brightray/browser/views/views_delegate.cc b/brightray/browser/views/views_delegate.cc index 8da35dea80..7f2a2249df 100644 --- a/brightray/browser/views/views_delegate.cc +++ b/brightray/browser/views/views_delegate.cc @@ -89,7 +89,8 @@ void ViewsDelegate::OnBeforeWidgetInit( return; // The native_widget is required when using aura. - if (params->parent == NULL && params->context == NULL && !params->child) + if (params->type == views::Widget::InitParams::TYPE_MENU || + (params->parent == NULL && params->context == NULL && !params->child)) params->native_widget = new views::DesktopNativeWidgetAura(delegate); }