Index: chrome/browser/ui/views/frame/glass_browser_frame_view.cc |
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 b48229282765b0ff82e64f7cf9b384a32787626f..6d70928b8568557e507947dfcc89771807ddfbcc 100644 |
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc |
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc |
@@ -11,9 +11,11 @@ |
#include "chrome/app/chrome_dll_resource.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/profiles/profiles_state.h" |
#include "chrome/browser/themes/theme_properties.h" |
#include "chrome/browser/ui/views/avatar_menu_button.h" |
#include "chrome/browser/ui/views/frame/browser_view.h" |
+#include "chrome/browser/ui/views/new_avatar_button.h" |
#include "chrome/browser/ui/views/tabs/tab.h" |
#include "chrome/browser/ui/views/tabs/tab_strip.h" |
#include "chrome/browser/ui/views/toolbar_view.h" |
@@ -55,6 +57,8 @@ const int kAvatarBottomSpacing = 2; |
const int kAvatarLeftSpacing = 2; |
// Space between the right edge of the avatar and the tabstrip. |
const int kAvatarRightSpacing = -2; |
+// How far the new avatar button is from the left of the minimize button. |
+const int kNewAvatarButtonOffset = 5; |
// The content left/right images have a shadow built into them. |
const int kContentEdgeShadowThickness = 2; |
// The top 3 px of the tabstrip is shadow; in maximized mode we push this off |
@@ -85,7 +89,12 @@ GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, |
if (browser_view->ShouldShowWindowIcon()) |
InitThrobberIcons(); |
- UpdateAvatarInfo(); |
+ if (browser_view->IsRegularOrGuestSession() && |
+ profiles::IsNewProfileManagementEnabled()) |
+ UpdateNewStyleAvatarInfo(this, NewAvatarButton::GLASS_BUTTON); |
+ else |
+ UpdateAvatarInfo(); |
+ |
if (!browser_view->IsOffTheRecord()) { |
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
content::NotificationService::AllSources()); |
@@ -102,6 +111,12 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
views::View* tabstrip) const { |
int minimize_button_offset = |
std::min(frame()->GetMinimizeButtonOffset(), width()); |
+ |
+ // The new avatar button is optionally displayed to the left of the |
+ // minimize button. |
+ if (browser_view()->ShouldShowAvatar() && new_avatar_button()) |
+ minimize_button_offset -= new_avatar_button()->width(); |
+ |
int tabstrip_x = browser_view()->ShouldShowAvatar() ? |
(avatar_bounds_.right() + kAvatarRightSpacing) : |
NonClientBorderThickness() + kTabStripIndent; |
@@ -210,6 +225,10 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
if (avatar_button() && avatar_button()->GetMirroredBounds().Contains(point)) |
return HTCLIENT; |
+ if (new_avatar_button() && |
+ new_avatar_button()->GetMirroredBounds().Contains(point)) |
+ return HTCLIENT; |
+ |
int frame_component = frame()->client_view()->NonClientHitTest(point); |
// See if we're in the sysmenu region. We still have to check the tabstrip |
@@ -244,14 +263,32 @@ void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
} |
void GlassBrowserFrameView::Layout() { |
- LayoutAvatar(); |
+ if (browser_view()->ShouldShowAvatar()) { |
+ if (browser_view()->IsRegularOrGuestSession() && |
+ profiles::IsNewProfileManagementEnabled()) |
+ LayoutNewStyleAvatar(); |
+ else |
+ LayoutAvatar(); |
+ } |
+ |
LayoutClientView(); |
} |
bool GlassBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { |
- return (avatar_button() && |
- avatar_button()->GetMirroredBounds().Intersects(rect)) || |
- !frame()->client_view()->bounds().Intersects(rect); |
+ bool hit_avatar_button = avatar_button() && |
+ avatar_button()->GetMirroredBounds().Intersects(rect); |
+ bool hit_new_avatar_button = new_avatar_button() && |
+ new_avatar_button()->GetMirroredBounds().Intersects(rect); |
+ return hit_avatar_button || hit_new_avatar_button || |
+ !frame()->client_view()->bounds().Intersects(rect); |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+// GlassBrowserFrameView, views::ButtonListener overrides: |
+void GlassBrowserFrameView::ButtonPressed(views::Button* sender, |
+ const ui::Event& event) { |
+ if (sender == new_avatar_button()) |
+ ShowProfileChooserViewBubble(); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -403,6 +440,28 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
toolbar_color); |
} |
+void GlassBrowserFrameView::LayoutNewStyleAvatar() { |
+ if (!new_avatar_button()) |
+ return; |
+ |
+ gfx::Size label_size = new_avatar_button()->GetPreferredSize(); |
+ int button_size_with_offset = kNewAvatarButtonOffset + label_size.width(); |
+ |
+ int button_x = frame()->GetMinimizeButtonOffset() - |
+ kNewAvatarButtonOffset - label_size.width(); |
+ |
+ if (base::i18n::IsRTL()) |
+ button_x = width() - frame()->GetMinimizeButtonOffset() + |
+ kNewAvatarButtonOffset; |
+ |
+ int button_y = frame()->IsMaximized() ? NonClientTopBorderHeight(false) : 1; |
+ new_avatar_button()->SetBounds( |
+ button_x, |
+ button_y, |
+ label_size.width(), |
+ button_y + gfx::win::GetSystemMetricsInDIP(SM_CXMENUSIZE)); |
+} |
+ |
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 |
@@ -504,7 +563,11 @@ void GlassBrowserFrameView::Observe( |
const content::NotificationDetails& details) { |
switch (type) { |
case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
- UpdateAvatarInfo(); |
+ if (browser_view()->IsRegularOrGuestSession() && |
+ profiles::IsNewProfileManagementEnabled()) |
+ UpdateNewStyleAvatarInfo(this, NewAvatarButton::GLASS_BUTTON); |
+ else |
+ UpdateAvatarInfo(); |
break; |
default: |
NOTREACHED() << "Got a notification we didn't register for!"; |