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

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

Issue 2920853004: [sync] Display an error when sync settings aren't confirmed (Closed)
Patch Set: Created 3 years, 6 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 (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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 namespace sync_ui_util { 54 namespace sync_ui_util {
55 55
56 namespace { 56 namespace {
57 57
58 bool IsChromeDashboardEnabled() { 58 bool IsChromeDashboardEnabled() {
59 const std::string group_name = 59 const std::string group_name =
60 base::FieldTrialList::FindFullName("ChromeDashboard"); 60 base::FieldTrialList::FindFullName("ChromeDashboard");
61 return group_name == "Enabled"; 61 return group_name == "Enabled";
62 } 62 }
63 63
64 bool IsSyncConfirmationNeeded(ProfileSyncService* service) {
65 // The user is signed in and sync is requested, but setup is incomplete.
66 // Sync confirmation needs to be completed.
67 return service->IsSyncRequested() && !service->IsFirstSetupComplete();
68 }
69
64 // Returns the message that should be displayed when the user is authenticated 70 // Returns the message that should be displayed when the user is authenticated
65 // and can connect to the sync server. If the user hasn't yet authenticated, an 71 // and can connect to the sync server. If the user hasn't yet authenticated, an
66 // empty string is returned. 72 // empty string is returned.
67 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service, 73 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service,
68 const SigninManagerBase& signin, 74 const SigninManagerBase& signin,
69 StatusLabelStyle style, 75 StatusLabelStyle style,
70 bool sync_everything) { 76 bool sync_everything) {
71 if (!service || service->IsManaged()) { 77 if (!service || service->IsManaged()) {
72 // User is signed in, but sync is disabled. 78 // User is signed in, but sync is disabled.
73 return l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED); 79 return l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 322 }
317 result_type = SYNC_ERROR; 323 result_type = SYNC_ERROR;
318 } 324 }
319 } else if (service->HasUnrecoverableError()) { 325 } else if (service->HasUnrecoverableError()) {
320 result_type = SYNC_ERROR; 326 result_type = SYNC_ERROR;
321 if (status_label && link_label) { 327 if (status_label && link_label) {
322 GetStatusForUnrecoverableError(profile, service, status_label, 328 GetStatusForUnrecoverableError(profile, service, status_label,
323 link_label, action_type); 329 link_label, action_type);
324 } 330 }
325 } else if (signin.IsAuthenticated()) { 331 } else if (signin.IsAuthenticated()) {
326 // The user is signed in, but sync has been stopped. 332 if (IsSyncConfirmationNeeded(service)) {
327 result_type = PRE_SYNCED; 333 if (status_label && link_label) {
328 if (status_label) { 334 status_label->assign(
329 status_label->assign( 335 l10n_util::GetStringUTF16(IDS_SYNC_SETTINGS_NOT_CONFIRMED));
330 l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED)); 336 link_label->assign(l10n_util::GetStringUTF16(
337 IDS_SYNC_ERROR_USER_MENU_CONFIRM_SYNC_SETTINGS_BUTTON));
338 }
339 *action_type = CONFIRM_SYNC_SETTINGS;
340 if (!status_label->empty())
skym 2017/06/01 19:48:44 First, what a function. Combines figuring out your
Patrick Noland 2017/06/07 19:07:23 Done.
341 return SYNC_ERROR;
342 } else {
343 // The user is signed in, but sync has been stopped.
344 result_type = PRE_SYNCED;
345 if (status_label) {
346 status_label->assign(
347 l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED));
348 }
331 } 349 }
332 } 350 }
333 } 351 }
334 return result_type; 352 return result_type;
335 } 353 }
336 354
337 // Returns the status info for use on the new tab page, where we want slightly 355 // Returns the status info for use on the new tab page, where we want slightly
338 // different information than in the settings panel. 356 // different information than in the settings panel.
339 MessageType GetStatusInfoForNewTabPage(Profile* profile, 357 MessageType GetStatusInfoForNewTabPage(Profile* profile,
340 ProfileSyncService* service, 358 ProfileSyncService* service,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 const SigninManagerBase& signin, 412 const SigninManagerBase& signin,
395 base::string16* status_label, 413 base::string16* status_label,
396 base::string16* link_label) { 414 base::string16* link_label) {
397 DCHECK(status_label); 415 DCHECK(status_label);
398 DCHECK(link_label); 416 DCHECK(link_label);
399 return sync_ui_util::GetStatusInfoForNewTabPage(profile, service, signin, 417 return sync_ui_util::GetStatusInfoForNewTabPage(profile, service, signin,
400 status_label, link_label); 418 status_label, link_label);
401 } 419 }
402 420
403 #if !defined(OS_CHROMEOS) 421 #if !defined(OS_CHROMEOS)
404 AvatarSyncErrorType GetMessagesForAvatarSyncError(Profile* profile, 422 AvatarSyncErrorType GetMessagesForAvatarSyncError(
405 int* content_string_id, 423 Profile* profile,
406 int* button_string_id) { 424 const SigninManagerBase& signin,
425 int* content_string_id,
426 int* button_string_id) {
407 ProfileSyncService* service = 427 ProfileSyncService* service =
408 ProfileSyncServiceFactory::GetForProfile(profile); 428 ProfileSyncServiceFactory::GetForProfile(profile);
409 429
410 // The order or priority is going to be: 1. Unrecoverable errors. 430 // The order or priority is going to be: 1. Unrecoverable errors.
411 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. 431 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors.
412 if (service && service->HasUnrecoverableError()) { 432 if (service && service->HasUnrecoverableError()) {
413 // An unrecoverable error is sometimes accompanied by an actionable error. 433 // An unrecoverable error is sometimes accompanied by an actionable error.
414 // If an actionable error is not set to be UPGRADE_CLIENT, then show a 434 // If an actionable error is not set to be UPGRADE_CLIENT, then show a
415 // generic unrecoverable error message. 435 // generic unrecoverable error message.
416 ProfileSyncService::Status status; 436 ProfileSyncService::Status status;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 482 }
463 483
464 // Check for a sync passphrase error. 484 // Check for a sync passphrase error.
465 syncer::SyncErrorController* sync_error_controller = 485 syncer::SyncErrorController* sync_error_controller =
466 service->sync_error_controller(); 486 service->sync_error_controller();
467 if (sync_error_controller && sync_error_controller->HasError()) { 487 if (sync_error_controller && sync_error_controller->HasError()) {
468 *content_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_MESSAGE; 488 *content_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_MESSAGE;
469 *button_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_BUTTON; 489 *button_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_BUTTON;
470 return PASSPHRASE_ERROR; 490 return PASSPHRASE_ERROR;
471 } 491 }
492
493 // Check for a sync confirmation error.
494 if (signin.IsAuthenticated() && IsSyncConfirmationNeeded(service)) {
495 *content_string_id = IDS_SYNC_SETTINGS_NOT_CONFIRMED;
496 *button_string_id = IDS_SYNC_ERROR_USER_MENU_CONFIRM_SYNC_SETTINGS_BUTTON;
497 return SETTINGS_UNCONFIRMED_ERROR;
498 }
472 } 499 }
473 500
474 // There is no error. 501 // There is no error.
475 return NO_SYNC_ERROR; 502 return NO_SYNC_ERROR;
476 } 503 }
477 #endif 504 #endif
478 505
479 MessageType GetStatus(Profile* profile, 506 MessageType GetStatus(Profile* profile,
480 ProfileSyncService* service, 507 ProfileSyncService* service,
481 const SigninManagerBase& signin) { 508 const SigninManagerBase& signin) {
482 ActionType action_type = NO_ACTION; 509 ActionType action_type = NO_ACTION;
483 return sync_ui_util::GetStatusInfo(profile, service, signin, WITH_HTML, 510 return sync_ui_util::GetStatusInfo(profile, service, signin, WITH_HTML,
484 nullptr, nullptr, &action_type); 511 nullptr, nullptr, &action_type);
485 } 512 }
486 513
487 base::string16 ConstructTime(int64_t time_in_int) { 514 base::string16 ConstructTime(int64_t time_in_int) {
488 base::Time time = base::Time::FromInternalValue(time_in_int); 515 base::Time time = base::Time::FromInternalValue(time_in_int);
489 516
490 // If time is null the format function returns a time in 1969. 517 // If time is null the format function returns a time in 1969.
491 if (time.is_null()) 518 if (time.is_null())
492 return base::string16(); 519 return base::string16();
493 return base::TimeFormatFriendlyDateAndTime(time); 520 return base::TimeFormatFriendlyDateAndTime(time);
494 } 521 }
495 522
496 } // namespace sync_ui_util 523 } // namespace sync_ui_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698