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() { 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_; 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); } diff --git a/brightray/browser/views/views_delegate.cc b/brightray/browser/views/views_delegate.cc index 6ade87e338..7f2a2249df 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() { @@ -85,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); } @@ -95,7 +100,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 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