summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-08 02:19:04 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-08 02:19:04 +0000
commit255f8277e7e4f9e19b8f19988ded37e38c932c73 (patch)
tree190c630f1e979cf3cc696dd9f98aae0805299f60
parent102d61716706329822b280ee3cd2eddda5af1b56 (diff)
downloadchromium_src-255f8277e7e4f9e19b8f19988ded37e38c932c73.zip
chromium_src-255f8277e7e4f9e19b8f19988ded37e38c932c73.tar.gz
chromium_src-255f8277e7e4f9e19b8f19988ded37e38c932c73.tar.bz2
Refactor browser frames to eliminate duplicate UpdateAvatarInfo
There's a fair amount of duplicate code between OpaqueBrowserFrameView, GlassBrowserFrameView and the other subclasses of BrowserFrameView. Start moving shared functionality into the parent class. No functionality changes. BUG=103255 TEST=profile switching still works, avatar icon paints correctly Review URL: http://codereview.chromium.org/8492021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108965 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/panels/panel_browser_frame_view.cc47
-rw-r--r--chrome/browser/ui/panels/panel_browser_frame_view.h7
-rw-r--r--chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc46
-rw-r--r--chrome/browser/ui/views/frame/app_panel_browser_frame_view.h7
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view.cc53
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view.h26
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc27
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h3
-rw-r--r--chrome/browser/ui/views/frame/glass_browser_frame_view.cc129
-rw-r--r--chrome/browser/ui/views/frame/glass_browser_frame_view.h14
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.cc193
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.h19
-rw-r--r--chrome/browser/ui/views/frame/popup_non_client_frame_view.cc7
-rw-r--r--chrome/browser/ui/views/frame/popup_non_client_frame_view.h1
-rw-r--r--chrome/chrome_browser.gypi3
16 files changed, 253 insertions, 331 deletions
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc
index 5f883fc..88bd90c 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc
@@ -166,8 +166,8 @@ PanelBrowserFrameView::MouseWatcher::~MouseWatcher() {
bool PanelBrowserFrameView::MouseWatcher::IsCursorInViewBounds() const {
gfx::Point cursor_point = gfx::Screen::GetCursorScreenPoint();
- return view_->browser_view_->GetBounds().Contains(cursor_point.x(),
- cursor_point.y());
+ return view_->browser_view()->GetBounds().Contains(cursor_point.x(),
+ cursor_point.y());
}
#if defined(OS_WIN)
@@ -234,9 +234,8 @@ void PanelBrowserFrameView::MouseWatcher::HandleGlobalMouseMoveEvent() {
PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame,
PanelBrowserView* browser_view)
- : BrowserNonClientFrameView(),
- frame_(frame),
- browser_view_(browser_view),
+ : BrowserNonClientFrameView(frame, browser_view),
+ panel_browser_view_(browser_view),
paint_state_(NOT_PAINTED),
settings_button_(NULL),
close_button_(NULL),
@@ -244,7 +243,7 @@ PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame,
title_label_(NULL),
is_settings_button_visible_(false) {
EnsureResourcesInitialized();
- frame_->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM);
+ frame->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM);
settings_button_ = new views::MenuButton(NULL, string16(), this, false);
settings_button_->SetIcon(*(settings_button_resources.normal_image));
@@ -307,10 +306,6 @@ void PanelBrowserFrameView::UpdateThrobber(bool running) {
title_icon_->Update();
}
-AvatarMenuButton* PanelBrowserFrameView::GetAvatarMenuButton() {
- return NULL;
-}
-
gfx::Rect PanelBrowserFrameView::GetBoundsForClientView() const {
return client_view_bounds_;
}
@@ -330,7 +325,7 @@ int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
return HTNOWHERE;
int frame_component =
- frame_->client_view()->NonClientHitTest(point);
+ frame()->client_view()->NonClientHitTest(point);
if (frame_component != HTNOWHERE)
return frame_component;
@@ -341,7 +336,7 @@ int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point,
NonClientBorderThickness(), NonClientBorderThickness(),
0, 0,
- frame_->widget_delegate()->CanResize());
+ frame()->widget_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -393,9 +388,9 @@ void PanelBrowserFrameView::UpdateWindowIcon() {
void PanelBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
// The font and color need to be updated depending on the panel's state.
PaintState paint_state;
- if (browser_view_->panel()->IsDrawingAttention())
+ if (panel_browser_view_->panel()->IsDrawingAttention())
paint_state = PAINT_FOR_ATTENTION;
- else if (browser_view_->focused())
+ else if (panel_browser_view_->focused())
paint_state = PAINT_AS_ACTIVE;
else
paint_state = PAINT_AS_INACTIVE;
@@ -482,26 +477,26 @@ void PanelBrowserFrameView::GetAccessibleState(ui::AccessibleViewState* state) {
bool PanelBrowserFrameView::OnMousePressed(const views::MouseEvent& event) {
if (event.IsOnlyLeftMouseButton() &&
- browser_view_->OnTitlebarMousePressed(event.location())) {
+ panel_browser_view_->OnTitlebarMousePressed(event.location())) {
return true;
}
return BrowserNonClientFrameView::OnMousePressed(event);
}
bool PanelBrowserFrameView::OnMouseDragged(const views::MouseEvent& event) {
- if (browser_view_->OnTitlebarMouseDragged(event.location()))
+ if (panel_browser_view_->OnTitlebarMouseDragged(event.location()))
return true;
return BrowserNonClientFrameView::OnMouseDragged(event);
}
void PanelBrowserFrameView::OnMouseReleased(const views::MouseEvent& event) {
- if (browser_view_->OnTitlebarMouseReleased())
+ if (panel_browser_view_->OnTitlebarMouseReleased())
return;
BrowserNonClientFrameView::OnMouseReleased(event);
}
void PanelBrowserFrameView::OnMouseCaptureLost() {
- if (browser_view_->OnTitlebarMouseCaptureLost())
+ if (panel_browser_view_->OnTitlebarMouseCaptureLost())
return;
BrowserNonClientFrameView::OnMouseCaptureLost();
}
@@ -509,7 +504,7 @@ void PanelBrowserFrameView::OnMouseCaptureLost() {
void PanelBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == close_button_)
- frame_->Close();
+ frame()->Close();
}
void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) {
@@ -530,12 +525,12 @@ bool PanelBrowserFrameView::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.
- TabContents* current_tab = browser_view_->GetSelectedTabContents();
+ TabContents* current_tab = browser_view()->GetSelectedTabContents();
return current_tab ? current_tab->IsLoading() : false;
}
SkBitmap PanelBrowserFrameView::GetFaviconForTabIconView() {
- return frame_->widget_delegate()->GetWindowIcon();
+ return frame()->widget_delegate()->GetWindowIcon();
}
void PanelBrowserFrameView::AnimationEnded(const ui::Animation* animation) {
@@ -722,7 +717,7 @@ void PanelBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) {
}
void PanelBrowserFrameView::UpdateTitleBar() {
- title_label_->SetText(frame_->widget_delegate()->GetWindowTitle());
+ title_label_->SetText(frame()->widget_delegate()->GetWindowTitle());
}
void PanelBrowserFrameView::OnFocusChanged(bool focused) {
@@ -733,9 +728,9 @@ void PanelBrowserFrameView::OnFocusChanged(bool focused) {
void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) {
// Panel might be closed when we still watch the mouse event.
- if (!browser_view_->panel())
+ if (!panel_browser_view_->panel())
return;
- UpdateSettingsButtonVisibility(browser_view_->focused(),
+ UpdateSettingsButtonVisibility(panel_browser_view_->focused(),
mouse_entered);
}
@@ -767,12 +762,12 @@ bool PanelBrowserFrameView::EnsureSettingsMenuCreated() {
if (settings_menu_runner_.get())
return true;
- const Extension* extension = browser_view_->panel()->GetExtension();
+ const Extension* extension = panel_browser_view_->panel()->GetExtension();
if (!extension)
return false;
settings_menu_model_.reset(
- new PanelSettingsMenuModel(browser_view_->panel()));
+ new PanelSettingsMenuModel(panel_browser_view_->panel()));
settings_menu_adapter_.reset(
new views::MenuModelAdapter(settings_menu_model_.get()));
settings_menu_ = new views::MenuItemView(settings_menu_adapter_.get());
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.h b/chrome/browser/ui/panels/panel_browser_frame_view.h
index 2dc3c5e..7e517cc 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.h
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.h
@@ -58,7 +58,6 @@ class PanelBrowserFrameView : public BrowserNonClientFrameView,
virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE;
virtual void UpdateThrobber(bool running) OVERRIDE;
- virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE;
// Overridden from views::NonClientFrameView:
virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
@@ -172,14 +171,10 @@ class PanelBrowserFrameView : public BrowserNonClientFrameView,
}
#endif
- // The frame that hosts this view. This is a weak reference such that frame_
- // will always be valid in the lifetime of this view.
- BrowserFrame* frame_;
-
// The client view hosted within this non-client frame view that is
// guaranteed to be freed before the client view.
// (see comments about view hierarchies in non_client_view.h)
- PanelBrowserView* browser_view_;
+ PanelBrowserView* panel_browser_view_;
PaintState paint_state_;
views::MenuButton* settings_button_;
diff --git a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
index 668a157..7eab62b 100644
--- a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
@@ -56,16 +56,14 @@ const int kCloseButtonFrameBorderSpacing = 4;
AppPanelBrowserFrameView::AppPanelBrowserFrameView(BrowserFrame* frame,
BrowserView* browser_view)
- : BrowserNonClientFrameView(),
+ : BrowserNonClientFrameView(frame, browser_view),
ALLOW_THIS_IN_INITIALIZER_LIST(
close_button_(new views::ImageButton(this))),
- window_icon_(NULL),
- frame_(frame),
- browser_view_(browser_view) {
+ window_icon_(NULL) {
DCHECK(browser_view->ShouldShowWindowIcon());
DCHECK(browser_view->ShouldShowWindowTitle());
- frame_->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM);
+ frame->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
close_button_->SetImage(views::CustomButton::BS_NORMAL,
@@ -107,12 +105,8 @@ void AppPanelBrowserFrameView::UpdateThrobber(bool running) {
window_icon_->Update();
}
-AvatarMenuButton* AppPanelBrowserFrameView::GetAvatarMenuButton() {
- return NULL;
-}
-
gfx::Size AppPanelBrowserFrameView::GetMinimumSize() {
- gfx::Size min_size(browser_view_->GetMinimumSize());
+ gfx::Size min_size(browser_view()->GetMinimumSize());
int border_thickness = NonClientBorderThickness();
min_size.Enlarge(2 * border_thickness,
NonClientTopBorderHeight() + border_thickness);
@@ -144,14 +138,14 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
- int frame_component = frame_->client_view()->NonClientHitTest(point);
+ int frame_component = frame()->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. (We check the ClientView first to be
// consistent with OpaqueBrowserFrameView; it's not really necessary here.)
gfx::Rect sysmenu_rect(IconBounds());
// In maximized mode we extend the rect to the screen corner to take advantage
// of Fitts' Law.
- if (frame_->IsMaximized())
+ if (frame()->IsMaximized())
sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
if (sysmenu_rect.Contains(point))
@@ -168,7 +162,7 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point,
NonClientBorderThickness(), NonClientBorderThickness(),
kResizeAreaCornerSize, kResizeAreaCornerSize,
- frame_->widget_delegate()->CanResize());
+ frame()->widget_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -177,7 +171,7 @@ void AppPanelBrowserFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
DCHECK(window_mask);
- if (frame_->IsMaximized())
+ if (frame()->IsMaximized())
return;
// Redefine the window visible region for the new size.
@@ -216,12 +210,12 @@ void AppPanelBrowserFrameView::UpdateWindowIcon() {
// AppPanelBrowserFrameView, views::View overrides:
void AppPanelBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
- if (frame_->IsMaximized())
+ if (frame()->IsMaximized())
PaintMaximizedFrameBorder(canvas);
else
PaintRestoredFrameBorder(canvas);
PaintTitleBar(canvas);
- if (!frame_->IsMaximized())
+ if (!frame()->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -237,7 +231,7 @@ void AppPanelBrowserFrameView::Layout() {
void AppPanelBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == close_button_)
- frame_->Close();
+ frame()->Close();
}
///////////////////////////////////////////////////////////////////////////////
@@ -247,24 +241,24 @@ bool AppPanelBrowserFrameView::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.
- TabContents* current_tab = browser_view_->GetSelectedTabContents();
+ TabContents* current_tab = browser_view()->GetSelectedTabContents();
return current_tab ? current_tab->IsLoading() : false;
}
SkBitmap AppPanelBrowserFrameView::GetFaviconForTabIconView() {
- return frame_->widget_delegate()->GetWindowIcon();
+ return frame()->widget_delegate()->GetWindowIcon();
}
///////////////////////////////////////////////////////////////////////////////
// AppPanelBrowserFrameView, private:
int AppPanelBrowserFrameView::FrameBorderThickness() const {
- return frame_->IsMaximized() ? 0 : kFrameBorderThickness;
+ return frame()->IsMaximized() ? 0 : kFrameBorderThickness;
}
int AppPanelBrowserFrameView::NonClientBorderThickness() const {
return FrameBorderThickness() +
- (frame_->IsMaximized() ? 0 : kClientEdgeThickness);
+ (frame()->IsMaximized() ? 0 : kClientEdgeThickness);
}
int AppPanelBrowserFrameView::NonClientTopBorderHeight() const {
@@ -275,7 +269,7 @@ int AppPanelBrowserFrameView::NonClientTopBorderHeight() const {
int AppPanelBrowserFrameView::TitlebarBottomThickness() const {
return kTitlebarTopAndBottomEdgeThickness +
- (frame_->IsMaximized() ? 0 : kClientEdgeThickness);
+ (frame()->IsMaximized() ? 0 : kClientEdgeThickness);
}
int AppPanelBrowserFrameView::IconSize() const {
@@ -299,7 +293,7 @@ gfx::Rect AppPanelBrowserFrameView::IconBounds() const {
// with restored windows, so when the window is restored, instead of
// calculating the remaining space from below the frame border, we calculate
// from below the top border-plus-padding.
- int unavailable_px_at_top = frame_->IsMaximized() ?
+ int unavailable_px_at_top = frame()->IsMaximized() ?
frame_thickness : kTitlebarTopAndBottomEdgeThickness;
// When the icon is shorter than the minimum space we reserve for the caption
// button, we vertically center it. We want to bias rounding to put extra
@@ -407,13 +401,13 @@ void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER);
int edge_height = titlebar_bottom->height() - kClientEdgeThickness;
canvas->TileImageInt(*titlebar_bottom, 0,
- frame_->client_view()->y() - edge_height,
+ frame()->client_view()->y() - edge_height,
width(), edge_height);
}
void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
// The window icon is painted by the TabIconView.
- views::WidgetDelegate* d = frame_->widget_delegate();
+ views::WidgetDelegate* d = frame()->widget_delegate();
canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(),
SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(),
title_bounds_.width(), title_bounds_.height());
@@ -473,7 +467,7 @@ void AppPanelBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
void AppPanelBrowserFrameView::LayoutWindowControls() {
close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
views::ImageButton::ALIGN_BOTTOM);
- bool is_maximized = frame_->IsMaximized();
+ bool is_maximized = frame()->IsMaximized();
// There should always be the same number of non-border pixels visible to the
// side of the close button. In maximized mode we extend the button to the
// screen corner to obey Fitts' Law.
diff --git a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.h b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.h
index 141176a..85d1d72 100644
--- a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.h
+++ b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.h
@@ -36,7 +36,6 @@ class AppPanelBrowserFrameView : public BrowserNonClientFrameView,
virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE;
virtual void UpdateThrobber(bool running) OVERRIDE;
- virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE;
virtual gfx::Size GetMinimumSize() OVERRIDE;
protected:
@@ -110,12 +109,6 @@ class AppPanelBrowserFrameView : public BrowserNonClientFrameView,
// The Window icon.
TabIconView* window_icon_;
- // The frame that hosts this view.
- BrowserFrame* frame_;
-
- // The BrowserView hosted within this View.
- BrowserView* browser_view_;
-
// The bounds of the ClientView.
gfx::Rect client_view_bounds_;
diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index 72213b2..666bdbf 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -151,5 +151,5 @@ void BrowserFrame::OnNativeWidgetActivationChanged(bool active) {
}
AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() {
- return browser_frame_view_->GetAvatarMenuButton();
+ return browser_frame_view_->avatar_button();
}
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
new file mode 100644
index 0000000..c35df07
--- /dev/null
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_info_cache.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/views/avatar_menu_button.h"
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "ui/gfx/image/image.h"
+
+BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame,
+ BrowserView* browser_view)
+ : frame_(frame),
+ browser_view_(browser_view) {
+}
+
+BrowserNonClientFrameView::~BrowserNonClientFrameView() {
+}
+
+void BrowserNonClientFrameView::UpdateAvatarInfo() {
+ if (browser_view_->ShouldShowAvatar()) {
+ if (!avatar_button_.get()) {
+ avatar_button_.reset(new AvatarMenuButton(
+ browser_view_->browser(), !browser_view_->IsOffTheRecord()));
+ AddChildView(avatar_button_.get());
+ frame_->GetRootView()->Layout();
+ }
+ } else if (avatar_button_.get()) {
+ RemoveChildView(avatar_button_.get());
+ avatar_button_.reset();
+ frame_->GetRootView()->Layout();
+ }
+
+ if (!avatar_button_.get())
+ return;
+
+ if (browser_view_->IsOffTheRecord()) {
+ avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon());
+ } else {
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ Profile* profile = browser_view_->browser()->profile();
+ size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
+ if (index != std::string::npos) {
+ avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index));
+ avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index));
+ }
+ }
+}
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
index c781f38..2f7ca2c 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_H_
#pragma once
+#include "base/memory/scoped_ptr.h"
#include "views/window/non_client_view.h"
class AvatarMenuButton;
@@ -16,8 +17,10 @@ class BrowserView;
// Browser-specific methods.
class BrowserNonClientFrameView : public views::NonClientFrameView {
public:
- BrowserNonClientFrameView() : NonClientFrameView() {}
- virtual ~BrowserNonClientFrameView() {}
+ BrowserNonClientFrameView(BrowserFrame* frame, BrowserView* browser_view);
+ virtual ~BrowserNonClientFrameView();
+
+ AvatarMenuButton* avatar_button() const { return avatar_button_.get(); }
// Returns the bounds within which the TabStrip should be laid out.
virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const = 0;
@@ -31,8 +34,23 @@ class BrowserNonClientFrameView : public views::NonClientFrameView {
// Updates the throbber.
virtual void UpdateThrobber(bool running) = 0;
- // Gets the avatar menu button. The button maybe NULL.
- virtual AvatarMenuButton* GetAvatarMenuButton() = 0;
+ protected:
+ BrowserView* browser_view() const { return browser_view_; }
+ BrowserFrame* frame() const { return frame_; }
+
+ // Updates the title and icon of the avatar button.
+ void UpdateAvatarInfo();
+
+ private:
+ // The frame that hosts this view.
+ BrowserFrame* frame_;
+
+ // The BrowserView hosted within this View.
+ BrowserView* browser_view_;
+
+ // Menu button that displays that either the incognito icon or the profile
+ // icon. May be NULL for some frame styles.
+ scoped_ptr<AvatarMenuButton> avatar_button_;
};
namespace browser {
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc
index e7825132..746daa2 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc
@@ -222,9 +222,7 @@ class FrameBackground : public views::View,
BrowserNonClientFrameViewAura::BrowserNonClientFrameViewAura(
BrowserFrame* frame, BrowserView* browser_view)
- : BrowserNonClientFrameView(),
- browser_frame_(frame),
- browser_view_(browser_view),
+ : BrowserNonClientFrameView(frame, browser_view),
last_hittest_code_(HTNOWHERE) {
frame_background_ = new FrameBackground();
AddChildView(frame_background_);
@@ -411,11 +409,6 @@ void BrowserNonClientFrameViewAura::UpdateThrobber(bool running) {
// TODO(jamescook): Do we need this?
}
-AvatarMenuButton* BrowserNonClientFrameViewAura::GetAvatarMenuButton() {
- // TODO(jamescook)
- return NULL;
-}
-
///////////////////////////////////////////////////////////////////////////////
// views::NonClientFrameView overrides:
@@ -503,12 +496,12 @@ bool BrowserNonClientFrameViewAura::HitTest(const gfx::Point& p) const {
maximize_button_->bounds().Contains(p))
return true;
// Otherwise claim it only if it's in a non-tab portion of the tabstrip.
- if (!browser_view_->tabstrip())
+ if (!browser_view()->tabstrip())
return false;
- gfx::Rect tabstrip_bounds(browser_view_->tabstrip()->bounds());
+ gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
gfx::Point tabstrip_origin(tabstrip_bounds.origin());
View::ConvertPointToView(
- browser_frame_->client_view(), this, &tabstrip_origin);
+ frame()->client_view(), this, &tabstrip_origin);
tabstrip_bounds.set_origin(tabstrip_origin);
if (p.y() > tabstrip_bounds.bottom())
return false;
@@ -517,8 +510,8 @@ bool BrowserNonClientFrameViewAura::HitTest(const gfx::Point& p) const {
// completely. We need to do this since we're not a parent of the tabstrip,
// meaning ConvertPointToView would otherwise return something bogus.
gfx::Point browser_view_point(p);
- View::ConvertPointToView(parent(), browser_view_, &browser_view_point);
- return browser_view_->IsPositionInWindowCaption(browser_view_point);
+ View::ConvertPointToView(parent(), browser_view(), &browser_view_point);
+ return browser_view()->IsPositionInWindowCaption(browser_view_point);
}
void BrowserNonClientFrameViewAura::OnMouseMoved(
@@ -564,12 +557,12 @@ gfx::NativeCursor BrowserNonClientFrameViewAura::GetCursor(
void BrowserNonClientFrameViewAura::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == close_button_) {
- browser_frame_->Close();
+ frame()->Close();
} else if (sender == maximize_button_) {
- if (browser_frame_->IsMaximized())
- browser_frame_->Restore();
+ if (frame()->IsMaximized())
+ frame()->Restore();
else
- browser_frame_->Maximize();
+ frame()->Maximize();
}
}
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h
index 947853c..231c2bc 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h
@@ -55,7 +55,6 @@ class BrowserNonClientFrameViewAura : public BrowserNonClientFrameView,
virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE;
virtual void UpdateThrobber(bool running) OVERRIDE;
- virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE;
// views::NonClientFrameView overrides:
virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
@@ -89,8 +88,6 @@ class BrowserNonClientFrameViewAura : public BrowserNonClientFrameView,
// aura_shell::WindowFrame overrides:
virtual void OnWindowHoverChanged(bool hovered) OVERRIDE;
- BrowserFrame* browser_frame_;
- BrowserView* browser_view_;
int last_hittest_code_;
WindowControlButton* maximize_button_;
WindowControlButton* close_button_;
diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
index c92c7df..3ae0a19 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -8,11 +8,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/chrome_dll_resource.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_info_cache.h"
-#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/views/avatar_menu_button.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
@@ -73,16 +69,14 @@ const int kNewTabCaptionMaximizedSpacing = 16;
GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame,
BrowserView* browser_view)
- : BrowserNonClientFrameView(),
- frame_(frame),
- browser_view_(browser_view),
+ : BrowserNonClientFrameView(frame, browser_view),
throbber_running_(false),
throbber_frame_(0) {
- if (browser_view_->ShouldShowWindowIcon())
+ if (browser_view->ShouldShowWindowIcon())
InitThrobberIcons();
UpdateAvatarInfo();
- if (!browser_view_->IsOffTheRecord()) {
+ if (!browser_view->IsOffTheRecord()) {
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
content::NotificationService::AllSources());
}
@@ -97,8 +91,8 @@ GlassBrowserFrameView::~GlassBrowserFrameView() {
gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
views::View* tabstrip) const {
int minimize_button_offset =
- std::min(frame_->GetMinimizeButtonOffset(), width());
- int tabstrip_x = browser_view_->ShouldShowAvatar() ?
+ std::min(frame()->GetMinimizeButtonOffset(), width());
+ int tabstrip_x = browser_view()->ShouldShowAvatar() ?
(avatar_bounds_.right() + kAvatarSideSpacing) :
NonClientBorderThickness();
// In RTL languages, we have moved an avatar icon left by the size of window
@@ -107,12 +101,12 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
// a tab strip until the left end of this window without considering the size
// of window controls in RTL languages.
if (base::i18n::IsRTL()) {
- if (!browser_view_->ShouldShowAvatar() && frame_->IsMaximized())
+ if (!browser_view()->ShouldShowAvatar() && frame()->IsMaximized())
tabstrip_x += avatar_bounds_.x();
minimize_button_offset = width();
}
int tabstrip_width = minimize_button_offset - tabstrip_x -
- (frame_->IsMaximized() ?
+ (frame()->IsMaximized() ?
kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing);
return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
std::max(0, tabstrip_width),
@@ -137,7 +131,7 @@ void GlassBrowserFrameView::UpdateThrobber(bool running) {
}
gfx::Size GlassBrowserFrameView::GetMinimumSize() {
- gfx::Size min_size(browser_view_->GetMinimumSize());
+ gfx::Size min_size(browser_view()->GetMinimumSize());
// Account for the client area insets.
gfx::Insets insets = GetClientAreaInsets();
@@ -147,8 +141,8 @@ gfx::Size GlassBrowserFrameView::GetMinimumSize() {
// Ensure that the minimum width is enough to hold a tab strip with minimum
// width at its usual insets.
- if (browser_view_->IsTabStripVisible()) {
- AbstractTabStripView* tabstrip = browser_view_->tabstrip();
+ if (browser_view()->IsTabStripVisible()) {
+ AbstractTabStripView* tabstrip = browser_view()->tabstrip();
int min_tabstrip_width = tabstrip->GetMinimumSize().width();
int min_tabstrip_area_width =
width() - GetBoundsForTabStrip(tabstrip).width() + min_tabstrip_width;
@@ -167,8 +161,8 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const {
gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
- HWND hwnd = frame_->GetNativeWindow();
- if (!browser_view_->IsTabStripVisible() && hwnd) {
+ HWND hwnd = frame()->GetNativeWindow();
+ if (!browser_view()->IsTabStripVisible() && hwnd) {
// If we don't have a tabstrip, we're either a popup or an app window, in
// which case we have a standard size non-client area and can just use
// AdjustWindowRectEx to obtain it. We check for a non-NULL window handle in
@@ -191,15 +185,15 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
// 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
// out.
- if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point))
+ if (!browser_view()->IsBrowserTypeNormal() || !bounds().Contains(point))
return HTNOWHERE;
// See if the point is within the avatar menu button.
- if (avatar_button_.get() &&
- avatar_button_->GetMirroredBounds().Contains(point))
+ if (avatar_button() &&
+ avatar_button()->GetMirroredBounds().Contains(point))
return HTCLIENT;
- int frame_component = frame_->client_view()->NonClientHitTest(point);
+ int frame_component = frame()->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. We still have to check the tabstrip
// first so that clicks in a tab don't get treated as sysmenu clicks.
@@ -216,24 +210,20 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point, frame_border_thickness,
nonclient_border_thickness, frame_border_thickness,
kResizeAreaCornerSize - frame_border_thickness,
- frame_->widget_delegate()->CanResize());
+ frame()->widget_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
-AvatarMenuButton* GlassBrowserFrameView::GetAvatarMenuButton() {
- return avatar_button_.get();
-}
-
///////////////////////////////////////////////////////////////////////////////
// GlassBrowserFrameView, views::View overrides:
void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
- if (!browser_view_->IsTabStripVisible())
+ if (!browser_view()->IsTabStripVisible())
return; // Nothing is visible, so don't bother to paint.
PaintToolbarBackground(canvas);
- if (!frame_->IsMaximized())
+ if (!frame()->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -243,21 +233,21 @@ void GlassBrowserFrameView::Layout() {
}
bool GlassBrowserFrameView::HitTest(const gfx::Point& l) const {
- return (avatar_button_.get() &&
- avatar_button_->GetMirroredBounds().Contains(l)) ||
- !frame_->client_view()->bounds().Contains(l);
+ return (avatar_button() &&
+ avatar_button()->GetMirroredBounds().Contains(l)) ||
+ !frame()->client_view()->bounds().Contains(l);
}
///////////////////////////////////////////////////////////////////////////////
// GlassBrowserFrameView, private:
int GlassBrowserFrameView::FrameBorderThickness() const {
- return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ return (frame()->IsMaximized() || frame()->IsFullscreen()) ?
0 : GetSystemMetrics(SM_CXSIZEFRAME);
}
int GlassBrowserFrameView::NonClientBorderThickness() const {
- if (frame_->IsMaximized() || frame_->IsFullscreen())
+ if (frame()->IsMaximized() || frame()->IsFullscreen())
return 0;
return kNonClientBorderThickness;
@@ -265,22 +255,22 @@ int GlassBrowserFrameView::NonClientBorderThickness() const {
int GlassBrowserFrameView::NonClientTopBorderHeight(
bool restored) const {
- if (!restored && frame_->IsFullscreen())
+ if (!restored && frame()->IsFullscreen())
return 0;
// We'd like to use FrameBorderThickness() here, but the maximized Aero glass
// frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border
// at the top (see AeroGlassFrame::OnGetMinMaxInfo()).
return GetSystemMetrics(SM_CYSIZEFRAME) +
- ((!restored && browser_view_->IsMaximized()) ?
+ ((!restored && browser_view()->IsMaximized()) ?
-kTabstripTopShadowThickness : kNonClientRestoredExtraThickness);
}
void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
ui::ThemeProvider* tp = GetThemeProvider();
- gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
+ gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
gfx::Point toolbar_origin(toolbar_bounds.origin());
- View::ConvertPointToView(browser_view_, this, &toolbar_origin);
+ View::ConvertPointToView(browser_view(), this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
int x = toolbar_bounds.x();
int w = toolbar_bounds.width();
@@ -343,8 +333,8 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
// The client edges start below the toolbar upper corner images regardless
// of how tall the toolbar itself is.
- int client_area_top = frame_->client_view()->y() +
- browser_view_->GetToolbarBounds().y() +
+ int client_area_top = frame()->client_view()->y() +
+ browser_view()->GetToolbarBounds().y() +
tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
int client_area_bottom =
std::max(client_area_top, height() - NonClientBorderThickness());
@@ -390,7 +380,7 @@ void GlassBrowserFrameView::LayoutAvatar() {
// Even though the avatar is used for both incognito and profiles we always
// use the incognito icon to layout the avatar button. The profile icon
// can be customized so we can't depend on its size to perform layout.
- SkBitmap incognito_icon = browser_view_->GetOTRAvatarIcon();
+ SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon();
int avatar_x = NonClientBorderThickness() + kAvatarSideSpacing;
// Move this avatar icon by the size of window controls to prevent it from
@@ -398,19 +388,19 @@ void GlassBrowserFrameView::LayoutAvatar() {
// the width of a tab strip to avoid decreasing this size twice. (See the
// comment in GetBoundsForTabStrip().)
if (base::i18n::IsRTL())
- avatar_x += width() - frame_->GetMinimizeButtonOffset();
+ avatar_x += width() - frame()->GetMinimizeButtonOffset();
int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) +
- browser_view_->GetTabStripHeight() - kAvatarBottomSpacing;
+ browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
int avatar_restored_y = avatar_bottom - incognito_icon.height();
- int avatar_y = frame_->IsMaximized() ?
+ int avatar_y = frame()->IsMaximized() ?
(NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) :
avatar_restored_y;
avatar_bounds_.SetRect(avatar_x, avatar_y, incognito_icon.width(),
- browser_view_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
+ browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
- if (avatar_button_.get())
- avatar_button_->SetBoundsRect(avatar_bounds_);
+ if (avatar_button())
+ avatar_button()->SetBoundsRect(avatar_bounds_);
}
void GlassBrowserFrameView::LayoutClientView() {
@@ -418,7 +408,7 @@ void GlassBrowserFrameView::LayoutClientView() {
}
gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const {
- if (!browser_view_->IsTabStripVisible())
+ if (!browser_view()->IsTabStripVisible())
return gfx::Insets();
const int top_height = NonClientTopBorderHeight(false);
@@ -441,7 +431,7 @@ void GlassBrowserFrameView::StartThrobber() {
throbber_running_ = true;
throbber_frame_ = 0;
InitThrobberIcons();
- SendMessage(frame_->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
}
@@ -454,8 +444,8 @@ void GlassBrowserFrameView::StopThrobber() {
HICON frame_icon = NULL;
// Check if hosted BrowserView has a window icon to use.
- if (browser_view_->ShouldShowWindowIcon()) {
- SkBitmap icon = browser_view_->GetWindowIcon();
+ if (browser_view()->ShouldShowWindowIcon()) {
+ SkBitmap icon = browser_view()->GetWindowIcon();
if (!icon.isNull())
frame_icon = IconUtil::CreateHICONFromSkBitmap(icon);
}
@@ -463,13 +453,13 @@ void GlassBrowserFrameView::StopThrobber() {
// Fallback to class icon.
if (!frame_icon) {
frame_icon = reinterpret_cast<HICON>(GetClassLongPtr(
- frame_->GetNativeWindow(), GCLP_HICONSM));
+ frame()->GetNativeWindow(), GCLP_HICONSM));
}
// This will reset the small icon which we set in the throbber code.
// WM_SETICON with NULL icon restores the icon for title bar but not
// for taskbar. See http://crbug.com/29996
- SendMessage(frame_->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(frame_icon));
}
@@ -477,7 +467,7 @@ void GlassBrowserFrameView::StopThrobber() {
void GlassBrowserFrameView::DisplayNextThrobberFrame() {
throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
- SendMessage(frame_->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
}
@@ -508,34 +498,3 @@ void GlassBrowserFrameView::InitThrobberIcons() {
initialized = true;
}
}
-
-void GlassBrowserFrameView::UpdateAvatarInfo() {
- if (browser_view_->ShouldShowAvatar()) {
- if (!avatar_button_.get()) {
- avatar_button_.reset(new AvatarMenuButton(
- browser_view_->browser(), !browser_view_->IsOffTheRecord()));
- AddChildView(avatar_button_.get());
- frame_->GetRootView()->Layout();
- }
- } else if (avatar_button_.get()) {
- RemoveChildView(avatar_button_.get());
- avatar_button_.reset();
- frame_->GetRootView()->Layout();
- }
-
- if (!avatar_button_.get())
- return;
-
- if (browser_view_->IsOffTheRecord()) {
- avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon());
- } else {
- ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- Profile* profile = browser_view_->browser()->profile();
- size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
- if (index != std::string::npos) {
- avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index));
- avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index));
- }
- }
-}
diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.h b/chrome/browser/ui/views/frame/glass_browser_frame_view.h
index 60b3b45..60c8c68 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.h
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.h
@@ -41,7 +41,6 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
virtual void EnableClose(bool enable) OVERRIDE { }
virtual void ResetWindowControls() OVERRIDE { }
virtual void UpdateWindowIcon() OVERRIDE { }
- virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE;
protected:
// Overridden from views::View:
@@ -89,25 +88,12 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // Updates the title and icon of the avatar button.
- void UpdateAvatarInfo();
-
// The layout rect of the avatar icon, if visible.
gfx::Rect avatar_bounds_;
- // The frame that hosts this view.
- BrowserFrame* frame_;
-
- // The BrowserView hosted within this View.
- BrowserView* browser_view_;
-
// The bounds of the ClientView.
gfx::Rect client_view_bounds_;
- // Menu button that displays that either the incognito icon or the profile
- // icon.
- scoped_ptr<AvatarMenuButton> avatar_button_;
-
// Whether or not the window throbber is currently animating.
bool throbber_running_;
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index d3def33..e146714 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -10,11 +10,7 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_info_cache.h"
-#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/views/avatar_menu_button.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
@@ -123,7 +119,7 @@ bool ConvertedContainsCheck(gfx::Rect bounds, const views::View* src,
OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
BrowserView* browser_view)
- : BrowserNonClientFrameView(),
+ : BrowserNonClientFrameView(frame, browser_view),
ALLOW_THIS_IN_INITIALIZER_LIST(
minimize_button_(new views::ImageButton(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(
@@ -132,10 +128,8 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
restore_button_(new views::ImageButton(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(
close_button_(new views::ImageButton(this))),
- window_icon_(NULL),
- frame_(frame),
- browser_view_(browser_view) {
- ui::ThemeProvider* tp = frame_->GetThemeProvider();
+ window_icon_(NULL) {
+ ui::ThemeProvider* tp = frame->GetThemeProvider();
SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND);
SkBitmap* background =
tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND);
@@ -145,7 +139,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
tp->GetBitmapNamed(IDR_MINIMIZE_H));
minimize_button_->SetImage(views::CustomButton::BS_PUSHED,
tp->GetBitmapNamed(IDR_MINIMIZE_P));
- if (browser_view_->IsBrowserTypeNormal()) {
+ if (browser_view->IsBrowserTypeNormal()) {
minimize_button_->SetBackground(color, background,
tp->GetBitmapNamed(IDR_MINIMIZE_BUTTON_MASK));
}
@@ -165,7 +159,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
tp->GetBitmapNamed(IDR_MAXIMIZE_H));
maximize_button_->SetImage(views::CustomButton::BS_PUSHED,
tp->GetBitmapNamed(IDR_MAXIMIZE_P));
- if (browser_view_->IsBrowserTypeNormal()) {
+ if (browser_view->IsBrowserTypeNormal()) {
maximize_button_->SetBackground(color, background,
tp->GetBitmapNamed(IDR_MAXIMIZE_BUTTON_MASK));
}
@@ -179,7 +173,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
tp->GetBitmapNamed(IDR_RESTORE_H));
restore_button_->SetImage(views::CustomButton::BS_PUSHED,
tp->GetBitmapNamed(IDR_RESTORE_P));
- if (browser_view_->IsBrowserTypeNormal()) {
+ if (browser_view->IsBrowserTypeNormal()) {
restore_button_->SetBackground(color, background,
tp->GetBitmapNamed(IDR_RESTORE_BUTTON_MASK));
}
@@ -193,7 +187,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
tp->GetBitmapNamed(IDR_CLOSE_H));
close_button_->SetImage(views::CustomButton::BS_PUSHED,
tp->GetBitmapNamed(IDR_CLOSE_P));
- if (browser_view_->IsBrowserTypeNormal()) {
+ if (browser_view->IsBrowserTypeNormal()) {
close_button_->SetBackground(color, background,
tp->GetBitmapNamed(IDR_CLOSE_BUTTON_MASK));
}
@@ -202,7 +196,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
AddChildView(close_button_);
// Initializing the TabIconView is expensive, so only do it if we need to.
- if (browser_view_->ShouldShowWindowIcon()) {
+ if (browser_view->ShouldShowWindowIcon()) {
window_icon_ = new TabIconView(this);
window_icon_->set_is_light(true);
AddChildView(window_icon_);
@@ -210,7 +204,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
}
UpdateAvatarInfo();
- if (!browser_view_->IsOffTheRecord()) {
+ if (!browser_view->IsOffTheRecord()) {
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
content::NotificationService::AllSources());
}
@@ -242,7 +236,7 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForReservedArea() const {
int OpaqueBrowserFrameView::NonClientTopBorderHeight(
bool restored) const {
- views::WidgetDelegate* delegate = frame_->widget_delegate();
+ views::WidgetDelegate* delegate = frame()->widget_delegate();
// |delegate| may be NULL if called from callback of InputMethodChanged while
// a window is being destroyed.
// See more discussion at http://crosbug.com/8958
@@ -253,8 +247,8 @@ int OpaqueBrowserFrameView::NonClientTopBorderHeight(
}
return FrameBorderThickness(restored) -
- ((browser_view_->IsTabStripVisible() && !restored &&
- frame_->IsMaximized()) ? kTabstripTopShadowThickness : 0);
+ ((browser_view()->IsTabStripVisible() && !restored &&
+ frame()->IsMaximized()) ? kTabstripTopShadowThickness : 0);
}
///////////////////////////////////////////////////////////////////////////////
@@ -265,13 +259,13 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
if (!tabstrip)
return gfx::Rect();
- int tabstrip_x = browser_view_->ShouldShowAvatar() ?
+ int tabstrip_x = browser_view()->ShouldShowAvatar() ?
(avatar_bounds_.right() + kAvatarSideSpacing) :
NonClientBorderThickness() + kTabStripIndent;
int maximized_spacing = kNewTabCaptionMaximizedSpacing;
int tabstrip_width = minimize_button_->x() - tabstrip_x -
- (frame_->IsMaximized() ?
+ (frame()->IsMaximized() ?
maximized_spacing : kNewTabCaptionRestoredSpacing);
return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
std::max(0, tabstrip_width), tabstrip->GetPreferredSize().height());
@@ -280,8 +274,8 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset(
bool restored) const {
return NonClientTopBorderHeight(restored) + ((!restored &&
- (frame_->IsMaximized() ||
- frame_->IsFullscreen())) ?
+ (frame()->IsMaximized() ||
+ frame()->IsFullscreen())) ?
0 : kNonClientRestoredExtraThickness);
}
@@ -291,12 +285,12 @@ void OpaqueBrowserFrameView::UpdateThrobber(bool running) {
}
gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
- gfx::Size min_size(browser_view_->GetMinimumSize());
+ gfx::Size min_size(browser_view()->GetMinimumSize());
int border_thickness = NonClientBorderThickness();
min_size.Enlarge(2 * border_thickness,
NonClientTopBorderHeight(false) + border_thickness);
- views::WidgetDelegate* delegate = frame_->widget_delegate();
+ views::WidgetDelegate* delegate = frame()->widget_delegate();
int min_titlebar_width = (2 * FrameBorderThickness(false)) +
kIconLeftSpacing +
(delegate && delegate->ShouldShowWindowIcon() ?
@@ -333,18 +327,18 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
return HTNOWHERE;
// See if the point is within the avatar menu button.
- if (avatar_button_.get() &&
- avatar_button_->GetMirroredBounds().Contains(point))
+ if (avatar_button() &&
+ avatar_button()->GetMirroredBounds().Contains(point))
return HTCLIENT;
- int frame_component = frame_->client_view()->NonClientHitTest(point);
+ int frame_component = frame()->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. We still have to check the tabstrip
// first so that clicks in a tab don't get treated as sysmenu clicks.
gfx::Rect sysmenu_rect(IconBounds());
// In maximized mode we extend the rect to the screen corner to take advantage
// of Fitts' Law.
- if (frame_->IsMaximized())
+ if (frame()->IsMaximized())
sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
if (sysmenu_rect.Contains(point))
@@ -367,7 +361,7 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
minimize_button_->GetMirroredBounds().Contains(point))
return HTMINBUTTON;
- views::WidgetDelegate* delegate = frame_->widget_delegate();
+ views::WidgetDelegate* delegate = frame()->widget_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL, returning safe default.";
return HTCAPTION;
@@ -383,7 +377,7 @@ void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
DCHECK(window_mask);
- if (frame_->IsMaximized() || frame_->IsFullscreen())
+ if (frame()->IsMaximized() || frame()->IsFullscreen())
return;
views::GetDefaultWindowMask(size, window_mask);
@@ -404,25 +398,21 @@ void OpaqueBrowserFrameView::UpdateWindowIcon() {
window_icon_->SchedulePaint();
}
-AvatarMenuButton* OpaqueBrowserFrameView::GetAvatarMenuButton() {
- return avatar_button_.get();
-}
-
///////////////////////////////////////////////////////////////////////////////
// OpaqueBrowserFrameView, views::View overrides:
void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
- if (frame_->IsFullscreen())
+ if (frame()->IsFullscreen())
return; // Nothing is visible, so don't bother to paint.
- if (frame_->IsMaximized())
+ if (frame()->IsMaximized())
PaintMaximizedFrameBorder(canvas);
else
PaintRestoredFrameBorder(canvas);
PaintTitleBar(canvas);
- if (browser_view_->IsToolbarVisible())
+ if (browser_view()->IsToolbarVisible())
PaintToolbarBackground(canvas);
- if (!frame_->IsMaximized())
+ if (!frame()->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -440,11 +430,11 @@ bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
return in_nonclient;
// Otherwise claim it only if it's in a non-tab portion of the tabstrip.
- if (!browser_view_->tabstrip())
+ if (!browser_view()->tabstrip())
return false;
- gfx::Rect tabstrip_bounds(browser_view_->tabstrip()->bounds());
+ gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
gfx::Point tabstrip_origin(tabstrip_bounds.origin());
- View::ConvertPointToView(frame_->client_view(), this, &tabstrip_origin);
+ View::ConvertPointToView(frame()->client_view(), this, &tabstrip_origin);
tabstrip_bounds.set_origin(tabstrip_origin);
if (l.y() > tabstrip_bounds.bottom())
return false;
@@ -453,8 +443,8 @@ bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
// completely. We need to do this since we're not a parent of the tabstrip,
// meaning ConvertPointToView would otherwise return something bogus.
gfx::Point browser_view_point(l);
- View::ConvertPointToView(parent(), browser_view_, &browser_view_point);
- return browser_view_->IsPositionInWindowCaption(browser_view_point);
+ View::ConvertPointToView(parent(), browser_view(), &browser_view_point);
+ return browser_view()->IsPositionInWindowCaption(browser_view_point);
}
void OpaqueBrowserFrameView::GetAccessibleState(
@@ -468,13 +458,13 @@ void OpaqueBrowserFrameView::GetAccessibleState(
void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == minimize_button_)
- frame_->Minimize();
+ frame()->Minimize();
else if (sender == maximize_button_)
- frame_->Maximize();
+ frame()->Maximize();
else if (sender == restore_button_)
- frame_->Restore();
+ frame()->Restore();
else if (sender == close_button_)
- frame_->Close();
+ frame()->Close();
}
///////////////////////////////////////////////////////////////////////////////
@@ -484,12 +474,12 @@ 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.
- TabContents* current_tab = browser_view_->GetSelectedTabContents();
+ TabContents* current_tab = browser_view()->GetSelectedTabContents();
return current_tab ? current_tab->IsLoading() : false;
}
SkBitmap OpaqueBrowserFrameView::GetFaviconForTabIconView() {
- views::WidgetDelegate* delegate = frame_->widget_delegate();
+ views::WidgetDelegate* delegate = frame()->widget_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL, returning safe default.";
return SkBitmap();
@@ -518,7 +508,7 @@ void OpaqueBrowserFrameView::Observe(
// OpaqueBrowserFrameView, private:
int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const {
- return (!restored && (frame_->IsMaximized() || frame_->IsFullscreen())) ?
+ return (!restored && (frame()->IsMaximized() || frame()->IsFullscreen())) ?
0 : kFrameBorderThickness;
}
@@ -529,7 +519,7 @@ int OpaqueBrowserFrameView::TopResizeHeight() const {
int OpaqueBrowserFrameView::NonClientBorderThickness() const {
// When we fill the screen, we don't show a client edge.
return FrameBorderThickness(false) +
- ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ ((frame()->IsMaximized() || frame()->IsFullscreen()) ?
0 : kClientEdgeThickness);
}
@@ -540,13 +530,13 @@ void OpaqueBrowserFrameView::ModifyMaximizedFramePainting(
int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const {
// Maximized buttons start at window top so that even if their images aren't
// drawn flush with the screen edge, they still obey Fitts' Law.
- return (!restored && frame_->IsMaximized()) ?
+ return (!restored && frame()->IsMaximized()) ?
FrameBorderThickness(false) : kFrameShadowThickness;
}
int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const {
return kTitlebarTopAndBottomEdgeThickness +
- ((!restored && frame_->IsMaximized()) ? 0 : kClientEdgeThickness);
+ ((!restored && frame()->IsMaximized()) ? 0 : kClientEdgeThickness);
}
int OpaqueBrowserFrameView::IconSize() const {
@@ -563,7 +553,7 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
int size = IconSize();
int frame_thickness = FrameBorderThickness(false);
int y;
- views::WidgetDelegate* delegate = frame_->widget_delegate();
+ views::WidgetDelegate* delegate = frame()->widget_delegate();
if (delegate && (delegate->ShouldShowWindowIcon() ||
delegate->ShouldShowWindowTitle())) {
// Our frame border has a different "3D look" than Windows'. Theirs has a
@@ -574,7 +564,7 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
// with restored windows, so when the window is restored, instead of
// calculating the remaining space from below the frame border, we calculate
// from below the 3D edge.
- int unavailable_px_at_top = frame_->IsMaximized() ?
+ int unavailable_px_at_top = frame()->IsMaximized() ?
frame_thickness : kTitlebarTopAndBottomEdgeThickness;
// When the icon is shorter than the minimum space we reserve for the
// caption button, we vertically center it. We want to bias rounding to put
@@ -622,9 +612,9 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
// areas not covered by the theme image.
SkBitmap* theme_frame = GetFrameBitmap();
int top_area_height = theme_frame->height();
- if (browser_view_->IsTabStripVisible()) {
+ if (browser_view()->IsTabStripVisible()) {
top_area_height = std::max(top_area_height,
- GetBoundsForTabStrip(browser_view_->tabstrip()).bottom());
+ GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
}
SkColor frame_color = GetFrameColor();
canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height));
@@ -654,8 +644,8 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
// Draw the theme frame overlay.
if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
- browser_view_->IsBrowserTypeNormal() &&
- !browser_view_->IsOffTheRecord()) {
+ browser_view()->IsBrowserTypeNormal() &&
+ !browser_view()->IsOffTheRecord()) {
canvas->DrawBitmapInt(*tp->GetBitmapNamed(ShouldPaintAsActive() ?
IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE), 0, 0);
}
@@ -714,7 +704,7 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
SkBitmap* theme_frame = GetFrameBitmap();
int theme_frame_bottom = top_offset + theme_frame->height();
int top_area_height =
- GetBoundsForTabStrip(browser_view_->tabstrip()).bottom();
+ GetBoundsForTabStrip(browser_view()->tabstrip()).bottom();
if (top_area_height > theme_frame_bottom) {
SkColor frame_color = GetFrameColor();
canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height));
@@ -743,14 +733,14 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
theme_frame->height());
// Draw the theme frame overlay
if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
- browser_view_->IsBrowserTypeNormal() &&
- !browser_view_->IsOffTheRecord()) {
+ browser_view()->IsBrowserTypeNormal() &&
+ !browser_view()->IsOffTheRecord()) {
SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ?
IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
canvas->DrawBitmapInt(*theme_overlay, 0, theme_background_y);
}
- if (!browser_view_->IsToolbarVisible()) {
+ if (!browser_view()->IsToolbarVisible()) {
// There's no toolbar to edge the frame border, so we need to draw a bottom
// edge. The graphic we use for this has a built in client edge, so we clip
// it off the bottom.
@@ -758,13 +748,13 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
tp->GetBitmapNamed(IDR_APP_TOP_CENTER);
int edge_height = top_center->height() - kClientEdgeThickness;
canvas->TileImageInt(*top_center, 0,
- frame_->client_view()->y() - edge_height, width(), edge_height);
+ frame()->client_view()->y() - edge_height, width(), edge_height);
}
}
void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
// The window icon is painted by the TabIconView.
- views::WidgetDelegate* delegate = frame_->widget_delegate();
+ views::WidgetDelegate* delegate = frame()->widget_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL";
return;
@@ -784,11 +774,11 @@ void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
}
void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
- gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
+ gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
if (toolbar_bounds.IsEmpty())
return;
gfx::Point toolbar_origin(toolbar_bounds.origin());
- ConvertPointToView(browser_view_, this, &toolbar_origin);
+ ConvertPointToView(browser_view(), this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
int x = toolbar_bounds.x();
@@ -889,22 +879,22 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
ui::ThemeProvider* tp = GetThemeProvider();
- int client_area_top = frame_->client_view()->y();
+ int client_area_top = frame()->client_view()->y();
int image_top = client_area_top;
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR);
- if (browser_view_->IsToolbarVisible()) {
+ if (browser_view()->IsToolbarVisible()) {
// The client edge images always start below the toolbar corner images. The
// client edge filled rects start there or at the bottom of the toolbar,
// whichever is shorter.
- gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
+ gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
image_top += toolbar_bounds.y() +
tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
client_area_top = std::min(image_top,
client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness);
- } else if (!browser_view_->IsTabStripVisible()) {
+ } else if (!browser_view()->IsTabStripVisible()) {
// The toolbar isn't going to draw a client edge for us, so draw one
// ourselves.
SkBitmap* top_left = tp->GetBitmapNamed(IDR_APP_TOP_LEFT);
@@ -977,9 +967,9 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
}
SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const {
- bool is_incognito = browser_view_->IsOffTheRecord();
+ bool is_incognito = browser_view()->IsOffTheRecord();
int resource_id;
- if (browser_view_->IsBrowserTypeNormal()) {
+ if (browser_view()->IsBrowserTypeNormal()) {
if (ShouldPaintAsActive()) {
resource_id = is_incognito ?
IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
@@ -1002,8 +992,8 @@ SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const {
}
SkColor OpaqueBrowserFrameView::GetFrameColor() const {
- bool is_incognito = browser_view_->IsOffTheRecord();
- if (browser_view_->IsBrowserTypeNormal()) {
+ bool is_incognito = browser_view()->IsOffTheRecord();
+ if (browser_view()->IsBrowserTypeNormal()) {
if (ShouldPaintAsActive()) {
return GetThemeProvider()->GetColor(is_incognito ?
ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME);
@@ -1023,7 +1013,7 @@ SkColor OpaqueBrowserFrameView::GetFrameColor() const {
}
void OpaqueBrowserFrameView::LayoutWindowControls() {
- bool is_maximized = frame_->IsMaximized();
+ bool is_maximized = frame()->IsMaximized();
close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
views::ImageButton::ALIGN_BOTTOM);
int caption_y = CaptionButtonY(false);
@@ -1047,12 +1037,12 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
// as maximized mode.
// TODO(oshima): Optimize the relayout logic to defer the frame view's
// relayout until it is necessary, i.e when it becomes visible.
- if (is_maximized || frame_->IsFullscreen()) {
+ if (is_maximized || frame()->IsFullscreen()) {
minimize_button_->SetVisible(false);
restore_button_->SetVisible(false);
maximize_button_->SetVisible(false);
- if (browser_view_->browser()->is_devtools()) {
+ if (browser_view()->browser()->is_devtools()) {
close_button_->SetVisible(true);
minimize_button_->SetBounds(close_button_->bounds().x(), 0, 0, 0);
} else {
@@ -1073,7 +1063,7 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
// When the window is restored, we show a maximized button; otherwise, we show
// a restore button.
- bool is_restored = !is_maximized && !frame_->IsMinimized();
+ bool is_restored = !is_maximized && !frame()->IsMinimized();
views::ImageButton* invisible_button = is_restored ?
restore_button_ : maximize_button_;
invisible_button->SetVisible(false);
@@ -1106,7 +1096,7 @@ void OpaqueBrowserFrameView::LayoutTitleBar() {
// The window title is based on the calculated icon position, even when there
// is no icon.
gfx::Rect icon_bounds(IconBounds());
- views::WidgetDelegate* delegate = frame_->widget_delegate();
+ views::WidgetDelegate* delegate = frame()->widget_delegate();
if (delegate && delegate->ShouldShowWindowIcon())
window_icon_->SetBoundsRect(icon_bounds);
@@ -1131,20 +1121,20 @@ void OpaqueBrowserFrameView::LayoutAvatar() {
// Even though the avatar is used for both incognito and profiles we always
// use the incognito icon to layout the avatar button. The profile icon
// can be customized so we can't depend on its size to perform layout.
- SkBitmap incognito_icon = browser_view_->GetOTRAvatarIcon();
+ SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon();
int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) +
- browser_view_->GetTabStripHeight() - kAvatarBottomSpacing;
+ browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
int avatar_restored_y = avatar_bottom - incognito_icon.height();
- int avatar_y = frame_->IsMaximized() ?
+ int avatar_y = frame()->IsMaximized() ?
(NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) :
avatar_restored_y;
avatar_bounds_.SetRect(NonClientBorderThickness() + kAvatarSideSpacing,
avatar_y, incognito_icon.width(),
- browser_view_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
+ browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
- if (avatar_button_.get())
- avatar_button_->SetBoundsRect(avatar_bounds_);
+ if (avatar_button())
+ avatar_button()->SetBoundsRect(avatar_bounds_);
}
gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
@@ -1156,34 +1146,3 @@ gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
std::max(0, height - GetReservedHeight() -
top_height - border_thickness));
}
-
-void OpaqueBrowserFrameView::UpdateAvatarInfo() {
- if (browser_view_->ShouldShowAvatar()) {
- if (!avatar_button_.get()) {
- avatar_button_.reset(new AvatarMenuButton(
- browser_view_->browser(), !browser_view_->IsOffTheRecord()));
- AddChildView(avatar_button_.get());
- frame_->GetRootView()->Layout();
- }
- } else if (avatar_button_.get()) {
- RemoveChildView(avatar_button_.get());
- avatar_button_.reset();
- frame_->GetRootView()->Layout();
- }
-
- if (!avatar_button_.get())
- return;
-
- if (browser_view_->IsOffTheRecord()) {
- avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon());
- } else {
- ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- Profile* profile = browser_view_->browser()->profile();
- size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
- if (index != std::string::npos) {
- avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index));
- avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index));
- }
- }
-}
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
index c6a2b1e..1795f91 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
@@ -41,7 +41,6 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
virtual gfx::Size GetMinimumSize() OVERRIDE;
protected:
- BrowserView* browser_view() const { return browser_view_; }
views::ImageButton* minimize_button() const { return minimize_button_; }
views::ImageButton* maximize_button() const { return maximize_button_; }
views::ImageButton* restore_button() const { return restore_button_; }
@@ -67,10 +66,6 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
SkBitmap** left_corner,
SkBitmap** right_corner);
- // Expose these to subclasses.
- BrowserFrame* frame() { return frame_; }
- BrowserView* browser_view() { return browser_view_; }
-
// Overridden from views::NonClientFrameView:
virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
virtual gfx::Rect GetWindowBoundsForClientBounds(
@@ -81,7 +76,6 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
virtual void EnableClose(bool enable) OVERRIDE;
virtual void ResetWindowControls() OVERRIDE;
virtual void UpdateWindowIcon() OVERRIDE;
- virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE;
// Overridden from views::View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
@@ -156,9 +150,6 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// Returns the bounds of the client area for the specified view size.
gfx::Rect CalculateClientAreaBounds(int width, int height) const;
- // Updates the title and icon of the avatar button.
- void UpdateAvatarInfo();
-
// The layout rect of the title, if visible.
gfx::Rect title_bounds_;
@@ -174,19 +165,9 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// The Window icon.
TabIconView* window_icon_;
- // The frame that hosts this view.
- BrowserFrame* frame_;
-
- // The BrowserView hosted within this View.
- BrowserView* browser_view_;
-
// The bounds of the ClientView.
gfx::Rect client_view_bounds_;
- // Menu button that displays that either the incognito icon or the profile
- // icon.
- scoped_ptr<AvatarMenuButton> avatar_button_;
-
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameView);
diff --git a/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc b/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc
index b9764a5..2e816c4 100644
--- a/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc
+++ b/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc
@@ -13,7 +13,8 @@
#include "views/window/hit_test.h"
#endif
-PopupNonClientFrameView::PopupNonClientFrameView(BrowserFrame* frame) {
+PopupNonClientFrameView::PopupNonClientFrameView(BrowserFrame* frame)
+ : BrowserNonClientFrameView(frame, NULL) {
frame->set_frame_type(views::Widget::FRAME_TYPE_FORCE_NATIVE);
}
@@ -55,7 +56,3 @@ int PopupNonClientFrameView::GetHorizontalTabStripVerticalOffset(
void PopupNonClientFrameView::UpdateThrobber(bool running) {
}
-
-AvatarMenuButton* PopupNonClientFrameView::GetAvatarMenuButton() {
- return NULL;
-}
diff --git a/chrome/browser/ui/views/frame/popup_non_client_frame_view.h b/chrome/browser/ui/views/frame/popup_non_client_frame_view.h
index 9f89915..d15cd9b 100644
--- a/chrome/browser/ui/views/frame/popup_non_client_frame_view.h
+++ b/chrome/browser/ui/views/frame/popup_non_client_frame_view.h
@@ -30,7 +30,6 @@ class PopupNonClientFrameView : public BrowserNonClientFrameView {
virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE;
virtual void UpdateThrobber(bool running) OVERRIDE;
- virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(PopupNonClientFrameView);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index e93b349..bc7b783 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3428,6 +3428,7 @@
'browser/ui/views/frame/browser_frame_views.h',
'browser/ui/views/frame/browser_frame_win.cc',
'browser/ui/views/frame/browser_frame_win.h',
+ 'browser/ui/views/frame/browser_non_client_frame_view.cc',
'browser/ui/views/frame/browser_non_client_frame_view.h',
'browser/ui/views/frame/browser_non_client_frame_view_aura.h',
'browser/ui/views/frame/browser_non_client_frame_view_aura.cc',
@@ -4765,6 +4766,8 @@
['include', '^browser/ui/views/frame/browser_frame_gtk.h'],
['include', '^browser/ui/views/frame/browser_frame_views.cc'],
['include', '^browser/ui/views/frame/browser_frame_views.h'],
+ ['include', '^browser/ui/views/frame/browser_non_client_frame_view.cc'],
+ ['include', '^browser/ui/views/frame/browser_non_client_frame_view.h'],
['include', '^browser/ui/views/frame/browser_root_view.cc'],
['include', '^browser/ui/views/frame/browser_root_view.h'],
['include', '^browser/ui/views/frame/browser_view.cc'],