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

Side by Side Diff: chrome/browser/sync/sync_ui_util.cc

Issue 2492293002: [MD Settings][Options] Fixes bugs with the sync status messages/actions (Closed)
Patch Set: 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync/sync_ui_util.h" 5 #include "chrome/browser/sync/sync_ui_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 IDS_SYNC_ACCOUNT_SYNCING_WITH_MANAGE_LINK, 92 IDS_SYNC_ACCOUNT_SYNCING_WITH_MANAGE_LINK,
93 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); 93 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL));
94 default: 94 default:
95 NOTREACHED(); 95 NOTREACHED();
96 return nullptr; 96 return nullptr;
97 } 97 }
98 } 98 }
99 99
100 void GetStatusForActionableError(const syncer::SyncProtocolError& error, 100 void GetStatusForActionableError(const syncer::SyncProtocolError& error,
101 base::string16* status_label, 101 base::string16* status_label,
102 base::string16* link_label,
102 ActionType* action_type) { 103 ActionType* action_type) {
103 DCHECK(status_label); 104 DCHECK(status_label);
105 DCHECK(link_label);
104 switch (error.action) { 106 switch (error.action) {
105 case syncer::UPGRADE_CLIENT: 107 case syncer::UPGRADE_CLIENT:
106 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_UPGRADE_CLIENT)); 108 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_UPGRADE_CLIENT));
109 link_label->assign(
110 l10n_util::GetStringUTF16(IDS_SYNC_UPGRADE_CLIENT_LINK_LABEL));
107 *action_type = UPGRADE_CLIENT; 111 *action_type = UPGRADE_CLIENT;
108 break; 112 break;
109 case syncer::ENABLE_SYNC_ON_ACCOUNT: 113 case syncer::ENABLE_SYNC_ON_ACCOUNT:
110 status_label->assign( 114 status_label->assign(
111 l10n_util::GetStringUTF16(IDS_SYNC_STATUS_ENABLE_SYNC_ON_ACCOUNT)); 115 l10n_util::GetStringUTF16(IDS_SYNC_STATUS_ENABLE_SYNC_ON_ACCOUNT));
112 break; 116 break;
113 default: 117 default:
114 status_label->clear(); 118 status_label->clear();
115 break; 119 break;
116 } 120 }
117 } 121 }
118 122
119 void GetStatusForUnrecoverableError(Profile* profile, 123 void GetStatusForUnrecoverableError(Profile* profile,
120 ProfileSyncService* service, 124 ProfileSyncService* service,
121 base::string16* status_label, 125 base::string16* status_label,
126 base::string16* link_label,
122 ActionType* action_type) { 127 ActionType* action_type) {
123 // Unrecoverable error is sometimes accompanied by actionable error. 128 // Unrecoverable error is sometimes accompanied by actionable error.
124 // If status message is set display that message, otherwise show generic 129 // If status message is set display that message, otherwise show generic
125 // unrecoverable error message. 130 // unrecoverable error message.
126 ProfileSyncService::Status status; 131 ProfileSyncService::Status status;
127 service->QueryDetailedSyncStatus(&status); 132 service->QueryDetailedSyncStatus(&status);
128 GetStatusForActionableError(status.sync_protocol_error, status_label, 133 GetStatusForActionableError(status.sync_protocol_error, status_label,
129 action_type); 134 link_label, action_type);
130 if (status_label->empty()) { 135 if (status_label->empty()) {
131 *action_type = REAUTHENTICATE; 136 *action_type = REAUTHENTICATE;
137 link_label->assign(
138 l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL));
132 139
133 #if !defined(OS_CHROMEOS) 140 #if !defined(OS_CHROMEOS)
134 status_label->assign(l10n_util::GetStringUTF16( 141 status_label->assign(l10n_util::GetStringUTF16(
135 IDS_SYNC_STATUS_UNRECOVERABLE_ERROR)); 142 IDS_SYNC_STATUS_UNRECOVERABLE_ERROR));
136 // The message for managed accounts is the same as that of the cros. 143 // The message for managed accounts is the same as that of the cros.
137 if (SigninManagerFactory::GetForProfile(profile)->IsSignoutProhibited()) { 144 if (SigninManagerFactory::GetForProfile(profile)->IsSignoutProhibited()) {
138 status_label->assign(l10n_util::GetStringUTF16( 145 status_label->assign(l10n_util::GetStringUTF16(
139 IDS_SYNC_STATUS_UNRECOVERABLE_ERROR_NEEDS_SIGNOUT)); 146 IDS_SYNC_STATUS_UNRECOVERABLE_ERROR_NEEDS_SIGNOUT));
140 } 147 }
141 #else 148 #else
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 205
199 if (!signin.IsAuthenticated()) 206 if (!signin.IsAuthenticated())
200 return PRE_SYNCED; 207 return PRE_SYNCED;
201 208
202 if (!service || service->IsManaged() || service->IsFirstSetupComplete() || 209 if (!service || service->IsManaged() || service->IsFirstSetupComplete() ||
203 !service->IsSyncRequested()) { 210 !service->IsSyncRequested()) {
204 // The order or priority is going to be: 1. Unrecoverable errors. 211 // The order or priority is going to be: 1. Unrecoverable errors.
205 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. 212 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors.
206 213
207 if (service && service->HasUnrecoverableError()) { 214 if (service && service->HasUnrecoverableError()) {
208 if (status_label) { 215 if (status_label && link_label) {
209 GetStatusForUnrecoverableError(profile, service, status_label, 216 GetStatusForUnrecoverableError(profile, service, status_label,
210 action_type); 217 link_label, action_type);
211 } 218 }
212 return SYNC_ERROR; 219 return SYNC_ERROR;
213 } 220 }
214 221
215 // For auth errors first check if an auth is in progress. 222 // For auth errors first check if an auth is in progress.
216 if (signin.AuthInProgress()) { 223 if (signin.AuthInProgress()) {
217 if (status_label) { 224 if (status_label) {
218 status_label->assign( 225 status_label->assign(
219 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); 226 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
220 } 227 }
221 return PRE_SYNCED; 228 return PRE_SYNCED;
222 } 229 }
223 230
224 // Check for sync errors if the sync service is enabled. 231 // Check for sync errors if the sync service is enabled.
225 if (service) { 232 if (service) {
226 // Since there is no auth in progress, check for an auth error first. 233 // Since there is no auth in progress, check for an auth error first.
227 AuthError auth_error = 234 AuthError auth_error =
228 SigninErrorControllerFactory::GetForProfile(profile)->auth_error(); 235 SigninErrorControllerFactory::GetForProfile(profile)->auth_error();
229 if (auth_error.state() != AuthError::NONE) { 236 if (auth_error.state() != AuthError::NONE) {
230 if (status_label && link_label) { 237 if (status_label && link_label) {
231 GetStatusForAuthError(profile, signin, status_label, link_label, 238 GetStatusForAuthError(profile, signin, status_label, link_label,
232 action_type); 239 action_type);
233 } 240 }
234 return SYNC_ERROR; 241 return SYNC_ERROR;
235 } 242 }
236 243
237 // We don't have an auth error. Check for an actionable error. 244 // We don't have an auth error. Check for an actionable error.
238 ProfileSyncService::Status status; 245 ProfileSyncService::Status status;
239 service->QueryDetailedSyncStatus(&status); 246 service->QueryDetailedSyncStatus(&status);
240 if (status_label) { 247 if (status_label && link_label) {
241 GetStatusForActionableError(status.sync_protocol_error, status_label, 248 GetStatusForActionableError(status.sync_protocol_error, status_label,
242 action_type); 249 link_label, action_type);
243 if (!status_label->empty()) 250 if (!status_label->empty())
244 return SYNC_ERROR; 251 return SYNC_ERROR;
245 } 252 }
246 253
247 // Check for a passphrase error. 254 // Check for a passphrase error.
248 if (service->IsPassphraseRequired() && 255 if (service->IsPassphraseRequired() &&
249 service->IsPassphraseRequiredForDecryption()) { 256 service->IsPassphraseRequiredForDecryption()) {
250 if (status_label && link_label) { 257 if (status_label && link_label) {
251 status_label->assign( 258 status_label->assign(
252 l10n_util::GetStringUTF16(IDS_SYNC_STATUS_NEEDS_PASSWORD)); 259 l10n_util::GetStringUTF16(IDS_SYNC_STATUS_NEEDS_PASSWORD));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } else if (auth_error.state() != AuthError::NONE && 303 } else if (auth_error.state() != AuthError::NONE &&
297 auth_error.state() != AuthError::TWO_FACTOR) { 304 auth_error.state() != AuthError::TWO_FACTOR) {
298 if (status_label && link_label) { 305 if (status_label && link_label) {
299 GetStatusForAuthError(profile, signin, status_label, link_label, 306 GetStatusForAuthError(profile, signin, status_label, link_label,
300 action_type); 307 action_type);
301 } 308 }
302 result_type = SYNC_ERROR; 309 result_type = SYNC_ERROR;
303 } 310 }
304 } else if (service->HasUnrecoverableError()) { 311 } else if (service->HasUnrecoverableError()) {
305 result_type = SYNC_ERROR; 312 result_type = SYNC_ERROR;
306 if (status_label) { 313 if (status_label && link_label) {
307 GetStatusForUnrecoverableError(profile, service, status_label, 314 GetStatusForUnrecoverableError(profile, service, status_label,
308 action_type); 315 link_label, action_type);
309 } 316 }
310 } else if (signin.IsAuthenticated()) { 317 } else if (signin.IsAuthenticated()) {
311 // The user is signed in, but sync has been stopped. 318 // The user is signed in, but sync has been stopped.
312 result_type = PRE_SYNCED; 319 result_type = PRE_SYNCED;
313 if (status_label) { 320 if (status_label) {
314 status_label->assign( 321 status_label->assign(
315 l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED)); 322 l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED));
316 } 323 }
317 } 324 }
318 } 325 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 base::string16 ConstructTime(int64_t time_in_int) { 508 base::string16 ConstructTime(int64_t time_in_int) {
502 base::Time time = base::Time::FromInternalValue(time_in_int); 509 base::Time time = base::Time::FromInternalValue(time_in_int);
503 510
504 // If time is null the format function returns a time in 1969. 511 // If time is null the format function returns a time in 1969.
505 if (time.is_null()) 512 if (time.is_null())
506 return base::string16(); 513 return base::string16();
507 return base::TimeFormatFriendlyDateAndTime(time); 514 return base::TimeFormatFriendlyDateAndTime(time);
508 } 515 }
509 516
510 } // namespace sync_ui_util 517 } // namespace sync_ui_util
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/sync_setup_overlay.js ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698