summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 00:28:00 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 00:28:00 +0000
commit32670b07a6c42634f446e3d471f42a9fb40090f2 (patch)
tree77b15435f3a436d54fcaa5cb4c0d4371a007fad6 /chrome/browser
parenta0e5688cc11f7f5e835b5c1a75c17ce4a28a1527 (diff)
downloadchromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.zip
chromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.tar.gz
chromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.tar.bz2
Support DWM switching.
This completes the collapsing of window types and browser frames around a single class: views::Window. CustomFrameWindow is removed with this change. The Browser window is represented by a single views::Window subclass: BrowserFrame, which replaces both AeroGlassFrame and OpaqueFrame. NonClientView is now a container of two sibling classes - the Window's ClientView (in the Browser's case, BrowserView), and a NonClientFrameView subclass, which provides the rendering for the non-client portions of the window. These Views are siblings rather than the ClientView a child of the NonClientFrameView because when the DWM is toggled, the ClientView would have to be re-parented. Many Views make the assumption they are only inserted into a View hierarchy once, and so this is problematic. By having the views be siblings, this is avoided. With this in mind, all of the former NonClientViews now become NonClientFrameView subclasses: DefaultNonClientView -> CustomFrameView (non-existent, NonClientView) -> NativeFrameView AeroGlassNonClientView -> GlassBrowserFrameView OpaqueNonClientView -> OpaqueBrowserFrameView The latter two derive from NonClientFrameView via BrowserNonClientFrameView, which adds some extras. I also had to modify the TabRenderer class to know how to drop its cache of tab background images when the theme changes since it uses different ones for Glass and non-Glass. This change also fixes a few non-client flicker issues relating to window non-client activation by using more ScopedRedrawLocks. (Touches info_bubble.cc, window.cc) Bugs fixed: http://crbug.com/153 http://crbug.com/747 http://crbug.com/2371 http://crbug.com/3264 http://crbug.com/8234 Plumbing for http://crbug.com/8247 Design docs: http://dev.chromium.org/developers/design-documents/views-windowing http://dev.chromium.org/developers/design-documents/browser-window Review URL: http://codereview.chromium.org/27317 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_focus_uitest.cc2
-rw-r--r--chrome/browser/views/browser_views.vcproj26
-rw-r--r--chrome/browser/views/constrained_window_impl.cc183
-rw-r--r--chrome/browser/views/constrained_window_impl.h17
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.cc243
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.h95
-rw-r--r--chrome/browser/views/frame/browser_frame.cc191
-rw-r--r--chrome/browser/views/frame/browser_frame.h108
-rw-r--r--chrome/browser/views/frame/browser_view.cc70
-rw-r--r--chrome/browser/views/frame/browser_window_factory.cc50
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc (renamed from chrome/browser/views/frame/aero_glass_non_client_view.cc)200
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.h (renamed from chrome/browser/views/frame/aero_glass_non_client_view.h)70
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc (renamed from chrome/browser/views/frame/opaque_non_client_view.cc)170
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.h (renamed from chrome/browser/views/frame/opaque_non_client_view.h)51
-rw-r--r--chrome/browser/views/frame/opaque_frame.cc139
-rw-r--r--chrome/browser/views/frame/opaque_frame.h74
-rw-r--r--chrome/browser/views/hung_renderer_view.cc2
-rw-r--r--chrome/browser/views/info_bubble.cc3
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc54
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h4
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc3
-rw-r--r--chrome/browser/views/toolbar_view.cc12
-rw-r--r--chrome/browser/views/toolbar_view.h2
23 files changed, 736 insertions, 1033 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 6ff0f35..d920a012 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -245,7 +245,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()->GetWindow()->IsActive());
+ EXPECT_TRUE(browser_view->frame()->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 92d345d..41b7bb1 100644
--- a/chrome/browser/views/browser_views.vcproj
+++ b/chrome/browser/views/browser_views.vcproj
@@ -125,19 +125,7 @@
Name="Frame"
>
<File
- RelativePath=".\frame\aero_glass_frame.cc"
- >
- </File>
- <File
- RelativePath=".\frame\aero_glass_frame.h"
- >
- </File>
- <File
- RelativePath=".\frame\aero_glass_non_client_view.cc"
- >
- </File>
- <File
- RelativePath=".\frame\aero_glass_non_client_view.h"
+ RelativePath=".\frame\browser_frame.cc"
>
</File>
<File
@@ -153,23 +141,19 @@
>
</File>
<File
- RelativePath=".\frame\browser_window_factory.cc"
- >
- </File>
- <File
- RelativePath=".\frame\opaque_frame.cc"
+ RelativePath=".\frame\glass_browser_frame_view.cc"
>
</File>
<File
- RelativePath=".\frame\opaque_frame.h"
+ RelativePath=".\frame\glass_browser_frame_view.h"
>
</File>
<File
- RelativePath=".\frame\opaque_non_client_view.cc"
+ RelativePath=".\frame\opaque_browser_frame_view.cc"
>
</File>
<File
- RelativePath=".\frame\opaque_non_client_view.h"
+ RelativePath=".\frame\opaque_browser_frame_view.h"
>
</File>
</Filter>
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 8b57d18..8005457 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -184,22 +184,22 @@ SkBitmap* VistaWindowResources::bitmaps_[];
SkBitmap* OTRWindowResources::bitmaps_[];
////////////////////////////////////////////////////////////////////////////////
-// ConstrainedWindowNonClientView
+// ConstrainedWindowFrameView
-class ConstrainedWindowNonClientView
- : public views::NonClientView,
+class ConstrainedWindowFrameView
+ : public views::NonClientFrameView,
public views::BaseButton::ButtonListener {
public:
- ConstrainedWindowNonClientView(ConstrainedWindowImpl* container,
- TabContents* owner);
- virtual ~ConstrainedWindowNonClientView();
+ explicit ConstrainedWindowFrameView(ConstrainedWindowImpl* container);
+ virtual ~ConstrainedWindowFrameView();
void UpdateWindowTitle();
- // Overridden from views::NonClientView:
- virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const;
- virtual gfx::Size CalculateWindowSizeForClientSize(int width,
- int height) const;
+ // Overridden from views::NonClientFrameView:
+ virtual gfx::Rect GetBoundsForClientView() const;
+ virtual bool AlwaysUseCustomFrame() const;
+ virtual gfx::Rect GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const;
virtual gfx::Point GetSystemMenuPoint() const;
virtual int NonClientHitTest(const gfx::Point& point);
virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask);
@@ -209,7 +209,7 @@ class ConstrainedWindowNonClientView
// Overridden from views::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);
+ virtual void ThemeChanged();
// Overridden from views::BaseButton::ButtonListener:
virtual void ButtonPressed(views::BaseButton* sender);
@@ -242,11 +242,17 @@ class ConstrainedWindowNonClientView
void LayoutTitleBar();
void LayoutClientView();
+ // Returns the bounds of the client area for the specified view size.
+ gfx::Rect CalculateClientAreaBounds(int width, int height) const;
+
SkColor GetTitleColor() const {
return (container_->owner()->profile()->IsOffTheRecord() ||
!win_util::ShouldUseVistaFrame()) ? SK_ColorWHITE : SK_ColorBLACK;
}
+ // Loads the appropriate set of WindowResources for the frame view.
+ void InitWindowResources();
+
ConstrainedWindowImpl* container_;
scoped_ptr<views::WindowResources> resources_;
@@ -255,15 +261,18 @@ class ConstrainedWindowNonClientView
views::Button* close_button_;
+ // The bounds of the ClientView.
+ gfx::Rect client_view_bounds_;
+
static void InitClass();
// The font to be used to render the titlebar text.
static ChromeFont title_font_;
- DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowNonClientView);
+ DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowFrameView);
};
-ChromeFont ConstrainedWindowNonClientView::title_font_;
+ChromeFont ConstrainedWindowFrameView::title_font_;
namespace {
// The frame border is only visible in restored mode and is hardcoded to 4 px on
@@ -294,23 +303,15 @@ const SkColor kContentsBorderColor = SkColorSetRGB(219, 235, 255);
}
////////////////////////////////////////////////////////////////////////////////
-// ConstrainedWindowNonClientView, public:
+// ConstrainedWindowFrameView, public:
-ConstrainedWindowNonClientView::ConstrainedWindowNonClientView(
- ConstrainedWindowImpl* container, TabContents* owner)
- : NonClientView(),
+ConstrainedWindowFrameView::ConstrainedWindowFrameView(
+ ConstrainedWindowImpl* container)
+ : NonClientFrameView(),
container_(container),
close_button_(new views::Button) {
InitClass();
- if (owner->profile()->IsOffTheRecord()) {
- resources_.reset(new OTRWindowResources);
- } else {
- if (win_util::ShouldUseVistaFrame()) {
- resources_.reset(new VistaWindowResources);
- } else {
- resources_.reset(new XPWindowResources);
- }
- }
+ InitWindowResources();
close_button_->SetImage(views::Button::BS_NORMAL,
resources_->GetPartBitmap(FRAME_CLOSE_BUTTON_ICON));
@@ -324,35 +325,37 @@ ConstrainedWindowNonClientView::ConstrainedWindowNonClientView(
AddChildView(close_button_);
}
-ConstrainedWindowNonClientView::~ConstrainedWindowNonClientView() {
+ConstrainedWindowFrameView::~ConstrainedWindowFrameView() {
}
-void ConstrainedWindowNonClientView::UpdateWindowTitle() {
+void ConstrainedWindowFrameView::UpdateWindowTitle() {
SchedulePaint(title_bounds_, false);
}
////////////////////////////////////////////////////////////////////////////////
-// ConstrainedWindowNonClientView, views::NonClientView implementation:
+// ConstrainedWindowFrameView, views::NonClientFrameView implementation:
-gfx::Rect ConstrainedWindowNonClientView::CalculateClientAreaBounds(
- int width,
- int height) const {
- int top_height = NonClientTopBorderHeight();
- int border_thickness = NonClientBorderThickness();
- return gfx::Rect(border_thickness, top_height,
- std::max(0, width - (2 * border_thickness)),
- std::max(0, height - top_height - border_thickness));
+gfx::Rect ConstrainedWindowFrameView::GetBoundsForClientView() const {
+ return client_view_bounds_;
}
-gfx::Size ConstrainedWindowNonClientView::CalculateWindowSizeForClientSize(
- int width,
- int height) const {
+bool ConstrainedWindowFrameView::AlwaysUseCustomFrame() const {
+ // Constrained windows always use the custom frame - they just have a
+ // different set of bitmaps.
+ return true;
+}
+
+gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const {
+ int top_height = NonClientTopBorderHeight();
int border_thickness = NonClientBorderThickness();
- return gfx::Size(width + (2 * border_thickness),
- height + NonClientTopBorderHeight() + border_thickness);
+ return gfx::Rect(std::max(0, client_bounds.x() - border_thickness),
+ std::max(0, client_bounds.y() - top_height),
+ client_bounds.width() + (2 * border_thickness),
+ client_bounds.height() + top_height + border_thickness);
}
-gfx::Point ConstrainedWindowNonClientView::GetSystemMenuPoint() const {
+gfx::Point ConstrainedWindowFrameView::GetSystemMenuPoint() const {
// Doesn't really matter, since we never show system menus on constrained
// windows...
gfx::Point system_menu_point(FrameBorderThickness(),
@@ -361,7 +364,7 @@ gfx::Point ConstrainedWindowNonClientView::GetSystemMenuPoint() const {
return system_menu_point;
}
-int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) {
+int ConstrainedWindowFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
@@ -380,8 +383,8 @@ int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) {
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
-void ConstrainedWindowNonClientView::GetWindowMask(const gfx::Size& size,
- gfx::Path* window_mask) {
+void ConstrainedWindowFrameView::GetWindowMask(const gfx::Size& size,
+ gfx::Path* window_mask) {
DCHECK(window_mask);
// Redefine the window visible region for the new size.
@@ -403,60 +406,55 @@ void ConstrainedWindowNonClientView::GetWindowMask(const gfx::Size& size,
window_mask->close();
}
-void ConstrainedWindowNonClientView::EnableClose(bool enable) {
+void ConstrainedWindowFrameView::EnableClose(bool enable) {
close_button_->SetEnabled(enable);
}
////////////////////////////////////////////////////////////////////////////////
-// ConstrainedWindowNonClientView, views::View implementation:
+// ConstrainedWindowFrameView, views::View implementation:
-void ConstrainedWindowNonClientView::Paint(ChromeCanvas* canvas) {
+void ConstrainedWindowFrameView::Paint(ChromeCanvas* canvas) {
PaintFrameBorder(canvas);
PaintTitleBar(canvas);
PaintClientEdge(canvas);
}
-void ConstrainedWindowNonClientView::Layout() {
+void ConstrainedWindowFrameView::Layout() {
LayoutWindowControls();
LayoutTitleBar();
LayoutClientView();
}
-void ConstrainedWindowNonClientView::ViewHierarchyChanged(bool is_add,
- View *parent,
- View *child) {
- // Add our Client View as we are added to the Container so that if we are
- // subsequently resized all the parent-child relationships are established.
- if (is_add && GetWidget() && child == this)
- AddChildView(container_->client_view());
+void ConstrainedWindowFrameView::ThemeChanged() {
+ InitWindowResources();
}
////////////////////////////////////////////////////////////////////////////////
-// ConstrainedWindowNonClientView, views::BaseButton::Button
+// ConstrainedWindowFrameView, views::BaseButton::Button
// implementation:
-void ConstrainedWindowNonClientView::ButtonPressed(views::BaseButton* sender) {
+void ConstrainedWindowFrameView::ButtonPressed(views::BaseButton* sender) {
if (sender == close_button_)
container_->ExecuteSystemMenuCommand(SC_CLOSE);
}
////////////////////////////////////////////////////////////////////////////////
-// ConstrainedWindowNonClientView, private:
+// ConstrainedWindowFrameView, private:
-int ConstrainedWindowNonClientView::FrameBorderThickness() const {
+int ConstrainedWindowFrameView::FrameBorderThickness() const {
return kFrameBorderThickness;
}
-int ConstrainedWindowNonClientView::NonClientBorderThickness() const {
+int ConstrainedWindowFrameView::NonClientBorderThickness() const {
return FrameBorderThickness() + kClientEdgeThickness;
}
-int ConstrainedWindowNonClientView::NonClientTopBorderHeight() const {
+int ConstrainedWindowFrameView::NonClientTopBorderHeight() const {
int title_top_spacing, title_thickness;
return TitleCoordinates(&title_top_spacing, &title_thickness);
}
-int ConstrainedWindowNonClientView::TitleCoordinates(
+int ConstrainedWindowFrameView::TitleCoordinates(
int* title_top_spacing,
int* title_thickness) const {
int frame_thickness = FrameBorderThickness();
@@ -470,7 +468,7 @@ int ConstrainedWindowNonClientView::TitleCoordinates(
return *title_top_spacing + *title_thickness + title_bottom_spacing;
}
-void ConstrainedWindowNonClientView::PaintFrameBorder(ChromeCanvas* canvas) {
+void ConstrainedWindowFrameView::PaintFrameBorder(ChromeCanvas* canvas) {
SkBitmap* top_left_corner = resources_->GetPartBitmap(FRAME_TOP_LEFT_CORNER);
SkBitmap* top_right_corner =
resources_->GetPartBitmap(FRAME_TOP_RIGHT_CORNER);
@@ -514,13 +512,13 @@ void ConstrainedWindowNonClientView::PaintFrameBorder(ChromeCanvas* canvas) {
height() - top_left_corner->height() - bottom_left_corner->height());
}
-void ConstrainedWindowNonClientView::PaintTitleBar(ChromeCanvas* canvas) {
+void ConstrainedWindowFrameView::PaintTitleBar(ChromeCanvas* canvas) {
canvas->DrawStringInt(container_->GetWindowTitle(), title_font_,
GetTitleColor(), MirroredLeftPointForRect(title_bounds_),
title_bounds_.y(), title_bounds_.width(), title_bounds_.height());
}
-void ConstrainedWindowNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
+void ConstrainedWindowFrameView::PaintClientEdge(ChromeCanvas* canvas) {
gfx::Rect client_edge_bounds(CalculateClientAreaBounds(width(), height()));
client_edge_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness);
gfx::Rect frame_shadow_bounds(client_edge_bounds);
@@ -535,7 +533,7 @@ void ConstrainedWindowNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
client_edge_bounds.height());
}
-void ConstrainedWindowNonClientView::LayoutWindowControls() {
+void ConstrainedWindowFrameView::LayoutWindowControls() {
gfx::Size close_button_size = close_button_->GetPreferredSize();
close_button_->SetBounds(
width() - close_button_size.width() - FrameBorderThickness(),
@@ -543,7 +541,7 @@ void ConstrainedWindowNonClientView::LayoutWindowControls() {
close_button_size.height());
}
-void ConstrainedWindowNonClientView::LayoutTitleBar() {
+void ConstrainedWindowFrameView::LayoutTitleBar() {
// Size the title.
int title_x = FrameBorderThickness() + kIconLeftSpacing;
int title_top_spacing, title_thickness;
@@ -554,13 +552,34 @@ void ConstrainedWindowNonClientView::LayoutTitleBar() {
title_font_.height());
}
-void ConstrainedWindowNonClientView::LayoutClientView() {
- container_->client_view()->SetBounds(CalculateClientAreaBounds(width(),
- height()));
+void ConstrainedWindowFrameView::LayoutClientView() {
+ client_view_bounds_ = CalculateClientAreaBounds(width(), height());
+}
+
+gfx::Rect ConstrainedWindowFrameView::CalculateClientAreaBounds(
+ int width,
+ int height) const {
+ int top_height = NonClientTopBorderHeight();
+ int border_thickness = NonClientBorderThickness();
+ return gfx::Rect(border_thickness, top_height,
+ std::max(0, width - (2 * border_thickness)),
+ std::max(0, height - top_height - border_thickness));
+}
+
+void ConstrainedWindowFrameView::InitWindowResources() {
+ if (container_->owner()->profile()->IsOffTheRecord()) {
+ resources_.reset(new OTRWindowResources);
+ } else {
+ if (win_util::ShouldUseVistaFrame()) {
+ resources_.reset(new VistaWindowResources);
+ } else {
+ resources_.reset(new XPWindowResources);
+ }
+ }
}
// static
-void ConstrainedWindowNonClientView::InitClass() {
+void ConstrainedWindowFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
title_font_ = win_util::GetWindowTitleFont();
@@ -583,8 +602,8 @@ ConstrainedWindowImpl::~ConstrainedWindowImpl() {
////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindowImpl, ConstrainedWindow implementation:
-ConstrainedWindowNonClientView* ConstrainedWindowImpl::non_client_view() {
- return static_cast<ConstrainedWindowNonClientView*>(non_client_view_);
+views::NonClientFrameView* ConstrainedWindowImpl::CreateFrameViewForWindow() {
+ return new ConstrainedWindowFrameView(this);
}
void ConstrainedWindowImpl::UpdateWindowTitle() {
@@ -652,13 +671,13 @@ const gfx::Rect& ConstrainedWindowImpl::GetCurrentBounds() const {
ConstrainedWindowImpl::ConstrainedWindowImpl(
TabContents* owner,
views::WindowDelegate* window_delegate)
- : CustomFrameWindow(window_delegate,
- new ConstrainedWindowNonClientView(this, owner)) {
- Init(owner);
+ : Window(window_delegate),
+ owner_(owner) {
+ non_client_view_->SetFrameView(CreateFrameViewForWindow());
+ Init();
}
-void ConstrainedWindowImpl::Init(TabContents* owner) {
- owner_ = owner;
+void ConstrainedWindowImpl::Init() {
focus_restoration_disabled_ = false;
set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION |
WS_THICKFRAME | WS_SYSMENU);
@@ -666,13 +685,13 @@ void ConstrainedWindowImpl::Init(TabContents* owner) {
}
void ConstrainedWindowImpl::InitAsDialog(const gfx::Rect& initial_bounds) {
- CustomFrameWindow::Init(owner_->GetNativeView(), initial_bounds);
+ Window::Init(owner_->GetNativeView(), initial_bounds);
ActivateConstrainedWindow();
}
void ConstrainedWindowImpl::UpdateUI(unsigned int changed_flags) {
if (changed_flags & TabContents::INVALIDATE_TITLE)
- non_client_view()->UpdateWindowTitle();
+ UpdateWindowTitle();
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/constrained_window_impl.h b/chrome/browser/views/constrained_window_impl.h
index 229555e..30e6303 100644
--- a/chrome/browser/views/constrained_window_impl.h
+++ b/chrome/browser/views/constrained_window_impl.h
@@ -8,11 +8,11 @@
#include "base/gfx/rect.h"
#include "chrome/browser/tab_contents/constrained_window.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
-#include "chrome/views/custom_frame_window.h"
+#include "chrome/views/window.h"
class ConstrainedTabContentsWindowDelegate;
class ConstrainedWindowAnimation;
-class ConstrainedWindowNonClientView;
+class ConstrainedWindowFrameView;
namespace views {
class HWNDView;
class WindowDelegate;
@@ -25,20 +25,15 @@ class WindowDelegate;
// a child HWND with a custom window frame.
//
class ConstrainedWindowImpl : public ConstrainedWindow,
- public views::CustomFrameWindow {
+ public views::Window {
public:
virtual ~ConstrainedWindowImpl();
// Returns the TabContents that constrains this Constrained Window.
TabContents* owner() const { return owner_; }
- // Returns the non-client view inside this Constrained Window.
- // NOTE: Defining the function body here would require pulling in the
- // declarations of ConstrainedWindowNonClientView, as well as all the classes
- // it depends on, from the .cc file; the benefit isn't worth it.
- ConstrainedWindowNonClientView* non_client_view();
-
- // Overridden from views::CustomFrameWindow:
+ // Overridden from views::Window:
+ virtual views::NonClientFrameView* CreateFrameViewForWindow();
virtual void UpdateWindowTitle();
// Overridden from ConstrainedWindow:
@@ -64,7 +59,7 @@ class ConstrainedWindowImpl : public ConstrainedWindow,
// ConstrainedWindow.
ConstrainedWindowImpl(TabContents* owner,
views::WindowDelegate* window_delegate);
- void Init(TabContents* owner);
+ void Init();
// Initialize the Constrained Window as a Constrained Dialog containing a
// views::View client area.
diff --git a/chrome/browser/views/frame/aero_glass_frame.cc b/chrome/browser/views/frame/aero_glass_frame.cc
deleted file mode 100644
index bc9b0f2..0000000
--- a/chrome/browser/views/frame/aero_glass_frame.cc
+++ /dev/null
@@ -1,243 +0,0 @@
-// 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.
-
-#include "chrome/browser/views/frame/aero_glass_frame.h"
-
-#include <dwmapi.h>
-
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/frame/aero_glass_non_client_view.h"
-#include "chrome/common/resource_bundle.h"
-#include "chrome/views/window_delegate.h"
-#include "grit/theme_resources.h"
-
-// static
-
-static const int kClientEdgeThickness = 3;
-
-HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount];
-
-///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, public:
-
-AeroGlassFrame::AeroGlassFrame(BrowserView* browser_view)
- : Window(browser_view),
- browser_view_(browser_view),
- frame_initialized_(false),
- throbber_running_(false),
- throbber_frame_(0) {
- non_client_view_ = new AeroGlassNonClientView(this, browser_view);
- browser_view_->set_frame(this);
-
- if (window_delegate()->ShouldShowWindowIcon())
- InitThrobberIcons();
-}
-
-AeroGlassFrame::~AeroGlassFrame() {
-}
-
-void AeroGlassFrame::Init() {
- Window::Init(NULL, gfx::Rect());
-}
-
-int AeroGlassFrame::GetMinimizeButtonOffset() const {
- TITLEBARINFOEX titlebar_info;
- titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
- SendMessage(GetHWND(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info);
-
- CPoint minimize_button_corner(titlebar_info.rgrect[2].left,
- titlebar_info.rgrect[2].top);
- MapWindowPoints(HWND_DESKTOP, GetHWND(), &minimize_button_corner, 1);
-
- return minimize_button_corner.x;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, BrowserFrame implementation:
-
-gfx::Rect AeroGlassFrame::GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds) {
- RECT rect = client_bounds.ToRECT();
- AdjustWindowRectEx(&rect, window_style(), FALSE, window_ex_style());
- return gfx::Rect(rect);
-}
-
-gfx::Rect AeroGlassFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const {
- return GetAeroGlassNonClientView()->GetBoundsForTabStrip(tabstrip);
-}
-
-void AeroGlassFrame::UpdateThrobber(bool running) {
- if (throbber_running_) {
- if (running) {
- DisplayNextThrobberFrame();
- } else {
- StopThrobber();
- }
- } else if (running) {
- StartThrobber();
- }
-}
-
-views::Window* AeroGlassFrame::GetWindow() {
- return this;
-}
-
-const views::Window* AeroGlassFrame::GetWindow() const {
- return this;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, views::WidgetWin overrides:
-
-bool AeroGlassFrame::AcceleratorPressed(views::Accelerator* accelerator) {
- return browser_view_->AcceleratorPressed(*accelerator);
-}
-
-bool AeroGlassFrame::GetAccelerator(int cmd_id,
- views::Accelerator* accelerator) {
- return browser_view_->GetAccelerator(cmd_id, accelerator);
-}
-
-void AeroGlassFrame::OnInitMenuPopup(HMENU menu, UINT position,
- BOOL is_system_menu) {
- browser_view_->PrepareToRunSystemMenu(menu);
-}
-
-void AeroGlassFrame::OnEnterSizeMove() {
- browser_view_->WindowMoveOrResizeStarted();
-}
-
-void AeroGlassFrame::OnEndSession(BOOL ending, UINT logoff) {
- BrowserList::WindowsSessionEnding();
-}
-
-LRESULT AeroGlassFrame::OnMouseActivate(HWND window, UINT hittest_code,
- UINT message) {
- return browser_view_->ActivateAppModalDialog() ? MA_NOACTIVATEANDEAT
- : MA_ACTIVATE;
-}
-
-void AeroGlassFrame::OnMove(const CPoint& point) {
- browser_view_->WindowMoved();
-}
-
-void AeroGlassFrame::OnMoving(UINT param, const RECT* new_bounds) {
- browser_view_->WindowMoved();
-}
-
-LRESULT AeroGlassFrame::OnNCActivate(BOOL active) {
- if (browser_view_->ActivateAppModalDialog())
- return TRUE;
-
- if (!frame_initialized_) {
- if (browser_view_->IsBrowserTypeNormal()) {
- ::SetWindowPos(GetHWND(), NULL, 0, 0, 0, 0,
- SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
- UpdateDWMFrame();
- }
- frame_initialized_ = true;
- }
- browser_view_->ActivationChanged(!!active);
- SetMsgHandled(false);
- return TRUE;
-}
-
-LRESULT AeroGlassFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
- if (!browser_view_->IsBrowserTypeNormal() || !mode) {
- SetMsgHandled(FALSE);
- return 0;
- }
-
- // In fullscreen mode, we make the whole window client area.
- if (!browser_view_->IsFullscreen()) {
- NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param);
- int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
- params->rgrc[0].left += (border_thickness - kClientEdgeThickness);
- params->rgrc[0].right -= (border_thickness - kClientEdgeThickness);
- params->rgrc[0].bottom -= (border_thickness - kClientEdgeThickness);
- }
-
- UpdateDWMFrame();
-
- SetMsgHandled(TRUE);
- return 0;
-}
-
-LRESULT AeroGlassFrame::OnNCHitTest(const CPoint& pt) {
- LRESULT result;
- if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y),
- &result)) {
- return result;
- }
- return Window::OnNCHitTest(pt);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, views::CustomFrameWindow overrides:
-
-int AeroGlassFrame::GetShowState() const {
- return browser_view_->GetShowState();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame, private:
-
-void AeroGlassFrame::UpdateDWMFrame() {
- // Nothing to do yet.
- if (!client_view())
- return;
-
- // In fullscreen mode, we don't extend glass into the client area at all,
- // because the GDI-drawn text in the web content composited over it will
- // become semi-transparent over any glass area.
- MARGINS margins = { 0 };
- if (!browser_view_->IsFullscreen()) {
- margins.cxLeftWidth = kClientEdgeThickness + 1;
- margins.cxRightWidth = kClientEdgeThickness + 1;
- margins.cyTopHeight =
- GetBoundsForTabStrip(browser_view_->tabstrip()).bottom();
- margins.cyBottomHeight = kClientEdgeThickness + 1;
- }
- DwmExtendFrameIntoClientArea(GetHWND(), &margins);
-}
-
-AeroGlassNonClientView* AeroGlassFrame::GetAeroGlassNonClientView() const {
- // We can safely assume that this conversion is true.
- return static_cast<AeroGlassNonClientView*>(non_client_view_);
-}
-
-void AeroGlassFrame::StartThrobber() {
- if (!throbber_running_) {
- throbber_running_ = true;
- throbber_frame_ = 0;
- InitThrobberIcons();
- ::SendMessage(GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL),
- reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
- }
-}
-
-void AeroGlassFrame::StopThrobber() {
- if (throbber_running_)
- throbber_running_ = false;
-}
-
-void AeroGlassFrame::DisplayNextThrobberFrame() {
- throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
- ::SendMessage(GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL),
- reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
-}
-
-// static
-void AeroGlassFrame::InitThrobberIcons() {
- static bool initialized = false;
- if (!initialized) {
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
- for (int i = 0; i < kThrobberIconCount; ++i) {
- throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i);
- DCHECK(throbber_icons_[i]);
- }
- initialized = true;
- }
-}
diff --git a/chrome/browser/views/frame/aero_glass_frame.h b/chrome/browser/views/frame/aero_glass_frame.h
deleted file mode 100644
index 4c7e2f8..0000000
--- a/chrome/browser/views/frame/aero_glass_frame.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// 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_AERO_GLASS_FRAME_H_
-#define CHROME_BROWSER_VIEWS_FRAME_AERO_GLASS_FRAME_H_
-
-#include "chrome/browser/views/frame/browser_frame.h"
-#include "chrome/views/window.h"
-
-class AeroGlassNonClientView;
-class BrowserView;
-
-///////////////////////////////////////////////////////////////////////////////
-// AeroGlassFrame
-//
-// AeroGlassFrame is a Window subclass that provides the window frame on
-// Windows Vista with DWM desktop compositing enabled. The window's non-client
-// areas are drawn by the system.
-//
-class AeroGlassFrame : public BrowserFrame,
- public views::Window {
- public:
- explicit AeroGlassFrame(BrowserView* browser_view);
- virtual ~AeroGlassFrame();
-
- void Init();
-
- // 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;
-
- // Overridden from BrowserFrame:
- virtual gfx::Rect GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds);
- virtual void SizeToContents(const gfx::Rect& contents_bounds) {}
- virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
- virtual void UpdateThrobber(bool running);
- virtual views::Window* GetWindow();
- virtual const views::Window* GetWindow() const;
-
- protected:
- // Overridden from views::WidgetWin:
- virtual bool AcceleratorPressed(views::Accelerator* accelerator);
- virtual bool GetAccelerator(int cmd_id, views::Accelerator* accelerator);
- virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu);
- virtual void OnEnterSizeMove();
- virtual void OnEndSession(BOOL ending, UINT logoff);
- 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; }
-
- private:
- // Updates the DWM with the frame bounds.
- void UpdateDWMFrame();
-
- // Return a pointer to the concrete type of our non-client view.
- AeroGlassNonClientView* GetAeroGlassNonClientView() const;
-
- // Starts/Stops the window throbber running.
- void StartThrobber();
- void StopThrobber();
-
- // Displays the next throbber frame.
- void DisplayNextThrobberFrame();
-
- // The BrowserView is our ClientView. This is a pointer to it.
- BrowserView* browser_view_;
-
- bool frame_initialized_;
-
- // Whether or not the window throbber is currently animating.
- bool throbber_running_;
-
- // The index of the current frame of the throbber animation.
- int throbber_frame_;
-
- static const int kThrobberIconCount = 24;
- static HICON throbber_icons_[kThrobberIconCount];
- static void InitThrobberIcons();
-
- DISALLOW_EVIL_CONSTRUCTORS(AeroGlassFrame);
-};
-
-#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_AERO_GLASS_FRAME_H_
-
diff --git a/chrome/browser/views/frame/browser_frame.cc b/chrome/browser/views/frame/browser_frame.cc
new file mode 100644
index 0000000..ac7f2d5
--- /dev/null
+++ b/chrome/browser/views/frame/browser_frame.cc
@@ -0,0 +1,191 @@
+// 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.
+
+#include "chrome/browser/views/frame/browser_frame.h"
+
+#include <dwmapi.h>
+
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/views/frame/browser_view.h"
+#include "chrome/browser/views/frame/glass_browser_frame_view.h"
+#include "chrome/browser/views/frame/opaque_browser_frame_view.h"
+#include "chrome/common/resource_bundle.h"
+#include "chrome/common/win_util.h"
+#include "chrome/views/window_delegate.h"
+#include "grit/theme_resources.h"
+
+// static
+static const int kClientEdgeThickness = 3;
+
+///////////////////////////////////////////////////////////////////////////////
+// BrowserFrame, public:
+
+BrowserFrame::BrowserFrame(BrowserView* browser_view)
+ : Window(browser_view),
+ browser_view_(browser_view),
+ frame_initialized_(false) {
+ browser_view_->set_frame(this);
+ non_client_view_->SetFrameView(CreateFrameViewForWindow());
+}
+
+BrowserFrame::~BrowserFrame() {
+}
+
+void BrowserFrame::Init() {
+ Window::Init(NULL, gfx::Rect());
+}
+
+int BrowserFrame::GetMinimizeButtonOffset() const {
+ TITLEBARINFOEX titlebar_info;
+ titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
+ SendMessage(GetHWND(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info);
+
+ CPoint minimize_button_corner(titlebar_info.rgrect[2].left,
+ titlebar_info.rgrect[2].top);
+ MapWindowPoints(HWND_DESKTOP, GetHWND(), &minimize_button_corner, 1);
+
+ return minimize_button_corner.x;
+}
+
+gfx::Rect BrowserFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const {
+ return browser_frame_view_->GetBoundsForTabStrip(tabstrip);
+}
+
+void BrowserFrame::UpdateThrobber(bool running) {
+ browser_frame_view_->UpdateThrobber(running);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// BrowserFrame, views::WidgetWin overrides:
+
+bool BrowserFrame::AcceleratorPressed(views::Accelerator* accelerator) {
+ return browser_view_->AcceleratorPressed(*accelerator);
+}
+
+bool BrowserFrame::GetAccelerator(int cmd_id, views::Accelerator* accelerator) {
+ return browser_view_->GetAccelerator(cmd_id, accelerator);
+}
+
+void BrowserFrame::OnEndSession(BOOL ending, UINT logoff) {
+ BrowserList::WindowsSessionEnding();
+}
+
+void BrowserFrame::OnEnterSizeMove() {
+ browser_view_->WindowMoveOrResizeStarted();
+}
+
+void BrowserFrame::OnInitMenuPopup(HMENU menu, UINT position,
+ BOOL is_system_menu) {
+ browser_view_->PrepareToRunSystemMenu(menu);
+}
+
+LRESULT BrowserFrame::OnMouseActivate(HWND window, UINT hittest_code,
+ UINT message) {
+ return browser_view_->ActivateAppModalDialog() ? MA_NOACTIVATEANDEAT
+ : MA_ACTIVATE;
+}
+
+void BrowserFrame::OnMove(const CPoint& point) {
+ browser_view_->WindowMoved();
+}
+
+void BrowserFrame::OnMoving(UINT param, const RECT* new_bounds) {
+ browser_view_->WindowMoved();
+}
+
+LRESULT BrowserFrame::OnNCActivate(BOOL active) {
+ if (browser_view_->ActivateAppModalDialog())
+ return TRUE;
+
+ // Perform first time initialization of the DWM frame insets, only if we're
+ // using the native frame.
+ if (non_client_view_->UseNativeFrame() && !frame_initialized_) {
+ if (browser_view_->IsBrowserTypeNormal()) {
+ ::SetWindowPos(GetHWND(), NULL, 0, 0, 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
+ UpdateDWMFrame();
+ }
+ frame_initialized_ = true;
+ }
+ browser_view_->ActivationChanged(!!active);
+ return Window::OnNCActivate(active);
+}
+
+LRESULT BrowserFrame::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 (!non_client_view_->UseNativeFrame() ||
+ !browser_view_->IsBrowserTypeNormal() || !mode) {
+ return Window::OnNCCalcSize(mode, l_param);
+ }
+
+ // In fullscreen mode, we make the whole window client area.
+ if (!browser_view_->IsFullscreen()) {
+ NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param);
+ int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
+ params->rgrc[0].left += (border_thickness - kClientEdgeThickness);
+ params->rgrc[0].right -= (border_thickness - kClientEdgeThickness);
+ params->rgrc[0].bottom -= (border_thickness - kClientEdgeThickness);
+ }
+
+ UpdateDWMFrame();
+
+ SetMsgHandled(TRUE);
+ return 0;
+}
+
+LRESULT BrowserFrame::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(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y),
+ &result)) {
+ return result;
+ }
+ }
+ return Window::OnNCHitTest(pt);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// BrowserFrame, views::CustomFrameWindow overrides:
+
+int BrowserFrame::GetShowState() const {
+ return browser_view_->GetShowState();
+}
+
+views::NonClientFrameView* BrowserFrame::CreateFrameViewForWindow() {
+ if (non_client_view_->UseNativeFrame())
+ browser_frame_view_ = new GlassBrowserFrameView(this, browser_view_);
+ else
+ browser_frame_view_ = new OpaqueBrowserFrameView(this, browser_view_);
+ return browser_frame_view_;
+}
+
+void BrowserFrame::UpdateFrameAfterFrameChange() {
+ Window::UpdateFrameAfterFrameChange();
+ UpdateDWMFrame();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// BrowserFrame, private:
+
+void BrowserFrame::UpdateDWMFrame() {
+ // Nothing to do yet.
+ if (!client_view())
+ return;
+
+ // In fullscreen mode, we don't extend glass into the client area at all,
+ // because the GDI-drawn text in the web content composited over it will
+ // become semi-transparent over any glass area.
+ MARGINS margins = { 0 };
+ if (!browser_view_->IsFullscreen()) {
+ margins.cxLeftWidth = kClientEdgeThickness + 1;
+ margins.cxRightWidth = kClientEdgeThickness + 1;
+ margins.cyTopHeight =
+ GetBoundsForTabStrip(browser_view_->tabstrip()).bottom();
+ margins.cyBottomHeight = kClientEdgeThickness + 1;
+ }
+ DwmExtendFrameIntoClientArea(GetHWND(), &margins);
+}
+
diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h
index ee908b5..c7efcab 100644
--- a/chrome/browser/views/frame/browser_frame.h
+++ b/chrome/browser/views/frame/browser_frame.h
@@ -2,63 +2,91 @@
// 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_H_
-#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_H_
+#ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_
+#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_
+#include "chrome/views/window.h"
+
+class AeroGlassNonClientView;
class BrowserView;
-namespace views {
-class Window;
-}
-namespace gfx {
-class Rect;
-}
+class NonClientFrameView;
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;
+};
+
///////////////////////////////////////////////////////////////////////////////
// BrowserFrame
//
-// BrowserFrame is an interface that represents a top level browser window
-// frame. Implementations of this interface exist to supply the browser window
-// for specific environments, e.g. Vista with Aero Glass enabled.
+// BrowserFrame is a Window subclass that provides the window frame for the
+// Chrome browser window.
//
-class BrowserFrame {
+class BrowserFrame : public views::Window {
public:
- // TODO(beng): We should _not_ have to expose this method here... it's only
- // because BrowserView needs it to implement BrowserWindow
- // because we're doing popup setup in browser.cc when we
- // shouldn't be...
- virtual gfx::Rect GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds) = 0;
+ explicit BrowserFrame(BrowserView* browser_view);
+ virtual ~BrowserFrame();
- // Sizes the frame assuming the contents view's bounds are as specified.
- virtual void SizeToContents(const gfx::Rect& contents_bounds) = 0;
+ // Initialize the frame. Creates the Window.
+ void Init();
- // Retrieve the bounds for the specified |tabstrip|, in window coordinates.
- virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 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;
- // Updates the current frame of the Throbber animation, if applicable.
- // |running| is whether or not the throbber should be running.
- virtual void UpdateThrobber(bool running) = 0;
+ // Retrieves the bounds, in non-client view coordinates for the specified
+ // TabStrip.
+ gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
+
+ // Tells the frame to update the throbber.
+ void UpdateThrobber(bool running);
+
+ protected:
+ // Overridden from views::WidgetWin:
+ virtual bool AcceleratorPressed(views::Accelerator* accelerator);
+ virtual bool GetAccelerator(int cmd_id, views::Accelerator* accelerator);
+ virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu);
+ virtual void OnEnterSizeMove();
+ virtual void OnEndSession(BOOL ending, UINT logoff);
+ 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();
- // Returns the views::Window associated with this frame.
- virtual views::Window* GetWindow() = 0;
- virtual const views::Window* GetWindow() const = 0;
+ private:
+ // Updates the DWM with the frame bounds.
+ void UpdateDWMFrame();
- enum FrameType {
- FRAMETYPE_OPAQUE,
- FRAMETYPE_AERO_GLASS
- };
+ // The BrowserView is our ClientView. This is a pointer to it.
+ BrowserView* browser_view_;
- // Returns the FrameType that should be constructed given the current system
- // settings.
- static FrameType GetActiveFrameType();
+ // A pointer to our NonClientFrameView as a BrowserNonClientFrameView.
+ BrowserNonClientFrameView* browser_frame_view_;
- // Creates a BrowserFrame instance for the specified FrameType and
- // BrowserView.
- static BrowserFrame* CreateForBrowserView(FrameType type,
- BrowserView* browser_view);
+ bool frame_initialized_;
+ DISALLOW_EVIL_CONSTRUCTORS(BrowserFrame);
};
-#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_H_
+#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_FRAME_
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index f287485..72e8e8f 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/command_line.h"
-
#include "chrome/browser/views/frame/browser_view.h"
+#include "base/command_line.h"
#include "base/file_version_info.h"
#include "base/time.h"
#include "chrome/app/chrome_dll_resource.h"
@@ -367,19 +366,6 @@ bool BrowserView::GetAccelerator(int cmd_id, views::Accelerator* accelerator) {
return false;
}
-bool BrowserView::SystemCommandReceived(UINT notification_code,
- const gfx::Point& point) {
- bool handled = false;
-
- if (browser_->command_updater()->SupportsCommand(notification_code) &&
- browser_->command_updater()->IsCommandEnabled(notification_code)) {
- browser_->ExecuteCommand(notification_code);
- handled = true;
- }
-
- return handled;
-}
-
void BrowserView::AddViewToDropList(views::View* view) {
dropable_views_.insert(view);
}
@@ -489,8 +475,8 @@ void BrowserView::Init() {
void BrowserView::Show() {
// If the window is already visible, just activate it.
- if (frame_->GetWindow()->IsVisible()) {
- frame_->GetWindow()->Activate();
+ if (frame_->IsVisible()) {
+ frame_->Activate();
return;
}
@@ -508,32 +494,29 @@ void BrowserView::Show() {
if (selected_tab_contents)
selected_tab_contents->RestoreFocus();
- frame_->GetWindow()->Show();
- int show_state = frame_->GetWindow()->GetShowState();
- if (show_state == SW_SHOWNORMAL || show_state == SW_SHOWMAXIMIZED)
- frame_->GetWindow()->Activate();
+ frame_->Show();
}
void BrowserView::SetBounds(const gfx::Rect& bounds) {
- frame_->GetWindow()->SetBounds(bounds);
+ frame_->SetBounds(bounds);
}
void BrowserView::Close() {
- frame_->GetWindow()->Close();
+ frame_->Close();
}
void BrowserView::Activate() {
- frame_->GetWindow()->Activate();
+ frame_->Activate();
}
bool BrowserView::IsActive() const {
- return frame_->GetWindow()->IsActive();
+ return frame_->IsActive();
}
void BrowserView::FlashFrame() {
FLASHWINFO fwi;
fwi.cbSize = sizeof(fwi);
- fwi.hwnd = frame_->GetWindow()->GetHWND();
+ fwi.hwnd = frame_->GetHWND();
fwi.dwFlags = FLASHW_ALL;
fwi.uCount = 4;
fwi.dwTimeout = 0;
@@ -564,9 +547,9 @@ void BrowserView::SelectedTabToolbarSizeChanged(bool is_animating) {
}
void BrowserView::UpdateTitleBar() {
- frame_->GetWindow()->UpdateWindowTitle();
+ frame_->UpdateWindowTitle();
if (ShouldShowWindowIcon())
- frame_->GetWindow()->UpdateWindowIcon();
+ frame_->UpdateWindowIcon();
}
void BrowserView::UpdateLoadingAnimations(bool should_animate) {
@@ -598,13 +581,13 @@ gfx::Rect BrowserView::GetNormalBounds() const {
WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
- const bool ret = !!GetWindowPlacement(frame_->GetWindow()->GetHWND(), &wp);
+ const bool ret = !!GetWindowPlacement(frame_->GetHWND(), &wp);
DCHECK(ret);
return gfx::Rect(wp.rcNormalPosition);
}
bool BrowserView::IsMaximized() const {
- return frame_->GetWindow()->IsMaximized();
+ return frame_->IsMaximized();
}
void BrowserView::SetFullscreen(bool fullscreen) {
@@ -637,7 +620,7 @@ void BrowserView::SetFullscreen(bool fullscreen) {
// taskbar if the window is in the maximized state.
saved_window_info_.maximized = IsMaximized();
if (saved_window_info_.maximized)
- frame_->GetWindow()->ExecuteSystemMenuCommand(SC_RESTORE);
+ frame_->ExecuteSystemMenuCommand(SC_RESTORE);
saved_window_info_.style = GetWindowLong(hwnd, GWL_STYLE);
saved_window_info_.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE);
GetWindowRect(hwnd, &saved_window_info_.window_rect);
@@ -667,7 +650,7 @@ void BrowserView::SetFullscreen(bool fullscreen) {
new_rect.height(),
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
if (saved_window_info_.maximized)
- frame_->GetWindow()->ExecuteSystemMenuCommand(SC_MAXIMIZE);
+ frame_->ExecuteSystemMenuCommand(SC_MAXIMIZE);
}
// Turn fullscreen bubble on or off.
@@ -999,6 +982,8 @@ bool BrowserView::ShouldShowWindowIcon() const {
}
bool BrowserView::ExecuteWindowsCommand(int command_id) {
+ // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND.
+
// Translate WM_APPCOMMAND command ids into a command id that the browser
// knows how to handle.
int command_id_from_app_command = GetCommandIDForAppCommandID(command_id);
@@ -1047,7 +1032,8 @@ bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
bounds->height() + toolbar_->GetPreferredSize().height());
}
- gfx::Rect window_rect = frame_->GetWindowBoundsForClientBounds(*bounds);
+ gfx::Rect window_rect =
+ frame_->GetWindowBoundsForClientBounds(*bounds);
window_rect.set_origin(bounds->origin());
// When we are given x/y coordinates of 0 on a created popup window,
@@ -1102,7 +1088,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_->GetWindow()->Hide();
+ frame_->Hide();
browser_->OnWindowClosing();
return false;
}
@@ -1110,7 +1096,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_->GetWindow()->GetHWND()),
+ Source<HWND>(frame_->GetHWND()),
NotificationService::NoDetails());
return true;
}
@@ -1123,7 +1109,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
if (CanCurrentlyResize()) {
CRect client_rect;
- ::GetClientRect(frame_->GetWindow()->GetHWND(), &client_rect);
+ ::GetClientRect(frame_->GetHWND(), &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(),
@@ -1283,7 +1269,7 @@ int BrowserView::OnPerformDrop(const views::DropTargetEvent& event) {
// BrowserView, private:
void BrowserView::InitSystemMenu() {
- HMENU system_menu = GetSystemMenu(frame_->GetWindow()->GetHWND(), FALSE);
+ HMENU system_menu = GetSystemMenu(frame_->GetHWND(), FALSE);
system_menu_.reset(new Menu(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
@@ -1434,7 +1420,7 @@ void BrowserView::LayoutStatusBubble(int top) {
// In restored mode, the client area has a client edge between it and the
// frame.
int overlap = kStatusBubbleOverlap +
- (IsMaximized() ? 0 : views::NonClientView::kClientEdgeThickness);
+ (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness);
gfx::Point origin(-overlap, top - kStatusBubbleHeight + overlap);
ConvertPointToView(this, GetParent(), &origin);
status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3,
@@ -1679,3 +1665,11 @@ void BrowserView::InitClass() {
initialized = true;
}
}
+
+// static
+BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
+ BrowserView* browser_view = new BrowserView(browser);
+ (new BrowserFrame(browser_view))->Init();
+ return browser_view;
+}
+
diff --git a/chrome/browser/views/frame/browser_window_factory.cc b/chrome/browser/views/frame/browser_window_factory.cc
deleted file mode 100644
index 9a6853b..0000000
--- a/chrome/browser/views/frame/browser_window_factory.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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.
-
-#include "base/command_line.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_process.h" // TODO(beng): remove once done.
-#include "chrome/browser/browser_window.h"
-#include "chrome/browser/views/frame/aero_glass_frame.h"
-#include "chrome/browser/views/frame/browser_frame.h"
-#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/frame/opaque_frame.h"
-#include "chrome/common/win_util.h"
-
-///////////////////////////////////////////////////////////////////////////////
-// BrowserWindow, public:
-
-// static
-BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
- BrowserView* browser_view = new BrowserView(browser);
- BrowserFrame::CreateForBrowserView(BrowserFrame::GetActiveFrameType(),
- browser_view);
- return browser_view;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// BrowserFrame, public:
-
-// static
-BrowserFrame::FrameType BrowserFrame::GetActiveFrameType() {
- return win_util::ShouldUseVistaFrame() ? BrowserFrame::FRAMETYPE_AERO_GLASS
- : BrowserFrame::FRAMETYPE_OPAQUE;
-}
-
-// static
-BrowserFrame* BrowserFrame::CreateForBrowserView(BrowserFrame::FrameType type,
- BrowserView* browser_view) {
- if (type == FRAMETYPE_OPAQUE) {
- OpaqueFrame* frame = new OpaqueFrame(browser_view);
- frame->Init();
- return frame;
- } else if (type == FRAMETYPE_AERO_GLASS) {
- AeroGlassFrame* frame = new AeroGlassFrame(browser_view);
- frame->Init();
- return frame;
- }
- NOTREACHED() << "Unsupported frame type";
- return NULL;
-}
-
diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc
index 93031d1..54982d7 100644
--- a/chrome/browser/views/frame/aero_glass_non_client_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.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/aero_glass_non_client_view.h"
+#include "chrome/browser/views/frame/glass_browser_frame_view.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
@@ -27,12 +27,12 @@ enum {
FRAME_PART_BITMAP_COUNT // Must be last.
};
-class AeroGlassWindowResources {
+class GlassBrowserWindowResources {
public:
- AeroGlassWindowResources() {
+ GlassBrowserWindowResources() {
InitClass();
}
- virtual ~AeroGlassWindowResources() { }
+ virtual ~GlassBrowserWindowResources() { }
virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const {
return standard_frame_bitmaps_[part];
@@ -59,14 +59,15 @@ class AeroGlassWindowResources {
static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT];
- DISALLOW_EVIL_CONSTRUCTORS(AeroGlassWindowResources);
+ DISALLOW_EVIL_CONSTRUCTORS(GlassBrowserWindowResources);
};
// static
-SkBitmap* AeroGlassWindowResources::standard_frame_bitmaps_[];
+SkBitmap* GlassBrowserWindowResources::standard_frame_bitmaps_[];
-AeroGlassWindowResources* AeroGlassNonClientView::resources_ = NULL;
-SkBitmap* AeroGlassNonClientView::distributor_logo_ = NULL;
+GlassBrowserWindowResources* GlassBrowserFrameView::resources_ = NULL;
+SkBitmap* GlassBrowserFrameView::distributor_logo_ = NULL;
+HICON GlassBrowserFrameView::throbber_icons_[GlassBrowserFrameView::kThrobberIconCount];
namespace {
// There are 3 px of client edge drawn inside the outer frame borders.
@@ -103,19 +104,28 @@ const int kLogoCaptionSpacing = 7;
}
///////////////////////////////////////////////////////////////////////////////
-// AeroGlassNonClientView, public:
-
-AeroGlassNonClientView::AeroGlassNonClientView(AeroGlassFrame* frame,
- BrowserView* browser_view)
- : frame_(frame),
- browser_view_(browser_view) {
+// GlassBrowserFrameView, public:
+
+GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame,
+ BrowserView* browser_view)
+ : BrowserNonClientFrameView(),
+ frame_(frame),
+ browser_view_(browser_view),
+ throbber_running_(false),
+ throbber_frame_(0) {
InitClass();
+ if (frame_->window_delegate()->ShouldShowWindowIcon())
+ InitThrobberIcons();
}
-AeroGlassNonClientView::~AeroGlassNonClientView() {
+GlassBrowserFrameView::~GlassBrowserFrameView() {
}
-gfx::Rect AeroGlassNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) {
+///////////////////////////////////////////////////////////////////////////////
+// GlassBrowserFrameView, BrowserNonClientFrameView implementation:
+
+gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
+ TabStrip* tabstrip) const {
int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
(otr_avatar_bounds_.right() + kOTRSideSpacing) :
NonClientBorderThickness();
@@ -126,43 +136,56 @@ gfx::Rect AeroGlassNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) {
std::max(0, tabstrip_width), tabstrip->GetPreferredHeight());
}
-///////////////////////////////////////////////////////////////////////////////
-// AeroGlassNonClientView, views::NonClientView implementation:
+void GlassBrowserFrameView::UpdateThrobber(bool running) {
+ if (throbber_running_) {
+ if (running) {
+ DisplayNextThrobberFrame();
+ } else {
+ StopThrobber();
+ }
+ } else if (running) {
+ StartThrobber();
+ }
+}
-gfx::Rect AeroGlassNonClientView::CalculateClientAreaBounds(int width,
- int height) const {
- if (!browser_view_->IsTabStripVisible())
- return gfx::Rect(0, 0, this->width(), this->height());
+///////////////////////////////////////////////////////////////////////////////
+// GlassBrowserFrameView, views::NonClientFrameView implementation:
- int top_height = NonClientTopBorderHeight();
- int border_thickness = NonClientBorderThickness();
- return gfx::Rect(border_thickness, top_height,
- std::max(0, width - (2 * border_thickness)),
- std::max(0, height - top_height - border_thickness));
+gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const {
+ return client_view_bounds_;
}
-gfx::Size AeroGlassNonClientView::CalculateWindowSizeForClientSize(
- int width,
- int height) const {
- if (!browser_view_->IsTabStripVisible())
- return gfx::Size(width, height);
+gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const {
+ if (!browser_view_->IsTabStripVisible()) {
+ // 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.
+ RECT rect = client_bounds.ToRECT();
+ AdjustWindowRectEx(&rect, frame_->window_style(), FALSE,
+ frame_->window_ex_style());
+ return gfx::Rect(rect);
+ }
+ int top_height = NonClientTopBorderHeight();
int border_thickness = NonClientBorderThickness();
- return gfx::Size(width + (2 * border_thickness),
- height + NonClientTopBorderHeight() + border_thickness);
+ return gfx::Rect(std::max(0, client_bounds.x() - border_thickness),
+ std::max(0, client_bounds.y() - top_height),
+ client_bounds.width() + (2 * border_thickness),
+ client_bounds.height() + top_height + border_thickness);
}
-gfx::Point AeroGlassNonClientView::GetSystemMenuPoint() const {
+gfx::Point GlassBrowserFrameView::GetSystemMenuPoint() const {
gfx::Point system_menu_point;
if (browser_view_->IsBrowserTypeNormal()) {
- // The X coordinate conditional is because in maximized mode the frame edge
+ // The maximized mode bit here is because in maximized mode the frame edge
// and the client edge are both offscreen, whereas in the opaque frame
// (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() -
- (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0),
+ (frame_->IsMaximized() ? 0 : kClientEdgeThickness),
NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() -
- (browser_view_->IsFullscreen() ? 0 : kClientEdgeThickness));
+ kClientEdgeThickness);
} else {
system_menu_point.SetPoint(0, -kFrameShadowThickness);
}
@@ -170,7 +193,7 @@ gfx::Point AeroGlassNonClientView::GetSystemMenuPoint() const {
return system_menu_point;
}
-int AeroGlassNonClientView::NonClientHitTest(const gfx::Point& point) {
+int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
// If the browser isn't in normal mode, we haven't customized the frame, so
// Windows can figure this out. If the point isn't within our bounds, then
// it's in the native portion of the frame, so again Windows can figure it
@@ -192,9 +215,9 @@ int AeroGlassNonClientView::NonClientHitTest(const gfx::Point& point) {
}
///////////////////////////////////////////////////////////////////////////////
-// AeroGlassNonClientView, views::View overrides:
+// GlassBrowserFrameView, views::View overrides:
-void AeroGlassNonClientView::Paint(ChromeCanvas* canvas) {
+void GlassBrowserFrameView::Paint(ChromeCanvas* canvas) {
if (!browser_view_->IsTabStripVisible())
return; // Nothing is visible, so don't bother to paint.
@@ -204,39 +227,29 @@ void AeroGlassNonClientView::Paint(ChromeCanvas* canvas) {
PaintClientEdge(canvas);
}
-void AeroGlassNonClientView::Layout() {
+void GlassBrowserFrameView::Layout() {
LayoutDistributorLogo();
LayoutOTRAvatar();
LayoutClientView();
}
-void AeroGlassNonClientView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (is_add && child == this) {
- DCHECK(GetWidget());
- DCHECK(frame_->client_view()->GetParent() != this);
- AddChildView(frame_->client_view());
- }
-}
-
///////////////////////////////////////////////////////////////////////////////
-// AeroGlassNonClientView, private:
+// GlassBrowserFrameView, private:
-int AeroGlassNonClientView::FrameBorderThickness() const {
- return browser_view_->IsFullscreen() ? 0 : GetSystemMetrics(SM_CXSIZEFRAME);
+int GlassBrowserFrameView::FrameBorderThickness() const {
+ return GetSystemMetrics(SM_CXSIZEFRAME);
}
-int AeroGlassNonClientView::NonClientBorderThickness() const {
- return browser_view_->IsFullscreen() ? 0 : kNonClientBorderThickness;
+int GlassBrowserFrameView::NonClientBorderThickness() const {
+ return kNonClientBorderThickness;
}
-int AeroGlassNonClientView::NonClientTopBorderHeight() const {
- return FrameBorderThickness() + (browser_view_->CanCurrentlyResize() ?
- kNonClientRestoredExtraThickness : 0);
+int GlassBrowserFrameView::NonClientTopBorderHeight() const {
+ return FrameBorderThickness() +
+ (frame_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness);
}
-void AeroGlassNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) {
+void GlassBrowserFrameView::PaintDistributorLogo(ChromeCanvas* 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_) {
@@ -248,7 +261,7 @@ void AeroGlassNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) {
}
}
-void AeroGlassNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) {
+void GlassBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) {
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
gfx::Point toolbar_origin(toolbar_bounds.origin());
View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin);
@@ -269,7 +282,7 @@ void AeroGlassNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) {
toolbar_bounds.right(), toolbar_bounds.y());
}
-void AeroGlassNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) {
+void GlassBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) {
if (!browser_view_->ShouldShowOffTheRecordAvatar())
return;
@@ -281,7 +294,7 @@ void AeroGlassNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) {
otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false);
}
-void AeroGlassNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
+void GlassBrowserFrameView::PaintClientEdge(ChromeCanvas* canvas) {
// The client edges start below the toolbar upper corner images regardless
// of how tall the toolbar itself is.
int client_area_top =
@@ -315,7 +328,7 @@ void AeroGlassNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
client_area_top, left->width(), client_area_height);
}
-void AeroGlassNonClientView::LayoutDistributorLogo() {
+void GlassBrowserFrameView::LayoutDistributorLogo() {
if (distributor_logo_) {
logo_bounds_.SetRect(frame_->GetMinimizeButtonOffset() -
distributor_logo_->width() - kLogoCaptionSpacing, kLogoTopSpacing,
@@ -326,7 +339,7 @@ void AeroGlassNonClientView::LayoutDistributorLogo() {
}
}
-void AeroGlassNonClientView::LayoutOTRAvatar() {
+void GlassBrowserFrameView::LayoutOTRAvatar() {
SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
int top_height = NonClientTopBorderHeight();
int tabstrip_height, otr_height;
@@ -343,16 +356,61 @@ void AeroGlassNonClientView::LayoutOTRAvatar() {
otr_avatar_icon.width(), otr_height);
}
-void AeroGlassNonClientView::LayoutClientView() {
- frame_->client_view()->SetBounds(CalculateClientAreaBounds(width(),
- height()));
+void GlassBrowserFrameView::LayoutClientView() {
+ client_view_bounds_ = CalculateClientAreaBounds(width(), height());
+}
+
+gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds(int width,
+ int height) const {
+ if (!browser_view_->IsTabStripVisible())
+ return gfx::Rect(0, 0, this->width(), this->height());
+
+ int top_height = NonClientTopBorderHeight();
+ int border_thickness = NonClientBorderThickness();
+ return gfx::Rect(border_thickness, top_height,
+ std::max(0, width - (2 * border_thickness)),
+ std::max(0, height - top_height - border_thickness));
+}
+
+void GlassBrowserFrameView::StartThrobber() {
+ if (!throbber_running_) {
+ throbber_running_ = true;
+ throbber_frame_ = 0;
+ InitThrobberIcons();
+ SendMessage(frame_->GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL),
+ reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
+ }
+}
+
+void GlassBrowserFrameView::StopThrobber() {
+ if (throbber_running_)
+ throbber_running_ = false;
+}
+
+void GlassBrowserFrameView::DisplayNextThrobberFrame() {
+ throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
+ SendMessage(frame_->GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL),
+ reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
+}
+
+// static
+void GlassBrowserFrameView::InitThrobberIcons() {
+ static bool initialized = false;
+ if (!initialized) {
+ ResourceBundle &rb = ResourceBundle::GetSharedInstance();
+ for (int i = 0; i < kThrobberIconCount; ++i) {
+ throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i);
+ DCHECK(throbber_icons_[i]);
+ }
+ initialized = true;
+ }
}
// static
-void AeroGlassNonClientView::InitClass() {
+void GlassBrowserFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
- resources_ = new AeroGlassWindowResources;
+ resources_ = new GlassBrowserWindowResources;
#if defined(GOOGLE_CHROME_BUILD)
distributor_logo_ = ResourceBundle::GetSharedInstance().
diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.h b/chrome/browser/views/frame/glass_browser_frame_view.h
index 5023ea0..f325dde 100644
--- a/chrome/browser/views/frame/aero_glass_non_client_view.h
+++ b/chrome/browser/views/frame/glass_browser_frame_view.h
@@ -2,43 +2,40 @@
// 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_AERO_GLASS_NON_CLIENT_VIEW_H_
-#define CHROME_BROWSER_VIEWS_FRAME_AERO_GLASS_NON_CLIENT_VIEW_H_
+#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/aero_glass_frame.h"
+#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/views/non_client_view.h"
#include "chrome/views/button.h"
class BrowserView;
-class AeroGlassWindowResources;
+class GlassBrowserWindowResources;
-class AeroGlassNonClientView : public views::NonClientView {
+class GlassBrowserFrameView : public BrowserNonClientFrameView {
public:
- // Constructs a non-client view for an AeroGlassFrame.
- AeroGlassNonClientView(AeroGlassFrame* frame, BrowserView* browser_view);
- virtual ~AeroGlassNonClientView();
-
- // Retrieve the bounds for the specified |tabstrip|, in the coordinate system
- // of the non-client view (which whould be window coordinates).
- gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip);
-
- protected:
- // Overridden from views::NonClientView:
- virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const;
- virtual gfx::Size CalculateWindowSizeForClientSize(int width,
- int height) const;
+ // Constructs a non-client view for an BrowserFrame.
+ GlassBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view);
+ virtual ~GlassBrowserFrameView();
+
+ // Overridden from BrowserNonClientFrameView:
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
+ virtual void UpdateThrobber(bool running);
+
+ // Overridden from views::NonClientFrameView:
+ virtual gfx::Rect GetBoundsForClientView() const;
+ virtual gfx::Rect GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const;
virtual gfx::Point GetSystemMenuPoint() const;
virtual int NonClientHitTest(const gfx::Point& point);
virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) { }
virtual void EnableClose(bool enable) { }
virtual void ResetWindowControls() { }
+ protected:
// Overridden from views::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
private:
// Returns the thickness of the border that makes up the window frame edges.
@@ -63,7 +60,17 @@ class AeroGlassNonClientView : public views::NonClientView {
void LayoutDistributorLogo();
void LayoutOTRAvatar();
void LayoutClientView();
+
+ // Returns the bounds of the client area for the specified view size.
+ gfx::Rect CalculateClientAreaBounds(int width, int height) const;
+ // Starts/Stops the window throbber running.
+ void StartThrobber();
+ void StopThrobber();
+
+ // Displays the next throbber frame.
+ void DisplayNextThrobberFrame();
+
// The layout rect of the distributor logo, if visible.
gfx::Rect logo_bounds_;
@@ -71,17 +78,30 @@ class AeroGlassNonClientView : public views::NonClientView {
gfx::Rect otr_avatar_bounds_;
// The frame that hosts this view.
- AeroGlassFrame* frame_;
+ BrowserFrame* frame_;
// The BrowserView hosted within this View.
BrowserView* browser_view_;
+ // The bounds of the ClientView.
+ gfx::Rect client_view_bounds_;
+
+ // Whether or not the window throbber is currently animating.
+ bool throbber_running_;
+
+ // The index of the current frame of the throbber animation.
+ int throbber_frame_;
+
static void InitClass();
static SkBitmap* distributor_logo_;
- static AeroGlassWindowResources* resources_;
+ static GlassBrowserWindowResources* resources_;
+
+ static const int kThrobberIconCount = 24;
+ static HICON throbber_icons_[kThrobberIconCount];
+ static void InitThrobberIcons();
- DISALLOW_EVIL_CONSTRUCTORS(AeroGlassNonClientView);
+ DISALLOW_EVIL_CONSTRUCTORS(GlassBrowserFrameView);
};
-#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_AERO_GLASS_NON_CLIENT_VIEW_H_
+#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 2ed23f8..98a71c3 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -2,8 +2,9 @@
// 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/opaque_non_client_view.h"
+#include "chrome/browser/views/frame/opaque_browser_frame_view.h"
+#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
#include "chrome/common/gfx/chrome_canvas.h"
@@ -252,12 +253,12 @@ SkBitmap* InactiveWindowResources::standard_frame_bitmaps_[];
SkBitmap* OTRActiveWindowResources::standard_frame_bitmaps_[];
SkBitmap* OTRInactiveWindowResources::standard_frame_bitmaps_[];
-views::WindowResources* OpaqueNonClientView::active_resources_ = NULL;
-views::WindowResources* OpaqueNonClientView::inactive_resources_ = NULL;
-views::WindowResources* OpaqueNonClientView::active_otr_resources_ = NULL;
-views::WindowResources* OpaqueNonClientView::inactive_otr_resources_ = NULL;
-SkBitmap* OpaqueNonClientView::distributor_logo_ = NULL;
-ChromeFont OpaqueNonClientView::title_font_;
+views::WindowResources* OpaqueBrowserFrameView::active_resources_ = NULL;
+views::WindowResources* OpaqueBrowserFrameView::inactive_resources_ = NULL;
+views::WindowResources* OpaqueBrowserFrameView::active_otr_resources_ = NULL;
+views::WindowResources* OpaqueBrowserFrameView::inactive_otr_resources_ = NULL;
+SkBitmap* OpaqueBrowserFrameView::distributor_logo_ = NULL;
+ChromeFont OpaqueBrowserFrameView::title_font_;
namespace {
// The frame border is only visible in restored mode and is hardcoded to 4 px on
@@ -326,11 +327,11 @@ const int kCaptionTopSpacing = 1;
}
///////////////////////////////////////////////////////////////////////////////
-// OpaqueNonClientView, public:
+// OpaqueBrowserFrameView, public:
-OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame,
- BrowserView* browser_view)
- : NonClientView(),
+OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
+ BrowserView* browser_view)
+ : BrowserNonClientFrameView(),
minimize_button_(new views::Button),
maximize_button_(new views::Button),
restore_button_(new views::Button),
@@ -421,20 +422,14 @@ OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame,
InitAppWindowResources();
}
-OpaqueNonClientView::~OpaqueNonClientView() {
+OpaqueBrowserFrameView::~OpaqueBrowserFrameView() {
}
-gfx::Rect OpaqueNonClientView::GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds) {
- int top_height = NonClientTopBorderHeight();
- int border_thickness = NonClientBorderThickness();
- return gfx::Rect(std::max(0, client_bounds.x() - border_thickness),
- std::max(0, client_bounds.y() - top_height),
- client_bounds.width() + (2 * border_thickness),
- client_bounds.height() + top_height + border_thickness);
-}
+///////////////////////////////////////////////////////////////////////////////
+// OpaqueBrowserFrameView, BrowserNonClientFrameView implementation:
-gfx::Rect OpaqueNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) {
+gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
+ TabStrip* tabstrip) const {
int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
(otr_avatar_bounds_.right() + kOTRSideSpacing) :
NonClientBorderThickness();
@@ -445,40 +440,37 @@ gfx::Rect OpaqueNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) {
std::max(0, tabstrip_width), tabstrip->GetPreferredHeight());
}
-void OpaqueNonClientView::UpdateWindowIcon() {
+void OpaqueBrowserFrameView::UpdateThrobber(bool running) {
if (window_icon_)
window_icon_->Update();
}
///////////////////////////////////////////////////////////////////////////////
-// OpaqueNonClientView, views::NonClientView implementation:
+// OpaqueBrowserFrameView, views::NonClientFrameView implementation:
-gfx::Rect OpaqueNonClientView::CalculateClientAreaBounds(int width,
- int height) const {
- int top_height = NonClientTopBorderHeight();
- int border_thickness = NonClientBorderThickness();
- return gfx::Rect(border_thickness, top_height,
- std::max(0, width - (2 * border_thickness)),
- std::max(0, height - top_height - border_thickness));
+gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const {
+ return client_view_bounds_;
}
-gfx::Size OpaqueNonClientView::CalculateWindowSizeForClientSize(
- int width,
- int height) const {
+gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const {
+ int top_height = NonClientTopBorderHeight();
int border_thickness = NonClientBorderThickness();
- return gfx::Size(width + (2 * border_thickness),
- height + NonClientTopBorderHeight() + border_thickness);
+ return gfx::Rect(std::max(0, client_bounds.x() - border_thickness),
+ std::max(0, client_bounds.y() - top_height),
+ client_bounds.width() + (2 * border_thickness),
+ client_bounds.height() + top_height + border_thickness);
}
-gfx::Point OpaqueNonClientView::GetSystemMenuPoint() const {
+gfx::Point OpaqueBrowserFrameView::GetSystemMenuPoint() const {
gfx::Point system_menu_point(FrameBorderThickness(),
NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() -
- (browser_view_->IsFullscreen() ? 0 : kClientEdgeThickness));
+ kClientEdgeThickness);
ConvertPointToScreen(this, &system_menu_point);
return system_menu_point;
}
-int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) {
+int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
@@ -509,8 +501,8 @@ int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) {
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
-void OpaqueNonClientView::GetWindowMask(const gfx::Size& size,
- gfx::Path* window_mask) {
+void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
+ gfx::Path* window_mask) {
DCHECK(window_mask);
if (browser_view_->IsFullscreen())
@@ -535,11 +527,11 @@ void OpaqueNonClientView::GetWindowMask(const gfx::Size& size,
window_mask->close();
}
-void OpaqueNonClientView::EnableClose(bool enable) {
+void OpaqueBrowserFrameView::EnableClose(bool enable) {
close_button_->SetEnabled(enable);
}
-void OpaqueNonClientView::ResetWindowControls() {
+void OpaqueBrowserFrameView::ResetWindowControls() {
restore_button_->SetState(views::Button::BS_NORMAL);
minimize_button_->SetState(views::Button::BS_NORMAL);
maximize_button_->SetState(views::Button::BS_NORMAL);
@@ -547,9 +539,9 @@ void OpaqueNonClientView::ResetWindowControls() {
}
///////////////////////////////////////////////////////////////////////////////
-// OpaqueNonClientView, views::View overrides:
+// OpaqueBrowserFrameView, views::View overrides:
-void OpaqueNonClientView::Paint(ChromeCanvas* canvas) {
+void OpaqueBrowserFrameView::Paint(ChromeCanvas* canvas) {
if (browser_view_->IsFullscreen())
return; // Nothing is visible, so don't bother to paint.
@@ -565,7 +557,7 @@ void OpaqueNonClientView::Paint(ChromeCanvas* canvas) {
PaintRestoredClientEdge(canvas);
}
-void OpaqueNonClientView::Layout() {
+void OpaqueBrowserFrameView::Layout() {
LayoutWindowControls();
LayoutDistributorLogo();
LayoutTitleBar();
@@ -573,8 +565,8 @@ void OpaqueNonClientView::Layout() {
LayoutClientView();
}
-views::View* OpaqueNonClientView::GetViewForPoint(const gfx::Point& point,
- bool can_create_floating) {
+views::View* OpaqueBrowserFrameView::GetViewForPoint(const gfx::Point& point,
+ bool can_create_floating) {
// We override this function because the ClientView can overlap the non -
// client view, making it impossible to click on the window controls. We need
// to ensure the window controls are checked _first_.
@@ -590,14 +582,10 @@ views::View* OpaqueNonClientView::GetViewForPoint(const gfx::Point& point,
return View::GetViewForPoint(point, can_create_floating);
}
-void OpaqueNonClientView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
+void OpaqueBrowserFrameView::ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) {
if (is_add && child == this) {
- DCHECK(GetWidget());
- DCHECK(frame_->client_view()->GetParent() != this);
- AddChildView(frame_->client_view());
-
// The Accessibility glue looks for the product name on these two views to
// determine if this is in fact a Chrome window.
GetRootView()->SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
@@ -605,7 +593,7 @@ void OpaqueNonClientView::ViewHierarchyChanged(bool is_add,
}
}
-bool OpaqueNonClientView::GetAccessibleRole(VARIANT* role) {
+bool OpaqueBrowserFrameView::GetAccessibleRole(VARIANT* role) {
DCHECK(role);
// We aren't actually the client area of the window, but we act like it as
// far as MSAA and the UI tests are concerned.
@@ -614,7 +602,7 @@ bool OpaqueNonClientView::GetAccessibleRole(VARIANT* role) {
return true;
}
-bool OpaqueNonClientView::GetAccessibleName(std::wstring* name) {
+bool OpaqueBrowserFrameView::GetAccessibleName(std::wstring* name) {
if (!accessible_name_.empty()) {
*name = accessible_name_;
return true;
@@ -622,14 +610,14 @@ bool OpaqueNonClientView::GetAccessibleName(std::wstring* name) {
return false;
}
-void OpaqueNonClientView::SetAccessibleName(const std::wstring& name) {
+void OpaqueBrowserFrameView::SetAccessibleName(const std::wstring& name) {
accessible_name_ = name;
}
///////////////////////////////////////////////////////////////////////////////
-// OpaqueNonClientView, views::BaseButton::ButtonListener implementation:
+// OpaqueBrowserFrameView, views::BaseButton::ButtonListener implementation:
-void OpaqueNonClientView::ButtonPressed(views::BaseButton* sender) {
+void OpaqueBrowserFrameView::ButtonPressed(views::BaseButton* sender) {
if (sender == minimize_button_)
frame_->ExecuteSystemMenuCommand(SC_MINIMIZE);
else if (sender == maximize_button_)
@@ -641,9 +629,9 @@ void OpaqueNonClientView::ButtonPressed(views::BaseButton* sender) {
}
///////////////////////////////////////////////////////////////////////////////
-// OpaqueNonClientView, TabIconView::TabContentsProvider implementation:
+// OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation:
-bool OpaqueNonClientView::ShouldTabIconViewAnimate() const {
+bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const {
// This function is queried during the creation of the window as the
// TabIconView we host is initialized, so we need to NULL check the selected
// TabContents because in this condition there is not yet a selected tab.
@@ -651,31 +639,31 @@ bool OpaqueNonClientView::ShouldTabIconViewAnimate() const {
return current_tab ? current_tab->is_loading() : false;
}
-SkBitmap OpaqueNonClientView::GetFavIconForTabIconView() {
+SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() {
return frame_->window_delegate()->GetWindowIcon();
}
///////////////////////////////////////////////////////////////////////////////
-// OpaqueNonClientView, private:
+// OpaqueBrowserFrameView, private:
-int OpaqueNonClientView::FrameBorderThickness() const {
+int OpaqueBrowserFrameView::FrameBorderThickness() const {
if (browser_view_->IsFullscreen())
return 0;
return frame_->IsMaximized() ?
GetSystemMetrics(SM_CXSIZEFRAME) : kFrameBorderThickness;
}
-int OpaqueNonClientView::TopResizeHeight() const {
+int OpaqueBrowserFrameView::TopResizeHeight() const {
return FrameBorderThickness() - kTopResizeAdjust;
}
-int OpaqueNonClientView::NonClientBorderThickness() const {
+int OpaqueBrowserFrameView::NonClientBorderThickness() const {
// When we fill the screen, we don't show a client edge.
return FrameBorderThickness() +
(browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0);
}
-int OpaqueNonClientView::NonClientTopBorderHeight() const {
+int OpaqueBrowserFrameView::NonClientTopBorderHeight() const {
if (frame_->window_delegate()->ShouldShowWindowTitle()) {
int title_top_spacing, title_thickness;
return TitleCoordinates(&title_top_spacing, &title_thickness);
@@ -685,7 +673,7 @@ int OpaqueNonClientView::NonClientTopBorderHeight() const {
kNonClientRestoredExtraThickness : 0);
}
-int OpaqueNonClientView::UnavailablePixelsAtBottomOfNonClientHeight() const {
+int OpaqueBrowserFrameView::UnavailablePixelsAtBottomOfNonClientHeight() const {
// Tricky: When a toolbar is edging the titlebar, it not only draws its own
// shadow and client edge, but an extra, light "shadow" pixel as well, which
// is treated as available space. Thus the nonclient area actually _fails_ to
@@ -697,8 +685,8 @@ int OpaqueNonClientView::UnavailablePixelsAtBottomOfNonClientHeight() const {
(frame_->IsMaximized() ? 0 : kClientEdgeThickness);
}
-int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing,
- int* title_thickness) const {
+int OpaqueBrowserFrameView::TitleCoordinates(int* title_top_spacing,
+ int* title_thickness) const {
int frame_thickness = FrameBorderThickness();
int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness;
*title_top_spacing = frame_thickness + kTitleTopSpacing;
@@ -724,7 +712,7 @@ int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing,
UnavailablePixelsAtBottomOfNonClientHeight();
}
-void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) {
+void OpaqueBrowserFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) {
SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER);
SkBitmap* top_right_corner =
resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER);
@@ -772,7 +760,7 @@ void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) {
height() - top_left_corner->height() - bottom_left_corner->height());
}
-void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) {
+void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) {
SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE);
canvas->TileImageInt(*top_edge, 0, FrameBorderThickness(), width(),
top_edge->height());
@@ -789,7 +777,7 @@ void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) {
}
}
-void OpaqueNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) {
+void OpaqueBrowserFrameView::PaintDistributorLogo(ChromeCanvas* 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_) {
@@ -798,7 +786,7 @@ void OpaqueNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) {
}
}
-void OpaqueNonClientView::PaintTitleBar(ChromeCanvas* canvas) {
+void OpaqueBrowserFrameView::PaintTitleBar(ChromeCanvas* canvas) {
// The window icon is painted by the TabIconView.
views::WindowDelegate* d = frame_->window_delegate();
if (d->ShouldShowWindowTitle()) {
@@ -814,7 +802,7 @@ void OpaqueNonClientView::PaintTitleBar(ChromeCanvas* canvas) {
}
}
-void OpaqueNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) {
+void OpaqueBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) {
if (!browser_view_->IsToolbarVisible())
return;
@@ -848,7 +836,7 @@ void OpaqueNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) {
toolbar_bounds.right(), toolbar_bounds.y());
}
-void OpaqueNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) {
+void OpaqueBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) {
if (!browser_view_->ShouldShowOffTheRecordAvatar())
return;
@@ -860,7 +848,7 @@ void OpaqueNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) {
otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false);
}
-void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
+void OpaqueBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
int client_area_top = frame_->client_view()->y();
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
@@ -916,7 +904,7 @@ void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
client_area_top, left->width(), client_area_height);
}
-void OpaqueNonClientView::LayoutWindowControls() {
+void OpaqueBrowserFrameView::LayoutWindowControls() {
close_button_->SetImageAlignment(views::Button::ALIGN_LEFT,
views::Button::ALIGN_BOTTOM);
// Maximized buttons start at window top so that even if their images aren't
@@ -965,7 +953,7 @@ void OpaqueNonClientView::LayoutWindowControls() {
minimize_button_size.height() + top_extra_height);
}
-void OpaqueNonClientView::LayoutDistributorLogo() {
+void OpaqueBrowserFrameView::LayoutDistributorLogo() {
// Always lay out the logo, even when it's not present, so we can lay out the
// window title based on its position.
if (distributor_logo_) {
@@ -977,7 +965,7 @@ void OpaqueNonClientView::LayoutDistributorLogo() {
}
}
-void OpaqueNonClientView::LayoutTitleBar() {
+void OpaqueBrowserFrameView::LayoutTitleBar() {
// Always lay out the icon, even when it's not present, so we can lay out the
// window title based on its position.
int frame_thickness = FrameBorderThickness();
@@ -1023,7 +1011,7 @@ void OpaqueNonClientView::LayoutTitleBar() {
}
}
-void OpaqueNonClientView::LayoutOTRAvatar() {
+void OpaqueBrowserFrameView::LayoutOTRAvatar() {
SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
int top_height = NonClientTopBorderHeight();
int tabstrip_height, otr_height;
@@ -1040,13 +1028,21 @@ void OpaqueNonClientView::LayoutOTRAvatar() {
otr_avatar_icon.width(), otr_height);
}
-void OpaqueNonClientView::LayoutClientView() {
- frame_->client_view()->SetBounds(CalculateClientAreaBounds(width(),
- height()));
+void OpaqueBrowserFrameView::LayoutClientView() {
+ client_view_bounds_ = CalculateClientAreaBounds(width(), height());
+}
+
+gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
+ int height) const {
+ int top_height = NonClientTopBorderHeight();
+ int border_thickness = NonClientBorderThickness();
+ return gfx::Rect(border_thickness, top_height,
+ std::max(0, width - (2 * border_thickness)),
+ std::max(0, height - top_height - border_thickness));
}
// static
-void OpaqueNonClientView::InitClass() {
+void OpaqueBrowserFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
active_resources_ = new ActiveWindowResources;
@@ -1062,7 +1058,7 @@ void OpaqueNonClientView::InitClass() {
}
// static
-void OpaqueNonClientView::InitAppWindowResources() {
+void OpaqueBrowserFrameView::InitAppWindowResources() {
static bool initialized = false;
if (!initialized) {
title_font_ = win_util::GetWindowTitleFont();
diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h
index 6160b9d..7eed20d 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.h
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.h
@@ -2,48 +2,41 @@
// 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_OPAQUE_NON_CLIENT_VIEW_H_
-#define CHROME_BROWSER_VIEWS_FRAME_OPAQUE_NON_CLIENT_VIEW_H_
+#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/opaque_frame.h"
+#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/browser/views/tab_icon_view.h"
#include "chrome/views/non_client_view.h"
#include "chrome/views/button.h"
class BrowserView;
class ChromeFont;
-class OpaqueFrame;
class TabContents;
class TabStrip;
namespace views {
class WindowResources;
}
-class OpaqueNonClientView : public views::NonClientView,
- public views::BaseButton::ButtonListener,
- public TabIconView::TabIconViewModel {
+class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
+ public views::BaseButton::ButtonListener,
+ public TabIconView::TabIconViewModel {
public:
- // Constructs a non-client view for an OpaqueFrame. |is_otr| specifies if the
+ // Constructs a non-client view for an BrowserFrame. |is_otr| specifies if the
// frame was created "off-the-record" and as such different bitmaps should be
// used to render the frame.
- OpaqueNonClientView(OpaqueFrame* frame, BrowserView* browser_view);
- virtual ~OpaqueNonClientView();
+ OpaqueBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view);
+ virtual ~OpaqueBrowserFrameView();
- // Retrieve the bounds of the window for the specified contents bounds.
- gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect& client_bounds);
-
- // Retrieve the bounds for the specified |tabstrip|, in the coordinate system
- // of the non-client view (which whould be window coordinates).
- gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip);
-
- // Updates the window icon/throbber.
- void UpdateWindowIcon();
+ // Overridden from BrowserNonClientFrameView:
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
+ virtual void UpdateThrobber(bool running);
protected:
- // Overridden from views::NonClientView:
- virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const;
- virtual gfx::Size CalculateWindowSizeForClientSize(int width,
- int height) const;
+ // Overridden from views::NonClientFrameView:
+ virtual gfx::Rect GetBoundsForClientView() const;
+ virtual gfx::Rect GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const;
virtual gfx::Point GetSystemMenuPoint() const;
virtual int NonClientHitTest(const gfx::Point& point);
virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask);
@@ -115,6 +108,9 @@ class OpaqueNonClientView : public views::NonClientView,
void LayoutOTRAvatar();
void LayoutClientView();
+ // Returns the bounds of the client area for the specified view size.
+ gfx::Rect CalculateClientAreaBounds(int width, int height) const;
+
// Returns the set of resources to use to paint this view.
views::WindowResources* resources() const {
return frame_->is_active() || paint_as_active() ?
@@ -140,11 +136,14 @@ class OpaqueNonClientView : public views::NonClientView,
TabIconView* window_icon_;
// The frame that hosts this view.
- OpaqueFrame* frame_;
+ BrowserFrame* frame_;
// The BrowserView hosted within this View.
BrowserView* browser_view_;
+ // The bounds of the ClientView.
+ gfx::Rect client_view_bounds_;
+
// The resources currently used to paint this view.
views::WindowResources* current_active_resources_;
views::WindowResources* current_inactive_resources_;
@@ -161,8 +160,8 @@ class OpaqueNonClientView : public views::NonClientView,
static views::WindowResources* inactive_otr_resources_;
static ChromeFont title_font_;
- DISALLOW_EVIL_CONSTRUCTORS(OpaqueNonClientView);
+ DISALLOW_EVIL_CONSTRUCTORS(OpaqueBrowserFrameView);
};
-#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_NON_CLIENT_VIEW_H_
+#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_
diff --git a/chrome/browser/views/frame/opaque_frame.cc b/chrome/browser/views/frame/opaque_frame.cc
deleted file mode 100644
index 066bcad..0000000
--- a/chrome/browser/views/frame/opaque_frame.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-// 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.
-
-#include "chrome/browser/views/frame/opaque_frame.h"
-
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/frame/opaque_non_client_view.h"
-#include "chrome/browser/views/tabs/tab_strip.h"
-#include "chrome/views/window_delegate.h"
-
-///////////////////////////////////////////////////////////////////////////////
-// OpaqueFrame, public:
-
-OpaqueFrame::OpaqueFrame(BrowserView* browser_view)
- : CustomFrameWindow(browser_view, new OpaqueNonClientView(this,
- browser_view)),
- browser_view_(browser_view) {
- browser_view_->set_frame(this);
-}
-
-OpaqueFrame::~OpaqueFrame() {
-}
-
-void OpaqueFrame::Init() {
- CustomFrameWindow::Init(NULL, gfx::Rect());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OpaqueFrame, BrowserFrame implementation:
-
-gfx::Rect OpaqueFrame::GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds) {
- return GetOpaqueNonClientView()->GetWindowBoundsForClientBounds(
- client_bounds);
-}
-
-void OpaqueFrame::SizeToContents(const gfx::Rect& contents_bounds) {
- gfx::Rect window_bounds = GetOpaqueNonClientView()->
- GetWindowBoundsForClientBounds(contents_bounds);
- SetBounds(window_bounds);
-}
-
-gfx::Rect OpaqueFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const {
- return GetOpaqueNonClientView()->GetBoundsForTabStrip(tabstrip);
-}
-
-void OpaqueFrame::UpdateThrobber(bool running) {
- // TODO(beng): pass |running| through rather than letting
- // OpaqueNonClientView's TabIconView try and figure it out.
- // The throbber doesn't run in the Windows TaskBar, so we just update the
- // non-client view. Updating the taskbar is muy expensivo.
- GetOpaqueNonClientView()->UpdateWindowIcon();
-}
-
-views::Window* OpaqueFrame::GetWindow() {
- return this;
-}
-
-const views::Window* OpaqueFrame::GetWindow() const {
- return this;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OpaqueFrame, views::CustomFrameWindow overrides:
-
-void OpaqueFrame::UpdateWindowIcon() {
- CustomFrameWindow::UpdateWindowIcon();
- GetOpaqueNonClientView()->UpdateWindowIcon();
-}
-
-int OpaqueFrame::GetShowState() const {
- return browser_view_->GetShowState();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OpaqueFrame, views::WidgetWin overrides:
-
-bool OpaqueFrame::AcceleratorPressed(views::Accelerator* accelerator) {
- return browser_view_->AcceleratorPressed(*accelerator);
-}
-
-bool OpaqueFrame::GetAccelerator(int cmd_id, views::Accelerator* accelerator) {
- return browser_view_->GetAccelerator(cmd_id, accelerator);
-}
-
-void OpaqueFrame::OnEndSession(BOOL ending, UINT logoff) {
- BrowserList::WindowsSessionEnding();
-}
-
-void OpaqueFrame::OnEnterSizeMove() {
- browser_view_->WindowMoveOrResizeStarted();
-}
-
-void OpaqueFrame::OnInitMenuPopup(HMENU menu, UINT position,
- BOOL is_system_menu) {
- browser_view_->PrepareToRunSystemMenu(menu);
-}
-
-LRESULT OpaqueFrame::OnMouseActivate(HWND window, UINT hittest_code,
- UINT message) {
- return browser_view_->ActivateAppModalDialog() ? MA_NOACTIVATEANDEAT
- : MA_ACTIVATE;
-}
-
-void OpaqueFrame::OnMove(const CPoint& point) {
- browser_view_->WindowMoved();
-}
-
-void OpaqueFrame::OnMoving(UINT param, const RECT* new_bounds) {
- browser_view_->WindowMoved();
-}
-
-LRESULT OpaqueFrame::OnNCActivate(BOOL active) {
- if (browser_view_->ActivateAppModalDialog())
- return TRUE;
-
- CustomFrameWindow::OnNCActivate(active);
- browser_view_->ActivationChanged(!!active);
- return TRUE;
-}
-
-void OpaqueFrame::OnSysCommand(UINT notification_code, CPoint click) {
- if (!browser_view_->SystemCommandReceived(notification_code,
- gfx::Point(click))) {
- // Use the default implementation for any other command.
- CustomFrameWindow::OnSysCommand(notification_code, click);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OpaqueFrame, private:
-
-OpaqueNonClientView* OpaqueFrame::GetOpaqueNonClientView() const {
- // We can safely assume that this conversion is true.
- return static_cast<OpaqueNonClientView*>(non_client_view_);
-}
-
diff --git a/chrome/browser/views/frame/opaque_frame.h b/chrome/browser/views/frame/opaque_frame.h
deleted file mode 100644
index 7042002..0000000
--- a/chrome/browser/views/frame/opaque_frame.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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_OPAQUE_FRAME_H_
-#define CHROME_BROWSER_VIEWS_FRAME_OPAQUE_FRAME_H_
-
-#include "chrome/browser/views/frame/browser_frame.h"
-#include "chrome/views/custom_frame_window.h"
-
-class BrowserView;
-namespace views {
-class Window;
-}
-class OpaqueNonClientView;
-class TabStrip;
-
-///////////////////////////////////////////////////////////////////////////////
-// OpaqueFrame
-//
-// OpaqueFrame is a CustomFrameWindow subclass that in conjunction with
-// OpaqueNonClientView provides the window frame on Windows XP and on Windows
-// Vista when DWM desktop compositing is disabled. The window title and
-// borders are provided with bitmaps.
-//
-class OpaqueFrame : public BrowserFrame,
- public views::CustomFrameWindow {
- public:
- explicit OpaqueFrame(BrowserView* browser_view);
- virtual ~OpaqueFrame();
-
- void Init();
-
- protected:
- // Overridden from BrowserFrame:
- virtual gfx::Rect GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds);
- virtual void SizeToContents(const gfx::Rect& contents_bounds);
- virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
- virtual void UpdateThrobber(bool running);
- virtual views::Window* GetWindow();
- virtual const views::Window* GetWindow() const;
-
- // Overridden from views::CustomFrameWindow:
- virtual void UpdateWindowIcon();
- virtual int GetShowState() const;
- virtual bool IsAppWindow() const { return true; }
-
- // 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 void OnSysCommand(UINT notification_code, CPoint click);
-
- private:
- // Return a pointer to the concrete type of our non-client view.
- OpaqueNonClientView* GetOpaqueNonClientView() const;
-
- // The BrowserView is our ClientView. This is a pointer to it.
- BrowserView* browser_view_;
-
- DISALLOW_EVIL_CONSTRUCTORS(OpaqueFrame);
-};
-
-#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_FRAME_H_
-
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index a539ea8..a293bb9 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -16,13 +16,13 @@
#include "chrome/common/logging_chrome.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/views/client_view.h"
-#include "chrome/views/custom_frame_window.h"
#include "chrome/views/dialog_delegate.h"
#include "chrome/views/grid_layout.h"
#include "chrome/views/group_table_view.h"
#include "chrome/views/image_view.h"
#include "chrome/views/label.h"
#include "chrome/views/native_button.h"
+#include "chrome/views/window.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 3ab8ec0..8c030d6 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -100,7 +100,7 @@ void InfoBubble::Init(HWND parent_hwnd,
DCHECK(BrowserView::GetBrowserViewForHWND(owning_frame_hwnd));
parent_ = reinterpret_cast<views::Window*>(win_util::GetWindowUserData(
owning_frame_hwnd));
- parent_->DisableInactiveRendering(true);
+ parent_->DisableInactiveRendering();
if (kInfoBubbleCornerTopLeft == NULL) {
kInfoBubbleCornerTopLeft = ResourceBundle::GetSharedInstance()
@@ -207,7 +207,6 @@ void InfoBubble::Close(bool closed_by_escape) {
// We don't fade out because it looks terrible.
if (delegate_)
delegate_->InfoBubbleClosing(this, closed_by_escape);
- parent_->DisableInactiveRendering(false);
closed_ = true;
WidgetWin::Close();
}
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index cc7cf4c..1580d05 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -15,6 +15,7 @@
#include "chrome/common/l10n_util.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/common/win_util.h"
+#include "chrome/views/window.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "skia/ext/image_operations.h"
@@ -78,6 +79,31 @@ static int download_icon_height = 0;
namespace {
+// Loads the images to be used for the tab background. Uses the images for
+// Vista if |use_vista_images| is true.
+void LoadTabImages(bool use_vista_images) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ if (use_vista_images) {
+ tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
+ tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
+ tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
+
+ // Our Vista frame doesn't change background color to show OTR,
+ // so we continue to use the existing background tabs.
+ tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
+ tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
+ tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
+ } else {
+ tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
+ tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
+ tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
+
+ tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR);
+ tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR);
+ tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR);
+ }
+}
+
void InitResources() {
static bool initialized = false;
if (!initialized) {
@@ -97,25 +123,7 @@ void InitResources() {
tab_active_l_width = tab_active_l->width();
tab_active_r_width = tab_active_r->width();
- if (win_util::ShouldUseVistaFrame()) {
- tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
- tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
- tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
-
- // Our Vista frame doesn't change background color to show OTR,
- // so we continue to use the existing background tabs.
- tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
- tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
- tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
- } else {
- tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
- tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
- tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
-
- tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR);
- tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR);
- tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR);
- }
+ LoadTabImages(win_util::ShouldUseVistaFrame());
tab_hover_l = rb.GetBitmapNamed(IDR_TAB_HOVER_LEFT);
tab_hover_c = rb.GetBitmapNamed(IDR_TAB_HOVER_CENTER);
@@ -535,6 +543,12 @@ void TabRenderer::OnMouseExited(const views::MouseEvent& e) {
hover_animation_->Hide();
}
+void TabRenderer::ThemeChanged() {
+ if (GetWidget() && GetWidget()->AsWindow())
+ LoadTabImages(GetWidget()->AsWindow()->UseNativeFrame());
+ View::ThemeChanged();
+}
+
///////////////////////////////////////////////////////////////////////////////
// TabRenderer, AnimationDelegate implementation:
@@ -566,7 +580,7 @@ void TabRenderer::PaintTabBackground(ChromeCanvas* canvas) {
animation = pulse_animation_.get();
if (animation->GetCurrentValue() > 0) {
PaintHoverTabBackground(canvas, animation->GetCurrentValue() *
- (win_util::ShouldUseVistaFrame() ?
+ (GetWidget()->AsWindow()->UseNativeFrame() ?
kHoverOpacityVista : kHoverOpacity));
} else {
PaintInactiveTabBackground(canvas);
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index 9cad816..68df3e3 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -76,6 +76,7 @@ class TabRenderer : public views::View,
virtual void Layout();
virtual void OnMouseEntered(const views::MouseEvent& event);
virtual void OnMouseExited(const views::MouseEvent& event);
+ virtual void ThemeChanged();
// Overridden from AnimationDelegate:
virtual void AnimationProgressed(const Animation* animation);
@@ -166,6 +167,9 @@ class TabRenderer : public views::View,
bool should_display_crashed_favicon_;
+ static void InitClass();
+ static bool initialized_;
+
DISALLOW_EVIL_CONSTRUCTORS(TabRenderer);
};
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index fceb5af..e3ec025 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -25,6 +25,7 @@
#include "chrome/common/win_util.h"
#include "chrome/views/image_view.h"
#include "chrome/views/painter.h"
+#include "chrome/views/window.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -618,7 +619,7 @@ void TabStrip::PaintChildren(ChromeCanvas* canvas) {
}
}
- if (win_util::ShouldUseVistaFrame()) {
+ if (GetWidget()->AsWindow()->UseNativeFrame()) {
// Make sure unselected tabs are somewhat transparent.
SkPaint paint;
paint.setColor(SkColorSetARGB(200, 255, 255, 255));
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index dd88eff..25c7161 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -47,7 +47,7 @@
#include "chrome/views/label.h"
#include "chrome/views/non_client_view.h"
#include "chrome/views/tooltip_manager.h"
-#include "chrome/views/widget.h"
+#include "chrome/views/window.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -354,7 +354,7 @@ void BrowserToolbarView::Paint(ChromeCanvas* canvas) {
// For glass, we need to draw a black line below the location bar to separate
// it from the content area. For non-glass, the NonClientView draws the
// toolbar background below the location bar for us.
- if (win_util::ShouldUseVistaFrame())
+ if (GetWidget()->AsWindow()->UseNativeFrame())
canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1);
}
@@ -497,8 +497,9 @@ gfx::Size BrowserToolbarView::GetPreferredSize() {
return gfx::Size(0, normal_background.height());
}
- int vertical_spacing = PopupTopSpacing() + (win_util::ShouldUseVistaFrame() ?
- kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass);
+ int vertical_spacing = PopupTopSpacing() +
+ (GetWidget()->AsWindow()->UseNativeFrame() ? kPopupBottomSpacingGlass
+ : kPopupBottomSpacingNonGlass);
return gfx::Size(0, location_bar_->GetPreferredSize().height() +
vertical_spacing);
}
@@ -806,7 +807,8 @@ void BrowserToolbarView::ButtonPressed(views::BaseButton* sender) {
// static
int BrowserToolbarView::PopupTopSpacing() {
- return win_util::ShouldUseVistaFrame() ? 0 : kPopupTopSpacingNonGlass;
+ return GetWidget()->AsWindow()->UseNativeFrame() ? 0
+ : kPopupTopSpacingNonGlass;
}
void BrowserToolbarView::Observe(NotificationType type,
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index 1712ef4..970b378 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -131,7 +131,7 @@ class BrowserToolbarView : public views::View,
};
// Returns the number of pixels above the location bar in non-normal display.
- static int PopupTopSpacing();
+ int PopupTopSpacing();
// NotificationObserver
virtual void Observe(NotificationType type,