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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/prefs/pref_registry.h"
6
7 #include "base/logging.h"
8 #include "base/values.h"
9
10 PrefRegistry::PrefRegistry()
11 : defaults_(new DefaultPrefStore()) {
12 }
13
14 PrefRegistry::~PrefRegistry() {
15 }
16
17 scoped_refptr<PrefStore> PrefRegistry::defaults() {
18 return defaults_.get();
19 }
20
21 PrefRegistry::const_iterator PrefRegistry::begin() const {
22 return defaults_->begin();
23 }
24
25 PrefRegistry::const_iterator PrefRegistry::end() const {
26 return defaults_->end();
27 }
28
29 void PrefRegistry::SetRegistrationCallback(
30 const RegistrationCallback& callback) {
31 registration_callback_ = callback;
32 }
33
34 void PrefRegistry::SetUnregistrationCallback(
35 const UnregistrationCallback& callback) {
36 unregistration_callback_ = callback;
37 }
38
39 void PrefRegistry::DeprecatedUnregisterPreference(const char* path) {
40 DCHECK(defaults_->GetValue(path, NULL)) <<
41 "Trying to unregister an unregistered pref: " << path;
42
43 defaults_->RemoveDefaultValue(path);
44
45 if (!unregistration_callback_.is_null())
46 unregistration_callback_.Run(path);
47 }
48
49 void PrefRegistry::RegisterPreference(const char* path,
50 base::Value* default_value) {
51 base::Value::Type orig_type = default_value->GetType();
52 DCHECK(orig_type != Value::TYPE_NULL && orig_type != Value::TYPE_BINARY) <<
53 "invalid preference type: " << orig_type;
54
55 defaults_->SetDefaultValue(path, default_value);
56
57 if (!registration_callback_.is_null())
58 registration_callback_.Run(path, default_value);
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698