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

Unified Diff: chrome/browser/prefs/pref_registry.cc

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix double registration in Chrome Frame test. Created 7 years, 10 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/prefs/pref_registry.h ('k') | chrome/browser/prefs/pref_registry_simple.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_registry.cc
diff --git a/chrome/browser/prefs/pref_registry.cc b/chrome/browser/prefs/pref_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c91aa8346bbbe13f52edd3d11865e2ef4e0e7de8
--- /dev/null
+++ b/chrome/browser/prefs/pref_registry.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/prefs/pref_registry.h"
+
+#include "base/logging.h"
+#include "base/prefs/default_pref_store.h"
+#include "base/prefs/pref_store.h"
+#include "base/values.h"
+
+PrefRegistry::PrefRegistry()
+ : defaults_(new DefaultPrefStore()) {
+}
+
+PrefRegistry::~PrefRegistry() {
+}
+
+scoped_refptr<PrefStore> PrefRegistry::defaults() {
+ return defaults_.get();
+}
+
+PrefRegistry::const_iterator PrefRegistry::begin() const {
+ return defaults_->begin();
+}
+
+PrefRegistry::const_iterator PrefRegistry::end() const {
+ return defaults_->end();
+}
+
+void PrefRegistry::SetRegistrationCallback(
+ const RegistrationCallback& callback) {
+ registration_callback_ = callback;
+}
+
+void PrefRegistry::SetUnregistrationCallback(
+ const UnregistrationCallback& callback) {
+ unregistration_callback_ = callback;
+}
+
+void PrefRegistry::DeprecatedUnregisterPreference(const char* path) {
+ DCHECK(defaults_->GetValue(path, NULL)) <<
+ "Trying to unregister an unregistered pref: " << path;
+
+ defaults_->RemoveDefaultValue(path);
+
+ if (!unregistration_callback_.is_null())
+ unregistration_callback_.Run(path);
+}
+
+void PrefRegistry::RegisterPreference(const char* path,
+ base::Value* default_value) {
+ base::Value::Type orig_type = default_value->GetType();
+ DCHECK(orig_type != base::Value::TYPE_NULL &&
+ orig_type != base::Value::TYPE_BINARY) <<
+ "invalid preference type: " << orig_type;
+ DCHECK(!defaults_->GetValue(path, NULL)) <<
+ "Trying to register a previously registered pref: " << path;
+
+ defaults_->SetDefaultValue(path, default_value);
+
+ if (!registration_callback_.is_null())
+ registration_callback_.Run(path, default_value);
+}
« no previous file with comments | « chrome/browser/prefs/pref_registry.h ('k') | chrome/browser/prefs/pref_registry_simple.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698