| 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 "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK, | 159 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK, |
| 160 user_name, | 160 user_name, |
| 161 ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); | 161 ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); |
| 162 default: | 162 default: |
| 163 NOTREACHED(); | 163 NOTREACHED(); |
| 164 return NULL; | 164 return NULL; |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 void GetStatusForActionableError( | 168 void GetStatusForActionableError( |
| 169 const csync::SyncProtocolError& error, | 169 const syncer::SyncProtocolError& error, |
| 170 string16* status_label) { | 170 string16* status_label) { |
| 171 DCHECK(status_label); | 171 DCHECK(status_label); |
| 172 switch (error.action) { | 172 switch (error.action) { |
| 173 case csync::STOP_AND_RESTART_SYNC: | 173 case syncer::STOP_AND_RESTART_SYNC: |
| 174 status_label->assign( | 174 status_label->assign( |
| 175 l10n_util::GetStringUTF16(IDS_SYNC_STOP_AND_RESTART_SYNC)); | 175 l10n_util::GetStringUTF16(IDS_SYNC_STOP_AND_RESTART_SYNC)); |
| 176 break; | 176 break; |
| 177 case csync::UPGRADE_CLIENT: | 177 case syncer::UPGRADE_CLIENT: |
| 178 status_label->assign( | 178 status_label->assign( |
| 179 l10n_util::GetStringFUTF16(IDS_SYNC_UPGRADE_CLIENT, | 179 l10n_util::GetStringFUTF16(IDS_SYNC_UPGRADE_CLIENT, |
| 180 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 180 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 181 break; | 181 break; |
| 182 case csync::ENABLE_SYNC_ON_ACCOUNT: | 182 case syncer::ENABLE_SYNC_ON_ACCOUNT: |
| 183 status_label->assign( | 183 status_label->assign( |
| 184 l10n_util::GetStringUTF16(IDS_SYNC_ENABLE_SYNC_ON_ACCOUNT)); | 184 l10n_util::GetStringUTF16(IDS_SYNC_ENABLE_SYNC_ON_ACCOUNT)); |
| 185 break; | 185 break; |
| 186 case csync::CLEAR_USER_DATA_AND_RESYNC: | 186 case syncer::CLEAR_USER_DATA_AND_RESYNC: |
| 187 status_label->assign( | 187 status_label->assign( |
| 188 l10n_util::GetStringUTF16(IDS_SYNC_CLEAR_USER_DATA)); | 188 l10n_util::GetStringUTF16(IDS_SYNC_CLEAR_USER_DATA)); |
| 189 break; | 189 break; |
| 190 default: | 190 default: |
| 191 NOTREACHED(); | 191 NOTREACHED(); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 // TODO(akalin): Write unit tests for these three functions below. | 195 // TODO(akalin): Write unit tests for these three functions below. |
| 196 | 196 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // different information than in the settings panel. | 317 // different information than in the settings panel. |
| 318 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service, | 318 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service, |
| 319 const SigninManager& signin, | 319 const SigninManager& signin, |
| 320 string16* status_label, | 320 string16* status_label, |
| 321 string16* link_label) { | 321 string16* link_label) { |
| 322 DCHECK(status_label); | 322 DCHECK(status_label); |
| 323 DCHECK(link_label); | 323 DCHECK(link_label); |
| 324 | 324 |
| 325 if (service->HasSyncSetupCompleted() && | 325 if (service->HasSyncSetupCompleted() && |
| 326 service->IsPassphraseRequired()) { | 326 service->IsPassphraseRequired()) { |
| 327 if (service->passphrase_required_reason() == csync::REASON_ENCRYPTION) { | 327 if (service->passphrase_required_reason() == syncer::REASON_ENCRYPTION) { |
| 328 // First machine migrating to passwords. Show as a promotion. | 328 // First machine migrating to passwords. Show as a promotion. |
| 329 if (status_label && link_label) { | 329 if (status_label && link_label) { |
| 330 status_label->assign( | 330 status_label->assign( |
| 331 l10n_util::GetStringFUTF16( | 331 l10n_util::GetStringFUTF16( |
| 332 IDS_SYNC_NTP_PASSWORD_PROMO, | 332 IDS_SYNC_NTP_PASSWORD_PROMO, |
| 333 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 333 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 334 link_label->assign( | 334 link_label->assign( |
| 335 l10n_util::GetStringUTF16(IDS_SYNC_NTP_PASSWORD_ENABLE)); | 335 l10n_util::GetStringUTF16(IDS_SYNC_NTP_PASSWORD_ENABLE)); |
| 336 } | 336 } |
| 337 return SYNC_PROMO; | 337 return SYNC_PROMO; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 CHECK(strings); | 512 CHECK(strings); |
| 513 if (!service) { | 513 if (!service) { |
| 514 sync_ui_util::AddStringSyncDetails(sync_summary, "Summary", | 514 sync_ui_util::AddStringSyncDetails(sync_summary, "Summary", |
| 515 "Sync service does not exist"); | 515 "Sync service does not exist"); |
| 516 } else { | 516 } else { |
| 517 // This bypasses regular inter-thread communication mechanisms to grab a | 517 // This bypasses regular inter-thread communication mechanisms to grab a |
| 518 // very recent snapshot from the syncer thread. It should be up to date | 518 // very recent snapshot from the syncer thread. It should be up to date |
| 519 // with the last snapshot emitted by the syncer. Keep in mind, though, that | 519 // with the last snapshot emitted by the syncer. Keep in mind, though, that |
| 520 // not all events that update these values will ping the UI thread, so you | 520 // not all events that update these values will ping the UI thread, so you |
| 521 // might not see all intermediate values. | 521 // might not see all intermediate values. |
| 522 csync::SyncStatus full_status(service->QueryDetailedSyncStatus()); | 522 syncer::SyncStatus full_status(service->QueryDetailedSyncStatus()); |
| 523 | 523 |
| 524 // This is a cache of the last snapshot of type SYNC_CYCLE_ENDED where | 524 // This is a cache of the last snapshot of type SYNC_CYCLE_ENDED where |
| 525 // !snapshot.has_more_to_sync(). In other words, it's the last in this | 525 // !snapshot.has_more_to_sync(). In other words, it's the last in this |
| 526 // series of sync cycles. The series ends only when we've done all we can | 526 // series of sync cycles. The series ends only when we've done all we can |
| 527 // to resolve conflicts and there is nothing left to commit, or an error | 527 // to resolve conflicts and there is nothing left to commit, or an error |
| 528 // occurs. | 528 // occurs. |
| 529 // | 529 // |
| 530 // Despite the fact that it is updated only at the end of a series of | 530 // Despite the fact that it is updated only at the end of a series of |
| 531 // commits, its values do not reflect the series. Its counters are based on | 531 // commits, its values do not reflect the series. Its counters are based on |
| 532 // the values from a single sync cycle. | 532 // the values from a single sync cycle. |
| 533 // | 533 // |
| 534 // |snapshot| could be NULL if sync is not yet initialized. | 534 // |snapshot| could be NULL if sync is not yet initialized. |
| 535 const csync::sessions::SyncSessionSnapshot& snapshot = | 535 const syncer::sessions::SyncSessionSnapshot& snapshot = |
| 536 service->sync_initialized() ? | 536 service->sync_initialized() ? |
| 537 service->GetLastSessionSnapshot() : | 537 service->GetLastSessionSnapshot() : |
| 538 csync::sessions::SyncSessionSnapshot(); | 538 syncer::sessions::SyncSessionSnapshot(); |
| 539 | 539 |
| 540 sync_ui_util::AddStringSyncDetails(sync_summary, "Summary", | 540 sync_ui_util::AddStringSyncDetails(sync_summary, "Summary", |
| 541 service->QuerySyncStatusSummary()); | 541 service->QuerySyncStatusSummary()); |
| 542 | 542 |
| 543 ListValue* version_info = AddSyncDetailsSection(details, "Version Info"); | 543 ListValue* version_info = AddSyncDetailsSection(details, "Version Info"); |
| 544 sync_ui_util::AddStringSyncDetails(version_info, "Client Version", | 544 sync_ui_util::AddStringSyncDetails(version_info, "Client Version", |
| 545 GetVersionString()); | 545 GetVersionString()); |
| 546 sync_ui_util::AddStringSyncDetails(version_info, "Server URL", | 546 sync_ui_util::AddStringSyncDetails(version_info, "Server URL", |
| 547 service->sync_service_url().spec()); | 547 service->sync_service_url().spec()); |
| 548 | 548 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 full_status.crypto_has_pending_keys); | 604 full_status.crypto_has_pending_keys); |
| 605 sync_ui_util::AddStringSyncDetails(encryption, | 605 sync_ui_util::AddStringSyncDetails(encryption, |
| 606 "Encrypted Types", | 606 "Encrypted Types", |
| 607 syncable::ModelTypeSetToString(full_status.encrypted_types)); | 607 syncable::ModelTypeSetToString(full_status.encrypted_types)); |
| 608 | 608 |
| 609 | 609 |
| 610 ListValue* cycles = AddSyncDetailsSection( | 610 ListValue* cycles = AddSyncDetailsSection( |
| 611 details, "Status from Last Completed Session"); | 611 details, "Status from Last Completed Session"); |
| 612 sync_ui_util::AddStringSyncDetails( | 612 sync_ui_util::AddStringSyncDetails( |
| 613 cycles, "Sync Source", | 613 cycles, "Sync Source", |
| 614 csync::GetUpdatesSourceString( | 614 syncer::GetUpdatesSourceString( |
| 615 snapshot.source().updates_source)); | 615 snapshot.source().updates_source)); |
| 616 sync_ui_util::AddStringSyncDetails( | 616 sync_ui_util::AddStringSyncDetails( |
| 617 cycles, "Download Step Result", | 617 cycles, "Download Step Result", |
| 618 GetSyncerErrorString( | 618 GetSyncerErrorString( |
| 619 snapshot.model_neutral_state().last_download_updates_result)); | 619 snapshot.model_neutral_state().last_download_updates_result)); |
| 620 sync_ui_util::AddStringSyncDetails( | 620 sync_ui_util::AddStringSyncDetails( |
| 621 cycles, "Commit Step Result", | 621 cycles, "Commit Step Result", |
| 622 GetSyncerErrorString(snapshot.model_neutral_state().commit_result)); | 622 GetSyncerErrorString(snapshot.model_neutral_state().commit_result)); |
| 623 | 623 |
| 624 // Strictly increasing counters. | 624 // Strictly increasing counters. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 sync_ui_util::AddIntSyncDetail(transient_session, "Entries", | 709 sync_ui_util::AddIntSyncDetail(transient_session, "Entries", |
| 710 snapshot.num_entries()); | 710 snapshot.num_entries()); |
| 711 | 711 |
| 712 if (!full_status.throttled_types.Empty()) { | 712 if (!full_status.throttled_types.Empty()) { |
| 713 strings->Set("throttled_data_types", base::Value::CreateStringValue( | 713 strings->Set("throttled_data_types", base::Value::CreateStringValue( |
| 714 ModelTypeSetToString(full_status.throttled_types))); | 714 ModelTypeSetToString(full_status.throttled_types))); |
| 715 } | 715 } |
| 716 | 716 |
| 717 // Now set the actionable errors. | 717 // Now set the actionable errors. |
| 718 if ((full_status.sync_protocol_error.error_type != | 718 if ((full_status.sync_protocol_error.error_type != |
| 719 csync::UNKNOWN_ERROR) && | 719 syncer::UNKNOWN_ERROR) && |
| 720 (full_status.sync_protocol_error.error_type != | 720 (full_status.sync_protocol_error.error_type != |
| 721 csync::SYNC_SUCCESS)) { | 721 syncer::SYNC_SUCCESS)) { |
| 722 strings->Set("actionable_error_detected", | 722 strings->Set("actionable_error_detected", |
| 723 base::Value::CreateBooleanValue(true)); | 723 base::Value::CreateBooleanValue(true)); |
| 724 ListValue* actionable_error = new ListValue(); | 724 ListValue* actionable_error = new ListValue(); |
| 725 strings->Set("actionable_error", actionable_error); | 725 strings->Set("actionable_error", actionable_error); |
| 726 sync_ui_util::AddStringSyncDetails(actionable_error, "Error Type", | 726 sync_ui_util::AddStringSyncDetails(actionable_error, "Error Type", |
| 727 csync::GetSyncErrorTypeString( | 727 syncer::GetSyncErrorTypeString( |
| 728 full_status.sync_protocol_error.error_type)); | 728 full_status.sync_protocol_error.error_type)); |
| 729 sync_ui_util::AddStringSyncDetails(actionable_error, "Action", | 729 sync_ui_util::AddStringSyncDetails(actionable_error, "Action", |
| 730 csync::GetClientActionString( | 730 syncer::GetClientActionString( |
| 731 full_status.sync_protocol_error.action)); | 731 full_status.sync_protocol_error.action)); |
| 732 sync_ui_util::AddStringSyncDetails(actionable_error, "url", | 732 sync_ui_util::AddStringSyncDetails(actionable_error, "url", |
| 733 full_status.sync_protocol_error.url); | 733 full_status.sync_protocol_error.url); |
| 734 sync_ui_util::AddStringSyncDetails(actionable_error, "Error Description", | 734 sync_ui_util::AddStringSyncDetails(actionable_error, "Error Description", |
| 735 full_status.sync_protocol_error.error_description); | 735 full_status.sync_protocol_error.error_description); |
| 736 } else { | 736 } else { |
| 737 strings->Set("actionable_error_detected", | 737 strings->Set("actionable_error_detected", |
| 738 base::Value::CreateBooleanValue(false)); | 738 base::Value::CreateBooleanValue(false)); |
| 739 } | 739 } |
| 740 | 740 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 } | 775 } |
| 776 } else { | 776 } else { |
| 777 version_modifier = " " + version_modifier; | 777 version_modifier = " " + version_modifier; |
| 778 } | 778 } |
| 779 return chrome_version.Name() + " " + chrome_version.OSType() + " " + | 779 return chrome_version.Name() + " " + chrome_version.OSType() + " " + |
| 780 chrome_version.Version() + " (" + chrome_version.LastChange() + ")" + | 780 chrome_version.Version() + " (" + chrome_version.LastChange() + ")" + |
| 781 version_modifier; | 781 version_modifier; |
| 782 } | 782 } |
| 783 | 783 |
| 784 } // namespace sync_ui_util | 784 } // namespace sync_ui_util |
| OLD | NEW |