| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/histogram.h" | 15 #include "base/histogram.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/stl_util-inl.h" | 17 #include "base/stl_util-inl.h" |
| 18 #include "base/string16.h" |
| 18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 19 #include "base/task.h" | 20 #include "base/task.h" |
| 20 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 21 #include "chrome/browser/chrome_thread.h" | 22 #include "chrome/browser/chrome_thread.h" |
| 22 #include "chrome/browser/history/history_types.h" | 23 #include "chrome/browser/history/history_types.h" |
| 23 #include "chrome/browser/platform_util.h" | 24 #include "chrome/browser/platform_util.h" |
| 24 #include "chrome/browser/pref_service.h" | 25 #include "chrome/browser/pref_service.h" |
| 25 #include "chrome/browser/profile.h" | 26 #include "chrome/browser/profile.h" |
| 26 #include "chrome/browser/net/gaia/token_service.h" | 27 #include "chrome/browser/net/gaia/token_service.h" |
| 27 #include "chrome/browser/sync/engine/syncapi.h" | 28 #include "chrome/browser/sync/engine/syncapi.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 SyncBackendHost::Status status = | 549 SyncBackendHost::Status status = |
| 549 { SyncBackendHost::Status::OFFLINE_UNUSABLE }; | 550 { SyncBackendHost::Status::OFFLINE_UNUSABLE }; |
| 550 return status; | 551 return status; |
| 551 } | 552 } |
| 552 } | 553 } |
| 553 | 554 |
| 554 bool ProfileSyncService::SetupInProgress() const { | 555 bool ProfileSyncService::SetupInProgress() const { |
| 555 return !HasSyncSetupCompleted() && WizardIsVisible(); | 556 return !HasSyncSetupCompleted() && WizardIsVisible(); |
| 556 } | 557 } |
| 557 | 558 |
| 558 std::wstring ProfileSyncService::BuildSyncStatusSummaryText( | 559 std::string ProfileSyncService::BuildSyncStatusSummaryText( |
| 559 const sync_api::SyncManager::Status::Summary& summary) { | 560 const sync_api::SyncManager::Status::Summary& summary) { |
| 560 switch (summary) { | 561 switch (summary) { |
| 561 case sync_api::SyncManager::Status::OFFLINE: | 562 case sync_api::SyncManager::Status::OFFLINE: |
| 562 return L"OFFLINE"; | 563 return "OFFLINE"; |
| 563 case sync_api::SyncManager::Status::OFFLINE_UNSYNCED: | 564 case sync_api::SyncManager::Status::OFFLINE_UNSYNCED: |
| 564 return L"OFFLINE_UNSYNCED"; | 565 return "OFFLINE_UNSYNCED"; |
| 565 case sync_api::SyncManager::Status::SYNCING: | 566 case sync_api::SyncManager::Status::SYNCING: |
| 566 return L"SYNCING"; | 567 return "SYNCING"; |
| 567 case sync_api::SyncManager::Status::READY: | 568 case sync_api::SyncManager::Status::READY: |
| 568 return L"READY"; | 569 return "READY"; |
| 569 case sync_api::SyncManager::Status::CONFLICT: | 570 case sync_api::SyncManager::Status::CONFLICT: |
| 570 return L"CONFLICT"; | 571 return "CONFLICT"; |
| 571 case sync_api::SyncManager::Status::OFFLINE_UNUSABLE: | 572 case sync_api::SyncManager::Status::OFFLINE_UNUSABLE: |
| 572 return L"OFFLINE_UNUSABLE"; | 573 return "OFFLINE_UNUSABLE"; |
| 573 case sync_api::SyncManager::Status::INVALID: // fall through | 574 case sync_api::SyncManager::Status::INVALID: // fall through |
| 574 default: | 575 default: |
| 575 return L"UNKNOWN"; | 576 return "UNKNOWN"; |
| 576 } | 577 } |
| 577 } | 578 } |
| 578 | 579 |
| 579 std::wstring ProfileSyncService::GetLastSyncedTimeString() const { | 580 string16 ProfileSyncService::GetLastSyncedTimeString() const { |
| 580 if (last_synced_time_.is_null()) | 581 if (last_synced_time_.is_null()) |
| 581 return l10n_util::GetString(IDS_SYNC_TIME_NEVER); | 582 return l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER); |
| 582 | 583 |
| 583 base::TimeDelta last_synced = base::Time::Now() - last_synced_time_; | 584 base::TimeDelta last_synced = base::Time::Now() - last_synced_time_; |
| 584 | 585 |
| 585 if (last_synced < base::TimeDelta::FromMinutes(1)) | 586 if (last_synced < base::TimeDelta::FromMinutes(1)) |
| 586 return l10n_util::GetString(IDS_SYNC_TIME_JUST_NOW); | 587 return l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW); |
| 587 | 588 |
| 588 return TimeFormat::TimeElapsed(last_synced); | 589 return WideToUTF16Hack(TimeFormat::TimeElapsed(last_synced)); |
| 589 } | 590 } |
| 590 | 591 |
| 591 string16 ProfileSyncService::GetAuthenticatedUsername() const { | 592 string16 ProfileSyncService::GetAuthenticatedUsername() const { |
| 592 if (backend_.get()) | 593 if (backend_.get()) |
| 593 return backend_->GetAuthenticatedUsername(); | 594 return backend_->GetAuthenticatedUsername(); |
| 594 else | 595 else |
| 595 return string16(); | 596 return string16(); |
| 596 } | 597 } |
| 597 | 598 |
| 598 void ProfileSyncService::OnUserSubmittedAuth( | 599 void ProfileSyncService::OnUserSubmittedAuth( |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 // is initialized, all enabled data types are consistent with one | 831 // is initialized, all enabled data types are consistent with one |
| 831 // another, and no unrecoverable error has transpired. | 832 // another, and no unrecoverable error has transpired. |
| 832 if (unrecoverable_error_detected_) | 833 if (unrecoverable_error_detected_) |
| 833 return false; | 834 return false; |
| 834 | 835 |
| 835 if (!data_type_manager_.get()) | 836 if (!data_type_manager_.get()) |
| 836 return false; | 837 return false; |
| 837 | 838 |
| 838 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 839 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| 839 } | 840 } |
| OLD | NEW |