Commit 87ff53f5 authored by noms's avatar noms Committed by Commit bot

[Win] The new profiles UI: now at an immersive mode near you

This includes
- actually drawing the button correctly in Metro/Win 8 CrOS/immersive mode
- fixing chrome://settings to display the multiple users box in these cases

Screenshots (including rtl and non-english characters YAY):
https://drive.google.com/open?id=0B1B1Up4p2NRMWmdhcklhUUtQVU0&authuser=1

BUG=422434
TEST=Start Chrome with --enable-new-avatar-menu. From the hot-dog menu,
relaunch Chrome in immersive mode. Everything should look like it does
in normal mode (avatar button on the right, tabs don't overlap it,
users are listed and can be edited in chrome://settings)

Review URL: https://codereview.chromium.org/668773002

Cr-Commit-Position: refs/heads/master@{#300968}
parent b94b8fd3
......@@ -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;
......
......@@ -115,8 +115,9 @@ class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView,
// accoutrements.
bool UseWebAppHeaderStyle() const;
// Layout the incognito icon.
// Layout the avatar button.
void LayoutAvatar();
void LayoutNewStyleAvatar();
// Returns true if there is anything to paint. Some fullscreen windows do not
// need their frames painted.
......
......@@ -53,8 +53,6 @@ NewAvatarButton::NewAvatarButton(views::ButtonListener* listener,
SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE);
SetTextColor(views::Button::STATE_HOVERED, SK_ColorWHITE);
SetTextColor(views::Button::STATE_PRESSED, SK_ColorWHITE);
SetTextShadows(gfx::ShadowValues(10,
gfx::ShadowValue(gfx::Point(), 1.0f, SK_ColorDKGRAY)));
SetTextSubpixelRenderingEnabled(false);
SetHorizontalAlignment(gfx::ALIGN_CENTER);
......@@ -74,7 +72,8 @@ NewAvatarButton::NewAvatarButton(views::ButtonListener* listener,
generic_avatar_ =
*rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_AVATAR).ToImageSkia();
#if defined(OS_WIN)
} else if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
} else if (base::win::GetVersion() >= base::win::VERSION_WIN8 ||
browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) {
const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_METRO_BUTTON_NORMAL);
const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_METRO_BUTTON_HOVER);
const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_METRO_BUTTON_PRESSED);
......@@ -185,6 +184,12 @@ void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() {
SetText(use_generic_button ? base::string16() :
profiles::GetAvatarButtonTextForProfile(browser_->profile()));
// If the button has no text, clear the text shadows to make sure the
// image is centered correctly.
SetTextShadows(use_generic_button ? gfx::ShadowValues() : gfx::ShadowValues(
10, gfx::ShadowValue(gfx::Point(), 1.0f, SK_ColorDKGRAY)));
// We want the button to resize if the new text is shorter.
SetMinSize(gfx::Size());
......
......@@ -1039,8 +1039,6 @@ bool BrowserOptionsHandler::ShouldShowMultiProfilesUserList() {
// On Chrome OS we use different UI for multi-profiles.
return false;
#else
if (helper::GetDesktopType(web_ui()) != chrome::HOST_DESKTOP_TYPE_NATIVE)
return false;
Profile* profile = Profile::FromWebUI(web_ui());
if (profile->IsGuestSession())
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment