Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/pref_value_store.cc

Issue 3051001: Adjust preference sync code to only sync user modifiable preferences. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: separate out the download_manager_unittest.cc fixes Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/pref_value_store.h" 5 #include "chrome/browser/pref_value_store.h"
6 6
7 PrefValueStore::PrefValueStore(PrefStore* managed_prefs, 7 PrefValueStore::PrefValueStore(PrefStore* managed_prefs,
8 PrefStore* extension_prefs, 8 PrefStore* extension_prefs,
9 PrefStore* command_line_prefs, 9 PrefStore* command_line_prefs,
10 PrefStore* user_prefs, 10 PrefStore* user_prefs,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 bool PrefValueStore::PrefValueInExtensionStore(const wchar_t* name) { 94 bool PrefValueStore::PrefValueInExtensionStore(const wchar_t* name) {
95 return PrefValueInStore(name, EXTENSION); 95 return PrefValueInStore(name, EXTENSION);
96 } 96 }
97 97
98 bool PrefValueStore::PrefValueInUserStore(const wchar_t* name) { 98 bool PrefValueStore::PrefValueInUserStore(const wchar_t* name) {
99 return PrefValueInStore(name, USER); 99 return PrefValueInStore(name, USER);
100 } 100 }
101 101
102 bool PrefValueStore::PrefValueFromExtensionStore(const wchar_t* name) { 102 bool PrefValueStore::PrefValueFromExtensionStore(const wchar_t* name) {
103 return PrefValueFromStore(name, EXTENSION); 103 return ControllingPrefStoreForPref(name) == EXTENSION;
104 } 104 }
105 105
106 bool PrefValueStore::PrefValueFromUserStore(const wchar_t* name) { 106 bool PrefValueStore::PrefValueFromUserStore(const wchar_t* name) {
107 return PrefValueFromStore(name, USER); 107 return ControllingPrefStoreForPref(name) == USER;
108 }
109
110 bool PrefValueStore::PrefValueUserModifiable(const wchar_t* name) {
111 PrefStoreType effective_store = ControllingPrefStoreForPref(name);
112 return effective_store >= USER || effective_store == INVALID;
108 } 113 }
109 114
110 bool PrefValueStore::PrefValueInStore(const wchar_t* name, PrefStoreType type) { 115 bool PrefValueStore::PrefValueInStore(const wchar_t* name, PrefStoreType type) {
111 if (pref_stores_[type].get() == NULL) { 116 if (pref_stores_[type].get() == NULL) {
112 // No store of that type set, so this pref can't be in it. 117 // No store of that type set, so this pref can't be in it.
113 return false; 118 return false;
114 } 119 }
115 Value* tmp_value; 120 Value* tmp_value;
116 return pref_stores_[type]->prefs()->Get(name, &tmp_value); 121 return pref_stores_[type]->prefs()->Get(name, &tmp_value);
117 } 122 }
118 123
119 bool PrefValueStore::PrefValueFromStore(const wchar_t* name, 124 PrefValueStore::PrefStoreType PrefValueStore::ControllingPrefStoreForPref(
120 PrefStoreType type) { 125 const wchar_t* name) {
121 // No need to look in PrefStores with lower priority than the one we want. 126 for (int i = 0; i <= PREF_STORE_TYPE_MAX; ++i) {
122 for (int i = 0; i <= type; ++i) {
123 if (PrefValueInStore(name, static_cast<PrefStoreType>(i))) 127 if (PrefValueInStore(name, static_cast<PrefStoreType>(i)))
124 return (i == type); 128 return static_cast<PrefStoreType>(i);
125 } 129 }
126 return false; 130 return INVALID;
127 } 131 }
OLDNEW
« no previous file with comments | « chrome/browser/pref_value_store.h ('k') | chrome/browser/sync/glue/preference_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698