| 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);
|
| +}
|
|
|