Chromium Code Reviews| 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 faea78af5046460c3dc338fce761ccc99a3a04d7..091bd711accac550b9a9204688eeb45405a5a5dd 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(); |
| @@ -1088,7 +1102,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); |
| @@ -1111,7 +1126,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); |
| @@ -1495,21 +1510,57 @@ 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 item_icon; |
| + AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); |
| + gfx::Image image = profiles::GetSizedAvatarIcon( |
| + item_icon, true, kProfileIconSize, kProfileIconSize, true); |
|
Roger Tawa OOO till Jul 10th
2016/06/13 15:20:44
Instead of using true|false for last arg (the new
Jane
2016/06/13 17:53:42
Done.
|
| + 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()) { |
| + 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)); |
| @@ -1531,8 +1582,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), |
| @@ -1541,6 +1594,10 @@ 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); |
|
Roger Tawa OOO till Jul 10th
2016/06/13 15:20:44
Add { and } when the block of the if statement spa
Jane
2016/06/13 17:53:42
Done.
|
| return view; |
| } |