summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-19 14:51:36 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-19 14:51:36 +0000
commit6c8c80e7b1b85f30ad4c6626a9ec3f31818086da (patch)
treea066456b010b480d579b214ecffee48b3cb75057
parent3c4beb226d1f279685d82861a062b599401cd2a9 (diff)
downloadchromium_src-6c8c80e7b1b85f30ad4c6626a9ec3f31818086da.zip
chromium_src-6c8c80e7b1b85f30ad4c6626a9ec3f31818086da.tar.gz
chromium_src-6c8c80e7b1b85f30ad4c6626a9ec3f31818086da.tar.bz2
Factor out a BrowserFrame interface, and move the existing Windows-based code
to a new class: BrowserFrameWin. The major other change I had to make was the way that the TabStrip is set in the BrowserRootView. Now there is a method on the frame that the view can call when it creats the tabstrip that will set the tabstrip on the root view. Review URL: http://codereview.chromium.org/113511 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16373 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_focus_uitest.cc2
-rw-r--r--chrome/browser/views/browser_views.vcproj8
-rw-r--r--chrome/browser/views/frame/browser_frame.h112
-rw-r--r--chrome/browser/views/frame/browser_frame_win.cc (renamed from chrome/browser/views/frame/browser_frame.cc)85
-rw-r--r--chrome/browser/views/frame/browser_frame_win.h109
-rw-r--r--chrome/browser/views/frame/browser_root_view.cc2
-rw-r--r--chrome/browser/views/frame/browser_root_view.h8
-rw-r--r--chrome/browser/views/frame/browser_view.cc71
-rw-r--r--chrome/browser/views/frame/browser_view.h1
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc52
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.h2
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc79
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.h2
-rw-r--r--chrome/browser/views/info_bubble.cc2
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc1
-rw-r--r--chrome/chrome.gyp4
-rw-r--r--views/window/window.h14
-rw-r--r--views/window/window_gtk.cc12
-rw-r--r--views/window/window_gtk.h3
-rw-r--r--views/window/window_win.cc19
-rw-r--r--views/window/window_win.h11
21 files changed, 375 insertions, 224 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index cd46616..01603ac 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -251,7 +251,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) {
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
ASSERT_TRUE(browser_view);
- EXPECT_TRUE(browser_view->frame()->IsActive());
+ EXPECT_TRUE(browser_view->frame()->GetWindow()->IsActive());
// Close the 2nd browser to avoid a DCHECK().
HWND hwnd2 = reinterpret_cast<HWND>(browser2->window()->GetNativeHandle());
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj
index 4fd8613..4a19a49 100644
--- a/chrome/browser/views/browser_views.vcproj
+++ b/chrome/browser/views/browser_views.vcproj
@@ -125,11 +125,15 @@
Name="Frame"
>
<File
- RelativePath=".\frame\browser_frame.cc"
+ RelativePath=".\frame\browser_frame.h"
>
</File>
<File
- RelativePath=".\frame\browser_frame.h"
+ RelativePath=".\frame\browser_frame_win.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\frame\browser_frame_win.h"
>
</File>
<File
diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h
index fdb5e49..e0539e9 100644
--- a/chrome/browser/views/frame/browser_frame.h
+++ b/chrome/browser/views/frame/browser_frame.h
@@ -2,105 +2,59 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_
-#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_
+#ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_H_
+#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_H_
-#include "views/window/window_win.h"
+#include "build/build_config.h"
#include "views/window/non_client_view.h"
-class AeroGlassNonClientView;
class BrowserView;
-class NonClientFrameView;
class Profile;
class TabStrip;
+class ThemeProvider;
-// A specialization of the NonClientFrameView object that provides additional
-// Browser-specific methods.
-class BrowserNonClientFrameView : public views::NonClientFrameView {
- public:
- BrowserNonClientFrameView() : NonClientFrameView() {}
- virtual ~BrowserNonClientFrameView() {}
+namespace gfx {
+class Rect;
+} // namespace gfx
- // Returns the bounds within which the TabStrip should be laid out.
- virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0;
+namespace views {
+class Window;
- // Updates the throbber.
- virtual void UpdateThrobber(bool running) = 0;
-};
+#if defined(OS_WIN)
+class WindowWin;
+#endif
+} // namespace views
-///////////////////////////////////////////////////////////////////////////////
-// BrowserFrame
-//
-// BrowserFrame is a WindowWin subclass that provides the window frame for the
-// Chrome browser window.
-//
-class BrowserFrame : public views::WindowWin {
+// This is a virtual interface that allows system specific browser frames.
+class BrowserFrame {
public:
- explicit BrowserFrame(BrowserView* browser_view, Profile* profile);
- virtual ~BrowserFrame();
+ virtual ~BrowserFrame() {}
- // Initialize the frame. Creates the Window.
- void Init();
+ // Creates the appropriate BrowserFrame for this platform. The returned
+ // object is owned by the caller.
+ static BrowserFrame* Create(BrowserView* browser_view, Profile* profile);
+
+ // Returns the Window associated with this frame. Guraranteed non-NULL after
+ // construction.
+ virtual views::Window* GetWindow() = 0;
+
+ // Notification that the tab strip has been created. This should let the
+ // BrowserRootView know about it so it can enable drag and drop.
+ virtual void TabStripCreated(TabStrip* tabstrip) = 0;
// Determine the distance of the left edge of the minimize button from the
// left edge of the window. Used in our Non-Client View's Layout.
- int GetMinimizeButtonOffset() const;
+ virtual int GetMinimizeButtonOffset() const = 0;
// Retrieves the bounds, in non-client view coordinates for the specified
// TabStrip.
- gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0;
// Tells the frame to update the throbber.
- void UpdateThrobber(bool running);
-
- // Overridden from views::Widget.
- virtual ThemeProvider* GetThemeProvider() const;
- virtual ThemeProvider* GetDialogThemeProvider() const;
-
- BrowserView* browser_view() const { return browser_view_; }
-
-#if defined(FRAME_WINDOW)
- void SetBrowserNonClientFrameView(BrowserNonClientFrameView* view);
-#endif
-
- protected:
- // Overridden from views::WidgetWin:
- virtual bool AcceleratorPressed(views::Accelerator* accelerator);
- virtual bool GetAccelerator(int cmd_id, views::Accelerator* accelerator);
- virtual void OnEnterSizeMove();
- virtual void OnEndSession(BOOL ending, UINT logoff);
- virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu);
- virtual LRESULT OnMouseActivate(HWND window,
- UINT hittest_code,
- UINT message);
- virtual void OnMove(const CPoint& point);
- virtual void OnMoving(UINT param, const RECT* new_bounds);
- virtual LRESULT OnNCActivate(BOOL active);
- virtual LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param);
- virtual LRESULT OnNCHitTest(const CPoint& pt);
-
- // Overridden from views::Window:
- virtual int GetShowState() const;
- virtual bool IsAppWindow() const { return true; }
- virtual views::NonClientFrameView* CreateFrameViewForWindow();
- virtual void UpdateFrameAfterFrameChange();
- virtual views::RootView* CreateRootView();
-
- private:
- // Updates the DWM with the frame bounds.
- void UpdateDWMFrame();
-
- // 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_;
-
- bool frame_initialized_;
-
- Profile* profile_;
+ virtual void UpdateThrobber(bool running) = 0;
- DISALLOW_EVIL_CONSTRUCTORS(BrowserFrame);
+ // Returns the theme provider for this frame.
+ virtual ThemeProvider* GetThemeProviderForFrame() const = 0;
};
-#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_
+#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_H_
diff --git a/chrome/browser/views/frame/browser_frame.cc b/chrome/browser/views/frame/browser_frame_win.cc
index 0d39521..d206f4f 100644
--- a/chrome/browser/views/frame/browser_frame.cc
+++ b/chrome/browser/views/frame/browser_frame_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/views/frame/browser_frame.h"
+#include "chrome/browser/views/frame/browser_frame_win.h"
#include <dwmapi.h>
#include <shellapi.h>
@@ -21,12 +21,21 @@
// static
static const int kClientEdgeThickness = 3;
+// static (Factory method.)
+BrowserFrame* BrowserFrame::Create(BrowserView* browser_view,
+ Profile* profile) {
+ BrowserFrameWin* frame = new BrowserFrameWin(browser_view, profile);
+ frame->Init();
+ return frame;
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserFrame, public:
-BrowserFrame::BrowserFrame(BrowserView* browser_view, Profile* profile)
+BrowserFrameWin::BrowserFrameWin(BrowserView* browser_view, Profile* profile)
: WindowWin(browser_view),
browser_view_(browser_view),
+ root_view_(NULL),
frame_initialized_(false),
profile_(profile) {
browser_view_->set_frame(this);
@@ -35,14 +44,22 @@ BrowserFrame::BrowserFrame(BrowserView* browser_view, Profile* profile)
set_focus_on_creation(false);
}
-BrowserFrame::~BrowserFrame() {
+void BrowserFrameWin::Init() {
+ WindowWin::Init(NULL, gfx::Rect());
}
-void BrowserFrame::Init() {
- WindowWin::Init(NULL, gfx::Rect());
+BrowserFrameWin::~BrowserFrameWin() {
+}
+
+views::Window* BrowserFrameWin::GetWindow() {
+ return this;
+}
+
+void BrowserFrameWin::TabStripCreated(TabStrip* tabstrip) {
+ root_view_->set_tabstrip(tabstrip);
}
-int BrowserFrame::GetMinimizeButtonOffset() const {
+int BrowserFrameWin::GetMinimizeButtonOffset() const {
TITLEBARINFOEX titlebar_info;
titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
SendMessage(GetNativeView(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info);
@@ -54,24 +71,30 @@ int BrowserFrame::GetMinimizeButtonOffset() const {
return minimize_button_corner.x;
}
-gfx::Rect BrowserFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const {
+gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(TabStrip* tabstrip) const {
return browser_frame_view_->GetBoundsForTabStrip(tabstrip);
}
-void BrowserFrame::UpdateThrobber(bool running) {
+void BrowserFrameWin::UpdateThrobber(bool running) {
browser_frame_view_->UpdateThrobber(running);
}
-ThemeProvider* BrowserFrame::GetThemeProvider() const {
+ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const {
+ // This is implemented for a different interface than GetThemeProvider is,
+ // but they mean the same things.
+ return GetThemeProvider();
+}
+
+ThemeProvider* BrowserFrameWin::GetThemeProvider() const {
return profile_->GetThemeProvider();
}
-ThemeProvider* BrowserFrame::GetDialogThemeProvider() const {
+ThemeProvider* BrowserFrameWin::GetDialogThemeProvider() const {
return profile_->GetThemeProvider();
}
#if defined(FRAME_WINDOW)
-void BrowserFrame::SetBrowserNonClientFrameView(
+void BrowserFrameWin::SetBrowserNonClientFrameView(
BrowserNonClientFrameView* view) {
GetNonClientView()->SetFrameView(view);
// SetFrameView deletes the old browser_frame_view_.
@@ -82,42 +105,43 @@ void BrowserFrame::SetBrowserNonClientFrameView(
///////////////////////////////////////////////////////////////////////////////
// BrowserFrame, views::WidgetWin overrides:
-bool BrowserFrame::AcceleratorPressed(views::Accelerator* accelerator) {
+bool BrowserFrameWin::AcceleratorPressed(views::Accelerator* accelerator) {
return browser_view_->AcceleratorPressed(*accelerator);
}
-bool BrowserFrame::GetAccelerator(int cmd_id, views::Accelerator* accelerator) {
+bool BrowserFrameWin::GetAccelerator(int cmd_id,
+ views::Accelerator* accelerator) {
return browser_view_->GetAccelerator(cmd_id, accelerator);
}
-void BrowserFrame::OnEndSession(BOOL ending, UINT logoff) {
+void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) {
BrowserList::WindowsSessionEnding();
}
-void BrowserFrame::OnEnterSizeMove() {
+void BrowserFrameWin::OnEnterSizeMove() {
browser_view_->WindowMoveOrResizeStarted();
}
-void BrowserFrame::OnInitMenuPopup(HMENU menu, UINT position,
- BOOL is_system_menu) {
+void BrowserFrameWin::OnInitMenuPopup(HMENU menu, UINT position,
+ BOOL is_system_menu) {
browser_view_->PrepareToRunSystemMenu(menu);
}
-LRESULT BrowserFrame::OnMouseActivate(HWND window, UINT hittest_code,
- UINT message) {
+LRESULT BrowserFrameWin::OnMouseActivate(HWND window, UINT hittest_code,
+ UINT message) {
return browser_view_->ActivateAppModalDialog() ? MA_NOACTIVATEANDEAT
: MA_ACTIVATE;
}
-void BrowserFrame::OnMove(const CPoint& point) {
+void BrowserFrameWin::OnMove(const CPoint& point) {
browser_view_->WindowMoved();
}
-void BrowserFrame::OnMoving(UINT param, const RECT* new_bounds) {
+void BrowserFrameWin::OnMoving(UINT param, const RECT* new_bounds) {
browser_view_->WindowMoved();
}
-LRESULT BrowserFrame::OnNCActivate(BOOL active) {
+LRESULT BrowserFrameWin::OnNCActivate(BOOL active) {
if (browser_view_->ActivateAppModalDialog())
return TRUE;
@@ -135,7 +159,7 @@ LRESULT BrowserFrame::OnNCActivate(BOOL active) {
return WindowWin::OnNCActivate(active);
}
-LRESULT BrowserFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
+LRESULT BrowserFrameWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
// We don't adjust the client area unless we're a tabbed browser window and
// are using the native frame.
if (!GetNonClientView()->UseNativeFrame() ||
@@ -199,7 +223,7 @@ LRESULT BrowserFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
return 0;
}
-LRESULT BrowserFrame::OnNCHitTest(const CPoint& pt) {
+LRESULT BrowserFrameWin::OnNCHitTest(const CPoint& pt) {
// Only do DWM hit-testing when we are using the native frame.
if (GetNonClientView()->UseNativeFrame()) {
LRESULT result;
@@ -214,11 +238,11 @@ LRESULT BrowserFrame::OnNCHitTest(const CPoint& pt) {
///////////////////////////////////////////////////////////////////////////////
// BrowserFrame, views::CustomFrameWindow overrides:
-int BrowserFrame::GetShowState() const {
+int BrowserFrameWin::GetShowState() const {
return browser_view_->GetShowState();
}
-views::NonClientFrameView* BrowserFrame::CreateFrameViewForWindow() {
+views::NonClientFrameView* BrowserFrameWin::CreateFrameViewForWindow() {
if (GetNonClientView()->UseNativeFrame())
browser_frame_view_ = new GlassBrowserFrameView(this, browser_view_);
else
@@ -226,19 +250,20 @@ views::NonClientFrameView* BrowserFrame::CreateFrameViewForWindow() {
return browser_frame_view_;
}
-void BrowserFrame::UpdateFrameAfterFrameChange() {
+void BrowserFrameWin::UpdateFrameAfterFrameChange() {
WindowWin::UpdateFrameAfterFrameChange();
UpdateDWMFrame();
}
-views::RootView* BrowserFrame::CreateRootView() {
- return new BrowserRootView(this);
+views::RootView* BrowserFrameWin::CreateRootView() {
+ root_view_ = new BrowserRootView(this);
+ return root_view_;
}
///////////////////////////////////////////////////////////////////////////////
// BrowserFrame, private:
-void BrowserFrame::UpdateDWMFrame() {
+void BrowserFrameWin::UpdateDWMFrame() {
// Nothing to do yet.
if (!GetClientView() || !browser_view_->IsBrowserTypeNormal())
return;
diff --git a/chrome/browser/views/frame/browser_frame_win.h b/chrome/browser/views/frame/browser_frame_win.h
new file mode 100644
index 0000000..5d72df4
--- /dev/null
+++ b/chrome/browser/views/frame/browser_frame_win.h
@@ -0,0 +1,109 @@
+// Copyright (c) 2006-2008 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.
+
+#ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_WIN_
+#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_WIN_
+
+#include "base/basictypes.h"
+#include "chrome/browser/views/frame/browser_frame.h"
+#include "views/window/window_win.h"
+
+class AeroGlassNonClientView;
+class BrowserRootView;
+class BrowserView;
+class NonClientFrameView;
+class Profile;
+class TabStrip;
+
+// A specialization of the NonClientFrameView object that provides additional
+// Browser-specific methods.
+class BrowserNonClientFrameView : public views::NonClientFrameView {
+ public:
+ BrowserNonClientFrameView() : NonClientFrameView() {}
+ virtual ~BrowserNonClientFrameView() {}
+
+ // Returns the bounds within which the TabStrip should be laid out.
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0;
+
+ // Updates the throbber.
+ virtual void UpdateThrobber(bool running) = 0;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// BrowserFrameWin
+//
+// BrowserFrame is a WindowWin subclass that provides the window frame for the
+// Chrome browser window.
+//
+class BrowserFrameWin : public BrowserFrame, public views::WindowWin {
+ public:
+ // Normally you will create this class by calling BrowserFrame::Create.
+ // Init must be called before using this class, which Create will do for you.
+ BrowserFrameWin(BrowserView* browser_view, Profile* profile);
+ virtual ~BrowserFrameWin();
+
+ // This initialization function must be called after construction, it is
+ // separate to avoid recursive calling of the frame from its constructor.
+ void Init();
+
+ // BrowserFrame implementation.
+ virtual views::Window* GetWindow();
+ virtual void TabStripCreated(TabStrip* tabstrip);
+ virtual int GetMinimizeButtonOffset() const;
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
+ virtual void UpdateThrobber(bool running);
+ virtual ThemeProvider* GetThemeProviderForFrame() const;
+
+ // Overridden from views::Widget.
+ virtual ThemeProvider* GetThemeProvider() const;
+ virtual ThemeProvider* GetDialogThemeProvider() const;
+
+ BrowserView* browser_view() const { return browser_view_; }
+
+ protected:
+ // Overridden from views::WidgetWin:
+ virtual bool AcceleratorPressed(views::Accelerator* accelerator);
+ virtual bool GetAccelerator(int cmd_id, views::Accelerator* accelerator);
+ virtual void OnEnterSizeMove();
+ virtual void OnEndSession(BOOL ending, UINT logoff);
+ virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu);
+ virtual LRESULT OnMouseActivate(HWND window,
+ UINT hittest_code,
+ UINT message);
+ virtual void OnMove(const CPoint& point);
+ virtual void OnMoving(UINT param, const RECT* new_bounds);
+ virtual LRESULT OnNCActivate(BOOL active);
+ virtual LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param);
+ virtual LRESULT OnNCHitTest(const CPoint& pt);
+
+ // Overridden from views::Window:
+ virtual int GetShowState() const;
+ virtual bool IsAppWindow() const { return true; }
+ virtual views::NonClientFrameView* CreateFrameViewForWindow();
+ virtual void UpdateFrameAfterFrameChange();
+ virtual views::RootView* CreateRootView();
+
+ private:
+ // Updates the DWM with the frame bounds.
+ void UpdateDWMFrame();
+
+ // 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 only on BrowserRootView.
+ BrowserRootView* root_view_;
+
+ bool frame_initialized_;
+
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserFrameWin);
+};
+
+#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_WIN_
diff --git a/chrome/browser/views/frame/browser_root_view.cc b/chrome/browser/views/frame/browser_root_view.cc
index 78f6ef0..86c919c 100644
--- a/chrome/browser/views/frame/browser_root_view.cc
+++ b/chrome/browser/views/frame/browser_root_view.cc
@@ -18,8 +18,6 @@ BrowserRootView::BrowserRootView(views::Widget* widget)
}
bool BrowserRootView::CanDrop(const OSExchangeData& data) {
- tabstrip_ =
- static_cast<BrowserFrame*>(GetWidget())->browser_view()->tabstrip();
can_drop_ = (tabstrip_ && tabstrip_->IsVisible() &&
!tabstrip_->IsAnimating() && data.HasURL());
return can_drop_;
diff --git a/chrome/browser/views/frame/browser_root_view.h b/chrome/browser/views/frame/browser_root_view.h
index a0460793..a5a2e39f 100644
--- a/chrome/browser/views/frame/browser_root_view.h
+++ b/chrome/browser/views/frame/browser_root_view.h
@@ -17,7 +17,13 @@ class TabStrip;
// TabStrip.
class BrowserRootView : public views::RootView {
public:
- explicit BrowserRootView(views::Widget* widget);
+ // You must call set_tabstrip before this class will accept drops.
+ BrowserRootView(views::Widget* widget);
+
+ // Sets the tabstrip associated with this window. This is used to forward
+ // drag and drop operations to, so no drops will be accepted if there is no
+ // tabstrip set.
+ void set_tabstrip(TabStrip* tabstrip) { tabstrip_ = tabstrip; }
virtual bool CanDrop(const OSExchangeData& data);
virtual void OnDragEntered(const views::DropTargetEvent& event);
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 72957ed..b8dd131 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -526,8 +526,8 @@ void BrowserView::DetachBrowserBubble(BrowserBubble* bubble) {
void BrowserView::Show() {
// If the window is already visible, just activate it.
- if (frame_->IsVisible()) {
- frame_->Activate();
+ if (frame_->GetWindow()->IsVisible()) {
+ frame_->GetWindow()->Activate();
return;
}
@@ -545,15 +545,15 @@ void BrowserView::Show() {
if (selected_tab_contents)
selected_tab_contents->view()->RestoreFocus();
- frame_->Show();
+ frame_->GetWindow()->Show();
}
void BrowserView::SetBounds(const gfx::Rect& bounds) {
- frame_->SetBounds(bounds);
+ frame_->GetWindow()->SetBounds(bounds);
}
void BrowserView::Close() {
- frame_->Close();
+ frame_->GetWindow()->Close();
BubbleSet::iterator bubble = browser_bubbles_.begin();
for (; bubble != browser_bubbles_.end(); ++bubble) {
@@ -562,17 +562,17 @@ void BrowserView::Close() {
}
void BrowserView::Activate() {
- frame_->Activate();
+ frame_->GetWindow()->Activate();
}
bool BrowserView::IsActive() const {
- return frame_->IsActive();
+ return frame_->GetWindow()->IsActive();
}
void BrowserView::FlashFrame() {
FLASHWINFO fwi;
fwi.cbSize = sizeof(fwi);
- fwi.hwnd = frame_->GetNativeView();
+ fwi.hwnd = frame_->GetWindow()->GetNativeWindow();
fwi.dwFlags = FLASHW_ALL;
fwi.uCount = 4;
fwi.dwTimeout = 0;
@@ -603,9 +603,9 @@ void BrowserView::SelectedTabToolbarSizeChanged(bool is_animating) {
}
void BrowserView::UpdateTitleBar() {
- frame_->UpdateWindowTitle();
+ frame_->GetWindow()->UpdateWindowTitle();
if (ShouldShowWindowIcon())
- frame_->UpdateWindowIcon();
+ frame_->GetWindow()->UpdateWindowIcon();
}
void BrowserView::UpdateLoadingAnimations(bool should_animate) {
@@ -630,11 +630,11 @@ void BrowserView::SetStarredState(bool is_starred) {
}
gfx::Rect BrowserView::GetNormalBounds() const {
- return frame_->GetNormalBounds();
+ return frame_->GetWindow()->GetNormalBounds();
}
bool BrowserView::IsMaximized() const {
- return frame_->IsMaximized();
+ return frame_->GetWindow()->IsMaximized();
}
void BrowserView::SetFullscreen(bool fullscreen) {
@@ -668,17 +668,18 @@ void BrowserView::SetFullscreen(bool fullscreen) {
edit_view->set_force_hidden(true);
ShowWindow(edit_view->m_hWnd, SW_HIDE);
}
- frame_->PushForceHidden();
+ frame_->GetWindow()->PushForceHidden();
// Notify bookmark bar, so it can set itself to the appropriate drawing state.
if (bookmark_bar_view_.get())
bookmark_bar_view_->OnFullscreenToggled(fullscreen);
// Toggle fullscreen mode.
- frame_->SetFullscreen(fullscreen);
+ frame_->GetWindow()->SetFullscreen(fullscreen);
if (IsFullscreen()) {
- fullscreen_bubble_.reset(new FullscreenExitBubble(frame_, browser_.get()));
+ fullscreen_bubble_.reset(new FullscreenExitBubble(GetWidget(),
+ browser_.get()));
} else {
// Show the edit again since we're no longer in fullscreen mode.
edit_view->set_force_hidden(false);
@@ -689,11 +690,11 @@ void BrowserView::SetFullscreen(bool fullscreen) {
// it's in its final position.
ignore_layout_ = false;
Layout();
- frame_->PopForceHidden();
+ frame_->GetWindow()->PopForceHidden();
}
bool BrowserView::IsFullscreen() const {
- return frame_->IsFullscreen();
+ return frame_->GetWindow()->IsFullscreen();
}
LocationBar* BrowserView::GetLocationBar() const {
@@ -746,7 +747,7 @@ bool BrowserView::IsBookmarkBarVisible() const {
}
gfx::Rect BrowserView::GetRootWindowResizerRect() const {
- if (frame_->IsMaximized() || frame_->IsFullscreen())
+ if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen())
return gfx::Rect();
// We don't specify a resize corner size if we have a bottom shelf either.
@@ -771,7 +772,7 @@ gfx::Rect BrowserView::GetRootWindowResizerRect() const {
}
void BrowserView::DisableInactiveFrame() {
- frame_->DisableInactiveRendering();
+ frame_->GetWindow()->DisableInactiveRendering();
}
void BrowserView::ToggleBookmarkBar() {
@@ -877,9 +878,9 @@ void BrowserView::ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
}
void BrowserView::UserChangedTheme() {
- frame_->GetNonClientView()->SetUseNativeFrame(false);
- frame_->GetRootView()->ThemeChanged();
- frame_->GetRootView()->SchedulePaint();
+ frame_->GetWindow()->GetNonClientView()->SetUseNativeFrame(false);
+ GetRootView()->ThemeChanged();
+ GetRootView()->SchedulePaint();
}
int BrowserView::GetExtraRenderViewHeight() const {
@@ -1060,8 +1061,8 @@ bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
bounds->height() + toolbar_->GetPreferredSize().height());
}
- gfx::Rect window_rect =
- frame_->GetNonClientView()->GetWindowBoundsForClientBounds(*bounds);
+ gfx::Rect window_rect = frame_->GetWindow()->GetNonClientView()->
+ GetWindowBoundsForClientBounds(*bounds);
window_rect.set_origin(bounds->origin());
// When we are given x/y coordinates of 0 on a created popup window,
@@ -1113,7 +1114,7 @@ bool BrowserView::CanClose() const {
// Tab strip isn't empty. Hide the frame (so it appears to have closed
// immediately) and close all the tabs, allowing the renderers to shut
// down. When the tab strip is empty we'll be called back again.
- frame_->Hide();
+ frame_->GetWindow()->HideWindow();
browser_->OnWindowClosing();
return false;
}
@@ -1121,7 +1122,7 @@ bool BrowserView::CanClose() const {
// Empty TabStripModel, it's now safe to allow the Window to be closed.
NotificationService::current()->Notify(
NotificationType::WINDOW_CLOSED,
- Source<HWND>(frame_->GetNativeView()),
+ Source<HWND>(frame_->GetWindow()->GetNativeWindow()),
NotificationService::NoDetails());
return true;
}
@@ -1132,9 +1133,10 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
// area of the window. So we need to treat hit-tests in these regions as
// hit-tests of the titlebar.
- if (!frame_->IsMaximized() && !frame_->IsFullscreen()) {
+ if (!frame_->GetWindow()->IsMaximized() &&
+ !frame_->GetWindow()->IsFullscreen()) {
CRect client_rect;
- ::GetClientRect(frame_->GetNativeView(), &client_rect);
+ ::GetClientRect(frame_->GetWindow()->GetNativeWindow(), &client_rect);
gfx::Size resize_corner_size = ResizeCorner::GetSize();
gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(),
client_rect.bottom - resize_corner_size.height(),
@@ -1295,6 +1297,7 @@ void BrowserView::Init() {
tabstrip_ = new TabStrip(browser_->tabstrip_model());
tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP));
AddChildView(tabstrip_);
+ frame_->TabStripCreated(tabstrip_);
toolbar_ = new BrowserToolbarView(browser_.get());
AddChildView(toolbar_);
@@ -1321,7 +1324,8 @@ void BrowserView::Init() {
}
void BrowserView::InitSystemMenu() {
- HMENU system_menu = GetSystemMenu(frame_->GetNativeView(), FALSE);
+ HMENU system_menu = GetSystemMenu(frame_->GetWindow()->GetNativeWindow(),
+ FALSE);
system_menu_.reset(new views::MenuWin(system_menu));
int insertion_index = std::max(0, system_menu_->ItemCount() - 1);
// We add the menu items in reverse order so that insertion_index never needs
@@ -1696,9 +1700,12 @@ void BrowserView::InitClass() {
BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
if (!views::ViewsDelegate::views_delegate)
views::ViewsDelegate::views_delegate = new ChromeViewsDelegate;
- BrowserView* browser_view = new BrowserView(browser);
- (new BrowserFrame(browser_view, browser->profile()))->Init();
- return browser_view;
+
+ // Create the view and the frame. The frame will attach itself via the view
+ // so we don't need to do anything with the pointer.
+ BrowserView* view = new BrowserView(browser);
+ BrowserFrame::Create(view, browser->profile());
+ return view;
}
// static
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index a7a5d31..fa3298f 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -30,6 +30,7 @@ class HtmlDialogUIDelegate;
class InfoBarContainer;
class StatusBubbleViews;
class TabContentsContainerView;
+class TabStrip;
namespace views {
class Menu;
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc
index c314a9e..4076879 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.cc
@@ -64,7 +64,7 @@ GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame,
throbber_running_(false),
throbber_frame_(0) {
InitClass();
- if (frame_->GetDelegate()->ShouldShowWindowIcon())
+ if (frame_->GetWindow()->GetDelegate()->ShouldShowWindowIcon())
InitThrobberIcons();
}
@@ -86,8 +86,8 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
if (UILayoutIsRightToLeft())
tabstrip_x += (width() - minimize_button_offset);
int tabstrip_width = minimize_button_offset - tabstrip_x -
- (frame_->IsMaximized() ? kNewTabCaptionMaximizedSpacing
- : kNewTabCaptionRestoredSpacing);
+ (frame_->GetWindow()->IsMaximized() ? kNewTabCaptionMaximizedSpacing
+ : kNewTabCaptionRestoredSpacing);
if (UILayoutIsRightToLeft())
tabstrip_width += tabstrip_x;
return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(),
@@ -115,13 +115,15 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const {
gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
- if (!browser_view_->IsTabStripVisible()) {
+ HWND hwnd = frame_->GetWindow()->GetNativeWindow();
+ if (!browser_view_->IsTabStripVisible() && hwnd) {
// If we don't have a tabstrip, we're either a popup or an app window, in
// which case we have a standard size non-client area and can just use
- // AdjustWindowRectEx to obtain it.
+ // AdjustWindowRectEx to obtain it. We check for a non-NULL window handle in
+ // case this gets called before the window is actually created.
RECT rect = client_bounds.ToRECT();
- AdjustWindowRectEx(&rect, frame_->window_style(), FALSE,
- frame_->window_ex_style());
+ AdjustWindowRectEx(&rect, GetWindowLong(hwnd, GWL_STYLE), FALSE,
+ GetWindowLong(hwnd, GWL_EXSTYLE));
return gfx::Rect(rect);
}
@@ -134,6 +136,7 @@ gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
}
gfx::Point GlassBrowserFrameView::GetSystemMenuPoint() const {
+ views::Window* window = frame_->GetWindow();
gfx::Point system_menu_point;
if (browser_view_->IsBrowserTypeNormal()) {
// The X coordinate conditional is because in maximized mode the frame edge
@@ -141,10 +144,10 @@ gfx::Point GlassBrowserFrameView::GetSystemMenuPoint() const {
// (where we don't do this trick) maximized windows have no client edge and
// only the frame edge is offscreen.
system_menu_point.SetPoint(NonClientBorderThickness() -
- ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ ((window->IsMaximized() || window->IsFullscreen()) ?
0 : kClientEdgeThickness),
NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() -
- (frame_->IsFullscreen() ? 0 : kClientEdgeThickness));
+ (frame_->GetWindow()->IsFullscreen() ? 0 : kClientEdgeThickness));
} else {
system_menu_point.SetPoint(0, -kFrameShadowThickness);
}
@@ -160,7 +163,8 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point))
return HTNOWHERE;
- int frame_component = frame_->GetClientView()->NonClientHitTest(point);
+ int frame_component =
+ frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
if (frame_component != HTNOWHERE)
return frame_component;
@@ -168,7 +172,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point, border_thickness,
NonClientBorderThickness(), border_thickness,
kResizeAreaCornerSize - border_thickness,
- frame_->GetDelegate()->CanResize());
+ frame_->GetWindow()->GetDelegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -183,7 +187,7 @@ void GlassBrowserFrameView::Paint(gfx::Canvas* canvas) {
PaintDistributorLogo(canvas);
PaintToolbarBackground(canvas);
PaintOTRAvatar(canvas);
- if (!frame_->IsMaximized())
+ if (!frame_->GetWindow()->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -197,17 +201,19 @@ void GlassBrowserFrameView::Layout() {
// GlassBrowserFrameView, private:
int GlassBrowserFrameView::FrameBorderThickness() const {
- return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ views::Window* window = frame_->GetWindow();
+ return (window->IsMaximized() || window->IsFullscreen()) ?
0 : GetSystemMetrics(SM_CXSIZEFRAME);
}
int GlassBrowserFrameView::NonClientBorderThickness() const {
- return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ views::Window* window = frame_->GetWindow();
+ return (window->IsMaximized() || window->IsFullscreen()) ?
0 : kNonClientBorderThickness;
}
int GlassBrowserFrameView::NonClientTopBorderHeight() const {
- if (frame_->IsFullscreen())
+ if (frame_->GetWindow()->IsFullscreen())
return 0;
// We'd like to use FrameBorderThickness() here, but the maximized Aero glass
// frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border
@@ -219,7 +225,7 @@ int GlassBrowserFrameView::NonClientTopBorderHeight() const {
void GlassBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) {
// The distributor logo is only painted when the frame is not maximized and
// when we actually have a logo.
- if (!frame_->IsMaximized() && distributor_logo_ &&
+ if (!frame_->GetWindow()->IsMaximized() && distributor_logo_ &&
browser_view_->ShouldShowDistributorLogo()) {
// NOTE: We don't mirror the logo placement here because the outer frame
// itself isn't mirrored in RTL. This is a bug; if it is fixed, this should
@@ -234,7 +240,8 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
gfx::Point toolbar_origin(toolbar_bounds.origin());
- View::ConvertPointToView(frame_->GetClientView(), this, &toolbar_origin);
+ View::ConvertPointToView(frame_->GetWindow()->GetClientView(),
+ this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
@@ -279,7 +286,8 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
// The client edges start below the toolbar upper corner images regardless
// of how tall the toolbar itself is.
int client_area_top =
- frame_->GetClientView()->y() + browser_view_->GetToolbarBounds().y() +
+ frame_->GetWindow()->GetClientView()->y() +
+ browser_view_->GetToolbarBounds().y() +
rb.GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
@@ -339,7 +347,7 @@ void GlassBrowserFrameView::LayoutOTRAvatar() {
int tabstrip_height, otr_height;
if (browser_view_->IsTabStripVisible()) {
tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
- otr_height = frame_->IsMaximized() ?
+ otr_height = frame_->GetWindow()->IsMaximized() ?
(tabstrip_height - kOTRMaximizedTopSpacing) :
otr_avatar_icon.height();
} else {
@@ -371,7 +379,7 @@ void GlassBrowserFrameView::StartThrobber() {
throbber_running_ = true;
throbber_frame_ = 0;
InitThrobberIcons();
- SendMessage(frame_->GetNativeView(), WM_SETICON,
+ SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
}
@@ -383,14 +391,14 @@ void GlassBrowserFrameView::StopThrobber() {
// This will reset the small icon which we set in the throbber code.
// Windows will then pick up the default icon from the window class.
- SendMessage(frame_->GetNativeView(), WM_SETICON,
+ SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL), NULL);
}
}
void GlassBrowserFrameView::DisplayNextThrobberFrame() {
throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
- SendMessage(frame_->GetNativeView(), WM_SETICON,
+ SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
}
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.h b/chrome/browser/views/frame/glass_browser_frame_view.h
index 7b999e1..53c964d 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.h
+++ b/chrome/browser/views/frame/glass_browser_frame_view.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_
#define CHROME_BROWSER_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_
-#include "chrome/browser/views/frame/browser_frame.h"
+#include "chrome/browser/views/frame/browser_frame_win.h"
#include "views/controls/button/button.h"
#include "views/window/non_client_view.h"
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 29ee9d9..618e90d 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -107,7 +107,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
browser_view_(browser_view) {
InitClass();
- ThemeProvider* tp = frame_->GetThemeProvider();
+ ThemeProvider* tp = frame_->GetThemeProviderForFrame();
minimize_button_->SetImage(
views::CustomButton::BS_NORMAL,
@@ -185,7 +185,7 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
(otr_avatar_bounds_.right() + kOTRSideSpacing) :
NonClientBorderThickness();
int tabstrip_width = minimize_button_->x() - tabstrip_x -
- (frame_->IsMaximized() ?
+ (frame_->GetWindow()->IsMaximized() ?
kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing);
return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(),
std::max(0, tabstrip_width), tabstrip->GetPreferredHeight());
@@ -202,7 +202,7 @@ gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
min_size.Enlarge(2 * border_thickness,
NonClientTopBorderHeight() + border_thickness);
- views::WindowDelegate* d = frame_->GetDelegate();
+ views::WindowDelegate* d = frame_->GetWindow()->GetDelegate();
int min_titlebar_width = (2 * FrameBorderThickness()) + kIconLeftSpacing +
(d->ShouldShowWindowIcon() ?
(IconSize(NULL, NULL, NULL) + kTitleLogoSpacing) : 0) +
@@ -237,7 +237,7 @@ gfx::Point OpaqueBrowserFrameView::GetSystemMenuPoint() const {
gfx::Point system_menu_point(
MirroredXCoordinateInsideView(FrameBorderThickness()),
NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() -
- (frame_->IsFullscreen() ? 0 : kClientEdgeThickness));
+ (frame_->GetWindow()->IsFullscreen() ? 0 : kClientEdgeThickness));
ConvertPointToScreen(this, &system_menu_point);
return system_menu_point;
}
@@ -246,7 +246,8 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
- int frame_component = frame_->GetClientView()->NonClientHitTest(point);
+ int frame_component =
+ frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
if (frame_component != HTNOWHERE)
return frame_component;
@@ -268,7 +269,7 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point, TopResizeHeight(),
NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
- frame_->GetDelegate()->CanResize());
+ frame_->GetWindow()->GetDelegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -277,7 +278,7 @@ void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
DCHECK(window_mask);
- if (frame_->IsMaximized() || frame_->IsFullscreen())
+ if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen())
return;
// Redefine the window visible region for the new size.
@@ -314,10 +315,11 @@ void OpaqueBrowserFrameView::ResetWindowControls() {
// OpaqueBrowserFrameView, views::View overrides:
void OpaqueBrowserFrameView::Paint(gfx::Canvas* canvas) {
- if (frame_->IsFullscreen())
+ views::Window* window = frame_->GetWindow();
+ if (window->IsFullscreen())
return; // Nothing is visible, so don't bother to paint.
- if (frame_->IsMaximized())
+ if (window->IsMaximized())
PaintMaximizedFrameBorder(canvas);
else
PaintRestoredFrameBorder(canvas);
@@ -325,7 +327,7 @@ void OpaqueBrowserFrameView::Paint(gfx::Canvas* canvas) {
PaintTitleBar(canvas);
PaintToolbarBackground(canvas);
PaintOTRAvatar(canvas);
- if (!frame_->IsMaximized())
+ if (!window->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -391,14 +393,15 @@ void OpaqueBrowserFrameView::SetAccessibleName(const std::wstring& name) {
// OpaqueBrowserFrameView, views::ButtonListener implementation:
void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender) {
+ views::Window* window = frame_->GetWindow();
if (sender == minimize_button_)
- frame_->Minimize();
+ window->Minimize();
else if (sender == maximize_button_)
- frame_->Maximize();
+ window->Maximize();
else if (sender == restore_button_)
- frame_->Restore();
+ window->Restore();
else if (sender == close_button_)
- frame_->Close();
+ window->Close();
}
///////////////////////////////////////////////////////////////////////////////
@@ -413,14 +416,15 @@ bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() {
- return frame_->GetDelegate()->GetWindowIcon();
+ return frame_->GetWindow()->GetDelegate()->GetWindowIcon();
}
///////////////////////////////////////////////////////////////////////////////
// OpaqueBrowserFrameView, private:
int OpaqueBrowserFrameView::FrameBorderThickness() const {
- return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ views::Window* window = frame_->GetWindow();
+ return (window->IsMaximized() || window->IsFullscreen()) ?
0 : kFrameBorderThickness;
}
@@ -430,17 +434,19 @@ int OpaqueBrowserFrameView::TopResizeHeight() const {
int OpaqueBrowserFrameView::NonClientBorderThickness() const {
// When we fill the screen, we don't show a client edge.
+ views::Window* window = frame_->GetWindow();
return FrameBorderThickness() +
- ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ ((window->IsMaximized() || window->IsFullscreen()) ?
0 : kClientEdgeThickness);
}
int OpaqueBrowserFrameView::NonClientTopBorderHeight() const {
- if (frame_->GetDelegate()->ShouldShowWindowTitle())
+ views::Window* window = frame_->GetWindow();
+ if (window->GetDelegate()->ShouldShowWindowTitle())
return TitleCoordinates(NULL, NULL);
return FrameBorderThickness() +
- ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ ((window->IsMaximized() || window->IsFullscreen()) ?
0 : kNonClientRestoredExtraThickness);
}
@@ -453,7 +459,7 @@ int OpaqueBrowserFrameView::UnavailablePixelsAtBottomOfNonClientHeight() const {
return -kFrameShadowThickness;
return kFrameShadowThickness +
- (frame_->IsMaximized() ? 0 : kClientEdgeThickness);
+ (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness);
}
int OpaqueBrowserFrameView::TitleCoordinates(int* title_top_spacing_ptr,
@@ -470,7 +476,7 @@ int OpaqueBrowserFrameView::TitleCoordinates(int* title_top_spacing_ptr,
// the toolbar).
int title_bottom_spacing =
kFrameBorderThickness + kTitleTopSpacing - kFrameShadowThickness;
- if (frame_->IsMaximized()) {
+ if (frame_->GetWindow()->IsMaximized()) {
// When we maximize, the top border appears to be chopped off; shift the
// title down to stay centered within the remaining space.
int title_adjust = (kFrameBorderThickness / 2);
@@ -526,7 +532,7 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
SkBitmap* theme_frame;
SkColor frame_color;
if (!browser_view_->IsOffTheRecord()) {
- if (frame_->IsActive()) {
+ if (frame_->GetWindow()->IsActive()) {
theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME);
frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME);
} else {
@@ -534,7 +540,7 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INACTIVE);
}
} else {
- if (frame_->IsActive()) {
+ if (frame_->GetWindow()->IsActive()) {
theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO);
frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INCOGNITO);
} else {
@@ -605,14 +611,16 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
ThemeProvider* tp = GetThemeProvider();
+ views::Window* window = frame_->GetWindow();
+
// Window frame mode and color
SkBitmap* theme_frame;
if (!browser_view_->IsOffTheRecord()) {
- theme_frame = frame_->IsActive() ?
+ theme_frame = window->IsActive() ?
tp->GetBitmapNamed(IDR_THEME_FRAME) :
tp->GetBitmapNamed(IDR_THEME_FRAME_INACTIVE);
} else {
- theme_frame = frame_->IsActive() ?
+ theme_frame = window->IsActive() ?
tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO) :
tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_INACTIVE);
}
@@ -628,14 +636,14 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
tp->GetBitmapNamed(IDR_APP_TOP_CENTER);
int edge_height = top_center->height() - kClientEdgeThickness;
canvas->TileImageInt(*top_center, 0,
- frame_->GetClientView()->y() - edge_height, width(), edge_height);
+ window->GetClientView()->y() - edge_height, width(), edge_height);
}
}
void OpaqueBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) {
// The distributor logo is only painted when the frame is not maximized and
// when we actually have a logo.
- if (!frame_->IsMaximized() && distributor_logo_ &&
+ if (!frame_->GetWindow()->IsMaximized() && distributor_logo_ &&
browser_view_->ShouldShowDistributorLogo()) {
canvas->DrawBitmapInt(*distributor_logo_,
MirroredLeftPointForRect(logo_bounds_), logo_bounds_.y());
@@ -644,7 +652,7 @@ void OpaqueBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) {
void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
// The window icon is painted by the TabIconView.
- views::WindowDelegate* d = frame_->GetDelegate();
+ views::WindowDelegate* d = frame_->GetWindow()->GetDelegate();
if (d->ShouldShowWindowTitle()) {
canvas->DrawStringInt(d->GetWindowTitle(), *title_font_, SK_ColorWHITE,
MirroredLeftPointForRect(title_bounds_), title_bounds_.y(),
@@ -665,7 +673,8 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
ThemeProvider* tp = GetThemeProvider();
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
gfx::Point toolbar_origin(toolbar_bounds.origin());
- View::ConvertPointToView(frame_->GetClientView(), this, &toolbar_origin);
+ View::ConvertPointToView(frame_->GetWindow()->GetClientView(),
+ this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
int strip_height = browser_view_->GetTabStripHeight();
@@ -730,7 +739,7 @@ void OpaqueBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) {
void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
ThemeProvider* tp = GetThemeProvider();
- int client_area_top = frame_->GetClientView()->y();
+ int client_area_top = frame_->GetWindow()->GetClientView()->y();
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
if (browser_view_->IsToolbarVisible()) {
@@ -809,7 +818,7 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
views::ImageButton::ALIGN_BOTTOM);
// Maximized buttons start at window top so that even if their images aren't
// drawn flush with the screen edge, they still obey Fitts' Law.
- bool is_maximized = frame_->IsMaximized();
+ bool is_maximized = frame_->GetWindow()->IsMaximized();
int frame_thickness = FrameBorderThickness();
int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing;
int top_extra_height = is_maximized ? kCaptionTopSpacing : 0;
@@ -826,7 +835,7 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
// When the window is restored, we show a maximized button; otherwise, we show
// a restore button.
- bool is_restored = !is_maximized && !frame_->IsMinimized();
+ bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized();
views::ImageButton* invisible_button = is_restored ?
restore_button_ : maximize_button_;
invisible_button->SetVisible(false);
@@ -881,10 +890,10 @@ void OpaqueBrowserFrameView::LayoutTitleBar() {
// the remaining space. Because the apparent shape of our border is simpler,
// using the same positioning makes things look slightly uncentered with
// restored windows, so we come up to compensate.
- if (!frame_->IsMaximized())
+ if (!frame_->GetWindow()->IsMaximized())
icon_y -= kIconRestoredAdjust;
- views::WindowDelegate* d = frame_->GetDelegate();
+ views::WindowDelegate* d = frame_->GetWindow()->GetDelegate();
if (!d->ShouldShowWindowIcon())
icon_size = 0;
if (window_icon_)
@@ -907,7 +916,7 @@ void OpaqueBrowserFrameView::LayoutOTRAvatar() {
int tabstrip_height, otr_height;
if (browser_view_->IsTabStripVisible()) {
tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
- otr_height = frame_->IsMaximized() ?
+ otr_height = frame_->GetWindow()->IsMaximized() ?
(tabstrip_height - kOTRMaximizedTopSpacing) :
otr_avatar_icon.height();
} else {
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h
index 575992b..d62b8f0 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_
#define CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_
-#include "chrome/browser/views/frame/browser_frame.h"
+#include "chrome/browser/views/frame/browser_frame_win.h"
#include "chrome/browser/views/tab_icon_view.h"
#include "views/controls/button/button.h"
#include "views/window/non_client_view.h"
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 9447285..6fdda8e 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -98,7 +98,7 @@ void InfoBubble::Init(HWND parent_hwnd,
BrowserView* browser_view =
BrowserView::GetBrowserViewForHWND(owning_frame_hwnd);
DCHECK(browser_view);
- parent_ = browser_view->frame();
+ parent_ = browser_view->frame()->GetWindow();
parent_->DisableInactiveRendering();
if (kInfoBubbleCornerTopLeft == NULL) {
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 4790878..045fe14 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -25,6 +25,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "views/event.h"
#include "views/widget/root_view.h"
+#include "views/window/window.h"
static const int kHorizontalMoveThreshold = 16; // pixels
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index a8bc6ed..b83ff86 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1352,8 +1352,8 @@
'browser/views/first_run_view.h',
'browser/views/first_run_view_base.cc',
'browser/views/first_run_view_base.h',
- 'browser/views/frame/browser_frame.cc',
- 'browser/views/frame/browser_frame.h',
+ 'browser/views/frame/browser_frame_win.cc',
+ 'browser/views/frame/browser_frame_win.h',
'browser/views/frame/browser_root_view.cc',
'browser/views/frame/browser_root_view.h',
'browser/views/frame/browser_view.cc',
diff --git a/views/window/window.h b/views/window/window.h
index 9d29a81..bb618ed 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -62,6 +62,20 @@ class Window {
// Makes the window visible.
virtual void Show() = 0;
+ // Hides the window. This does not delete the window, it just hides it. This
+ // always hides the window, it is separate from the stack maintained by
+ // Push/PopForceHidden.
+ virtual void HideWindow() = 0;
+
+ // Hides the window if it hasn't already been force-hidden. The force hidden
+ // count is tracked, so calling multiple times is allowed, you just have to
+ // be sure to call PopForceHidden the same number of times.
+ virtual void PushForceHidden() = 0;
+
+ // Decrements the force hidden count, showing the window if we have reached
+ // the top of the stack. See PushForceHidden.
+ virtual void PopForceHidden() = 0;
+
// Activate the window, assuming it already exists and is visible.
virtual void Activate() = 0;
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index b45f435..06558ae 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -55,6 +55,18 @@ void WindowGtk::Show() {
gtk_widget_show_all(GetNativeView());
}
+void WindowGtk::HideWindow() {
+ NOTIMPLEMENTED();
+}
+
+void WindowGtk::PushForceHidden() {
+ NOTIMPLEMENTED();
+}
+
+void WindowGtk::PopForceHidden() {
+ NOTIMPLEMENTED();
+}
+
void WindowGtk::Activate() {
NOTIMPLEMENTED();
}
diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h
index f7a5366..4391c19 100644
--- a/views/window/window_gtk.h
+++ b/views/window/window_gtk.h
@@ -31,6 +31,9 @@ class WindowGtk : public WidgetGtk, public Window {
virtual void SetBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window);
virtual void Show();
+ virtual void HideWindow();
+ virtual void PushForceHidden();
+ virtual void PopForceHidden();
virtual void Activate();
virtual void Close();
virtual void Maximize();
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 78fa32e..2286762 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -161,13 +161,9 @@ void WindowWin::Show(int show_state) {
SetInitialFocus();
}
-int WindowWin::GetShowState() const {
- return SW_SHOWNORMAL;
-}
-
-void WindowWin::ExecuteSystemMenuCommand(int command) {
- if (command)
- SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0);
+void WindowWin::HideWindow() {
+ // We can just call the function implemented by the widget.
+ Hide();
}
void WindowWin::PushForceHidden() {
@@ -182,6 +178,15 @@ void WindowWin::PopForceHidden() {
}
}
+int WindowWin::GetShowState() const {
+ return SW_SHOWNORMAL;
+}
+
+void WindowWin::ExecuteSystemMenuCommand(int command) {
+ if (command)
+ SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0);
+}
+
// static
int Window::GetLocalizedContentsWidth(int col_resource_id) {
double chars = _wtof(l10n_util::GetString(col_resource_id).c_str());
diff --git a/views/window/window_win.h b/views/window/window_win.h
index 1760caa..ddc2f21 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -44,14 +44,6 @@ class WindowWin : public WidgetWin,
// Executes the specified SC_command.
void ExecuteSystemMenuCommand(int command);
- // Hides the window if it hasn't already been force-hidden, then increments
- // |force_hidden_count_| to prevent it from being shown again until
- // PopForceHidden()) is called.
- void PushForceHidden();
-
- // Decrements |force_hidden_count_| and, if it is now zero, shows the window.
- void PopForceHidden();
-
// Accessors and setters for various properties.
HWND owning_window() const { return owning_hwnd_; }
void set_focus_on_creation(bool focus_on_creation) {
@@ -65,6 +57,9 @@ class WindowWin : public WidgetWin,
virtual void SetBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window);
virtual void Show();
+ virtual void HideWindow();
+ virtual void PushForceHidden();
+ virtual void PopForceHidden();
virtual void Activate();
virtual void Close();
virtual void Maximize();