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

Unified Diff: chrome/browser/pref_service.cc

Issue 2823037: Add an ExtensionPrefStore, layered between the user prefs nad the managed pre... (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_service.h ('k') | chrome/browser/pref_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/pref_service.cc
===================================================================
--- chrome/browser/pref_service.cc (revision 52073)
+++ chrome/browser/pref_service.cc (working copy)
@@ -30,6 +30,7 @@
#include "chrome/browser/dummy_configuration_policy_provider.h"
#include "chrome/browser/configuration_policy_pref_store.h"
+#include "chrome/browser/extensions/extension_pref_store.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/notification_service.h"
@@ -89,8 +90,10 @@
} // namespace
+// static
PrefService* PrefService::CreatePrefService(const FilePath& pref_filename) {
PrefStore* managed_prefs = NULL;
+ ExtensionPrefStore* extension_prefs = new ExtensionPrefStore(NULL);
PrefStore* local_prefs = new JsonPrefStore(
pref_filename,
ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE));
@@ -127,11 +130,30 @@
CommandLine::ForCurrentProcess(),
recommended_prefs_provider);
- // The PrefValueStore takes to ownership of the parameters.
+ // The PrefValueStore takes ownership of the PrefStores.
PrefValueStore* value_store = new PrefValueStore(
managed_prefs,
+ extension_prefs,
local_prefs,
recommended_prefs);
+
+ PrefService* pref_service = new PrefService(value_store);
+ extension_prefs->SetPrefService(pref_service);
+
+ return pref_service;
+}
+
+// static
+PrefService* PrefService::CreateUserPrefService(
+ const FilePath& pref_filename) {
+ PrefValueStore* value_store = new PrefValueStore(
+ NULL, /* no enforced prefs */
+ NULL, /* no extension prefs */
+ new JsonPrefStore(
+ pref_filename,
+ ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)),
+ /* user prefs */
+ NULL /* no advised prefs */);
return new PrefService(value_store);
}
@@ -376,6 +398,20 @@
return it == prefs_.end() ? NULL : *it;
}
+void PrefService::FireObserversIfChanged(const wchar_t* path,
+ const Value* old_value) {
+ if (PrefIsChanged(path, old_value))
+ FireObservers(path);
+}
+
+bool PrefService::PrefIsChanged(const wchar_t* path,
+ const Value* old_value) {
+ Value* new_value = NULL;
+ pref_value_store_->GetValue(path, &new_value);
+ // Some unit tests have no values for certain prefs.
+ return (!new_value || !old_value->Equals(new_value));
+}
+
const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
@@ -738,14 +774,6 @@
return pref->GetValue()->DeepCopy();
}
-void PrefService::FireObserversIfChanged(const wchar_t* path,
- const Value* old_value) {
- Value* new_value = NULL;
- pref_value_store_->GetValue(path, &new_value);
- if (!old_value->Equals(new_value))
- FireObservers(path);
-}
-
void PrefService::FireObservers(const wchar_t* path) {
DCHECK(CalledOnValidThread());
« no previous file with comments | « chrome/browser/pref_service.h ('k') | chrome/browser/pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698