diff options
35 files changed, 153 insertions, 130 deletions
diff --git a/chrome/app/chrome_command_ids.h b/chrome/app/chrome_command_ids.h index 3bf6071..b149d62 100644 --- a/chrome/app/chrome_command_ids.h +++ b/chrome/app/chrome_command_ids.h @@ -54,7 +54,6 @@ #define IDC_SEARCH 34035 #define IDC_TABPOSE 34036 #define IDC_COMPACT_NAVBAR 34037 -#define IDC_DEBUG_FRAME_TOGGLE 34038 // Page-related commands #define IDC_BOOKMARK_PAGE 35000 diff --git a/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc b/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc index e6f0640..2932112 100644 --- a/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc +++ b/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc @@ -13,7 +13,7 @@ namespace browser { BrowserNonClientFrameView* CreateBrowserNonClientFrameView( BrowserFrame* frame, BrowserView* browser_view) { if (browser_view->IsBrowserTypePopup() || browser_view->IsBrowserTypePanel()) - return new PopupNonClientFrameView(frame); + return new PopupNonClientFrameView(); else return new chromeos::BrowserFrameViewChromeos(frame, browser_view); } diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index 36033cf..56ac022 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -932,11 +932,7 @@ bool ExternalTabContainer::DrawInfoBarArrows(int* x) const { } // ExternalTabContainer instances do not have a window. -views::Window* ExternalTabContainer::GetContainingWindow() { - return NULL; -} - -const views::Window* ExternalTabContainer::GetContainingWindow() const { +views::Window* ExternalTabContainer::GetWindow() { return NULL; } diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index 6239386..4a3ac39 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -187,8 +187,7 @@ class ExternalTabContainer : public TabContentsDelegate, static scoped_refptr<ExternalTabContainer> RemovePendingTab(uintptr_t cookie); // Overridden from views::WidgetWin: - virtual views::Window* GetContainingWindow() OVERRIDE; - virtual const views::Window* GetContainingWindow() const OVERRIDE; + virtual views::Window* GetWindow(); // Handles the specified |accelerator| being pressed. bool AcceleratorPressed(const views::Accelerator& accelerator); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index cbbb22f..a9619cf 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -3740,7 +3740,6 @@ void Browser::InitCommandState() { command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, false); command_updater_.UpdateCommandEnabled(IDC_EXIT, true); command_updater_.UpdateCommandEnabled(IDC_TOGGLE_VERTICAL_TABS, true); - command_updater_.UpdateCommandEnabled(IDC_DEBUG_FRAME_TOGGLE, true); // Page-related commands command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true); diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc index d90c4ac..ee035f2 100644 --- a/chrome/browser/ui/panels/panel_browser_frame_view.cc +++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc @@ -141,7 +141,6 @@ PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame, title_icon_(NULL), title_label_(NULL) { EnsureResourcesInitialized(); - frame_->set_frame_type(views::Window::FRAME_TYPE_FORCE_CUSTOM); options_button_ = new views::MenuButton(NULL, std::wstring(), this, false); options_button_->SetIcon(*(options_button_resources.normal_image)); @@ -202,6 +201,10 @@ gfx::Rect PanelBrowserFrameView::GetBoundsForClientView() const { return client_view_bounds_; } +bool PanelBrowserFrameView::AlwaysUseCustomFrame() const { + return true; +} + gfx::Rect PanelBrowserFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { int top_height = NonClientTopBorderHeight(); @@ -212,6 +215,10 @@ gfx::Rect PanelBrowserFrameView::GetWindowBoundsForClientBounds( client_bounds.height() + top_height + border_thickness); } +bool PanelBrowserFrameView::AlwaysUseNativeFrame() const { + return frame_->AlwaysUseNativeFrame(); +} + int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) { if (!bounds().Contains(point)) return HTNOWHERE; diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.h b/chrome/browser/ui/panels/panel_browser_frame_view.h index 756a2bc..e1303e8 100644 --- a/chrome/browser/ui/panels/panel_browser_frame_view.h +++ b/chrome/browser/ui/panels/panel_browser_frame_view.h @@ -42,6 +42,8 @@ class PanelBrowserFrameView : public BrowserNonClientFrameView, // Overridden from views::NonClientFrameView: virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; + virtual bool AlwaysUseCustomFrame() const OVERRIDE; + virtual bool AlwaysUseNativeFrame() const OVERRIDE; virtual gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const OVERRIDE; virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; diff --git a/chrome/browser/ui/views/constrained_window_views.cc b/chrome/browser/ui/views/constrained_window_views.cc index 4d63c11..ef8f72c 100644 --- a/chrome/browser/ui/views/constrained_window_views.cc +++ b/chrome/browser/ui/views/constrained_window_views.cc @@ -155,6 +155,7 @@ class ConstrainedWindowFrameView // Overridden from views::NonClientFrameView: virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; + virtual bool AlwaysUseCustomFrame() const OVERRIDE; virtual gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const OVERRIDE; virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; @@ -272,10 +273,6 @@ ConstrainedWindowFrameView::ConstrainedWindowFrameView( InitClass(); InitWindowResources(); - // Constrained windows always use the custom frame - they just have a - // different set of bitmaps. - container->set_frame_type(views::Window::FRAME_TYPE_FORCE_CUSTOM); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); close_button_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_CLOSE_SA)); @@ -302,6 +299,12 @@ gfx::Rect ConstrainedWindowFrameView::GetBoundsForClientView() const { return client_view_bounds_; } +bool ConstrainedWindowFrameView::AlwaysUseCustomFrame() const { + // Constrained windows always use the custom frame - they just have a + // different set of bitmaps. + return true; +} + gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { int top_height = NonClientTopBorderHeight(); diff --git a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc index 68816a2..3f25d88 100644 --- a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc @@ -65,8 +65,6 @@ AppPanelBrowserFrameView::AppPanelBrowserFrameView(BrowserFrame* frame, DCHECK(browser_view->ShouldShowWindowIcon()); DCHECK(browser_view->ShouldShowWindowTitle()); - frame_->set_frame_type(views::Window::FRAME_TYPE_FORCE_CUSTOM); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); close_button_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_CLOSE_BAR)); @@ -126,6 +124,14 @@ gfx::Rect AppPanelBrowserFrameView::GetBoundsForClientView() const { return client_view_bounds_; } +bool AppPanelBrowserFrameView::AlwaysUseCustomFrame() const { + return true; +} + +bool AppPanelBrowserFrameView::AlwaysUseNativeFrame() const { + return frame_->AlwaysUseNativeFrame(); +} + gfx::Rect AppPanelBrowserFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { int top_height = NonClientTopBorderHeight(); diff --git a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.h b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.h index c896f9f..f13496d 100644 --- a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.h +++ b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.h @@ -41,6 +41,8 @@ class AppPanelBrowserFrameView : public BrowserNonClientFrameView, protected: // Overridden from views::NonClientFrameView: virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; + virtual bool AlwaysUseCustomFrame() const OVERRIDE; + virtual bool AlwaysUseNativeFrame() const OVERRIDE; virtual gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const OVERRIDE; virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc index 3deb8e3..0b0842e 100644 --- a/chrome/browser/ui/views/frame/browser_frame.cc +++ b/chrome/browser/ui/views/frame/browser_frame.cc @@ -69,6 +69,22 @@ void BrowserFrame::UpdateThrobber(bool running) { browser_frame_view_->UpdateThrobber(running); } +bool BrowserFrame::AlwaysUseNativeFrame() const { + // App panel windows draw their own frame. + if (browser_view_->IsBrowserTypePanel()) + return false; + + // We don't theme popup or app windows, so regardless of whether or not a + // theme is active for normal browser windows, we don't want to use the custom + // frame for popups/apps. + if (!browser_view_->IsBrowserTypeNormal() && ShouldUseNativeFrame()) + return true; + + // Otherwise, we use the native frame when we're told we should by the theme + // provider (e.g. no custom theme is active). + return GetThemeProvider()->ShouldUseNativeFrame(); +} + views::View* BrowserFrame::GetFrameView() const { return browser_frame_view_; } @@ -104,7 +120,7 @@ views::RootView* BrowserFrame::CreateRootView() { views::NonClientFrameView* BrowserFrame::CreateFrameViewForWindow() { #if defined(OS_WIN) - if (ShouldUseNativeFrame()) { + if (AlwaysUseNativeFrame()) { browser_frame_view_ = new GlassBrowserFrameView(this, browser_view_); } else { #endif diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h index 8747bed..2c07fd2 100644 --- a/chrome/browser/ui/views/frame/browser_frame.h +++ b/chrome/browser/ui/views/frame/browser_frame.h @@ -61,6 +61,11 @@ class BrowserFrame : public views::Window { // Tells the frame to update the throbber. void UpdateThrobber(bool running); + // Returns true if the window should use the native frame view. This is true + // if there are no themes applied on Vista, or if there are themes applied and + // this browser window is an app or popup. + bool AlwaysUseNativeFrame() const; + // Returns the NonClientFrameView of this frame. views::View* GetFrameView() const; diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc index 808cd39a3..1982d43 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_win.cc @@ -13,7 +13,6 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "grit/theme_resources.h" -#include "ui/base/theme_provider.h" #include "ui/gfx/font.h" #include "views/screen.h" #include "views/window/non_client_view.h" @@ -65,7 +64,7 @@ int BrowserFrameWin::GetShowState() const { gfx::Insets BrowserFrameWin::GetClientAreaInsets() const { // Use the default client insets for an opaque frame or a glass popup/app // frame. - if (!GetWindow()->ShouldUseNativeFrame() || + if (!GetWindow()->non_client_view()->UseNativeFrame() || !browser_view_->IsBrowserTypeNormal()) { return WindowWin::GetClientAreaInsets(); } @@ -120,24 +119,6 @@ void BrowserFrameWin::OnScreenReaderDetected() { WindowWin::OnScreenReaderDetected(); } -bool BrowserFrameWin::ShouldUseNativeFrame() const { - // App panel windows draw their own frame. - if (browser_view_->IsBrowserTypePanel()) - return false; - - // We don't theme popup or app windows, so regardless of whether or not a - // theme is active for normal browser windows, we don't want to use the custom - // frame for popups/apps. - if (!browser_view_->IsBrowserTypeNormal() && - WindowWin::ShouldUseNativeFrame()) { - return true; - } - - // Otherwise, we use the native frame when we're told we should by the theme - // provider (e.g. no custom theme is active). - return GetWidget()->GetThemeProvider()->ShouldUseNativeFrame(); -} - //////////////////////////////////////////////////////////////////////////////// // BrowserFrameWin, NativeBrowserFrame implementation: @@ -170,7 +151,7 @@ void BrowserFrameWin::TabStripDisplayModeChanged() { void BrowserFrameWin::UpdateDWMFrame() { // Nothing to do yet, or we're not showing a DWM frame. - if (!GetWindow()->client_view() || !browser_frame_->ShouldUseNativeFrame()) + if (!GetWindow()->client_view() || !browser_frame_->AlwaysUseNativeFrame()) return; MARGINS margins = { 0 }; diff --git a/chrome/browser/ui/views/frame/browser_frame_win.h b/chrome/browser/ui/views/frame/browser_frame_win.h index 499b15c..d7249f4 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.h +++ b/chrome/browser/ui/views/frame/browser_frame_win.h @@ -43,7 +43,6 @@ class BrowserFrameWin : public views::WindowWin, BOOL is_system_menu) OVERRIDE; virtual void OnWindowPosChanged(WINDOWPOS* window_pos) OVERRIDE; virtual void OnScreenReaderDetected() OVERRIDE; - virtual bool ShouldUseNativeFrame() const OVERRIDE; // Overridden from NativeBrowserFrame: virtual views::NativeWindow* AsNativeWindow() OVERRIDE; diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc index 2d82fa0..cda4b37 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc @@ -13,7 +13,7 @@ namespace browser { BrowserNonClientFrameView* CreateBrowserNonClientFrameView( BrowserFrame* frame, BrowserView* browser_view) { if (browser_view->IsBrowserTypePopup() || browser_view->IsBrowserTypePanel()) - return new PopupNonClientFrameView(frame); + return new PopupNonClientFrameView(); else return new OpaqueBrowserFrameView(frame, browser_view); } diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 18732f9..1f6dee6 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -1554,10 +1554,7 @@ bool BrowserView::ShouldShowWindowIcon() const { bool BrowserView::ExecuteWindowsCommand(int command_id) { // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. -#if defined(OS_WIN) - if (command_id == IDC_DEBUG_FRAME_TOGGLE) - GetWindow()->DebugToggleFrameType(); -#endif + // Translate WM_APPCOMMAND command ids into a command id that the browser // knows how to handle. int command_id_from_app_command = GetCommandIDForAppCommandID(command_id); @@ -1804,7 +1801,7 @@ void BrowserView::GetAccessibleState(ui::AccessibleViewState* state) { SkColor BrowserView::GetInfoBarSeparatorColor() const { // NOTE: Keep this in sync with ToolbarView::OnPaint()! - return (IsTabStripVisible() || !frame_->ShouldUseNativeFrame()) ? + return (IsTabStripVisible() || !frame_->non_client_view()->UseNativeFrame()) ? ResourceBundle::toolbar_separator_color : SK_ColorBLACK; } @@ -2359,7 +2356,6 @@ void BrowserView::BuildSystemMenuForBrowserWindow() { system_menu_contents_->AddSeparator(); system_menu_contents_->AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); - AddFrameToggleItems(); // If it's a regular browser window with tabs, we don't add any more items, // since it already has menus (Page, Chrome). } @@ -2400,16 +2396,6 @@ void BrowserView::BuildSystemMenuForAppOrPopupWindow() { IDS_CONTENT_CONTEXT_FORWARD); system_menu_contents_->AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); - AddFrameToggleItems(); -} - -void BrowserView::AddFrameToggleItems() { - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDebugEnableFrameToggle)) { - system_menu_contents_->AddSeparator(); - system_menu_contents_->AddItem(IDC_DEBUG_FRAME_TOGGLE, - L"Toggle Frame Type"); - } } #endif diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 150739f..b15312f 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -523,9 +523,6 @@ class BrowserView : public BrowserBubbleHost, // Builds the correct menu for when we have minimal chrome. void BuildSystemMenuForBrowserWindow(); void BuildSystemMenuForAppOrPopupWindow(); - - // Adds optional debug items for frame type toggling. - void AddFrameToggleItems(); #endif // Retrieves the command id for the specified Windows app command. diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc index d5dd6aa8..11e2950 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc @@ -171,6 +171,10 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { return client_view_bounds_; } +bool GlassBrowserFrameView::AlwaysUseNativeFrame() const { + return frame_->AlwaysUseNativeFrame(); +} + gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { HWND hwnd = frame_->GetNativeWindow(); diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.h b/chrome/browser/ui/views/frame/glass_browser_frame_view.h index fcec367..4137648 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.h +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.h @@ -35,6 +35,7 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView, // Overridden from views::NonClientFrameView: virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; + virtual bool AlwaysUseNativeFrame() const OVERRIDE; virtual gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const OVERRIDE; virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index a81140e..7efd98b 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -336,6 +336,14 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { return client_view_bounds_; } +bool OpaqueBrowserFrameView::AlwaysUseNativeFrame() const { + return frame_->AlwaysUseNativeFrame(); +} + +bool OpaqueBrowserFrameView::AlwaysUseCustomFrame() const { + return true; +} + gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { int top_height = NonClientTopBorderHeight(false, false); diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h index 03ef113..9cc00e3 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h @@ -79,6 +79,8 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, // Overridden from views::NonClientFrameView: virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; + virtual bool AlwaysUseNativeFrame() const OVERRIDE; + virtual bool AlwaysUseCustomFrame() const OVERRIDE; virtual gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const OVERRIDE; virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; diff --git a/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc b/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc index c2e6f63..cd075d9 100644 --- a/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc +++ b/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc @@ -4,7 +4,6 @@ #include "chrome/browser/ui/views/frame/popup_non_client_frame_view.h" -#include "chrome/browser/ui/views/frame/browser_frame.h" #include "ui/gfx/point.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" @@ -13,14 +12,18 @@ #include "views/window/hit_test.h" #endif -PopupNonClientFrameView::PopupNonClientFrameView(BrowserFrame* frame) { - frame->set_frame_type(views::Window::FRAME_TYPE_FORCE_NATIVE); -} - gfx::Rect PopupNonClientFrameView::GetBoundsForClientView() const { return gfx::Rect(0, 0, width(), height()); } +bool PopupNonClientFrameView::AlwaysUseCustomFrame() const { + return false; +} + +bool PopupNonClientFrameView::AlwaysUseNativeFrame() const { + return true; +} + gfx::Rect PopupNonClientFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { return client_bounds; diff --git a/chrome/browser/ui/views/frame/popup_non_client_frame_view.h b/chrome/browser/ui/views/frame/popup_non_client_frame_view.h index d15cd9b..abd4875 100644 --- a/chrome/browser/ui/views/frame/popup_non_client_frame_view.h +++ b/chrome/browser/ui/views/frame/popup_non_client_frame_view.h @@ -13,10 +13,12 @@ // nothing. class PopupNonClientFrameView : public BrowserNonClientFrameView { public: - explicit PopupNonClientFrameView(BrowserFrame* frame); + PopupNonClientFrameView() {} // NonClientFrameView: virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; + virtual bool AlwaysUseCustomFrame() const OVERRIDE; + virtual bool AlwaysUseNativeFrame() const OVERRIDE; virtual gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const OVERRIDE; virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index 4d3ab10..e3f62d2 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -450,7 +450,7 @@ void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { int tab_id; if (GetWidget() && - GetWidget()->GetContainingWindow()->ShouldUseNativeFrame()) { + GetWidget()->GetContainingWindow()->non_client_view()->UseNativeFrame()) { tab_id = IDR_THEME_TAB_BACKGROUND_V; } else { tab_id = data().incognito ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 6c014cc..15790fa 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -302,7 +302,7 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) { } } - if (GetWindow()->ShouldUseNativeFrame()) { + if (GetWindow()->non_client_view()->UseNativeFrame()) { bool multiple_tabs_selected = (!selected_tabs.empty() || tabs_dragging.size() > 1); // Make sure non-active tabs are somewhat transparent. diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index adc3786b..b45c46a 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -466,7 +466,7 @@ gfx::Size ToolbarView::GetPreferredSize() { } int vertical_spacing = PopupTopSpacing() + - (GetWindow()->ShouldUseNativeFrame() ? + (GetWindow()->non_client_view()->UseNativeFrame() ? kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); return gfx::Size(0, location_bar_->GetPreferredSize().height() + vertical_spacing); @@ -566,7 +566,7 @@ void ToolbarView::OnPaint(gfx::Canvas* canvas) { // it from the content area. For non-glass, the NonClientView draws the // toolbar background below the location bar for us. // NOTE: Keep this in sync with BrowserView::GetInfoBarSeparatorColor()! - if (GetWindow()->ShouldUseNativeFrame()) + if (GetWindow()->non_client_view()->UseNativeFrame()) canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); } @@ -646,7 +646,7 @@ int ToolbarView::PopupTopSpacing() const { // it's possible the crash may just show up somewhere else. const views::Window* window = GetWindow(); DCHECK(window) << "If you hit this please talk to beng"; - return window && window->ShouldUseNativeFrame() ? + return window && window->non_client_view()->UseNativeFrame() ? 0 : kPopupTopSpacingNonGlass; } diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 220818d..4afe3a8 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -150,10 +150,6 @@ const char kCountry[] = "country"; // without having to restart the browser). const char kDebugDevToolsFrontend[] = "debug-devtools-frontend"; -// Enables a frame context menu item that toggles the frame in and out of glass -// mode (Windows Vista and up only). -const char kDebugEnableFrameToggle[] = "debug-enable-frame-toggle"; - // Enables support to debug printing subsystem. const char kDebugPrint[] = "debug-print"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index b39a415..aa4cb99 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -57,7 +57,6 @@ extern const char kCloudPrintServiceURL[]; extern const char kConflictingModulesCheck[]; extern const char kCountry[]; extern const char kDebugDevToolsFrontend[]; -extern const char kDebugEnableFrameToggle[]; extern const char kDebugPrint[]; extern const char kDeviceManagementUrl[]; extern const char kDiagnostics[]; diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index c1a7cf0..460fa5d 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -564,8 +564,7 @@ LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) { // Windows special DWM window frame requires a special tooltip manager so // that window controls in Chrome windows don't flicker when you move your // mouse over them. See comment in aero_tooltip_manager.h. - Window* window = GetWidget()->GetContainingWindow(); - if (window && window->ShouldUseNativeFrame()) { + if (GetWidget()->GetThemeProvider()->ShouldUseNativeFrame()) { tooltip_manager_.reset(new AeroTooltipManager(GetWidget())); } else { tooltip_manager_.reset(new TooltipManagerWin(GetWidget())); @@ -1107,8 +1106,7 @@ void WidgetWin::RedrawLayeredWindowContents() { void WidgetWin::ClientAreaSizeChanged() { RECT r; - Window* window = GetWidget()->GetContainingWindow(); - if (IsZoomed() || (window && window->ShouldUseNativeFrame())) + if (GetWidget()->GetThemeProvider()->ShouldUseNativeFrame() || IsZoomed()) GetClientRect(&r); else GetWindowRect(&r); diff --git a/views/window/native_window_delegate.h b/views/window/native_window_delegate.h index 12cf3cf..c88924b 100644 --- a/views/window/native_window_delegate.h +++ b/views/window/native_window_delegate.h @@ -35,6 +35,10 @@ class NativeWindowDelegate { // Returns true if the window is a dialog box. virtual bool IsDialogBox() const = 0; + // Returns true if the window is using a system native frame. Returns false if + // it is rendering its own title bar, borders and controls. + virtual bool IsUsingNativeFrame() const = 0; + // Returns the smallest size the window can be resized to by the user. virtual gfx::Size GetMinimumSize() const = 0; diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc index a930a19..5830d73 100644 --- a/views/window/non_client_view.cc +++ b/views/window/non_client_view.cc @@ -66,6 +66,21 @@ void NonClientView::UpdateFrame() { frame_->UpdateFrameAfterFrameChange(); } +bool NonClientView::UseNativeFrame() const { + if (frame_view_.get()) { + // The frame view may always require a native frame, e.g. popups on Vista+ + // when themes are active. + if (frame_view_->AlwaysUseNativeFrame()) + return true; + + // The frame view may always require a custom frame, e.g. Constrained + // Windows. + if (frame_view_->AlwaysUseCustomFrame()) + return false; + } + return frame_->ShouldUseNativeFrame(); +} + void NonClientView::DisableInactiveRendering(bool disable) { frame_view_->DisableInactiveRendering(disable); } @@ -177,6 +192,14 @@ views::View* NonClientView::GetEventHandlerForPoint(const gfx::Point& point) { //////////////////////////////////////////////////////////////////////////////// // NonClientFrameView, View overrides: +bool NonClientFrameView::AlwaysUseCustomFrame() const { + return false; +} + +bool NonClientFrameView::AlwaysUseNativeFrame() const { + return false; +} + bool NonClientFrameView::HitTest(const gfx::Point& l) const { // For the default case, we assume the non-client frame view never overlaps // the client view. diff --git a/views/window/non_client_view.h b/views/window/non_client_view.h index 0127d8b..d678571 100644 --- a/views/window/non_client_view.h +++ b/views/window/non_client_view.h @@ -45,6 +45,16 @@ class NonClientFrameView : public View { // view should be laid out within. virtual gfx::Rect GetBoundsForClientView() const = 0; + // Returns true if this FrameView should always use the custom frame, + // regardless of the system settings. An example is the Constrained Window, + // which is a child window and must always provide its own frame. + virtual bool AlwaysUseCustomFrame() const; + + // Like AlwaysUseCustomFrame, returns true if this FrameView should always use + // the native frame, regardless of theme settings. An example is popup/app + // windows, which we do not ever want to show themed. + virtual bool AlwaysUseNativeFrame() const; + virtual gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const = 0; @@ -151,6 +161,10 @@ class NonClientView : public View { // |use_native_frame|. void UpdateFrame(); + // Returns true if the native window frame should be used, false if the + // NonClientView provides its own frame implementation. + bool UseNativeFrame() const; + // Prevents the window from being rendered as deactivated when |disable| is // true, until called with |disable| false. Used when a sub-window is to be // shown that shouldn't visually de-activate the window. diff --git a/views/window/window.cc b/views/window/window.cc index 8ebc366..efc9f15 100644 --- a/views/window/window.cc +++ b/views/window/window.cc @@ -37,8 +37,7 @@ Window::Window() saved_maximized_state_(false), minimum_size_(100, 100), disable_inactive_rendering_(false), - window_closed_(false), - frame_type_(FRAME_TYPE_DEFAULT) { + window_closed_(false) { } Window::~Window() { @@ -239,22 +238,9 @@ gfx::NativeWindow Window::GetNativeWindow() const { } bool Window::ShouldUseNativeFrame() const { - if (frame_type_ != FRAME_TYPE_DEFAULT) - return frame_type_ == FRAME_TYPE_FORCE_NATIVE; return native_window_->ShouldUseNativeFrame(); } -void Window::DebugToggleFrameType() { - if (frame_type_ == FRAME_TYPE_DEFAULT) { - frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM : - FRAME_TYPE_FORCE_NATIVE; - } else { - frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ? - FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM; - } - FrameTypeChanged(); -} - void Window::FrameTypeChanged() { native_window_->FrameTypeChanged(); } @@ -283,6 +269,10 @@ bool Window::IsDialogBox() const { return !!window_delegate_->AsDialogDelegate(); } +bool Window::IsUsingNativeFrame() const { + return non_client_view_->UseNativeFrame(); +} + gfx::Size Window::GetMinimumSize() const { return non_client_view_->GetMinimumSize(); } diff --git a/views/window/window.h b/views/window/window.h index eb8490a..191aba4 100644 --- a/views/window/window.h +++ b/views/window/window.h @@ -52,12 +52,6 @@ class Window : public Widget, Widget::InitParams widget_init_params; }; - enum FrameType { - FRAME_TYPE_DEFAULT, // Use whatever the default would be. - FRAME_TYPE_FORCE_CUSTOM, // Force the custom frame. - FRAME_TYPE_FORCE_NATIVE // Force the native frame. - }; - Window(); virtual ~Window(); @@ -168,16 +162,9 @@ class Window : public Widget, // Retrieves the Window's native window handle. gfx::NativeWindow GetNativeWindow() const; - void set_frame_type(FrameType frame_type) { frame_type_ = frame_type; } - FrameType frame_type() const { return frame_type_; } - // Whether we should be using a native frame. bool ShouldUseNativeFrame() const; - // Forces the frame into the alternate frame type (custom or native) depending - // on its current state. - void DebugToggleFrameType(); - // Tell the window that something caused the frame type to change. void FrameTypeChanged(); @@ -214,6 +201,7 @@ class Window : public Widget, virtual void EnableInactiveRendering() OVERRIDE; virtual bool IsModal() const OVERRIDE; virtual bool IsDialogBox() const OVERRIDE; + virtual bool IsUsingNativeFrame() const OVERRIDE; virtual gfx::Size GetMinimumSize() const OVERRIDE; virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; virtual bool ExecuteCommand(int command_id) OVERRIDE; @@ -260,10 +248,6 @@ class Window : public Widget, // Set to true if the window is in the process of closing . bool window_closed_; - // The current frame type in use by this window. Defaults to - // FRAME_TYPE_DEFAULT. - FrameType frame_type_; - DISALLOW_COPY_AND_ASSIGN(Window); }; diff --git a/views/window/window_win.cc b/views/window/window_win.cc index 8ac69b5..e73c144 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -310,7 +310,7 @@ gfx::Font WindowWin::GetWindowTitleFont() { gfx::Insets WindowWin::GetClientAreaInsets() const { // Returning an empty Insets object causes the default handling in // WidgetWin::OnNCCalcSize() to be invoked. - if (GetWindow()->ShouldUseNativeFrame()) + if (delegate_->IsUsingNativeFrame()) return gfx::Insets(); if (IsMaximized()) { @@ -331,7 +331,7 @@ gfx::Insets WindowWin::GetClientAreaInsets() const { // rect when using the opaque frame. // Note: this is only required for non-fullscreen windows. Note that // fullscreen windows are in restored state, not maximized. - return gfx::Insets(0, 0, 0, 0); + return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 0); } int WindowWin::GetShowState() const { @@ -414,7 +414,7 @@ void WindowWin::OnExitSizeMove() { WidgetWin::OnExitSizeMove(); delegate_->OnNativeWindowEndUserBoundsChange(); - if (!GetWindow()->ShouldUseNativeFrame()) { + if (!ShouldUseNativeFrame()) { // Sending SWP_FRAMECHANGED forces a non-client repaint, which fixes the // glitch in rendering the bottom pixel of the window caused by us // offsetting the client rect there (See comment in GetClientAreaInsets()). @@ -438,7 +438,7 @@ void WindowWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) { void WindowWin::OnInitMenu(HMENU menu) { // We only need to manually enable the system menu if we're not using a native // frame. - if (GetWindow()->ShouldUseNativeFrame()) + if (delegate_->IsUsingNativeFrame()) WidgetWin::OnInitMenu(menu); bool is_fullscreen = IsFullscreen(); @@ -484,8 +484,7 @@ LRESULT WindowWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { ExecuteSystemMenuCommand(id); return 0; } - } else if (message == WM_NCLBUTTONDOWN && - !GetWindow()->ShouldUseNativeFrame()) { + } else if (message == WM_NCLBUTTONDOWN && !delegate_->IsUsingNativeFrame()) { switch (w_param) { case HTCLOSE: case HTMINBUTTON: @@ -563,7 +562,7 @@ LRESULT WindowWin::OnNCActivate(BOOL active) { if (IsVisible()) GetWindow()->non_client_view()->SchedulePaint(); - if (!GetWindow()->ShouldUseNativeFrame()) { + if (!ShouldUseNativeFrame()) { // TODO(beng, et al): Hack to redraw this window and child windows // synchronously upon activation. Not all child windows are redrawing // themselves leading to issues like http://crbug.com/74604 @@ -584,7 +583,6 @@ LRESULT WindowWin::OnNCActivate(BOOL active) { } LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { - //return 0; // We only override the default handling if we need to specify a custom // non-client edge width. Note that in most cases "no insets" means no // custom width, but in fullscreen mode we want a custom width of 0. @@ -626,7 +624,7 @@ LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { if (EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor)) client_rect->left += kAutoHideTaskbarThicknessPx; if (EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) { - if (GetWindow()->ShouldUseNativeFrame()) { + if (delegate_->IsUsingNativeFrame()) { // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of // WM_NCHITTEST, having any nonclient area atop the window causes the // caption buttons to draw onscreen but not respond to mouse @@ -667,7 +665,7 @@ LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { LRESULT WindowWin::OnNCHitTest(const CPoint& point) { // If the DWM is rendering the window controls, we need to give the DWM's // default window procedure first chance to handle hit testing. - if (GetWindow()->ShouldUseNativeFrame()) { + if (ShouldUseNativeFrame()) { LRESULT result; if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, MAKELPARAM(point.x, point.y), &result)) { @@ -692,14 +690,14 @@ void WindowWin::OnNCPaint(HRGN rgn) { // When using a custom frame, we want to avoid calling DefWindowProc() since // that may render artifacts. SetMsgHandled((!IsActive() || is_in_size_move_) && - !GetWindow()->ShouldUseNativeFrame()); + !delegate_->IsUsingNativeFrame()); } LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param, LPARAM l_param) { // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for // an explanation about why we need to handle this message. - SetMsgHandled(!GetWindow()->ShouldUseNativeFrame()); + SetMsgHandled(!delegate_->IsUsingNativeFrame()); return 0; } @@ -707,7 +705,7 @@ LRESULT WindowWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) { // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for // an explanation about why we need to handle this message. - SetMsgHandled(!GetWindow()->ShouldUseNativeFrame()); + SetMsgHandled(!delegate_->IsUsingNativeFrame()); return 0; } @@ -764,7 +762,7 @@ void WindowWin::OnSysCommand(UINT notification_code, CPoint click) { ((notification_code & sc_mask) == SC_MOVE) || ((notification_code & sc_mask) == SC_MAXIMIZE))) return; - if (!GetWindow()->ShouldUseNativeFrame()) { + if (!delegate_->IsUsingNativeFrame()) { if ((notification_code & sc_mask) == SC_MINIMIZE || (notification_code & sc_mask) == SC_MAXIMIZE || (notification_code & sc_mask) == SC_RESTORE) { @@ -1207,7 +1205,7 @@ void WindowWin::SetUseDragFrame(bool use_drag_frame) { } NonClientFrameView* WindowWin::CreateFrameViewForWindow() { - if (GetWindow()->ShouldUseNativeFrame()) + if (ShouldUseNativeFrame()) return new NativeFrameView(GetWindow()); return new CustomFrameView(GetWindow()); } @@ -1234,8 +1232,8 @@ void WindowWin::FrameTypeChanged() { // the DWM's glass non-client rendering is enabled, which is why // DWMNCRP_ENABLED is used for the native frame case. _DISABLED means the // DWM doesn't render glass, and so is used in the custom frame case. - DWMNCRENDERINGPOLICY policy = GetWindow()->ShouldUseNativeFrame() ? - DWMNCRP_ENABLED : DWMNCRP_DISABLED; + DWMNCRENDERINGPOLICY policy = + delegate_->IsUsingNativeFrame() ? DWMNCRP_ENABLED : DWMNCRP_DISABLED; DwmSetWindowAttribute(GetNativeView(), DWMWA_NCRENDERING_POLICY, &policy, sizeof(DWMNCRENDERINGPOLICY)); } @@ -1309,7 +1307,7 @@ void WindowWin::UnlockUpdates() { void WindowWin::ResetWindowRegion(bool force) { // A native frame uses the native window region, and we don't want to mess // with it. - if (GetWindow()->ShouldUseNativeFrame()) { + if (delegate_->IsUsingNativeFrame()) { if (force) SetWindowRgn(NULL, TRUE); return; |