| Index: chrome/browser/ui/views/profiles/profile_chooser_view.cc
|
| diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
|
| index 6f262f9c51f78fc2fb90a8f49ff347d93027a0f0..51dfc3269fe24b34ea25eb6242c87e4f786e457f 100644
|
| --- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc
|
| +++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
|
| @@ -630,8 +630,11 @@ void ProfileChooserView::ShowBubble(
|
| // Don't start creating the view if it would be an empty fast user switcher.
|
| // It has to happen here to prevent the view system from creating an empty
|
| // container.
|
| + // Same for material design user menu since fast profile switcher will be
|
| + // migrated to the left-click menu.
|
| if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER &&
|
| - !profiles::HasProfileSwitchTargets(browser->profile())) {
|
| + (!profiles::HasProfileSwitchTargets(browser->profile()) ||
|
| + switches::IsMaterialDesignUserMenu())) {
|
| return;
|
| }
|
|
|
| @@ -698,6 +701,7 @@ void ProfileChooserView::ResetView() {
|
| auth_error_email_button_ = NULL;
|
| current_profile_photo_ = NULL;
|
| current_profile_name_ = NULL;
|
| + guest_profile_button_ = NULL;
|
| users_button_ = NULL;
|
| go_incognito_button_ = NULL;
|
| lock_button_ = NULL;
|
| @@ -902,7 +906,17 @@ bool ProfileChooserView::HandleContextMenu(
|
|
|
| void ProfileChooserView::ButtonPressed(views::Button* sender,
|
| const ui::Event& event) {
|
| - if (sender == users_button_) {
|
| + if (sender == guest_profile_button_) {
|
| + PrefService* service = g_browser_process->local_state();
|
| + DCHECK(service);
|
| + if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) {
|
| + profiles::SwitchToGuestProfile(ProfileManager::CreateCallback());
|
| + } else {
|
| + // The UI should have prevented the user from allowing the selection of
|
| + // guest mode.
|
| + NOTREACHED();
|
| + }
|
| + } else if (sender == users_button_) {
|
| // If this is a guest session, close all the guest browser windows.
|
| if (browser_->profile()->IsGuestSession()) {
|
| profiles::CloseGuestProfileWindows();
|
| @@ -1091,7 +1105,8 @@ void ProfileChooserView::PopulateCompleteProfileChooserView(
|
| const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
|
| if (item.active) {
|
| option_buttons_view = CreateOptionsView(
|
| - item.signed_in && profiles::IsLockAvailable(browser_->profile()));
|
| + item.signed_in && profiles::IsLockAvailable(browser_->profile()),
|
| + avatar_menu);
|
| current_profile_view = CreateCurrentProfileView(item, false);
|
| if (IsProfileChooser(view_mode_)) {
|
| tutorial_view = CreateTutorialViewIfNeeded(item);
|
| @@ -1114,7 +1129,7 @@ void ProfileChooserView::PopulateCompleteProfileChooserView(
|
| if (!current_profile_view) {
|
| // Guest windows don't have an active profile.
|
| current_profile_view = CreateGuestProfileView();
|
| - option_buttons_view = CreateOptionsView(false);
|
| + option_buttons_view = CreateOptionsView(false, avatar_menu);
|
| }
|
|
|
| layout->StartRow(1, 0);
|
| @@ -1498,21 +1513,60 @@ views::View* ProfileChooserView::CreateOtherProfilesView(
|
| return view;
|
| }
|
|
|
| -views::View* ProfileChooserView::CreateOptionsView(bool display_lock) {
|
| +views::View* ProfileChooserView::CreateOptionsView(
|
| + bool display_lock,
|
| + AvatarMenu* avatar_menu) {
|
| views::View* view = new views::View();
|
| views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
|
|
|
| + const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16;
|
| + if (switches::IsMaterialDesignUserMenu()) {
|
| + // Add the user switching buttons
|
| + const int kProfileIconSize = 18;
|
| + layout->StartRowWithPadding(1, 0, 0,
|
| + views::kRelatedControlVerticalSpacing);
|
| + for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
|
| + const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
|
| + if (!item.active) {
|
| + gfx::Image image = profiles::GetSizedAvatarIcon(
|
| + item.icon, true, kProfileIconSize, kProfileIconSize,
|
| + profiles::SHAPE_CIRCLE);
|
| + views::LabelButton* button = new BackgroundColorHoverButton(
|
| + this,
|
| + profiles::GetProfileSwitcherTextForItem(item),
|
| + *image.ToImageSkia());
|
| + open_other_profile_indexes_map_[button] = i;
|
| +
|
| + layout->StartRow(1, 0);
|
| + layout->AddView(button);
|
| + }
|
| + }
|
| +
|
| + // Add the "Guest" button for browsing as guest
|
| + if (!browser_->profile()->IsGuestSession()) {
|
| + PrefService* service = g_browser_process->local_state();
|
| + DCHECK(service);
|
| + if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) {
|
| + guest_profile_button_ = new BackgroundColorHoverButton(
|
| + this,
|
| + l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME),
|
| + gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE,
|
| + kIconSize, gfx::kChromeIconGrey));
|
| + layout->StartRow(1, 0);
|
| + layout->AddView(guest_profile_button_);
|
| + }
|
| + }
|
| + }
|
| +
|
| base::string16 text = browser_->profile()->IsGuestSession() ?
|
| l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) :
|
| l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON);
|
| + gfx::VectorIconId settings_icon = gfx::VectorIconId::ACCOUNT_BOX;
|
| if (!browser_->profile()->IsGuestSession()
|
| && switches::IsMaterialDesignUserMenu()) {
|
| text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON);
|
| + settings_icon = gfx::VectorIconId::SETTINGS;
|
| }
|
| - const int kIconSize = 16;
|
| -
|
| - gfx::VectorIconId settings_icon = switches::IsMaterialDesignUserMenu() ?
|
| - gfx::VectorIconId::SETTINGS : gfx::VectorIconId::ACCOUNT_BOX;
|
| users_button_ = new BackgroundColorHoverButton(
|
| this, text, gfx::CreateVectorIcon(settings_icon, kIconSize,
|
| gfx::kChromeIconGrey));
|
| @@ -1534,8 +1588,10 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock) {
|
| }
|
|
|
| if (display_lock) {
|
| - layout->StartRow(1, 0);
|
| - layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
|
| + if (!switches::IsMaterialDesignUserMenu()) {
|
| + layout->StartRow(1, 0);
|
| + layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
|
| + }
|
|
|
| lock_button_ = new BackgroundColorHoverButton(
|
| this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON),
|
| @@ -1544,6 +1600,11 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock) {
|
| layout->StartRow(1, 0);
|
| layout->AddView(lock_button_);
|
| }
|
| +
|
| + if (switches::IsMaterialDesignUserMenu()) {
|
| + layout->StartRowWithPadding(1, 0, 0,
|
| + views::kRelatedControlVerticalSpacing);
|
| + }
|
| return view;
|
| }
|
|
|
|
|