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_prefs.h" | 5 #include "chrome/browser/sync/sync_prefs.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 DCHECK(CalledOnValidThread()); | 45 DCHECK(CalledOnValidThread()); |
46 sync_pref_observers_.RemoveObserver(sync_pref_observer); | 46 sync_pref_observers_.RemoveObserver(sync_pref_observer); |
47 } | 47 } |
48 | 48 |
49 void SyncPrefs::ClearPreferences() { | 49 void SyncPrefs::ClearPreferences() { |
50 DCHECK(CalledOnValidThread()); | 50 DCHECK(CalledOnValidThread()); |
51 CHECK(pref_service_); | 51 CHECK(pref_service_); |
52 pref_service_->ClearPref(prefs::kSyncLastSyncedTime); | 52 pref_service_->ClearPref(prefs::kSyncLastSyncedTime); |
53 pref_service_->ClearPref(prefs::kSyncHasSetupCompleted); | 53 pref_service_->ClearPref(prefs::kSyncHasSetupCompleted); |
54 pref_service_->ClearPref(prefs::kSyncEncryptionBootstrapToken); | 54 pref_service_->ClearPref(prefs::kSyncEncryptionBootstrapToken); |
| 55 pref_service_->ClearPref(prefs::kSyncKeystoreEncryptionBootstrapToken); |
55 | 56 |
56 // TODO(nick): The current behavior does not clear | 57 // TODO(nick): The current behavior does not clear |
57 // e.g. prefs::kSyncBookmarks. Is that really what we want? | 58 // e.g. prefs::kSyncBookmarks. Is that really what we want? |
58 } | 59 } |
59 | 60 |
60 bool SyncPrefs::HasSyncSetupCompleted() const { | 61 bool SyncPrefs::HasSyncSetupCompleted() const { |
61 DCHECK(CalledOnValidThread()); | 62 DCHECK(CalledOnValidThread()); |
62 return | 63 return |
63 pref_service_ && | 64 pref_service_ && |
64 pref_service_->GetBoolean(prefs::kSyncHasSetupCompleted); | 65 pref_service_->GetBoolean(prefs::kSyncHasSetupCompleted); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return | 171 return |
171 pref_service_ ? | 172 pref_service_ ? |
172 pref_service_->GetString(prefs::kSyncEncryptionBootstrapToken) : ""; | 173 pref_service_->GetString(prefs::kSyncEncryptionBootstrapToken) : ""; |
173 } | 174 } |
174 | 175 |
175 void SyncPrefs::SetEncryptionBootstrapToken(const std::string& token) { | 176 void SyncPrefs::SetEncryptionBootstrapToken(const std::string& token) { |
176 DCHECK(CalledOnValidThread()); | 177 DCHECK(CalledOnValidThread()); |
177 pref_service_->SetString(prefs::kSyncEncryptionBootstrapToken, token); | 178 pref_service_->SetString(prefs::kSyncEncryptionBootstrapToken, token); |
178 } | 179 } |
179 | 180 |
| 181 std::string SyncPrefs::GetKeystoreEncryptionBootstrapToken() const { |
| 182 DCHECK(CalledOnValidThread()); |
| 183 return |
| 184 pref_service_ ? |
| 185 pref_service_->GetString(prefs::kSyncKeystoreEncryptionBootstrapToken) : |
| 186 ""; |
| 187 } |
| 188 |
| 189 void SyncPrefs::SetKeystoreEncryptionBootstrapToken(const std::string& token) { |
| 190 DCHECK(CalledOnValidThread()); |
| 191 pref_service_->SetString(prefs::kSyncKeystoreEncryptionBootstrapToken, token); |
| 192 } |
| 193 |
180 // static | 194 // static |
181 const char* SyncPrefs::GetPrefNameForDataType(syncer::ModelType data_type) { | 195 const char* SyncPrefs::GetPrefNameForDataType(syncer::ModelType data_type) { |
182 switch (data_type) { | 196 switch (data_type) { |
183 case syncer::BOOKMARKS: | 197 case syncer::BOOKMARKS: |
184 return prefs::kSyncBookmarks; | 198 return prefs::kSyncBookmarks; |
185 case syncer::PASSWORDS: | 199 case syncer::PASSWORDS: |
186 return prefs::kSyncPasswords; | 200 return prefs::kSyncPasswords; |
187 case syncer::PREFERENCES: | 201 case syncer::PREFERENCES: |
188 return prefs::kSyncPreferences; | 202 return prefs::kSyncPreferences; |
189 case syncer::AUTOFILL: | 203 case syncer::AUTOFILL: |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 346 } |
333 RegisterDataTypePreferredPref(type, enable_by_default); | 347 RegisterDataTypePreferredPref(type, enable_by_default); |
334 } | 348 } |
335 | 349 |
336 pref_service_->RegisterBooleanPref(prefs::kSyncManaged, | 350 pref_service_->RegisterBooleanPref(prefs::kSyncManaged, |
337 false, | 351 false, |
338 PrefService::UNSYNCABLE_PREF); | 352 PrefService::UNSYNCABLE_PREF); |
339 pref_service_->RegisterStringPref(prefs::kSyncEncryptionBootstrapToken, | 353 pref_service_->RegisterStringPref(prefs::kSyncEncryptionBootstrapToken, |
340 "", | 354 "", |
341 PrefService::UNSYNCABLE_PREF); | 355 PrefService::UNSYNCABLE_PREF); |
| 356 pref_service_->RegisterStringPref( |
| 357 prefs::kSyncKeystoreEncryptionBootstrapToken, |
| 358 "", |
| 359 PrefService::UNSYNCABLE_PREF); |
342 #if defined(OS_CHROMEOS) | 360 #if defined(OS_CHROMEOS) |
343 pref_service_->RegisterStringPref(prefs::kSyncSpareBootstrapToken, | 361 pref_service_->RegisterStringPref(prefs::kSyncSpareBootstrapToken, |
344 "", | 362 "", |
345 PrefService::UNSYNCABLE_PREF); | 363 PrefService::UNSYNCABLE_PREF); |
346 #endif | 364 #endif |
347 | 365 |
348 // We will start prompting people about new data types after the launch of | 366 // We will start prompting people about new data types after the launch of |
349 // SESSIONS - all previously launched data types are treated as if they are | 367 // SESSIONS - all previously launched data types are treated as if they are |
350 // already acknowledged. | 368 // already acknowledged. |
351 syncer::ModelTypeSet model_set; | 369 syncer::ModelTypeSet model_set; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (types.Has(i->first)) | 433 if (types.Has(i->first)) |
416 types_with_groups.PutAll(i->second); | 434 types_with_groups.PutAll(i->second); |
417 else | 435 else |
418 types_with_groups.RemoveAll(i->second); | 436 types_with_groups.RemoveAll(i->second); |
419 } | 437 } |
420 types_with_groups.RetainAll(registered_types); | 438 types_with_groups.RetainAll(registered_types); |
421 return types_with_groups; | 439 return types_with_groups; |
422 } | 440 } |
423 | 441 |
424 } // namespace browser_sync | 442 } // namespace browser_sync |
OLD | NEW |