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

Side by Side Diff: chrome/browser/signin/signin_ui_util.cc

Issue 2457483002: [MD Settings][Sync Settings] Updates sync status messages (Closed)
Patch Set: Addressed maxbogue's and dbeam's comments Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/signin/signin_ui_util.h ('k') | chrome/browser/sync/sync_ui_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/signin/signin_ui_util.h" 5 #include "chrome/browser/signin/signin_ui_util.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // Original email (containing dots) is stored as "display email". 46 // Original email (containing dots) is stored as "display email".
47 user_display_name = user_manager::UserManager::Get()->GetUserDisplayEmail( 47 user_display_name = user_manager::UserManager::Get()->GetUserDisplayEmail(
48 AccountId::FromUserEmail(user_display_name)); 48 AccountId::FromUserEmail(user_display_name));
49 } 49 }
50 #endif // defined(OS_CHROMEOS) 50 #endif // defined(OS_CHROMEOS)
51 } 51 }
52 52
53 return base::UTF8ToUTF16(user_display_name); 53 return base::UTF8ToUTF16(user_display_name);
54 } 54 }
55 55
56 // Given an authentication state this helper function returns various labels
57 // that can be used to display information about the state.
58 void GetStatusLabelsForAuthError(Profile* profile,
59 const SigninManagerBase& signin_manager,
60 base::string16* status_label,
61 base::string16* link_label) {
62 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
63 if (link_label)
64 link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL));
65
66 const GoogleServiceAuthError::State state =
67 SigninErrorControllerFactory::GetForProfile(profile)->
68 auth_error().state();
69 switch (state) {
70 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
71 case GoogleServiceAuthError::SERVICE_ERROR:
72 case GoogleServiceAuthError::ACCOUNT_DELETED:
73 case GoogleServiceAuthError::ACCOUNT_DISABLED:
74 // If the user name is empty then the first login failed, otherwise the
75 // credentials are out-of-date.
76 if (!signin_manager.IsAuthenticated()) {
77 if (status_label) {
78 status_label->assign(
79 l10n_util::GetStringUTF16(IDS_SYNC_INVALID_USER_CREDENTIALS));
80 }
81 } else {
82 if (status_label) {
83 status_label->assign(
84 l10n_util::GetStringUTF16(IDS_SYNC_LOGIN_INFO_OUT_OF_DATE));
85 }
86 }
87 break;
88 case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
89 if (status_label) {
90 status_label->assign(
91 l10n_util::GetStringUTF16(IDS_SYNC_SERVICE_UNAVAILABLE));
92 }
93 if (link_label)
94 link_label->clear();
95 break;
96 case GoogleServiceAuthError::CONNECTION_FAILED:
97 if (status_label) {
98 status_label->assign(
99 l10n_util::GetStringFUTF16(IDS_SYNC_SERVER_IS_UNREACHABLE,
100 product_name));
101 }
102 // Note that there is little the user can do if the server is not
103 // reachable. Since attempting to re-connect is done automatically by
104 // the Syncer, we do not show the (re)login link.
105 if (link_label)
106 link_label->clear();
107 break;
108 default:
109 if (status_label) {
110 status_label->assign(l10n_util::GetStringUTF16(
111 IDS_SYNC_ERROR_SIGNING_IN));
112 }
113 break;
114 }
115 }
116
117 void InitializePrefsForProfile(Profile* profile) { 56 void InitializePrefsForProfile(Profile* profile) {
118 if (profile->IsNewProfile()) { 57 if (profile->IsNewProfile()) {
119 // Suppresses the upgrade tutorial for a new profile. 58 // Suppresses the upgrade tutorial for a new profile.
120 profile->GetPrefs()->SetInteger( 59 profile->GetPrefs()->SetInteger(
121 prefs::kProfileAvatarTutorialShown, kUpgradeWelcomeTutorialShowMax + 1); 60 prefs::kProfileAvatarTutorialShown, kUpgradeWelcomeTutorialShowMax + 1);
122 } 61 }
123 } 62 }
124 63
125 void ShowSigninErrorLearnMorePage(Profile* profile) { 64 void ShowSigninErrorLearnMorePage(Profile* profile) {
126 static const char kSigninErrorLearnMoreUrl[] = 65 static const char kSigninErrorLearnMoreUrl[] =
(...skipping 10 matching lines...) Expand all
137 std::string email = account_tracker->GetAccountInfo(account_id).email; 76 std::string email = account_tracker->GetAccountInfo(account_id).email;
138 if (email.empty()) { 77 if (email.empty()) {
139 DCHECK_EQ(AccountTrackerService::MIGRATION_NOT_STARTED, 78 DCHECK_EQ(AccountTrackerService::MIGRATION_NOT_STARTED,
140 account_tracker->GetMigrationState()); 79 account_tracker->GetMigrationState());
141 return account_id; 80 return account_id;
142 } 81 }
143 return email; 82 return email;
144 } 83 }
145 84
146 } // namespace signin_ui_util 85 } // namespace signin_ui_util
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_ui_util.h ('k') | chrome/browser/sync/sync_ui_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698