 Chromium Code Reviews
 Chromium Code Reviews Issue 12033093:
  sync: Implementation of Priority Preferences.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 12033093:
  sync: Implementation of Priority Preferences.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" | 
| 9 #include "base/prefs/public/pref_member.h" | 9 #include "base/prefs/public/pref_member.h" | 
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" | 
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 case syncer::HISTORY_DELETE_DIRECTIVES: | 321 case syncer::HISTORY_DELETE_DIRECTIVES: | 
| 322 return prefs::kSyncHistoryDeleteDirectives; | 322 return prefs::kSyncHistoryDeleteDirectives; | 
| 323 case syncer::SYNCED_NOTIFICATIONS: | 323 case syncer::SYNCED_NOTIFICATIONS: | 
| 324 return prefs::kSyncSyncedNotifications; | 324 return prefs::kSyncSyncedNotifications; | 
| 325 case syncer::DICTIONARY: | 325 case syncer::DICTIONARY: | 
| 326 return prefs::kSyncDictionary; | 326 return prefs::kSyncDictionary; | 
| 327 case syncer::FAVICON_IMAGES: | 327 case syncer::FAVICON_IMAGES: | 
| 328 return prefs::kSyncFaviconImages; | 328 return prefs::kSyncFaviconImages; | 
| 329 case syncer::FAVICON_TRACKING: | 329 case syncer::FAVICON_TRACKING: | 
| 330 return prefs::kSyncFaviconTracking; | 330 return prefs::kSyncFaviconTracking; | 
| 331 case syncer::PRIORITY_PREFERENCES: | |
| 332 return prefs::kSyncPriorityPreferences; | |
| 331 default: | 333 default: | 
| 332 break; | 334 break; | 
| 333 } | 335 } | 
| 334 NOTREACHED(); | 336 NOTREACHED(); | 
| 335 return NULL; | 337 return NULL; | 
| 336 } | 338 } | 
| 337 | 339 | 
| 338 #if defined(OS_CHROMEOS) | 340 #if defined(OS_CHROMEOS) | 
| 339 std::string SyncPrefs::GetSpareBootstrapToken() const { | 341 std::string SyncPrefs::GetSpareBootstrapToken() const { | 
| 340 DCHECK(CalledOnValidThread()); | 342 DCHECK(CalledOnValidThread()); | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 | 388 | 
| 387 void SyncPrefs::RegisterPrefGroups() { | 389 void SyncPrefs::RegisterPrefGroups() { | 
| 388 pref_groups_[syncer::APPS].Put(syncer::APP_NOTIFICATIONS); | 390 pref_groups_[syncer::APPS].Put(syncer::APP_NOTIFICATIONS); | 
| 389 pref_groups_[syncer::APPS].Put(syncer::APP_SETTINGS); | 391 pref_groups_[syncer::APPS].Put(syncer::APP_SETTINGS); | 
| 390 | 392 | 
| 391 pref_groups_[syncer::AUTOFILL].Put(syncer::AUTOFILL_PROFILE); | 393 pref_groups_[syncer::AUTOFILL].Put(syncer::AUTOFILL_PROFILE); | 
| 392 | 394 | 
| 393 pref_groups_[syncer::EXTENSIONS].Put(syncer::EXTENSION_SETTINGS); | 395 pref_groups_[syncer::EXTENSIONS].Put(syncer::EXTENSION_SETTINGS); | 
| 394 | 396 | 
| 395 pref_groups_[syncer::PREFERENCES].Put(syncer::DICTIONARY); | 397 pref_groups_[syncer::PREFERENCES].Put(syncer::DICTIONARY); | 
| 398 pref_groups_[syncer::PREFERENCES].Put(syncer::PRIORITY_PREFERENCES); | |
| 396 pref_groups_[syncer::PREFERENCES].Put(syncer::SEARCH_ENGINES); | 399 pref_groups_[syncer::PREFERENCES].Put(syncer::SEARCH_ENGINES); | 
| 397 | 400 | 
| 398 // TODO(zea): put favicons in the bookmarks group as well once it handles | 401 // TODO(zea): put favicons in the bookmarks group as well once it handles | 
| 399 // those favicons. | 402 // those favicons. | 
| 400 pref_groups_[syncer::SESSIONS].Put(syncer::FAVICON_IMAGES); | 403 pref_groups_[syncer::SESSIONS].Put(syncer::FAVICON_IMAGES); | 
| 401 pref_groups_[syncer::SESSIONS].Put(syncer::FAVICON_TRACKING); | 404 pref_groups_[syncer::SESSIONS].Put(syncer::FAVICON_TRACKING); | 
| 402 | 405 | 
| 403 // TODO(akalin): Revisit this once UI lands. | 406 // TODO(akalin): Revisit this once UI lands. | 
| 404 pref_groups_[syncer::SESSIONS].Put(syncer::HISTORY_DELETE_DIRECTIVES); | 407 pref_groups_[syncer::SESSIONS].Put(syncer::HISTORY_DELETE_DIRECTIVES); | 
| 405 } | 408 } | 
| (...skipping 28 matching lines...) Expand all Loading... | |
| 434 void SyncPrefs::SetDataTypePreferred( | 437 void SyncPrefs::SetDataTypePreferred( | 
| 435 syncer::ModelType type, bool is_preferred) { | 438 syncer::ModelType type, bool is_preferred) { | 
| 436 DCHECK(CalledOnValidThread()); | 439 DCHECK(CalledOnValidThread()); | 
| 437 CHECK(pref_service_); | 440 CHECK(pref_service_); | 
| 438 const char* pref_name = GetPrefNameForDataType(type); | 441 const char* pref_name = GetPrefNameForDataType(type); | 
| 439 if (!pref_name) { | 442 if (!pref_name) { | 
| 440 NOTREACHED(); | 443 NOTREACHED(); | 
| 441 return; | 444 return; | 
| 442 } | 445 } | 
| 443 pref_service_->SetBoolean(pref_name, is_preferred); | 446 pref_service_->SetBoolean(pref_name, is_preferred); | 
| 447 | |
| 448 if (type == syncer::PREFERENCES) { | |
| 
Nicolas Zea
2013/02/21 23:41:11
Why is this necessary? Don't the pref groups handl
 
albertb
2013/02/22 20:08:47
Done.
 | |
| 449 SetDataTypePreferred(syncer::PRIORITY_PREFERENCES, is_preferred); | |
| 450 } | |
| 444 } | 451 } | 
| 445 | 452 | 
| 446 syncer::ModelTypeSet SyncPrefs::ResolvePrefGroups( | 453 syncer::ModelTypeSet SyncPrefs::ResolvePrefGroups( | 
| 447 syncer::ModelTypeSet registered_types, | 454 syncer::ModelTypeSet registered_types, | 
| 448 syncer::ModelTypeSet types) const { | 455 syncer::ModelTypeSet types) const { | 
| 449 DCHECK(registered_types.HasAll(types)); | 456 DCHECK(registered_types.HasAll(types)); | 
| 450 syncer::ModelTypeSet types_with_groups = types; | 457 syncer::ModelTypeSet types_with_groups = types; | 
| 451 for (PrefGroupsMap::const_iterator i = pref_groups_.begin(); | 458 for (PrefGroupsMap::const_iterator i = pref_groups_.begin(); | 
| 452 i != pref_groups_.end(); ++i) { | 459 i != pref_groups_.end(); ++i) { | 
| 453 if (types.Has(i->first)) | 460 if (types.Has(i->first)) | 
| 454 types_with_groups.PutAll(i->second); | 461 types_with_groups.PutAll(i->second); | 
| 455 else | 462 else | 
| 456 types_with_groups.RemoveAll(i->second); | 463 types_with_groups.RemoveAll(i->second); | 
| 457 } | 464 } | 
| 458 types_with_groups.RetainAll(registered_types); | 465 types_with_groups.RetainAll(registered_types); | 
| 459 return types_with_groups; | 466 return types_with_groups; | 
| 460 } | 467 } | 
| 461 | 468 | 
| 462 } // namespace browser_sync | 469 } // namespace browser_sync | 
| OLD | NEW |