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

Unified Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 869793004: Bring up the Fast User Switcher on Shift+Click on the new Avatar Button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to right click and port to Mac UI Created 5 years, 11 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/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 86f0e2a590bb1d60e19fe17f9ee938e53ce65e7b..08731c797f0becb2a87448ee0d52f2831134a897 100644
--- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
@@ -80,6 +80,11 @@ const int kLargeImageSide = 88;
const int kVerticalSpacing = 16;
+bool IsProfileChooser(profiles::BubbleViewMode mode) {
+ return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ||
+ mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER;
Roger Tawa OOO till Jul 10th 2015/01/29 23:00:35 Two more spaces.
anthonyvd 2015/01/30 15:02:20 Done.
+}
+
// Creates a GridLayout with a single column. This ensures that all the child
// views added get auto-expanded to fill the full width of the bubble.
views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) {
@@ -586,7 +591,7 @@ void ProfileChooserView::ResetView() {
void ProfileChooserView::Init() {
// If view mode is PROFILE_CHOOSER but there is an auth error, force
// ACCOUNT_MANAGEMENT mode.
- if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER &&
+ if (IsProfileChooser(view_mode_) &&
HasAuthError(browser_->profile()) &&
switches::IsEnableAccountConsistency() &&
avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()).
@@ -603,7 +608,7 @@ void ProfileChooserView::Init() {
void ProfileChooserView::OnAvatarMenuChanged(
AvatarMenu* avatar_menu) {
- if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ||
+ if (IsProfileChooser(view_mode_) ||
view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
// Refresh the view with the new menu. We can't just update the local copy
// as this may have been triggered by a sign out action, in which case
@@ -892,10 +897,9 @@ bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender,
return false;
}
-views::View* ProfileChooserView::CreateProfileChooserView(
+void ProfileChooserView::PopulateCompleteProfileChooserView(
+ views::GridLayout* layout,
AvatarMenu* avatar_menu) {
- views::View* view = new views::View();
- views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
// Separate items into active and alternatives.
Indexes other_profiles;
views::View* tutorial_view = NULL;
@@ -908,7 +912,7 @@ views::View* ProfileChooserView::CreateProfileChooserView(
option_buttons_view = CreateOptionsView(
item.signed_in && profiles::IsLockAvailable(browser_->profile()));
current_profile_view = CreateCurrentProfileView(item, false);
- if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
+ if (IsProfileChooser(view_mode_)) {
switch (tutorial_mode_) {
case profiles::TUTORIAL_MODE_NONE:
case profiles::TUTORIAL_MODE_WELCOME_UPGRADE:
@@ -948,7 +952,7 @@ views::View* ProfileChooserView::CreateProfileChooserView(
layout->StartRow(1, 0);
layout->AddView(current_profile_view);
- if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
+ if (!IsProfileChooser(view_mode_)) {
DCHECK(current_profile_accounts);
layout->StartRow(0, 0);
layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
@@ -963,10 +967,12 @@ views::View* ProfileChooserView::CreateProfileChooserView(
layout->AddView(CreateSupervisedUserDisclaimerView());
}
- if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
+ if (IsProfileChooser(view_mode_)) {
layout->StartRow(1, 0);
- if (switches::IsFastUserSwitching())
+ if (switches::IsFastUserSwitching() ||
+ view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) {
Roger Tawa OOO till Jul 10th 2015/01/29 23:00:35 Do we still need this view_mode_ check?
anthonyvd 2015/01/30 15:02:20 Done.
layout->AddView(CreateOtherProfilesView(other_profiles));
+ }
}
layout->StartRow(0, 0);
@@ -976,6 +982,33 @@ views::View* ProfileChooserView::CreateProfileChooserView(
layout->StartRow(0, 0);
layout->AddView(option_buttons_view);
}
+}
+
+void ProfileChooserView::PopulateMinimalProfileChooserView(
+ views::GridLayout* layout,
+ AvatarMenu* avatar_menu) {
+ Indexes other_profiles;
+ for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
+ const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
+ if (!item.active) {
+ other_profiles.push_back(i);
+ }
+ }
+
+ layout->StartRow(1, 0);
+ layout->AddView(CreateOtherProfilesView(other_profiles));
+}
+
+views::View* ProfileChooserView::CreateProfileChooserView(
+ AvatarMenu* avatar_menu) {
+ views::View* view = new views::View();
+ views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
+
+ if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) {
+ PopulateMinimalProfileChooserView(layout, avatar_menu);
+ } else {
+ PopulateCompleteProfileChooserView(layout, avatar_menu);
+ }
return view;
}
@@ -1163,7 +1196,7 @@ views::View* ProfileChooserView::CreateCurrentProfileView(
layout->StartRow(1, 0);
if (switches::IsEnableAccountConsistency()) {
base::string16 link_title = l10n_util::GetStringUTF16(
- view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ?
+ IsProfileChooser(view_mode_) ?
IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON :
IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON);
manage_accounts_link_ = CreateLink(link_title, this);

Powered by Google App Engine
This is Rietveld 408576698