Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3248)

Unified Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc

Issue 668773002: [Win] The new profiles UI: now at an immersive mode near you (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: + curlies Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c23b7867adae80f592c4b48e0cca1c8779a2d0da 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;
+// How far the new avatar button is from the left of the minimize button.
msw 2014/10/21 19:54:37 nit: the comment should match the surrounding patt
noms (inactive) 2014/10/21 20:55:18 Done.
+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,13 @@ 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::ShowAvatarMenu(browser_view()->browser());
msw 2014/10/21 19:54:38 nit: use IDC_SHOW_AVATAR_MENU to match the abstrac
noms (inactive) 2014/10/21 20:55:18 Done.
+ else
+ NOTREACHED();
+
msw 2014/10/21 19:54:37 nit: remove blank line
noms (inactive) 2014/10/21 20:55:17 Done.
}
///////////////////////////////////////////////////////////////////////////////
@@ -487,8 +507,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 +566,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());
msw 2014/10/21 19:54:37 nit: do you want the preferred height or the actua
noms (inactive) 2014/10/21 20:55:17 The rest of the file uses preferred height, so I k
msw 2014/10/21 21:00:40 Acknowledged.
+}
+
bool BrowserNonClientFrameViewAsh::ShouldPaint() const {
if (!frame()->IsFullscreen())
return true;

Powered by Google App Engine
This is Rietveld 408576698