| 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" |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 639 |
| 640 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 640 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 641 } | 641 } |
| 642 | 642 |
| 643 void ProfileSyncService::ShowChooseDataTypes(gfx::NativeWindow parent_window) { | 643 void ProfileSyncService::ShowChooseDataTypes(gfx::NativeWindow parent_window) { |
| 644 if (WizardIsVisible()) { | 644 if (WizardIsVisible()) { |
| 645 wizard_.Focus(); | 645 wizard_.Focus(); |
| 646 return; | 646 return; |
| 647 } | 647 } |
| 648 wizard_.SetParent(parent_window); | 648 wizard_.SetParent(parent_window); |
| 649 wizard_.Step(SyncSetupWizard::CHOOSE_DATA_TYPES); | 649 wizard_.Step(SyncSetupWizard::CONFIGURE); |
| 650 } | 650 } |
| 651 | 651 |
| 652 SyncBackendHost::StatusSummary ProfileSyncService::QuerySyncStatusSummary() { | 652 SyncBackendHost::StatusSummary ProfileSyncService::QuerySyncStatusSummary() { |
| 653 if (backend_.get() && backend_initialized_) | 653 if (backend_.get() && backend_initialized_) |
| 654 return backend_->GetStatusSummary(); | 654 return backend_->GetStatusSummary(); |
| 655 else | 655 else |
| 656 return SyncBackendHost::Status::OFFLINE_UNUSABLE; | 656 return SyncBackendHost::Status::OFFLINE_UNUSABLE; |
| 657 } | 657 } |
| 658 | 658 |
| 659 SyncBackendHost::Status ProfileSyncService::QueryDetailedSyncStatus() { | 659 SyncBackendHost::Status ProfileSyncService::QueryDetailedSyncStatus() { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 registered_types->clear(); | 829 registered_types->clear(); |
| 830 // The data_type_controllers_ are determined by command-line flags; that's | 830 // The data_type_controllers_ are determined by command-line flags; that's |
| 831 // effectively what controls the values returned here. | 831 // effectively what controls the values returned here. |
| 832 for (DataTypeController::TypeMap::const_iterator it = | 832 for (DataTypeController::TypeMap::const_iterator it = |
| 833 data_type_controllers_.begin(); | 833 data_type_controllers_.begin(); |
| 834 it != data_type_controllers_.end(); ++it) { | 834 it != data_type_controllers_.end(); ++it) { |
| 835 registered_types->insert((*it).first); | 835 registered_types->insert((*it).first); |
| 836 } | 836 } |
| 837 } | 837 } |
| 838 | 838 |
| 839 bool ProfileSyncService::IsUsingSecondaryPassphrase() const { |
| 840 return profile_->GetPrefs()->GetBoolean(prefs::kSyncUsingSecondaryPassphrase); |
| 841 } |
| 842 |
| 843 void ProfileSyncService::SetSecondaryPassphrase(const std::string& passphrase) { |
| 844 SetPassphrase(passphrase); |
| 845 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingSecondaryPassphrase, true); |
| 846 } |
| 847 |
| 839 bool ProfileSyncService::IsCryptographerReady() const { | 848 bool ProfileSyncService::IsCryptographerReady() const { |
| 840 return backend_.get() && backend_->IsCryptographerReady(); | 849 return backend_.get() && backend_->IsCryptographerReady(); |
| 841 } | 850 } |
| 842 | 851 |
| 843 void ProfileSyncService::ConfigureDataTypeManager() { | 852 void ProfileSyncService::ConfigureDataTypeManager() { |
| 844 if (!data_type_manager_.get()) { | 853 if (!data_type_manager_.get()) { |
| 845 data_type_manager_.reset( | 854 data_type_manager_.reset( |
| 846 factory_->CreateDataTypeManager(backend_.get(), | 855 factory_->CreateDataTypeManager(backend_.get(), |
| 847 data_type_controllers_)); | 856 data_type_controllers_)); |
| 848 registrar_.Add(this, | 857 registrar_.Add(this, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 DCHECK(backend_.get()); | 933 DCHECK(backend_.get()); |
| 925 DCHECK(backend_->IsNigoriEnabled()); | 934 DCHECK(backend_->IsNigoriEnabled()); |
| 926 observed_passphrase_required_ = true; | 935 observed_passphrase_required_ = true; |
| 927 | 936 |
| 928 if (!cached_passphrase_.empty()) { | 937 if (!cached_passphrase_.empty()) { |
| 929 SetPassphrase(cached_passphrase_); | 938 SetPassphrase(cached_passphrase_); |
| 930 cached_passphrase_.clear(); | 939 cached_passphrase_.clear(); |
| 931 break; | 940 break; |
| 932 } | 941 } |
| 933 | 942 |
| 934 // TODO(sync): Show the passphrase UI here. | 943 if (SetupInProgress()) { |
| 935 UpdateAuthErrorState(GoogleServiceAuthError( | 944 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); |
| 936 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); | 945 } else { |
| 946 UpdateAuthErrorState(GoogleServiceAuthError( |
| 947 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); |
| 948 } |
| 937 break; | 949 break; |
| 938 } | 950 } |
| 939 case NotificationType::SYNC_DATA_TYPES_UPDATED: { | 951 case NotificationType::SYNC_DATA_TYPES_UPDATED: { |
| 940 if (!HasSyncSetupCompleted()) break; | 952 if (!HasSyncSetupCompleted()) break; |
| 941 | 953 |
| 942 syncable::ModelTypeSet types; | 954 syncable::ModelTypeSet types; |
| 943 GetPreferredDataTypes(&types); | 955 GetPreferredDataTypes(&types); |
| 944 OnUserChoseDatatypes(false, types); | 956 OnUserChoseDatatypes(false, types); |
| 945 break; | 957 break; |
| 946 } | 958 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 // is initialized, all enabled data types are consistent with one | 1048 // is initialized, all enabled data types are consistent with one |
| 1037 // another, and no unrecoverable error has transpired. | 1049 // another, and no unrecoverable error has transpired. |
| 1038 if (unrecoverable_error_detected_) | 1050 if (unrecoverable_error_detected_) |
| 1039 return false; | 1051 return false; |
| 1040 | 1052 |
| 1041 if (!data_type_manager_.get()) | 1053 if (!data_type_manager_.get()) |
| 1042 return false; | 1054 return false; |
| 1043 | 1055 |
| 1044 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1056 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| 1045 } | 1057 } |
| OLD | NEW |