| OLD | NEW |
| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 result_type = SYNC_ERROR; | 317 result_type = SYNC_ERROR; |
| 318 } | 318 } |
| 319 } else if (service->HasUnrecoverableError()) { | 319 } else if (service->HasUnrecoverableError()) { |
| 320 result_type = SYNC_ERROR; | 320 result_type = SYNC_ERROR; |
| 321 if (status_label && link_label) { | 321 if (status_label && link_label) { |
| 322 GetStatusForUnrecoverableError(profile, service, status_label, | 322 GetStatusForUnrecoverableError(profile, service, status_label, |
| 323 link_label, action_type); | 323 link_label, action_type); |
| 324 } | 324 } |
| 325 } else if (signin.IsAuthenticated()) { | 325 } else if (signin.IsAuthenticated()) { |
| 326 // The user is signed in, but sync has been stopped. | 326 if (service->IsSyncConfirmationNeeded()) { |
| 327 result_type = PRE_SYNCED; | 327 if (status_label && link_label) { |
| 328 if (status_label) { | 328 status_label->assign( |
| 329 status_label->assign( | 329 l10n_util::GetStringUTF16(IDS_SYNC_SETTINGS_NOT_CONFIRMED)); |
| 330 l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED)); | 330 link_label->assign(l10n_util::GetStringUTF16( |
| 331 IDS_SYNC_ERROR_USER_MENU_CONFIRM_SYNC_SETTINGS_BUTTON)); |
| 332 } |
| 333 *action_type = CONFIRM_SYNC_SETTINGS; |
| 334 result_type = SYNC_ERROR; |
| 335 } else { |
| 336 // The user is signed in, but sync has been stopped. |
| 337 result_type = PRE_SYNCED; |
| 338 if (status_label) { |
| 339 status_label->assign( |
| 340 l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED)); |
| 341 } |
| 331 } | 342 } |
| 332 } | 343 } |
| 333 } | 344 } |
| 334 return result_type; | 345 return result_type; |
| 335 } | 346 } |
| 336 | 347 |
| 337 // Returns the status info for use on the new tab page, where we want slightly | 348 // Returns the status info for use on the new tab page, where we want slightly |
| 338 // different information than in the settings panel. | 349 // different information than in the settings panel. |
| 339 MessageType GetStatusInfoForNewTabPage(Profile* profile, | 350 MessageType GetStatusInfoForNewTabPage(Profile* profile, |
| 340 ProfileSyncService* service, | 351 ProfileSyncService* service, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 const SigninManagerBase& signin, | 405 const SigninManagerBase& signin, |
| 395 base::string16* status_label, | 406 base::string16* status_label, |
| 396 base::string16* link_label) { | 407 base::string16* link_label) { |
| 397 DCHECK(status_label); | 408 DCHECK(status_label); |
| 398 DCHECK(link_label); | 409 DCHECK(link_label); |
| 399 return sync_ui_util::GetStatusInfoForNewTabPage(profile, service, signin, | 410 return sync_ui_util::GetStatusInfoForNewTabPage(profile, service, signin, |
| 400 status_label, link_label); | 411 status_label, link_label); |
| 401 } | 412 } |
| 402 | 413 |
| 403 #if !defined(OS_CHROMEOS) | 414 #if !defined(OS_CHROMEOS) |
| 404 AvatarSyncErrorType GetMessagesForAvatarSyncError(Profile* profile, | 415 AvatarSyncErrorType GetMessagesForAvatarSyncError( |
| 405 int* content_string_id, | 416 Profile* profile, |
| 406 int* button_string_id) { | 417 const SigninManagerBase& signin, |
| 418 int* content_string_id, |
| 419 int* button_string_id) { |
| 407 ProfileSyncService* service = | 420 ProfileSyncService* service = |
| 408 ProfileSyncServiceFactory::GetForProfile(profile); | 421 ProfileSyncServiceFactory::GetForProfile(profile); |
| 409 | 422 |
| 410 // The order or priority is going to be: 1. Unrecoverable errors. | 423 // The order or priority is going to be: 1. Unrecoverable errors. |
| 411 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. | 424 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. |
| 412 if (service && service->HasUnrecoverableError()) { | 425 if (service && service->HasUnrecoverableError()) { |
| 413 // An unrecoverable error is sometimes accompanied by an actionable error. | 426 // 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 | 427 // If an actionable error is not set to be UPGRADE_CLIENT, then show a |
| 415 // generic unrecoverable error message. | 428 // generic unrecoverable error message. |
| 416 ProfileSyncService::Status status; | 429 ProfileSyncService::Status status; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 475 } |
| 463 | 476 |
| 464 // Check for a sync passphrase error. | 477 // Check for a sync passphrase error. |
| 465 syncer::SyncErrorController* sync_error_controller = | 478 syncer::SyncErrorController* sync_error_controller = |
| 466 service->sync_error_controller(); | 479 service->sync_error_controller(); |
| 467 if (sync_error_controller && sync_error_controller->HasError()) { | 480 if (sync_error_controller && sync_error_controller->HasError()) { |
| 468 *content_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_MESSAGE; | 481 *content_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_MESSAGE; |
| 469 *button_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_BUTTON; | 482 *button_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_BUTTON; |
| 470 return PASSPHRASE_ERROR; | 483 return PASSPHRASE_ERROR; |
| 471 } | 484 } |
| 485 |
| 486 // Check for a sync confirmation error. |
| 487 if (signin.IsAuthenticated() && service->IsSyncConfirmationNeeded()) { |
| 488 *content_string_id = IDS_SYNC_SETTINGS_NOT_CONFIRMED; |
| 489 *button_string_id = IDS_SYNC_ERROR_USER_MENU_CONFIRM_SYNC_SETTINGS_BUTTON; |
| 490 return SETTINGS_UNCONFIRMED_ERROR; |
| 491 } |
| 472 } | 492 } |
| 473 | 493 |
| 474 // There is no error. | 494 // There is no error. |
| 475 return NO_SYNC_ERROR; | 495 return NO_SYNC_ERROR; |
| 476 } | 496 } |
| 477 #endif | 497 #endif |
| 478 | 498 |
| 479 MessageType GetStatus(Profile* profile, | 499 MessageType GetStatus(Profile* profile, |
| 480 ProfileSyncService* service, | 500 ProfileSyncService* service, |
| 481 const SigninManagerBase& signin) { | 501 const SigninManagerBase& signin) { |
| 482 ActionType action_type = NO_ACTION; | 502 ActionType action_type = NO_ACTION; |
| 483 return sync_ui_util::GetStatusInfo(profile, service, signin, WITH_HTML, | 503 return sync_ui_util::GetStatusInfo(profile, service, signin, WITH_HTML, |
| 484 nullptr, nullptr, &action_type); | 504 nullptr, nullptr, &action_type); |
| 485 } | 505 } |
| 486 | 506 |
| 487 base::string16 ConstructTime(int64_t time_in_int) { | 507 base::string16 ConstructTime(int64_t time_in_int) { |
| 488 base::Time time = base::Time::FromInternalValue(time_in_int); | 508 base::Time time = base::Time::FromInternalValue(time_in_int); |
| 489 | 509 |
| 490 // If time is null the format function returns a time in 1969. | 510 // If time is null the format function returns a time in 1969. |
| 491 if (time.is_null()) | 511 if (time.is_null()) |
| 492 return base::string16(); | 512 return base::string16(); |
| 493 return base::TimeFormatFriendlyDateAndTime(time); | 513 return base::TimeFormatFriendlyDateAndTime(time); |
| 494 } | 514 } |
| 495 | 515 |
| 496 } // namespace sync_ui_util | 516 } // namespace sync_ui_util |
| OLD | NEW |