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

Unified Diff: chrome/browser/pref_value_store.cc

Issue 2989002: Add methods for determining which PrefStore contains a given preference, and ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/pref_value_store.h ('k') | chrome/browser/pref_value_store_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/pref_value_store.cc
===================================================================
--- chrome/browser/pref_value_store.cc (revision 52169)
+++ chrome/browser/pref_value_store.cc (working copy)
@@ -68,18 +68,6 @@
return rv;
}
-// The value of a Preference is managed if the PrefStore for managed
-// preferences contains a value for the given preference |name|.
-bool PrefValueStore::PrefValueIsManaged(const wchar_t* name) {
- if (pref_stores_[MANAGED].get() == NULL) {
- // No managed PreferenceStore set, hence there are no managed
- // preferences.
- return false;
- }
- Value* tmp_value;
- return pref_stores_[MANAGED]->prefs()->Get(name, &tmp_value);
-}
-
// Note the |DictionaryValue| referenced by the |PrefStore| user_prefs_
// (returned by the method prefs()) takes the ownership of the Value referenced
// by in_value.
@@ -96,3 +84,42 @@
pref_stores_[USER]->prefs()->Remove(name, NULL);
}
}
+
+bool PrefValueStore::PrefValueInManagedStore(const wchar_t* name) {
+ return PrefValueInStore(name, MANAGED);
+}
+
+bool PrefValueStore::PrefValueInExtensionStore(const wchar_t* name) {
+ return PrefValueInStore(name, EXTENSION);
+}
+
+bool PrefValueStore::PrefValueInUserStore(const wchar_t* name) {
+ return PrefValueInStore(name, USER);
+}
+
+bool PrefValueStore::PrefValueFromExtensionStore(const wchar_t* name) {
+ return PrefValueFromStore(name, EXTENSION);
+}
+
+bool PrefValueStore::PrefValueFromUserStore(const wchar_t* name) {
+ return PrefValueFromStore(name, USER);
+}
+
+bool PrefValueStore::PrefValueInStore(const wchar_t* name, PrefStoreType type) {
+ if (pref_stores_[type].get() == NULL) {
+ // No store of that type set, so this pref can't be in it.
+ return false;
+ }
+ Value* tmp_value;
+ return pref_stores_[type]->prefs()->Get(name, &tmp_value);
+}
+
+bool PrefValueStore::PrefValueFromStore(const wchar_t* name,
+ PrefStoreType type) {
+ // No need to look in PrefStores with lower priority than the one we want.
+ for (int i = 0; i <= type; ++i) {
+ if (PrefValueInStore(name, static_cast<PrefStoreType>(i)))
+ return (i == type);
+ }
+ return false;
+}
« no previous file with comments | « chrome/browser/pref_value_store.h ('k') | chrome/browser/pref_value_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698