diff options
27 files changed, 249 insertions, 242 deletions
diff --git a/chrome/browser/chromeos/frame/browser_frame_chromeos.cc b/chrome/browser/chromeos/frame/browser_frame_chromeos.cc index 2224068..f403694 100644 --- a/chrome/browser/chromeos/frame/browser_frame_chromeos.cc +++ b/chrome/browser/chromeos/frame/browser_frame_chromeos.cc @@ -29,11 +29,6 @@ BrowserFrameChromeos::~BrowserFrameChromeos() { } void BrowserFrameChromeos::InitBrowserFrame() { - // NOTE: This logic supersedes the logic in BrowserFrameGtk::Init() - // by always setting browser_frame_view_. - set_browser_frame_view( - browser::CreateBrowserNonClientFrameView(this, browser_view())); - BrowserFrameGtk::InitBrowserFrame(); if (!browser_view()->IsBrowserTypePopup()) { diff --git a/chrome/browser/chromeos/frame/panel_browser_view.cc b/chrome/browser/chromeos/frame/panel_browser_view.cc index 657039e..9a601f9 100644 --- a/chrome/browser/chromeos/frame/panel_browser_view.cc +++ b/chrome/browser/chromeos/frame/panel_browser_view.cc @@ -96,8 +96,8 @@ bool PanelBrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { return res; } -void PanelBrowserView::OnWindowActivate(bool active) { - ::BrowserView::OnWindowActivate(active); +void PanelBrowserView::OnWindowActivationChanged(bool active) { + ::BrowserView::OnWindowActivationChanged(active); if (panel_controller_.get()) { if (active) panel_controller_->OnFocusIn(); diff --git a/chrome/browser/chromeos/frame/panel_browser_view.h b/chrome/browser/chromeos/frame/panel_browser_view.h index cb51c3e..eec101d 100644 --- a/chrome/browser/chromeos/frame/panel_browser_view.h +++ b/chrome/browser/chromeos/frame/panel_browser_view.h @@ -32,7 +32,7 @@ class PanelBrowserView : public ::BrowserView, virtual void UpdateTitleBar(); virtual void SetCreatorView(PanelBrowserView* creator); virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const; - virtual void OnWindowActivate(bool active); + virtual void OnWindowActivationChanged(bool active); // PanelController::Delegate overrides virtual string16 GetPanelTitle(); diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc index 97b68ed..a151502 100644 --- a/chrome/browser/chromeos/login/user_controller.cc +++ b/chrome/browser/chromeos/login/user_controller.cc @@ -268,7 +268,7 @@ void UserController::UpdateUserCount(int index, int total_user_count) { //////////////////////////////////////////////////////////////////////////////// // UserController, WidgetDelegate implementation: // -void UserController::IsActiveChanged(bool active) { +void UserController::OnWidgetActivated(bool active) { is_user_selected_ = active; if (active) { delegate_->OnUserSelected(this); diff --git a/chrome/browser/chromeos/login/user_controller.h b/chrome/browser/chromeos/login/user_controller.h index bab0971..28250a1 100644 --- a/chrome/browser/chromeos/login/user_controller.h +++ b/chrome/browser/chromeos/login/user_controller.h @@ -103,22 +103,22 @@ class UserController : public views::WidgetDelegate, void UpdateUserCount(int index, int total_user_count); // views::WidgetDelegate implementation: - virtual void IsActiveChanged(bool active); + virtual void OnWidgetActivated(bool active) OVERRIDE; // NewUserView::Delegate implementation: virtual void OnLogin(const std::string& username, - const std::string& password); - virtual void OnLoginAsGuest(); - virtual void OnCreateAccount(); - virtual void ClearErrors(); - virtual void NavigateAway(); + const std::string& password) OVERRIDE; + virtual void OnLoginAsGuest() OVERRIDE; + virtual void OnCreateAccount() OVERRIDE; + virtual void ClearErrors() OVERRIDE; + virtual void NavigateAway() OVERRIDE; // UserView::Delegate implementation: - virtual void OnRemoveUser(); - virtual bool IsUserSelected() const { return is_user_selected_; } + virtual void OnRemoveUser() OVERRIDE; + virtual bool IsUserSelected() const OVERRIDE { return is_user_selected_; } // UsernameView::Delegate implementation: - virtual void OnLocaleChanged(); + virtual void OnLocaleChanged() OVERRIDE; // Padding between the user windows. static const int kPadding; diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc index 9bc3a02..94d0fa7 100644 --- a/chrome/browser/ui/views/frame/browser_frame.cc +++ b/chrome/browser/ui/views/frame/browser_frame.cc @@ -4,7 +4,12 @@ #include "chrome/browser/ui/views/frame/browser_frame.h" +#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" +#include "chrome/browser/ui/views/frame/browser_root_view.h" +#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/native_browser_frame.h" +#include "views/widget/native_widget.h" +#include "views/widget/widget.h" #include "views/window/native_window.h" #include "views/window/window.h" @@ -23,15 +28,15 @@ int BrowserFrame::GetMinimizeButtonOffset() const { } gfx::Rect BrowserFrame::GetBoundsForTabStrip(views::View* tabstrip) const { - return native_browser_frame_->GetBoundsForTabStrip(tabstrip); + return browser_frame_view_->GetBoundsForTabStrip(tabstrip); } int BrowserFrame::GetHorizontalTabStripVerticalOffset(bool restored) const { - return native_browser_frame_->GetHorizontalTabStripVerticalOffset(restored); + return browser_frame_view_->GetHorizontalTabStripVerticalOffset(restored); } void BrowserFrame::UpdateThrobber(bool running) { - native_browser_frame_->UpdateThrobber(running); + browser_frame_view_->UpdateThrobber(running); } ui::ThemeProvider* BrowserFrame::GetThemeProviderForFrame() const { @@ -43,7 +48,7 @@ bool BrowserFrame::AlwaysUseNativeFrame() const { } views::View* BrowserFrame::GetFrameView() const { - return native_browser_frame_->GetFrameView(); + return browser_frame_view_; } void BrowserFrame::TabStripDisplayModeChanged() { @@ -51,7 +56,28 @@ void BrowserFrame::TabStripDisplayModeChanged() { } //////////////////////////////////////////////////////////////////////////////// +// BrowserFrame, NativeBrowserFrameDelegate implementation: + +views::RootView* BrowserFrame::DelegateCreateRootView() { + root_view_ = new BrowserRootView( + browser_view_, + native_browser_frame_->AsNativeWindow()->AsNativeWidget()->GetWidget()); + return root_view_; +} + +views::NonClientFrameView* BrowserFrame::DelegateCreateFrameViewForWindow() { + browser_frame_view_ = + native_browser_frame_->CreateBrowserNonClientFrameView(); + return browser_frame_view_; +} + + +//////////////////////////////////////////////////////////////////////////////// // BrowserFrame, protected: -BrowserFrame::BrowserFrame() : native_browser_frame_(NULL) { +BrowserFrame::BrowserFrame(BrowserView* browser_view) + : native_browser_frame_(NULL), + root_view_(NULL), + browser_frame_view_(NULL), + browser_view_(browser_view) { } diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h index d58a16a..2a7ae13 100644 --- a/chrome/browser/ui/views/frame/browser_frame.h +++ b/chrome/browser/ui/views/frame/browser_frame.h @@ -6,12 +6,17 @@ #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ #pragma once +#include "base/compiler_specific.h" #include "base/logging.h" #include "build/build_config.h" #include "chrome/browser/ui/views/frame/native_browser_frame_delegate.h" +class AeroGlassNonClientView; +class BrowserNonClientFrameView; +class BrowserRootView; class BrowserView; class NativeBrowserFrame; +class NonClientFrameView; class Profile; namespace gfx { @@ -75,17 +80,33 @@ class BrowserFrame : public NativeBrowserFrameDelegate { void TabStripDisplayModeChanged(); protected: + // Overridden from NativeBrowserFrameDelegate: + virtual views::RootView* DelegateCreateRootView() OVERRIDE; + virtual views::NonClientFrameView* DelegateCreateFrameViewForWindow() + OVERRIDE; + // TODO(beng): Temporarily provided as a way to associate the subclass' // implementation of NativeBrowserFrame with this. void set_native_browser_frame(NativeBrowserFrame* native_browser_frame) { native_browser_frame_ = native_browser_frame; } - BrowserFrame(); + explicit BrowserFrame(BrowserView* browser_view); private: NativeBrowserFrame* native_browser_frame_; + // A weak reference to the root view associated with the window. We save a + // copy as a BrowserRootView to avoid evil casting later, when we need to call + // functions that only exist on BrowserRootView (versus RootView). + BrowserRootView* root_view_; + + // A pointer to our NonClientFrameView as a BrowserNonClientFrameView. + BrowserNonClientFrameView* browser_frame_view_; + + // The BrowserView is our ClientView. This is a pointer to it. + BrowserView* browser_view_; + DISALLOW_COPY_AND_ASSIGN(BrowserFrame); }; diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.cc b/chrome/browser/ui/views/frame/browser_frame_gtk.cc index 5c4d964..c56e0fc 100644 --- a/chrome/browser/ui/views/frame/browser_frame_gtk.cc +++ b/chrome/browser/ui/views/frame/browser_frame_gtk.cc @@ -33,41 +33,23 @@ const gfx::Font& BrowserFrame::GetTitleFont() { } BrowserFrameGtk::BrowserFrameGtk(BrowserView* browser_view, Profile* profile) - : WindowGtk(browser_view), - browser_view_(browser_view), - browser_frame_view_(NULL), - root_view_(NULL), - profile_(profile) { + : BrowserFrame(browser_view), + WindowGtk(browser_view), + ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), + browser_view_(browser_view) { set_native_browser_frame(this); browser_view_->set_frame(this); + non_client_view()->SetFrameView(CreateFrameViewForWindow()); } BrowserFrameGtk::~BrowserFrameGtk() { } void BrowserFrameGtk::InitBrowserFrame() { - if (browser_frame_view_ == NULL) - browser_frame_view_ = - browser::CreateBrowserNonClientFrameView(this, browser_view_); - - non_client_view()->SetFrameView(browser_frame_view_); WindowGtk::InitWindow(NULL, gfx::Rect()); // Don't focus anything on creation, selecting a tab will set the focus. } -ThemeProvider* BrowserFrameGtk::GetThemeProvider() const { - return profile_->GetThemeProvider(); -} - -views::RootView* BrowserFrameGtk::CreateRootView() { - root_view_ = new BrowserRootView(browser_view_, this); - return root_view_; -} - -void BrowserFrameGtk::SetInitialFocus() { - browser_view_->RestoreFocus(); -} - //////////////////////////////////////////////////////////////////////////////// // BrowserFrameGtk, NativeBrowserFrame implementation: @@ -79,23 +61,15 @@ const views::NativeWindow* BrowserFrameGtk::AsNativeWindow() const { return this; } +BrowserNonClientFrameView* BrowserFrameGtk::CreateBrowserNonClientFrameView() { + return browser::CreateBrowserNonClientFrameView(this, browser_view_); +} + int BrowserFrameGtk::GetMinimizeButtonOffset() const { NOTIMPLEMENTED(); return 0; } -gfx::Rect BrowserFrameGtk::GetBoundsForTabStrip(views::View* tabstrip) const { - return browser_frame_view_->GetBoundsForTabStrip(tabstrip); -} - -int BrowserFrameGtk::GetHorizontalTabStripVerticalOffset(bool restored) const { - return browser_frame_view_->GetHorizontalTabStripVerticalOffset(restored); -} - -void BrowserFrameGtk::UpdateThrobber(bool running) { - browser_frame_view_->UpdateThrobber(running); -} - ThemeProvider* BrowserFrameGtk::GetThemeProviderForFrame() const { // This is implemented for a different interface than GetThemeProvider is, // but they mean the same things. @@ -106,10 +80,6 @@ bool BrowserFrameGtk::AlwaysUseNativeFrame() const { return false; } -views::View* BrowserFrameGtk::GetFrameView() const { - return browser_frame_view_; -} - void BrowserFrameGtk::TabStripDisplayModeChanged() { if (GetRootView()->has_children()) { // Make sure the child of the root view gets Layout again. @@ -119,13 +89,29 @@ void BrowserFrameGtk::TabStripDisplayModeChanged() { } //////////////////////////////////////////////////////////////////////////////// -// BrowserFrameGtk, private: +// BrowserFrameGtk, WindowGtk overrides : + +ThemeProvider* BrowserFrameGtk::GetThemeProvider() const { + return browser_view_->browser()->profile()->GetThemeProvider(); +} + +void BrowserFrameGtk::SetInitialFocus() { + browser_view_->RestoreFocus(); +} + +views::RootView* BrowserFrameGtk::CreateRootView() { + return delegate_->DelegateCreateRootView(); +} bool BrowserFrameGtk::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { return browser_view_->GetAccelerator(cmd_id, accelerator); } +views::NonClientFrameView* BrowserFrameGtk::CreateFrameViewForWindow() { + return delegate_->DelegateCreateFrameViewForWindow(); +} + gboolean BrowserFrameGtk::OnWindowStateEvent(GtkWidget* widget, GdkEventWindowState* event) { bool was_full_screen = IsFullscreen(); diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.h b/chrome/browser/ui/views/frame/browser_frame_gtk.h index 78c8400..14536a1 100644 --- a/chrome/browser/ui/views/frame/browser_frame_gtk.h +++ b/chrome/browser/ui/views/frame/browser_frame_gtk.h @@ -29,56 +29,37 @@ class BrowserFrameGtk : public BrowserFrame, // constructor. virtual void InitBrowserFrame(); - // Overridden from views::Widget: - virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE; - virtual void SetInitialFocus() OVERRIDE; - protected: // Overridden from NativeBrowserFrame: virtual views::NativeWindow* AsNativeWindow() OVERRIDE; virtual const views::NativeWindow* AsNativeWindow() const OVERRIDE; + virtual BrowserNonClientFrameView* CreateBrowserNonClientFrameView() OVERRIDE; virtual int GetMinimizeButtonOffset() const OVERRIDE; - virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; - virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE; - virtual void UpdateThrobber(bool running) OVERRIDE; virtual ui::ThemeProvider* GetThemeProviderForFrame() const OVERRIDE; virtual bool AlwaysUseNativeFrame() const OVERRIDE; - virtual views::View* GetFrameView() const OVERRIDE; virtual void TabStripDisplayModeChanged() OVERRIDE; - void set_browser_frame_view(BrowserNonClientFrameView* browser_frame_view) { - browser_frame_view_ = browser_frame_view; - } - - // Overridden from views::WidgetGtk: + // Overridden from views::WindowGtk: + virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE; + virtual void SetInitialFocus() OVERRIDE; virtual views::RootView* CreateRootView(); virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator); - - // Overriden from views::WindowGtk: + virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE; virtual gboolean OnWindowStateEvent(GtkWidget* widget, GdkEventWindowState* event); virtual gboolean OnConfigureEvent(GtkWidget* widget, GdkEventConfigure* event); - protected: BrowserView* browser_view() const { return browser_view_; } private: + NativeBrowserFrameDelegate* delegate_; + // The BrowserView is our ClientView. This is a pointer to it. BrowserView* browser_view_; - // A pointer to our NonClientFrameView as a BrowserNonClientFrameView. - BrowserNonClientFrameView* browser_frame_view_; - - // An unowning reference to the root view associated with the window. We save - // a copy as a BrowserRootView to avoid evil casting later, when we need to - // call functions that only exist on BrowserRootView (versus RootView). - BrowserRootView* root_view_; - - Profile* profile_; - DISALLOW_COPY_AND_ASSIGN(BrowserFrameGtk); }; diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc index e646969..831a9c3 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_win.cc @@ -14,14 +14,13 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" -#include "chrome/browser/ui/views/frame/browser_root_view.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" #include "grit/theme_resources.h" #include "ui/gfx/font.h" #include "views/screen.h" +#include "views/widget/root_view.h" #include "views/widget/widget_win.h" -#include "views/window/window_delegate.h" #include "views/window/window_win.h" // static @@ -46,8 +45,8 @@ BrowserFrame* BrowserFrame::Create(BrowserView* browser_view, BrowserFrameWin::BrowserFrameWin(BrowserView* browser_view, Profile* profile) : WindowWin(browser_view), + BrowserFrame(browser_view), browser_view_(browser_view), - root_view_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)) { set_native_browser_frame(this); browser_view_->set_frame(this); @@ -109,39 +108,11 @@ void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) { BrowserList::SessionEnding(); } -void BrowserFrameWin::OnEnterSizeMove() { - browser_view_->WindowMoveOrResizeStarted(); -} - -void BrowserFrameWin::OnExitSizeMove() { - views::WidgetWin::OnExitSizeMove(); -} - void BrowserFrameWin::OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu) { browser_view_->PrepareToRunSystemMenu(menu); } -void BrowserFrameWin::OnMove(const CPoint& point) { - browser_view_->WindowMoved(); -} - -void BrowserFrameWin::OnMoving(UINT param, LPRECT new_bounds) { - browser_view_->WindowMoved(); -} - -LRESULT BrowserFrameWin::OnNCHitTest(const CPoint& pt) { - // Only do DWM hit-testing when we are using the native frame. - if (non_client_view()->UseNativeFrame()) { - LRESULT result; - if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, - MAKELPARAM(pt.x, pt.y), &result)) { - return result; - } - } - return WindowWin::OnNCHitTest(pt); -} - void BrowserFrameWin::OnWindowPosChanged(WINDOWPOS* window_pos) { WindowWin::OnWindowPosChanged(window_pos); UpdateDWMFrame(); @@ -185,15 +156,6 @@ void BrowserFrameWin::Activate() { WindowWin::Activate(); } -views::NonClientFrameView* BrowserFrameWin::CreateFrameViewForWindow() { - if (AlwaysUseNativeFrame()) - browser_frame_view_ = new GlassBrowserFrameView(this, browser_view_); - else - browser_frame_view_ = - browser::CreateBrowserNonClientFrameView(this, browser_view_); - return browser_frame_view_; -} - void BrowserFrameWin::UpdateFrameAfterFrameChange() { // We need to update the glass region on or off before the base class adjusts // the window region. @@ -202,8 +164,11 @@ void BrowserFrameWin::UpdateFrameAfterFrameChange() { } views::RootView* BrowserFrameWin::CreateRootView() { - root_view_ = new BrowserRootView(browser_view_, this); - return root_view_; + return delegate_->DelegateCreateRootView(); +} + +views::NonClientFrameView* BrowserFrameWin::CreateFrameViewForWindow() { + return delegate_->DelegateCreateFrameViewForWindow(); } //////////////////////////////////////////////////////////////////////////////// @@ -217,6 +182,12 @@ const views::NativeWindow* BrowserFrameWin::AsNativeWindow() const { return this; } +BrowserNonClientFrameView* BrowserFrameWin::CreateBrowserNonClientFrameView() { + if (AlwaysUseNativeFrame()) + return new GlassBrowserFrameView(this, browser_view_); + return browser::CreateBrowserNonClientFrameView(this, browser_view_); +} + int BrowserFrameWin::GetMinimizeButtonOffset() const { TITLEBARINFOEX titlebar_info; titlebar_info.cbSize = sizeof(TITLEBARINFOEX); @@ -229,18 +200,6 @@ int BrowserFrameWin::GetMinimizeButtonOffset() const { return minimize_button_corner.x; } -gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(views::View* tabstrip) const { - return browser_frame_view_->GetBoundsForTabStrip(tabstrip); -} - -int BrowserFrameWin::GetHorizontalTabStripVerticalOffset(bool restored) const { - return browser_frame_view_->GetHorizontalTabStripVerticalOffset(restored); -} - -void BrowserFrameWin::UpdateThrobber(bool running) { - browser_frame_view_->UpdateThrobber(running); -} - ui::ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const { // This is implemented for a different interface than GetThemeProvider is, // but they mean the same things. @@ -264,10 +223,6 @@ bool BrowserFrameWin::AlwaysUseNativeFrame() const { return GetThemeProvider()->ShouldUseNativeFrame(); } -views::View* BrowserFrameWin::GetFrameView() const { - return browser_frame_view_; -} - void BrowserFrameWin::TabStripDisplayModeChanged() { if (GetRootView()->has_children()) { // Make sure the child of the root view gets Layout again. diff --git a/chrome/browser/ui/views/frame/browser_frame_win.h b/chrome/browser/ui/views/frame/browser_frame_win.h index dbbd55a..4a3aa34 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.h +++ b/chrome/browser/ui/views/frame/browser_frame_win.h @@ -11,11 +11,7 @@ #include "chrome/browser/ui/views/frame/native_browser_frame.h" #include "views/window/window_win.h" -class AeroGlassNonClientView; -class BrowserNonClientFrameView; -class BrowserRootView; class BrowserView; -class NonClientFrameView; class Profile; /////////////////////////////////////////////////////////////////////////////// @@ -51,14 +47,9 @@ class BrowserFrameWin : public BrowserFrame, virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator) OVERRIDE; virtual void OnEndSession(BOOL ending, UINT logoff) OVERRIDE; - virtual void OnEnterSizeMove() OVERRIDE; - virtual void OnExitSizeMove() OVERRIDE; virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu) OVERRIDE; - virtual void OnMove(const CPoint& point) OVERRIDE; - virtual void OnMoving(UINT param, LPRECT new_bounds) OVERRIDE; - virtual LRESULT OnNCHitTest(const CPoint& pt) OVERRIDE; virtual void OnWindowPosChanged(WINDOWPOS* window_pos) OVERRIDE; virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE; virtual void OnScreenReaderDetected() OVERRIDE; @@ -66,39 +57,28 @@ class BrowserFrameWin : public BrowserFrame, // Overridden from views::Window: virtual void Activate() OVERRIDE; virtual bool IsAppWindow() const OVERRIDE { return true; } - virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE; virtual void UpdateFrameAfterFrameChange() OVERRIDE; virtual views::RootView* CreateRootView() OVERRIDE; + virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE; // Overridden from NativeBrowserFrame: virtual views::NativeWindow* AsNativeWindow() OVERRIDE; virtual const views::NativeWindow* AsNativeWindow() const OVERRIDE; + virtual BrowserNonClientFrameView* CreateBrowserNonClientFrameView() OVERRIDE; virtual int GetMinimizeButtonOffset() const OVERRIDE; - virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; - virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE; - virtual void UpdateThrobber(bool running) OVERRIDE; virtual ui::ThemeProvider* GetThemeProviderForFrame() const OVERRIDE; virtual bool AlwaysUseNativeFrame() const OVERRIDE; - virtual views::View* GetFrameView() const OVERRIDE; virtual void TabStripDisplayModeChanged() OVERRIDE; private: // Updates the DWM with the frame bounds. void UpdateDWMFrame(); + NativeBrowserFrameDelegate* delegate_; + // The BrowserView is our ClientView. This is a pointer to it. BrowserView* browser_view_; - // A pointer to our NonClientFrameView as a BrowserNonClientFrameView. - BrowserNonClientFrameView* browser_frame_view_; - - // A weak reference to the root view associated with the window. We save a - // copy as a BrowserRootView to avoid evil casting later, when we need to call - // functions that only exist on BrowserRootView (versus RootView). - BrowserRootView* root_view_; - - NativeBrowserFrameDelegate* delegate_; - DISALLOW_COPY_AND_ASSIGN(BrowserFrameWin); }; diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index ec2bf14..ad83930 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -500,29 +500,6 @@ BrowserView* BrowserView::GetBrowserViewForNativeWindow( return NULL; } -void BrowserView::WindowMoved() { - // Cancel any tabstrip animations, some of them may be invalidated by the - // window being repositioned. - // Comment out for one cycle to see if this fixes dist tests. - // tabstrip_->DestroyDragController(); - - status_bubble_->Reposition(); - - BrowserBubbleHost::WindowMoved(); - - browser::HideBookmarkBubbleView(); - - // Close the omnibox popup, if any. - if (toolbar_->location_bar()) - toolbar_->location_bar()->location_entry()->ClosePopup(); -} - -void BrowserView::WindowMoveOrResizeStarted() { - TabContents* tab_contents = GetSelectedTabContents(); - if (tab_contents) - tab_contents->WindowMoveOrResizeStarted(); -} - gfx::Rect BrowserView::GetToolbarBounds() const { gfx::Rect toolbar_bounds(toolbar_->bounds()); if (toolbar_bounds.IsEmpty()) @@ -1650,11 +1627,34 @@ views::ClientView* BrowserView::CreateClientView(views::Window* window) { return this; } -void BrowserView::OnWindowActivate(bool active) { +void BrowserView::OnWindowActivationChanged(bool active) { if (active) BrowserList::SetLastActive(browser_.get()); } +void BrowserView::OnWindowBeginUserBoundsChange() { + TabContents* tab_contents = GetSelectedTabContents(); + if (tab_contents) + tab_contents->WindowMoveOrResizeStarted(); +} + +void BrowserView::OnWidgetMove() { + // Cancel any tabstrip animations, some of them may be invalidated by the + // window being repositioned. + // Comment out for one cycle to see if this fixes dist tests. + // tabstrip_->DestroyDragController(); + + status_bubble_->Reposition(); + + BrowserBubbleHost::WindowMoved(); + + browser::HideBookmarkBubbleView(); + + // Close the omnibox popup, if any. + if (toolbar_->location_bar()) + toolbar_->location_bar()->location_entry()->ClosePopup(); +} + /////////////////////////////////////////////////////////////////////////////// // BrowserView, views::ClientView overrides: diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 4ede546..b84dbc9 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -102,14 +102,6 @@ class BrowserView : public BrowserBubbleHost, // Returns a Browser instance of this view. Browser* browser() const { return browser_.get(); } - // Called by the frame to notify the BrowserView that it was moved, and that - // any dependent popup windows should be repositioned. - void WindowMoved(); - - // Called by the frame to notify the BrowserView that a move or resize was - // initiated. - void WindowMoveOrResizeStarted(); - // Returns the apparent bounds of the toolbar, in BrowserView coordinates. // These differ from |toolbar_.bounds()| in that they match where the toolbar // background image is drawn -- slightly outside the "true" bounds @@ -372,7 +364,9 @@ class BrowserView : public BrowserBubbleHost, virtual bool GetSavedMaximizedState(bool* maximized) const OVERRIDE; virtual views::View* GetContentsView() OVERRIDE; virtual views::ClientView* CreateClientView(views::Window* window) OVERRIDE; - virtual void OnWindowActivate(bool active) OVERRIDE; + virtual void OnWindowActivationChanged(bool active) OVERRIDE; + virtual void OnWindowBeginUserBoundsChange() OVERRIDE; + virtual void OnWidgetMove() OVERRIDE; // Overridden from views::ClientView: virtual bool CanClose() OVERRIDE; diff --git a/chrome/browser/ui/views/frame/native_browser_frame.h b/chrome/browser/ui/views/frame/native_browser_frame.h index 1759e55..f72ec29 100644 --- a/chrome/browser/ui/views/frame/native_browser_frame.h +++ b/chrome/browser/ui/views/frame/native_browser_frame.h @@ -6,6 +6,8 @@ #define CHROME_BROWSER_UI_VIEWS_FRAME_NATIVE_BROWSER_FRAME_H_ #pragma once +class BrowserNonClientFrameView; + namespace gfx { class Rect; } @@ -29,15 +31,13 @@ class NativeBrowserFrame { protected: friend class BrowserFrame; + virtual BrowserNonClientFrameView* CreateBrowserNonClientFrameView() = 0; + // BrowserFrame pass-thrus --------------------------------------------------- // See browser_frame.h for documentation: virtual int GetMinimizeButtonOffset() const = 0; - virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const = 0; - virtual int GetHorizontalTabStripVerticalOffset(bool restored) const = 0; - virtual void UpdateThrobber(bool running) = 0; virtual ui::ThemeProvider* GetThemeProviderForFrame() const = 0; virtual bool AlwaysUseNativeFrame() const = 0; - virtual views::View* GetFrameView() const = 0; virtual void TabStripDisplayModeChanged() = 0; }; diff --git a/chrome/browser/ui/views/frame/native_browser_frame_delegate.h b/chrome/browser/ui/views/frame/native_browser_frame_delegate.h index 10c32dd..cacd34a 100644 --- a/chrome/browser/ui/views/frame/native_browser_frame_delegate.h +++ b/chrome/browser/ui/views/frame/native_browser_frame_delegate.h @@ -6,10 +6,19 @@ #define CHROME_BROWSER_UI_VIEWS_FRAME_NATIVE_BROWSER_FRAME_DELEGATE_H_ #pragma once +namespace views { +class NonClientFrameView; +class RootView; +} + class NativeBrowserFrameDelegate { public: virtual ~NativeBrowserFrameDelegate() {} + // TODO(beng): Remove these once BrowserFrame is-a Window is-a Widget, at + // which point BrowserFrame can just override Widget's method. + virtual views::RootView* DelegateCreateRootView() = 0; + virtual views::NonClientFrameView* DelegateCreateFrameViewForWindow() = 0; }; #endif // CHROME_BROWSER_UI_VIEWS_FRAME_NATIVE_BROWSER_FRAME_DELEGATE_H_ diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc index 3fdb610..26bee52 100644 --- a/chrome/browser/ui/views/notifications/balloon_view.cc +++ b/chrome/browser/ui/views/notifications/balloon_view.cc @@ -139,11 +139,11 @@ void BalloonViewImpl::RunMenu(views::View* source, const gfx::Point& pt) { RunOptionsMenu(pt); } -void BalloonViewImpl::DisplayChanged() { +void BalloonViewImpl::OnDisplayChanged() { collection_->DisplayChanged(); } -void BalloonViewImpl::WorkAreaChanged() { +void BalloonViewImpl::OnWorkAreaChanged() { collection_->DisplayChanged(); } diff --git a/chrome/browser/ui/views/notifications/balloon_view.h b/chrome/browser/ui/views/notifications/balloon_view.h index a956d6a..46e866e 100644 --- a/chrome/browser/ui/views/notifications/balloon_view.h +++ b/chrome/browser/ui/views/notifications/balloon_view.h @@ -74,8 +74,8 @@ class BalloonViewImpl : public BalloonView, virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; // views::WidgetDelegate interface. - virtual void DisplayChanged() OVERRIDE; - virtual void WorkAreaChanged() OVERRIDE; + virtual void OnDisplayChanged() OVERRIDE; + virtual void OnWorkAreaChanged() OVERRIDE; // views::ButtonListener interface. virtual void ButtonPressed( diff --git a/views/widget/widget_delegate.h b/views/widget/widget_delegate.h index 71ea6ee..b37c391 100644 --- a/views/widget/widget_delegate.h +++ b/views/widget/widget_delegate.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,15 +14,20 @@ class WidgetDelegate { public: virtual ~WidgetDelegate() {} - // Called with the display changes (color depth or resolution). - virtual void DisplayChanged() {} + // Called whenever the widget is activated or deactivated. + // TODO(beng): This should be consolidated with + // WindowDelegate::OnWindowActivationChanged(). + virtual void OnWidgetActivated(bool active) {} + + // Called whenever the widget's position changes. + virtual void OnWidgetMove() {} - // Called when widget active state has changed. - virtual void IsActiveChanged(bool active) {} + // Called with the display changes (color depth or resolution). + virtual void OnDisplayChanged() {} - // Called when the work area (the desktop area minus taskbars, - // menubars, etc.) changes in size. - virtual void WorkAreaChanged() {} + // Called when the work area (the desktop area minus task bars, + // menu bars, etc.) changes in size. + virtual void OnWorkAreaChanged() {} }; } // namespace views diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index badb66f..657ece9 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -564,7 +564,7 @@ void WidgetWin::OnDestroy() { void WidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) { if (widget_delegate()) - widget_delegate()->DisplayChanged(); + widget_delegate()->OnDisplayChanged(); } LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg, @@ -723,10 +723,14 @@ LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { } void WidgetWin::OnMove(const CPoint& point) { + if (widget_delegate()) + widget_delegate()->OnWidgetMove(); SetMsgHandled(FALSE); } void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { + if (widget_delegate()) + widget_delegate()->OnWidgetMove(); } LRESULT WidgetWin::OnNCActivate(BOOL active) { @@ -851,7 +855,7 @@ LRESULT WidgetWin::OnSetText(const wchar_t* text) { void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { if (flags == SPI_SETWORKAREA && widget_delegate()) - widget_delegate()->WorkAreaChanged(); + widget_delegate()->OnWorkAreaChanged(); SetMsgHandled(FALSE); } diff --git a/views/window/native_window.h b/views/window/native_window.h index 7e4bd6a..a2fb965 100644 --- a/views/window/native_window.h +++ b/views/window/native_window.h @@ -37,6 +37,9 @@ class NativeWindow { virtual Window* GetWindow() = 0; + virtual NativeWidget* AsNativeWidget() = 0; + virtual const NativeWidget* AsNativeWidget() const = 0; + protected: friend class Window; @@ -75,9 +78,6 @@ class NativeWindow { virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0; - virtual NativeWidget* AsNativeWidget() = 0; - virtual const NativeWidget* AsNativeWidget() const = 0; - // Window pass-thrus --------------------------------------------------------- // See documentation in window.h diff --git a/views/window/native_window_delegate.h b/views/window/native_window_delegate.h index 3807cfa..23705a5 100644 --- a/views/window/native_window_delegate.h +++ b/views/window/native_window_delegate.h @@ -51,6 +51,10 @@ class NativeWindowDelegate { // Called when the activation state of a window has changed. virtual void OnNativeWindowActivationChanged(bool active) = 0; + // Called when the user begins/ends to change the bounds of the window. + virtual void OnNativeWindowBeginUserBoundsChange() = 0; + virtual void OnNativeWindowEndUserBoundsChange() = 0; + // Called just before the native window is destroyed. This is the delegate's // last chance to do anything with the native window handle. virtual void OnNativeWindowDestroying() = 0; diff --git a/views/window/window.cc b/views/window/window.cc index 71f8cd8..ba7d055 100644 --- a/views/window/window.cc +++ b/views/window/window.cc @@ -298,7 +298,15 @@ void Window::OnNativeWindowCreated(const gfx::Rect& bounds) { void Window::OnNativeWindowActivationChanged(bool active) { if (!active) SaveWindowPosition(); - window_delegate_->OnWindowActivate(active); + window_delegate_->OnWindowActivationChanged(active); +} + +void Window::OnNativeWindowBeginUserBoundsChange() { + window_delegate_->OnWindowBeginUserBoundsChange(); +} + +void Window::OnNativeWindowEndUserBoundsChange() { + window_delegate_->OnWindowEndUserBoundsChange(); } void Window::OnNativeWindowDestroying() { diff --git a/views/window/window.h b/views/window/window.h index fc9f3a5..f18f4bb 100644 --- a/views/window/window.h +++ b/views/window/window.h @@ -213,6 +213,8 @@ class Window : public internal::NativeWindowDelegate { virtual bool ExecuteCommand(int command_id) OVERRIDE; virtual void OnNativeWindowCreated(const gfx::Rect& bounds) OVERRIDE; virtual void OnNativeWindowActivationChanged(bool active) OVERRIDE; + virtual void OnNativeWindowBeginUserBoundsChange() OVERRIDE; + virtual void OnNativeWindowEndUserBoundsChange() OVERRIDE; virtual void OnNativeWindowDestroying() OVERRIDE; virtual void OnNativeWindowDestroyed() OVERRIDE; virtual void OnNativeWindowBoundsChanged() OVERRIDE; diff --git a/views/window/window_delegate.h b/views/window/window_delegate.h index 379276c..d1a350a 100644 --- a/views/window/window_delegate.h +++ b/views/window/window_delegate.h @@ -10,6 +10,7 @@ #include "base/scoped_ptr.h" #include "ui/base/accessibility/accessibility_types.h" +#include "views/widget/widget_delegate.h" class SkBitmap; @@ -33,7 +34,7 @@ class Window; // it should be displayed and notify the delegate object of certain events. // /////////////////////////////////////////////////////////////////////////////// -class WindowDelegate { +class WindowDelegate : public WidgetDelegate { public: WindowDelegate(); virtual ~WindowDelegate(); @@ -117,7 +118,11 @@ class WindowDelegate { virtual void DeleteDelegate() {} // Called when the window's activation state changes. - virtual void OnWindowActivate(bool active) {} + virtual void OnWindowActivationChanged(bool active) {} + + // Called when the user begins/ends to change the bounds of the window. + virtual void OnWindowBeginUserBoundsChange() {} + virtual void OnWindowEndUserBoundsChange() {} // Returns the View that is contained within this Window. virtual View* GetContentsView(); diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index 23d0bce..a6f2c9f 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -46,6 +46,8 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window { protected: // Overridden from NativeWindow: + virtual NativeWidget* AsNativeWidget() OVERRIDE; + virtual const NativeWidget* AsNativeWidget() const OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; virtual void ShowNativeWindow(ShowState state) OVERRIDE; virtual void BecomeModal() OVERRIDE; @@ -59,8 +61,6 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window { virtual void SetAccessibleName(const std::wstring& name) OVERRIDE; virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; - virtual NativeWidget* AsNativeWidget() OVERRIDE; - virtual const NativeWidget* AsNativeWidget() const OVERRIDE; virtual Window* GetWindow() OVERRIDE; virtual void SetWindowBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window) OVERRIDE; diff --git a/views/window/window_win.cc b/views/window/window_win.cc index 32583e3..4708df5 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -142,6 +142,16 @@ void EnableMenuItem(HMENU menu, UINT command, bool enabled) { EnableMenuItem(menu, command, flags); } +bool IsDwmRenderingWindowControls(HWND window) { + if (base::win::GetVersion() < base::win::VERSION_VISTA) + return false; + + DWMNCRENDERINGPOLICY policy; + DwmGetWindowAttribute(window, DWMWA_NCRENDERING_POLICY, &policy, + sizeof(policy)); + return policy == DWMNCRP_ENABLED; +} + // If the hung renderer warning doesn't fit on screen, the amount of padding to // be left between the edge of the window and the edge of the nearest monitor, // after the window is nudged back on screen. Pixels. @@ -432,6 +442,16 @@ LRESULT WindowWin::OnDwmCompositionChanged(UINT msg, WPARAM w_param, return 0; } +void WindowWin::OnEnterSizeMove() { + WidgetWin::OnEnterSizeMove(); + delegate_->OnNativeWindowBeginUserBoundsChange(); +} + +void WindowWin::OnExitSizeMove() { + WidgetWin::OnExitSizeMove(); + delegate_->OnNativeWindowEndUserBoundsChange(); +} + void WindowWin::OnFinalMessage(HWND window) { delegate_->OnNativeWindowDestroyed(); WidgetWin::OnFinalMessage(window); @@ -605,9 +625,19 @@ 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 (IsDwmRenderingWindowControls(GetNativeView())) { + LRESULT result; + if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, + MAKELPARAM(point.x, point.y), &result)) { + return result; + } + } + // First, give the NonClientView a chance to test the point to see if it // provides any of the non-client area. - CPoint temp = point; + POINT temp = point; MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); int component = delegate_->GetNonClientComponent(gfx::Point(temp)); if (component != HTNOWHERE) @@ -852,6 +882,14 @@ void WindowWin::OnWindowPosChanging(WINDOWPOS* window_pos) { //////////////////////////////////////////////////////////////////////////////// // WindowWin, NativeWindow implementation: +NativeWidget* WindowWin::AsNativeWidget() { + return this; +} + +const NativeWidget* WindowWin::AsNativeWidget() const { + return this; +} + gfx::Rect WindowWin::GetRestoredBounds() const { // If we're in fullscreen mode, we've changed the normal bounds to the monitor // rect, so return the saved bounds instead. @@ -984,14 +1022,6 @@ void WindowWin::SetAccessibleState(ui::AccessibilityTypes::State state) { } } -NativeWidget* WindowWin::AsNativeWidget() { - return this; -} - -const NativeWidget* WindowWin::AsNativeWidget() const { - return this; -} - void WindowWin::SetWindowBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window) { SetChildBounds(GetNativeView(), GetParent(), other_window, bounds, diff --git a/views/window/window_win.h b/views/window/window_win.h index 222608a..114ea1e 100644 --- a/views/window/window_win.h +++ b/views/window/window_win.h @@ -104,6 +104,8 @@ class WindowWin : public WidgetWin, virtual LRESULT OnDwmCompositionChanged(UINT msg, WPARAM w_param, LPARAM l_param) OVERRIDE; + virtual void OnEnterSizeMove() OVERRIDE; + virtual void OnExitSizeMove() OVERRIDE; virtual void OnFinalMessage(HWND window) OVERRIDE; virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info) OVERRIDE; virtual void OnInitMenu(HMENU menu) OVERRIDE; @@ -135,6 +137,8 @@ class WindowWin : public WidgetWin, virtual const Window* GetWindow() const OVERRIDE { return this; } // Overridden from NativeWindow: + virtual NativeWidget* AsNativeWidget() OVERRIDE; + virtual const NativeWidget* AsNativeWidget() const OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; virtual void ShowNativeWindow(ShowState state) OVERRIDE; virtual void BecomeModal() OVERRIDE; @@ -148,8 +152,6 @@ class WindowWin : public WidgetWin, virtual void SetAccessibleName(const std::wstring& name) OVERRIDE; virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; - virtual NativeWidget* AsNativeWidget() OVERRIDE; - virtual const NativeWidget* AsNativeWidget() const OVERRIDE; virtual void SetWindowBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window) OVERRIDE; virtual void HideWindow() OVERRIDE; |