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 bc69baa1823503ce5ae077339d42ad34b3163eaf..82bd604754c325f3bf753aa0571cb3c03371bb0a 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/common/chrome_switches.h" |
@@ -54,6 +56,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 |
@@ -70,7 +74,6 @@ const int kNewTabCaptionMaximizedSpacing = 16; |
// How far to indent the tabstrip from the left side of the screen when there |
// is no avatar icon. |
const int kTabStripIndent = -6; |
- |
} // namespace |
/////////////////////////////////////////////////////////////////////////////// |
@@ -84,7 +87,13 @@ GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, |
if (browser_view->ShouldShowWindowIcon()) |
InitThrobberIcons(); |
- UpdateAvatarInfo(); |
+ bool is_incognito = browser_view->IsOffTheRecord() && |
+ !browser_view->IsGuestSession(); |
+ if (!is_incognito && profiles::IsNewProfileManagementEnabled()) |
+ UpdateNewStyleAvatarInfo(); |
+ else |
+ UpdateAvatarInfo(); |
+ |
if (!browser_view->IsOffTheRecord()) { |
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
content::NotificationService::AllSources()); |
@@ -101,6 +110,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; |
@@ -207,6 +222,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 |
@@ -242,14 +261,24 @@ void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
} |
void GlassBrowserFrameView::Layout() { |
- LayoutAvatar(); |
+ bool is_incognito = browser_view()->IsOffTheRecord() && |
+ !browser_view()->IsGuestSession(); |
+ |
+ if (!is_incognito && 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); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -397,6 +426,19 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
toolbar_color); |
} |
+void GlassBrowserFrameView::LayoutNewStyleAvatar() { |
+ gfx::Size label_size = new_avatar_button()->GetPreferredSize(); |
+ int x_position = frame()->GetMinimizeButtonOffset() - |
+ label_size.width() - kNewAvatarButtonOffset; |
+ |
+ int caption_y = frame()->IsMaximized() ? NonClientTopBorderHeight(false) : 1; |
+ new_avatar_button()->SetBounds( |
+ x_position, |
+ caption_y, |
+ label_size.width(), |
+ caption_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 |
@@ -496,9 +538,14 @@ void GlassBrowserFrameView::Observe( |
int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
+ bool is_incognito = browser_view()->IsOffTheRecord() && |
+ !browser_view()->IsGuestSession(); |
switch (type) { |
case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
- UpdateAvatarInfo(); |
+ if (!is_incognito && profiles::IsNewProfileManagementEnabled()) |
+ UpdateNewStyleAvatarInfo(); |
+ else |
+ UpdateAvatarInfo(); |
break; |
default: |
NOTREACHED() << "Got a notification we didn't register for!"; |