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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2151513002: Revamped signin/sync error surfacing on desktop user menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved a comment around Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/lifetime/application_lifetime.h" 11 #include "chrome/browser/lifetime/application_lifetime.h"
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" 12 #include "chrome/browser/prefs/incognito_mode_prefs.h"
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 13 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/profiles/profile_metrics.h" 15 #include "chrome/browser/profiles/profile_metrics.h"
16 #include "chrome/browser/profiles/profile_window.h" 16 #include "chrome/browser/profiles/profile_window.h"
17 #include "chrome/browser/profiles/profiles_state.h" 17 #include "chrome/browser/profiles/profiles_state.h"
18 #include "chrome/browser/signin/chrome_signin_helper.h" 18 #include "chrome/browser/signin/chrome_signin_helper.h"
19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
20 #include "chrome/browser/signin/signin_error_controller_factory.h" 20 #include "chrome/browser/signin/signin_error_controller_factory.h"
21 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
22 #include "chrome/browser/signin/signin_promo.h" 22 #include "chrome/browser/signin/signin_promo.h"
23 #include "chrome/browser/signin/signin_ui_util.h" 23 #include "chrome/browser/signin/signin_ui_util.h"
24 #include "chrome/browser/sync/profile_sync_service_factory.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_commands.h" 26 #include "chrome/browser/ui/browser_commands.h"
26 #include "chrome/browser/ui/browser_dialogs.h" 27 #include "chrome/browser/ui/browser_dialogs.h"
27 #include "chrome/browser/ui/browser_list.h" 28 #include "chrome/browser/ui/browser_list.h"
28 #include "chrome/browser/ui/chrome_pages.h" 29 #include "chrome/browser/ui/chrome_pages.h"
29 #include "chrome/browser/ui/singleton_tabs.h" 30 #include "chrome/browser/ui/singleton_tabs.h"
30 #include "chrome/browser/ui/user_manager.h" 31 #include "chrome/browser/ui/user_manager.h"
31 #include "chrome/browser/ui/views/profiles/signin_view_controller_delegate_views .h" 32 #include "chrome/browser/ui/views/profiles/signin_view_controller_delegate_views .h"
32 #include "chrome/browser/ui/views/profiles/user_manager_view.h" 33 #include "chrome/browser/ui/views/profiles/user_manager_view.h"
33 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 34 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
34 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 35 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
35 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
36 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
37 #include "chrome/grit/chromium_strings.h" 38 #include "chrome/grit/chromium_strings.h"
38 #include "chrome/grit/generated_resources.h" 39 #include "chrome/grit/generated_resources.h"
40 #include "components/browser_sync/browser/profile_sync_service.h"
39 #include "components/prefs/pref_service.h" 41 #include "components/prefs/pref_service.h"
40 #include "components/signin/core/browser/profile_oauth2_token_service.h" 42 #include "components/signin/core/browser/profile_oauth2_token_service.h"
41 #include "components/signin/core/browser/signin_error_controller.h" 43 #include "components/signin/core/browser/signin_error_controller.h"
42 #include "components/signin/core/browser/signin_header_helper.h" 44 #include "components/signin/core/browser/signin_header_helper.h"
43 #include "components/signin/core/browser/signin_manager.h" 45 #include "components/signin/core/browser/signin_manager.h"
44 #include "components/signin/core/common/profile_management_switches.h" 46 #include "components/signin/core/common/profile_management_switches.h"
47 #include "components/sync_driver/sync_error_controller.h"
45 #include "content/public/browser/render_widget_host_view.h" 48 #include "content/public/browser/render_widget_host_view.h"
46 #include "content/public/browser/user_metrics.h" 49 #include "content/public/browser/user_metrics.h"
47 #include "grit/theme_resources.h" 50 #include "grit/theme_resources.h"
48 #include "third_party/skia/include/core/SkColor.h" 51 #include "third_party/skia/include/core/SkColor.h"
49 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
50 #include "ui/base/material_design/material_design_controller.h" 53 #include "ui/base/material_design/material_design_controller.h"
51 #include "ui/base/resource/resource_bundle.h" 54 #include "ui/base/resource/resource_bundle.h"
52 #include "ui/compositor/clip_recorder.h" 55 #include "ui/compositor/clip_recorder.h"
53 #include "ui/compositor/paint_recorder.h" 56 #include "ui/compositor/paint_recorder.h"
54 #include "ui/gfx/canvas.h" 57 #include "ui/gfx/canvas.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 ProfileOAuth2TokenService* oauth2_token_service = 760 ProfileOAuth2TokenService* oauth2_token_service =
758 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); 761 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile());
759 if (oauth2_token_service) 762 if (oauth2_token_service)
760 oauth2_token_service->RemoveObserver(this); 763 oauth2_token_service->RemoveObserver(this);
761 } 764 }
762 765
763 void ProfileChooserView::ResetView() { 766 void ProfileChooserView::ResetView() {
764 open_other_profile_indexes_map_.clear(); 767 open_other_profile_indexes_map_.clear();
765 delete_account_button_map_.clear(); 768 delete_account_button_map_.clear();
766 reauth_account_button_map_.clear(); 769 reauth_account_button_map_.clear();
770 tutorial_sync_settings_ok_button_ = nullptr;
771 tutorial_close_button_ = nullptr;
772 tutorial_sync_settings_link_ = nullptr;
773 tutorial_see_whats_new_button_ = nullptr;
774 tutorial_not_you_link_ = nullptr;
775 tutorial_learn_more_link_ = nullptr;
776 sync_error_signin_button_ = nullptr;
777 sync_error_passphrase_button_ = nullptr;
778 sync_error_upgrade_button_ = nullptr;
779 sync_error_signin_again_button_ = nullptr;
780 sync_error_signout_button_ = nullptr;
767 manage_accounts_link_ = nullptr; 781 manage_accounts_link_ = nullptr;
768 manage_accounts_button_ = nullptr; 782 manage_accounts_button_ = nullptr;
769 signin_current_profile_button_ = nullptr; 783 signin_current_profile_button_ = nullptr;
770 auth_error_email_button_ = nullptr; 784 auth_error_email_button_ = nullptr;
771 current_profile_photo_ = nullptr; 785 current_profile_photo_ = nullptr;
772 current_profile_name_ = nullptr; 786 current_profile_name_ = nullptr;
773 current_profile_card_ = nullptr; 787 current_profile_card_ = nullptr;
774 guest_profile_button_ = nullptr; 788 guest_profile_button_ = nullptr;
775 users_button_ = nullptr; 789 users_button_ = nullptr;
776 go_incognito_button_ = nullptr; 790 go_incognito_button_ = nullptr;
777 lock_button_ = nullptr; 791 lock_button_ = nullptr;
778 close_all_windows_button_ = nullptr; 792 close_all_windows_button_ = nullptr;
779 add_account_link_ = nullptr; 793 add_account_link_ = nullptr;
780 gaia_signin_cancel_button_ = nullptr; 794 gaia_signin_cancel_button_ = nullptr;
781 remove_account_button_ = nullptr; 795 remove_account_button_ = nullptr;
782 account_removal_cancel_button_ = nullptr; 796 account_removal_cancel_button_ = nullptr;
783 add_person_button_ = nullptr; 797 add_person_button_ = nullptr;
784 disconnect_button_ = nullptr; 798 disconnect_button_ = nullptr;
785 switch_user_cancel_button_ = nullptr; 799 switch_user_cancel_button_ = nullptr;
786 tutorial_sync_settings_ok_button_ = nullptr;
787 tutorial_close_button_ = nullptr;
788 tutorial_sync_settings_link_ = nullptr;
789 tutorial_see_whats_new_button_ = nullptr;
790 tutorial_not_you_link_ = nullptr;
791 tutorial_learn_more_link_ = nullptr;
792 } 800 }
793 801
794 void ProfileChooserView::Init() { 802 void ProfileChooserView::Init() {
795 set_close_on_deactivate(close_on_deactivate_for_testing_); 803 set_close_on_deactivate(close_on_deactivate_for_testing_);
796 804
797 avatar_menu_.reset(new AvatarMenu( 805 avatar_menu_.reset(new AvatarMenu(
798 &g_browser_process->profile_manager()->GetProfileAttributesStorage(), 806 &g_browser_process->profile_manager()->GetProfileAttributesStorage(),
799 this, browser_)); 807 this, browser_));
800 avatar_menu_->RebuildMenu(); 808 avatar_menu_->RebuildMenu();
801 809
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 } 874 }
867 875
868 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, 876 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display,
869 AvatarMenu* avatar_menu) { 877 AvatarMenu* avatar_menu) {
870 // The account management view should only be displayed if the active profile 878 // The account management view should only be displayed if the active profile
871 // is signed in. 879 // is signed in.
872 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { 880 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
873 DCHECK(switches::IsEnableAccountConsistency()); 881 DCHECK(switches::IsEnableAccountConsistency());
874 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( 882 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt(
875 avatar_menu->GetActiveProfileIndex()); 883 avatar_menu->GetActiveProfileIndex());
876 DCHECK(active_item.signed_in); 884 if (!active_item.signed_in) {
885 // This is the case when the user selects the sign out option in the user
886 // menu upon encountering unrecoverable errors. Afterwards, the profile
887 // chooser view is shown instead of the account management view.
888 view_to_display = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
889 }
877 } 890 }
878 891
879 if (browser_->profile()->IsSupervised() && 892 if (browser_->profile()->IsSupervised() &&
880 (view_to_display == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || 893 (view_to_display == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
881 view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL)) { 894 view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL)) {
882 LOG(WARNING) << "Supervised user attempted to add/remove account"; 895 LOG(WARNING) << "Supervised user attempted to add/remove account";
883 return; 896 return;
884 } 897 }
885 898
886 ResetView(); 899 ResetView();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); 1007 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER);
995 } else if (sender == go_incognito_button_) { 1008 } else if (sender == go_incognito_button_) {
996 DCHECK(ShouldShowGoIncognito()); 1009 DCHECK(ShouldShowGoIncognito());
997 chrome::NewIncognitoWindow(browser_); 1010 chrome::NewIncognitoWindow(browser_);
998 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); 1011 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO);
999 } else if (sender == lock_button_) { 1012 } else if (sender == lock_button_) {
1000 profiles::LockProfile(browser_->profile()); 1013 profiles::LockProfile(browser_->profile());
1001 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); 1014 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK);
1002 } else if (sender == close_all_windows_button_) { 1015 } else if (sender == close_all_windows_button_) {
1003 profiles::CloseProfileWindows(browser_->profile()); 1016 profiles::CloseProfileWindows(browser_->profile());
1004 } else if (sender == auth_error_email_button_) { 1017 } else if (sender == auth_error_email_button_ ||
1018 sender == sync_error_signin_button_) {
1005 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); 1019 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH);
1020 } else if (sender == sync_error_passphrase_button_) {
1021 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage);
1022 } else if (sender == sync_error_upgrade_button_) {
1023 chrome::OpenUpdateChromeDialog(browser_);
1024 } else if (sender == sync_error_signin_again_button_) {
1025 if (ProfileSyncServiceFactory::GetForProfile(browser_->profile()))
1026 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
1027 SigninManagerFactory::GetForProfile(browser_->profile())
1028 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS,
1029 signin_metrics::SignoutDelete::IGNORE_METRIC);
1030 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN);
1031 } else if (sender == sync_error_signout_button_) {
1032 chrome::ShowSettingsSubPage(browser_, chrome::kSignOutSubPage);
1006 } else if (sender == tutorial_sync_settings_ok_button_) { 1033 } else if (sender == tutorial_sync_settings_ok_button_) {
1007 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 1034 LoginUIServiceFactory::GetForProfile(browser_->profile())->
1008 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); 1035 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS);
1009 DismissTutorial(); 1036 DismissTutorial();
1010 ProfileMetrics::LogProfileNewAvatarMenuSignin( 1037 ProfileMetrics::LogProfileNewAvatarMenuSignin(
1011 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); 1038 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK);
1012 } else if (sender == tutorial_close_button_) { 1039 } else if (sender == tutorial_close_button_) {
1013 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && 1040 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE &&
1014 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN); 1041 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN);
1015 DismissTutorial(); 1042 DismissTutorial();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 } 1196 }
1170 return false; 1197 return false;
1171 } 1198 }
1172 1199
1173 void ProfileChooserView::PopulateCompleteProfileChooserView( 1200 void ProfileChooserView::PopulateCompleteProfileChooserView(
1174 views::GridLayout* layout, 1201 views::GridLayout* layout,
1175 AvatarMenu* avatar_menu) { 1202 AvatarMenu* avatar_menu) {
1176 // Separate items into active and alternatives. 1203 // Separate items into active and alternatives.
1177 Indexes other_profiles; 1204 Indexes other_profiles;
1178 views::View* tutorial_view = NULL; 1205 views::View* tutorial_view = NULL;
1206 views::View* sync_error_view = NULL;
1179 views::View* current_profile_view = NULL; 1207 views::View* current_profile_view = NULL;
1180 views::View* current_profile_accounts = NULL; 1208 views::View* current_profile_accounts = NULL;
1181 views::View* option_buttons_view = NULL; 1209 views::View* option_buttons_view = NULL;
1182 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 1210 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
1183 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 1211 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
1184 if (item.active) { 1212 if (item.active) {
1185 option_buttons_view = CreateOptionsView( 1213 option_buttons_view = CreateOptionsView(
1186 item.signed_in && profiles::IsLockAvailable(browser_->profile()), 1214 item.signed_in && profiles::IsLockAvailable(browser_->profile()),
1187 avatar_menu); 1215 avatar_menu);
1188 current_profile_view = 1216 current_profile_view =
1189 switches::IsMaterialDesignUserMenu() 1217 switches::IsMaterialDesignUserMenu()
1190 ? CreateMaterialDesignCurrentProfileView(item, false) 1218 ? CreateMaterialDesignCurrentProfileView(item, false)
1191 : CreateCurrentProfileView(item, false); 1219 : CreateCurrentProfileView(item, false);
1192 if (IsProfileChooser(view_mode_)) { 1220 if (IsProfileChooser(view_mode_)) {
1193 tutorial_view = CreateTutorialViewIfNeeded(item); 1221 if (!switches::IsMaterialDesignUserMenu())
1222 tutorial_view = CreateTutorialViewIfNeeded(item);
1194 } else { 1223 } else {
1195 current_profile_accounts = CreateCurrentProfileAccountsView(item); 1224 current_profile_accounts = CreateCurrentProfileAccountsView(item);
1196 } 1225 }
1226 if (switches::IsMaterialDesignUserMenu())
1227 sync_error_view = CreateSyncErrorViewIfNeeded();
1197 } else { 1228 } else {
1198 other_profiles.push_back(i); 1229 other_profiles.push_back(i);
1199 } 1230 }
1200 } 1231 }
1201 1232
1202 if (tutorial_view) { 1233 if (tutorial_view) {
1203 // TODO(mlerman): update UMA stats for the new tutorial. 1234 // TODO(mlerman): update UMA stats for the new tutorial.
1204 layout->StartRow(1, 0); 1235 layout->StartRow(1, 0);
1205 layout->AddView(tutorial_view); 1236 layout->AddView(tutorial_view);
1206 } else { 1237 } else {
1207 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; 1238 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
1208 } 1239 }
1209 1240
1241 if (sync_error_view) {
1242 layout->StartRow(1, 0);
1243 layout->AddView(sync_error_view);
1244 layout->StartRow(0, 0);
1245 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1246 }
1247
1210 if (!current_profile_view) { 1248 if (!current_profile_view) {
1211 // Guest windows don't have an active profile. 1249 // Guest windows don't have an active profile.
1212 current_profile_view = CreateGuestProfileView(); 1250 current_profile_view = CreateGuestProfileView();
1213 option_buttons_view = CreateOptionsView(false, avatar_menu); 1251 option_buttons_view = CreateOptionsView(false, avatar_menu);
1214 } 1252 }
1215 1253
1216 layout->StartRow(1, 0); 1254 layout->StartRow(1, 0);
1217 layout->AddView(current_profile_view); 1255 layout->AddView(current_profile_view);
1218 1256
1219 if (!IsProfileChooser(view_mode_)) { 1257 if (!IsProfileChooser(view_mode_)) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 layout->SkipColumns(1); 1466 layout->SkipColumns(1);
1429 if (has_button) 1467 if (has_button)
1430 layout->AddView(*button); 1468 layout->AddView(*button);
1431 else 1469 else
1432 layout->SkipColumns(1); 1470 layout->SkipColumns(1);
1433 } 1471 }
1434 1472
1435 return view; 1473 return view;
1436 } 1474 }
1437 1475
1476 views::View* ProfileChooserView::CreateSyncErrorViewIfNeeded() {
1477 ProfileSyncService* service =
1478 ProfileSyncServiceFactory::GetForProfile(browser_->profile());
1479
1480 // The order or priority is going to be: 1. Unrecoverable errors.
1481 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors.
1482 if (service && service->HasUnrecoverableError()) {
1483 // An unrecoverable error is sometimes accompanied by an actionable error.
1484 // If an actionable error is not set to be UPGRADE_CLIENT, then show a
1485 // generic unrecoverable error message.
1486 ProfileSyncService::Status status;
1487 service->QueryDetailedSyncStatus(&status);
1488 if (status.sync_protocol_error.action != syncer::UPGRADE_CLIENT) {
1489 // Display different messages and buttons for managed accounts.
1490 if (SigninManagerFactory::GetForProfile(browser_->profile())
1491 ->IsSignoutProhibited()) {
1492 // For a managed user, the user is directed to the signout
1493 // confirmation dialogue in the settings page.
1494 return CreateSyncErrorView(IDS_SYNC_ERROR_USER_MENU_SIGNOUT_MESSAGE,
1495 IDS_SYNC_ERROR_USER_MENU_SIGNOUT_BUTTON,
1496 &sync_error_signout_button_);
1497 }
1498 // For a non-managed user, we sign out on the user's behalf and prompt
1499 // the user to sign in again.
1500 return CreateSyncErrorView(IDS_SYNC_ERROR_USER_MENU_SIGNIN_AGAIN_MESSAGE,
1501 IDS_SYNC_ERROR_USER_MENU_SIGNIN_AGAIN_BUTTON,
1502 &sync_error_signin_again_button_);
1503 }
1504 }
1505
1506 // Check for an auth error.
1507 if (HasAuthError(browser_->profile())) {
1508 return CreateSyncErrorView(IDS_SYNC_ERROR_USER_MENU_SIGNIN_MESSAGE,
1509 IDS_SYNC_ERROR_USER_MENU_SIGNIN_BUTTON,
1510 &sync_error_signin_button_);
1511 }
1512
1513 // Check for sync errors if the sync service is enabled.
1514 if (service) {
1515 // Check for an actionable UPGRADE_CLIENT error.
1516 ProfileSyncService::Status status;
1517 service->QueryDetailedSyncStatus(&status);
1518 if (status.sync_protocol_error.action == syncer::UPGRADE_CLIENT) {
1519 return CreateSyncErrorView(IDS_SYNC_ERROR_USER_MENU_UPGRADE_MESSAGE,
1520 IDS_SYNC_ERROR_USER_MENU_UPGRADE_BUTTON,
1521 &sync_error_upgrade_button_);
1522 }
1523
1524 // Check for a sync passphrase error.
1525 SyncErrorController* sync_error_controller =
1526 service->sync_error_controller();
1527 if (sync_error_controller && sync_error_controller->HasError()) {
1528 return CreateSyncErrorView(IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_MESSAGE,
1529 IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_BUTTON,
1530 &sync_error_passphrase_button_);
1531 }
1532 }
1533
1534 // There is no error.
1535 return nullptr;
1536 }
1537
1538 views::View* ProfileChooserView::CreateSyncErrorView(
1539 const int content_string_id,
1540 const int button_string_id,
1541 views::LabelButton** button_out) {
1542 // Sets an overall horizontal layout.
1543 views::View* view = new views::View();
1544 views::BoxLayout* layout = new views::BoxLayout(
1545 views::BoxLayout::kHorizontal, kMaterialMenuEdgeMargin,
1546 kMaterialMenuEdgeMargin, views::kUnrelatedControlHorizontalSpacing);
1547 layout->set_cross_axis_alignment(
1548 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1549 view->SetLayoutManager(layout);
1550
1551 // Adds the sync problem icon.
1552 views::ImageView* sync_problem_icon = new views::ImageView();
1553 sync_problem_icon->SetImage(gfx::CreateVectorIcon(
1554 gfx::VectorIconId::SYNC_PROBLEM, 20, gfx::kGoogleRed700));
1555 view->AddChildView(sync_problem_icon);
1556
1557 // Adds a vertical view to organize the error title, message, and button.
1558 views::View* vertical_view = new views::View();
1559 views::BoxLayout* vertical_layout =
1560 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
1561 views::kRelatedControlSmallVerticalSpacing);
1562 vertical_layout->set_cross_axis_alignment(
1563 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1564 vertical_view->SetLayoutManager(vertical_layout);
1565
1566 // Adds the title.
1567 views::Label* title_label = new views::Label(
1568 l10n_util::GetStringUTF16(IDS_SYNC_ERROR_USER_MENU_TITLE));
1569 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1570 title_label->SetEnabledColor(gfx::kGoogleRed700);
1571 vertical_view->AddChildView(title_label);
1572
1573 // Adds body content.
1574 views::Label* content_label =
1575 new views::Label(l10n_util::GetStringUTF16(content_string_id));
1576 content_label->SetMultiLine(true);
1577 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1578 vertical_view->AddChildView(content_label);
1579
1580 // Adds a padding row between error title/content and the button.
1581 SizedContainer* padding =
1582 new SizedContainer(gfx::Size(0, views::kRelatedControlVerticalSpacing));
1583 vertical_view->AddChildView(padding);
1584
1585 // Adds an action button.
1586 *button_out = views::MdTextButton::CreateSecondaryUiBlueButton(
1587 this, l10n_util::GetStringUTF16(button_string_id));
1588 vertical_view->AddChildView(*button_out);
1589
1590 view->AddChildView(vertical_view);
1591 view->SetBorder(views::Border::CreateEmptyBorder(
1592 0, 0, views::kRelatedControlSmallVerticalSpacing, 0));
1593
1594 return view;
1595 }
1596
1438 views::View* ProfileChooserView::CreateCurrentProfileView( 1597 views::View* ProfileChooserView::CreateCurrentProfileView(
1439 const AvatarMenu::Item& avatar_item, 1598 const AvatarMenu::Item& avatar_item,
1440 bool is_guest) { 1599 bool is_guest) {
1441 views::View* view = new views::View(); 1600 views::View* view = new views::View();
1442 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; 1601 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew;
1443 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); 1602 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width);
1444 layout->SetInsets(views::kButtonVEdgeMarginNew, 1603 layout->SetInsets(views::kButtonVEdgeMarginNew,
1445 views::kButtonHEdgeMarginNew, 1604 views::kButtonHEdgeMarginNew,
1446 views::kUnrelatedControlVerticalSpacing, 1605 views::kUnrelatedControlVerticalSpacing,
1447 views::kButtonHEdgeMarginNew); 1606 views::kButtonHEdgeMarginNew);
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
2158 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2317 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2159 IncognitoModePrefs::DISABLED; 2318 IncognitoModePrefs::DISABLED;
2160 return incognito_available && !browser_->profile()->IsGuestSession(); 2319 return incognito_available && !browser_->profile()->IsGuestSession();
2161 } 2320 }
2162 2321
2163 void ProfileChooserView::PostActionPerformed( 2322 void ProfileChooserView::PostActionPerformed(
2164 ProfileMetrics::ProfileDesktopMenu action_performed) { 2323 ProfileMetrics::ProfileDesktopMenu action_performed) {
2165 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2324 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
2166 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2325 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
2167 } 2326 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698