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

Side by Side Diff: components/pref_registry/pref_registry_syncable.cc

Issue 399433005: Extirpate CreateBooleanValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/boolean/bool Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/pref_registry/pref_registry_syncable.h" 5 #include "components/pref_registry/pref_registry_syncable.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/prefs/default_pref_store.h" 8 #include "base/prefs/default_pref_store.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
12 12
13 namespace user_prefs { 13 namespace user_prefs {
14 14
15 namespace { 15 namespace {
16 16
17 // A helper function for RegisterLocalized*Pref that creates a Value* 17 // A helper function for RegisterLocalized*Pref that creates a Value*
18 // based on a localized resource. Because we control the values in a 18 // based on a localized resource. Because we control the values in a
19 // locale dll, this should always return a Value of the appropriate 19 // locale dll, this should always return a Value of the appropriate
20 // type. 20 // type.
21 base::Value* CreateLocaleDefaultValue(base::Value::Type type, 21 base::Value* CreateLocaleDefaultValue(base::Value::Type type,
22 int message_id) { 22 int message_id) {
23 const std::string resource_string = l10n_util::GetStringUTF8(message_id); 23 const std::string resource_string = l10n_util::GetStringUTF8(message_id);
24 DCHECK(!resource_string.empty()); 24 DCHECK(!resource_string.empty());
25 switch (type) { 25 switch (type) {
26 case base::Value::TYPE_BOOLEAN: { 26 case base::Value::TYPE_BOOLEAN: {
27 if ("true" == resource_string) 27 if ("true" == resource_string)
28 return base::Value::CreateBooleanValue(true); 28 return new base::FundamentalValue(true);
29 if ("false" == resource_string) 29 if ("false" == resource_string)
30 return base::Value::CreateBooleanValue(false); 30 return new base::FundamentalValue(false);
31 break; 31 break;
32 } 32 }
33 33
34 case base::Value::TYPE_INTEGER: { 34 case base::Value::TYPE_INTEGER: {
35 int val; 35 int val;
36 base::StringToInt(resource_string, &val); 36 base::StringToInt(resource_string, &val);
37 return base::Value::CreateIntegerValue(val); 37 return base::Value::CreateIntegerValue(val);
38 } 38 }
39 39
40 case base::Value::TYPE_DOUBLE: { 40 case base::Value::TYPE_DOUBLE: {
(...skipping 29 matching lines...) Expand all
70 } 70 }
71 71
72 void PrefRegistrySyncable::SetSyncableRegistrationCallback( 72 void PrefRegistrySyncable::SetSyncableRegistrationCallback(
73 const SyncableRegistrationCallback& cb) { 73 const SyncableRegistrationCallback& cb) {
74 callback_ = cb; 74 callback_ = cb;
75 } 75 }
76 76
77 void PrefRegistrySyncable::RegisterBooleanPref(const char* path, 77 void PrefRegistrySyncable::RegisterBooleanPref(const char* path,
78 bool default_value, 78 bool default_value,
79 PrefSyncStatus sync_status) { 79 PrefSyncStatus sync_status) {
80 RegisterSyncablePreference(path, 80 RegisterSyncablePreference(
81 base::Value::CreateBooleanValue(default_value), 81 path, new base::FundamentalValue(default_value), sync_status);
82 sync_status);
83 } 82 }
84 83
85 void PrefRegistrySyncable::RegisterIntegerPref(const char* path, 84 void PrefRegistrySyncable::RegisterIntegerPref(const char* path,
86 int default_value, 85 int default_value,
87 PrefSyncStatus sync_status) { 86 PrefSyncStatus sync_status) {
88 RegisterSyncablePreference(path, 87 RegisterSyncablePreference(path,
89 base::Value::CreateIntegerValue(default_value), 88 base::Value::CreateIntegerValue(default_value),
90 sync_status); 89 sync_status);
91 } 90 }
92 91
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { 220 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() {
222 // TODO(joi): We can directly reuse the same PrefRegistry once 221 // TODO(joi): We can directly reuse the same PrefRegistry once
223 // PrefService no longer registers for callbacks on registration and 222 // PrefService no longer registers for callbacks on registration and
224 // unregistration. 223 // unregistration.
225 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); 224 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable());
226 registry->defaults_ = defaults_; 225 registry->defaults_ = defaults_;
227 return registry; 226 return registry;
228 } 227 }
229 228
230 } // namespace user_prefs 229 } // namespace user_prefs
OLDNEW
« no previous file with comments | « components/policy/tools/generate_policy_source.py ('k') | extensions/browser/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698