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

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: Update production interfaces based on review comments. Created 7 years, 11 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
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..6c8b84dbdac1ac6dedbf39b878f82a572360cf18
--- /dev/null
+++ b/chrome/browser/prefs/pref_registry.cc
@@ -0,0 +1,59 @@
+// 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/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 != Value::TYPE_NULL && orig_type != Value::TYPE_BINARY) <<
+ "invalid preference type: " << orig_type;
+
+ defaults_->SetDefaultValue(path, default_value);
+
+ if (!registration_callback_.is_null())
+ registration_callback_.Run(path, default_value);
+}

Powered by Google App Engine
This is Rietveld 408576698