Index: chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc |
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc |
index b3b5397212ec437833b338aaebf4965a63a2ccbe..c81f1f86e797c6bb39f03b37b127d1fb686dd079 100644 |
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc |
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc |
@@ -24,6 +24,7 @@ |
#include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
#include "chrome/browser/ui/views/tab_icon_view.h" |
#include "chrome/browser/ui/views/tabs/tab_strip.h" |
+#include "components/signin/core/common/profile_management_switches.h" |
#include "content/public/browser/web_contents.h" |
#include "grit/ash_resources.h" |
#include "grit/theme_resources.h" |
@@ -56,6 +57,8 @@ const int kAvatarBottomSpacing = 2; |
// There are 2 px on each side of the avatar (between the frame border and |
// it on the left, and between it and the tabstrip on the right). |
const int kAvatarSideSpacing = 2; |
+// Space between the new avatar button and the minimize button. |
+const int kNewAvatarButtonOffset = 5; |
// Space between left edge of window and tabstrip. |
const int kTabstripLeftSpacing = 0; |
// Space between right edge of tabstrip and maximize button. |
@@ -126,8 +129,12 @@ void BrowserNonClientFrameViewAsh::Init() { |
window_icon_->Update(); |
} |
- // Create incognito icon if necessary. |
- UpdateAvatarInfo(); |
+ if (browser_view()->IsRegularOrGuestSession() && |
+ switches::IsNewAvatarMenu()) { |
+ UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); |
+ } else { |
+ UpdateAvatarInfo(); |
+ } |
// HeaderPainter handles layout. |
if (UsePackagedAppHeaderStyle()) { |
@@ -238,12 +245,17 @@ int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { |
int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, |
caption_button_container_, point); |
- // See if the point is actually within the avatar menu button.d |
+ // See if the point is actually within either of the avatar menu buttons. |
if (hit_test == HTCAPTION && avatar_button() && |
ConvertedHitTest(this, avatar_button(), point)) { |
return HTCLIENT; |
} |
+ if (hit_test == HTCAPTION && new_avatar_button() && |
+ ConvertedHitTest(this, new_avatar_button(), point)) { |
+ return HTCLIENT; |
+ } |
+ |
// See if the point is actually within the web app back button. |
if (hit_test == HTCAPTION && web_app_back_button_ && |
ConvertedHitTest(this, web_app_back_button_, point)) { |
@@ -349,10 +361,13 @@ void BrowserNonClientFrameViewAsh::Layout() { |
painted_height = GetTopInset(); |
} |
header_painter_->SetHeaderHeightForPainting(painted_height); |
+ |
if (avatar_button()) { |
LayoutAvatar(); |
header_painter_->UpdateLeftViewXInset(avatar_button()->bounds().right()); |
} else { |
+ if (new_avatar_button()) |
+ LayoutNewStyleAvatar(); |
header_painter_->UpdateLeftViewXInset( |
ash::HeaderPainterUtil::GetDefaultLeftViewXInset()); |
} |
@@ -443,8 +458,12 @@ void BrowserNonClientFrameViewAsh::EnabledStateChangedForCommand(int id, |
void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender, |
const ui::Event& event) { |
- DCHECK_EQ(sender, web_app_back_button_); |
- chrome::ExecuteCommand(browser_view()->browser(), IDC_BACK); |
+ if (sender == web_app_back_button_) |
+ chrome::ExecuteCommand(browser_view()->browser(), IDC_BACK); |
+ else if (sender == new_avatar_button()) |
+ chrome::ExecuteCommand(browser_view()->browser(), IDC_SHOW_AVATAR_MENU); |
+ else |
+ NOTREACHED(); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -487,8 +506,12 @@ int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const { |
} |
int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const { |
- return caption_button_container_->GetPreferredSize().width() + |
- kTabstripRightSpacing; |
+ int tabstrip_width = kTabstripRightSpacing + |
+ caption_button_container_->GetPreferredSize().width(); |
+ |
+ return new_avatar_button() ? kNewAvatarButtonOffset + |
+ new_avatar_button()->GetPreferredSize().width() + tabstrip_width : |
+ tabstrip_width; |
} |
bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { |
@@ -542,6 +565,23 @@ void BrowserNonClientFrameViewAsh::LayoutAvatar() { |
avatar_button()->SetVisible(avatar_visible); |
} |
+void BrowserNonClientFrameViewAsh::LayoutNewStyleAvatar() { |
+ DCHECK(switches::IsNewAvatarMenu()); |
+ if (!new_avatar_button()) |
+ return; |
+ |
+ gfx::Size button_size = new_avatar_button()->GetPreferredSize(); |
+ int button_x = width() - |
+ caption_button_container_->GetPreferredSize().width() - |
+ kNewAvatarButtonOffset - button_size.width(); |
+ |
+ new_avatar_button()->SetBounds( |
+ button_x, |
+ 0, |
+ button_size.width(), |
+ caption_button_container_->GetPreferredSize().height()); |
+} |
+ |
bool BrowserNonClientFrameViewAsh::ShouldPaint() const { |
if (!frame()->IsFullscreen()) |
return true; |