OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" | 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 const int kFixedMenuWidth = 250; | 73 const int kFixedMenuWidth = 250; |
74 const int kButtonHeight = 32; | 74 const int kButtonHeight = 32; |
75 const int kFixedGaiaViewHeight = 440; | 75 const int kFixedGaiaViewHeight = 440; |
76 const int kFixedGaiaViewWidth = 360; | 76 const int kFixedGaiaViewWidth = 360; |
77 const int kFixedAccountRemovalViewWidth = 280; | 77 const int kFixedAccountRemovalViewWidth = 280; |
78 const int kFixedSwitchUserViewWidth = 320; | 78 const int kFixedSwitchUserViewWidth = 320; |
79 const int kLargeImageSide = 88; | 79 const int kLargeImageSide = 88; |
80 | 80 |
81 const int kVerticalSpacing = 16; | 81 const int kVerticalSpacing = 16; |
82 | 82 |
83 bool IsProfileChooser(profiles::BubbleViewMode mode) { | |
84 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | |
85 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | |
Roger Tawa OOO till Jul 10th
2015/01/26 20:30:40
Indent 85 only 4 spaces.
anthonyvd
2015/01/28 22:04:38
Done.
| |
86 } | |
87 | |
83 // Creates a GridLayout with a single column. This ensures that all the child | 88 // Creates a GridLayout with a single column. This ensures that all the child |
84 // views added get auto-expanded to fill the full width of the bubble. | 89 // views added get auto-expanded to fill the full width of the bubble. |
85 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { | 90 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
86 views::GridLayout* layout = new views::GridLayout(view); | 91 views::GridLayout* layout = new views::GridLayout(view); |
87 view->SetLayoutManager(layout); | 92 view->SetLayoutManager(layout); |
88 | 93 |
89 views::ColumnSet* columns = layout->AddColumnSet(0); | 94 views::ColumnSet* columns = layout->AddColumnSet(0); |
90 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 95 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
91 views::GridLayout::FIXED, width, width); | 96 views::GridLayout::FIXED, width, width); |
92 return layout; | 97 return layout; |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 tutorial_close_button_ = NULL; | 584 tutorial_close_button_ = NULL; |
580 tutorial_sync_settings_link_ = NULL; | 585 tutorial_sync_settings_link_ = NULL; |
581 tutorial_see_whats_new_button_ = NULL; | 586 tutorial_see_whats_new_button_ = NULL; |
582 tutorial_not_you_link_ = NULL; | 587 tutorial_not_you_link_ = NULL; |
583 tutorial_learn_more_link_ = NULL; | 588 tutorial_learn_more_link_ = NULL; |
584 } | 589 } |
585 | 590 |
586 void ProfileChooserView::Init() { | 591 void ProfileChooserView::Init() { |
587 // If view mode is PROFILE_CHOOSER but there is an auth error, force | 592 // If view mode is PROFILE_CHOOSER but there is an auth error, force |
588 // ACCOUNT_MANAGEMENT mode. | 593 // ACCOUNT_MANAGEMENT mode. |
589 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && | 594 if (IsProfileChooser(view_mode_) && |
590 HasAuthError(browser_->profile()) && | 595 HasAuthError(browser_->profile()) && |
591 switches::IsEnableAccountConsistency() && | 596 switches::IsEnableAccountConsistency() && |
592 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). | 597 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). |
593 signed_in) { | 598 signed_in) { |
594 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; | 599 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; |
595 } | 600 } |
596 | 601 |
597 // The arrow keys can be used to tab between items. | 602 // The arrow keys can be used to tab between items. |
598 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE)); | 603 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE)); |
599 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE)); | 604 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE)); |
600 | 605 |
601 ShowView(view_mode_, avatar_menu_.get()); | 606 ShowView(view_mode_, avatar_menu_.get()); |
602 } | 607 } |
603 | 608 |
604 void ProfileChooserView::OnAvatarMenuChanged( | 609 void ProfileChooserView::OnAvatarMenuChanged( |
605 AvatarMenu* avatar_menu) { | 610 AvatarMenu* avatar_menu) { |
606 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 611 if (IsProfileChooser(view_mode_) || |
607 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { | 612 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
608 // Refresh the view with the new menu. We can't just update the local copy | 613 // Refresh the view with the new menu. We can't just update the local copy |
609 // as this may have been triggered by a sign out action, in which case | 614 // as this may have been triggered by a sign out action, in which case |
610 // the view is being destroyed. | 615 // the view is being destroyed. |
611 ShowView(view_mode_, avatar_menu); | 616 ShowView(view_mode_, avatar_menu); |
612 } | 617 } |
613 } | 618 } |
614 | 619 |
615 void ProfileChooserView::OnRefreshTokenAvailable( | 620 void ProfileChooserView::OnRefreshTokenAvailable( |
616 const std::string& account_id) { | 621 const std::string& account_id) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 views::View* tutorial_view = NULL; | 906 views::View* tutorial_view = NULL; |
902 views::View* current_profile_view = NULL; | 907 views::View* current_profile_view = NULL; |
903 views::View* current_profile_accounts = NULL; | 908 views::View* current_profile_accounts = NULL; |
904 views::View* option_buttons_view = NULL; | 909 views::View* option_buttons_view = NULL; |
905 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 910 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
906 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 911 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
907 if (item.active) { | 912 if (item.active) { |
908 option_buttons_view = CreateOptionsView( | 913 option_buttons_view = CreateOptionsView( |
909 item.signed_in && profiles::IsLockAvailable(browser_->profile())); | 914 item.signed_in && profiles::IsLockAvailable(browser_->profile())); |
910 current_profile_view = CreateCurrentProfileView(item, false); | 915 current_profile_view = CreateCurrentProfileView(item, false); |
911 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { | 916 if (IsProfileChooser(view_mode_)) { |
912 switch (tutorial_mode_) { | 917 switch (tutorial_mode_) { |
913 case profiles::TUTORIAL_MODE_NONE: | 918 case profiles::TUTORIAL_MODE_NONE: |
914 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: | 919 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: |
915 tutorial_view = CreateWelcomeUpgradeTutorialViewIfNeeded( | 920 tutorial_view = CreateWelcomeUpgradeTutorialViewIfNeeded( |
916 tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE, | 921 tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE, |
917 item); | 922 item); |
918 break; | 923 break; |
919 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN: | 924 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN: |
920 tutorial_view = CreateSigninConfirmationView(); | 925 tutorial_view = CreateSigninConfirmationView(); |
921 break; | 926 break; |
(...skipping 19 matching lines...) Expand all Loading... | |
941 | 946 |
942 if (!current_profile_view) { | 947 if (!current_profile_view) { |
943 // Guest windows don't have an active profile. | 948 // Guest windows don't have an active profile. |
944 current_profile_view = CreateGuestProfileView(); | 949 current_profile_view = CreateGuestProfileView(); |
945 option_buttons_view = CreateOptionsView(false); | 950 option_buttons_view = CreateOptionsView(false); |
946 } | 951 } |
947 | 952 |
948 layout->StartRow(1, 0); | 953 layout->StartRow(1, 0); |
949 layout->AddView(current_profile_view); | 954 layout->AddView(current_profile_view); |
950 | 955 |
951 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { | 956 if (!IsProfileChooser(view_mode_)) { |
952 DCHECK(current_profile_accounts); | 957 DCHECK(current_profile_accounts); |
953 layout->StartRow(0, 0); | 958 layout->StartRow(0, 0); |
954 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 959 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
955 layout->StartRow(1, 0); | 960 layout->StartRow(1, 0); |
956 layout->AddView(current_profile_accounts); | 961 layout->AddView(current_profile_accounts); |
957 } | 962 } |
958 | 963 |
959 if (browser_->profile()->IsSupervised()) { | 964 if (browser_->profile()->IsSupervised()) { |
960 layout->StartRow(0, 0); | 965 layout->StartRow(0, 0); |
961 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 966 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
962 layout->StartRow(1, 0); | 967 layout->StartRow(1, 0); |
963 layout->AddView(CreateSupervisedUserDisclaimerView()); | 968 layout->AddView(CreateSupervisedUserDisclaimerView()); |
964 } | 969 } |
965 | 970 |
966 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { | 971 if (IsProfileChooser(view_mode_)) { |
967 layout->StartRow(1, 0); | 972 layout->StartRow(1, 0); |
968 if (switches::IsFastUserSwitching()) | 973 if (switches::IsFastUserSwitching() || |
974 view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) | |
969 layout->AddView(CreateOtherProfilesView(other_profiles)); | 975 layout->AddView(CreateOtherProfilesView(other_profiles)); |
Roger Tawa OOO till Jul 10th
2015/01/26 20:30:40
Add { and } to if body.
anthonyvd
2015/01/28 22:04:38
Done.
| |
970 } | 976 } |
971 | 977 |
972 layout->StartRow(0, 0); | 978 layout->StartRow(0, 0); |
973 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 979 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
974 | 980 |
975 if (option_buttons_view) { | 981 if (option_buttons_view) { |
976 layout->StartRow(0, 0); | 982 layout->StartRow(0, 0); |
977 layout->AddView(option_buttons_view); | 983 layout->AddView(option_buttons_view); |
978 } | 984 } |
979 | 985 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1156 layout->AddView(current_profile_name_); | 1162 layout->AddView(current_profile_name_); |
1157 | 1163 |
1158 if (is_guest) | 1164 if (is_guest) |
1159 return view; | 1165 return view; |
1160 | 1166 |
1161 // The available links depend on the type of profile that is active. | 1167 // The available links depend on the type of profile that is active. |
1162 if (avatar_item.signed_in) { | 1168 if (avatar_item.signed_in) { |
1163 layout->StartRow(1, 0); | 1169 layout->StartRow(1, 0); |
1164 if (switches::IsEnableAccountConsistency()) { | 1170 if (switches::IsEnableAccountConsistency()) { |
1165 base::string16 link_title = l10n_util::GetStringUTF16( | 1171 base::string16 link_title = l10n_util::GetStringUTF16( |
1166 view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ? | 1172 IsProfileChooser(view_mode_) ? |
1167 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : | 1173 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : |
1168 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | 1174 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); |
1169 manage_accounts_link_ = CreateLink(link_title, this); | 1175 manage_accounts_link_ = CreateLink(link_title, this); |
1170 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 1176 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
1171 layout->AddView(manage_accounts_link_); | 1177 layout->AddView(manage_accounts_link_); |
1172 } else { | 1178 } else { |
1173 // Badge the email address if there's an authentication error. | 1179 // Badge the email address if there's an authentication error. |
1174 if (HasAuthError(browser_->profile())) { | 1180 if (HasAuthError(browser_->profile())) { |
1175 const gfx::ImageSkia warning_image = *rb->GetImageNamed( | 1181 const gfx::ImageSkia warning_image = *rb->GetImageNamed( |
1176 IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR).ToImageSkia(); | 1182 IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR).ToImageSkia(); |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1668 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1674 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1669 IncognitoModePrefs::DISABLED; | 1675 IncognitoModePrefs::DISABLED; |
1670 return incognito_available && !browser_->profile()->IsGuestSession(); | 1676 return incognito_available && !browser_->profile()->IsGuestSession(); |
1671 } | 1677 } |
1672 | 1678 |
1673 void ProfileChooserView::PostActionPerformed( | 1679 void ProfileChooserView::PostActionPerformed( |
1674 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1680 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1675 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1681 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1676 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1682 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1677 } | 1683 } |
OLD | NEW |