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

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

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweaks 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"
(...skipping 26 matching lines...) Expand all
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: {
41 double val; 41 double val;
42 base::StringToDouble(resource_string, &val); 42 base::StringToDouble(resource_string, &val);
43 return base::Value::CreateDoubleValue(val); 43 return base::Value::CreateDoubleValue(val);
44 } 44 }
45 45
46 case base::Value::TYPE_STRING: { 46 case base::Value::TYPE_STRING: {
47 return base::Value::CreateStringValue(resource_string); 47 return new base::StringValue(resource_string);
48 } 48 }
49 49
50 default: { 50 default: {
51 NOTREACHED() << 51 NOTREACHED() <<
52 "list and dictionary types cannot have default locale values"; 52 "list and dictionary types cannot have default locale values";
53 } 53 }
54 } 54 }
55 NOTREACHED(); 55 NOTREACHED();
56 return base::Value::CreateNullValue(); 56 return base::Value::CreateNullValue();
57 } 57 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 double default_value, 94 double default_value,
95 PrefSyncStatus sync_status) { 95 PrefSyncStatus sync_status) {
96 RegisterSyncablePreference(path, 96 RegisterSyncablePreference(path,
97 base::Value::CreateDoubleValue(default_value), 97 base::Value::CreateDoubleValue(default_value),
98 sync_status); 98 sync_status);
99 } 99 }
100 100
101 void PrefRegistrySyncable::RegisterStringPref(const char* path, 101 void PrefRegistrySyncable::RegisterStringPref(const char* path,
102 const std::string& default_value, 102 const std::string& default_value,
103 PrefSyncStatus sync_status) { 103 PrefSyncStatus sync_status) {
104 RegisterSyncablePreference(path, 104 RegisterSyncablePreference(
105 base::Value::CreateStringValue(default_value), 105 path, new base::StringValue(default_value), sync_status);
106 sync_status);
107 } 106 }
108 107
109 void PrefRegistrySyncable::RegisterFilePathPref( 108 void PrefRegistrySyncable::RegisterFilePathPref(
110 const char* path, 109 const char* path,
111 const base::FilePath& default_value, 110 const base::FilePath& default_value,
112 PrefSyncStatus sync_status) { 111 PrefSyncStatus sync_status) {
113 RegisterSyncablePreference(path, 112 RegisterSyncablePreference(
114 base::Value::CreateStringValue( 113 path, new base::StringValue(default_value.value()), sync_status);
115 default_value.value()),
116 sync_status);
117 } 114 }
118 115
119 void PrefRegistrySyncable::RegisterListPref(const char* path, 116 void PrefRegistrySyncable::RegisterListPref(const char* path,
120 PrefSyncStatus sync_status) { 117 PrefSyncStatus sync_status) {
121 RegisterSyncablePreference(path, new base::ListValue(), sync_status); 118 RegisterSyncablePreference(path, new base::ListValue(), sync_status);
122 } 119 }
123 120
124 void PrefRegistrySyncable::RegisterListPref(const char* path, 121 void PrefRegistrySyncable::RegisterListPref(const char* path,
125 base::ListValue* default_value, 122 base::ListValue* default_value,
126 PrefSyncStatus sync_status) { 123 PrefSyncStatus sync_status) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 locale_default_message_id), 179 locale_default_message_id),
183 sync_status); 180 sync_status);
184 } 181 }
185 182
186 void PrefRegistrySyncable::RegisterInt64Pref( 183 void PrefRegistrySyncable::RegisterInt64Pref(
187 const char* path, 184 const char* path,
188 int64 default_value, 185 int64 default_value,
189 PrefSyncStatus sync_status) { 186 PrefSyncStatus sync_status) {
190 RegisterSyncablePreference( 187 RegisterSyncablePreference(
191 path, 188 path,
192 base::Value::CreateStringValue(base::Int64ToString(default_value)), 189 new base::StringValue(base::Int64ToString(default_value)),
193 sync_status); 190 sync_status);
194 } 191 }
195 192
196 void PrefRegistrySyncable::RegisterUint64Pref( 193 void PrefRegistrySyncable::RegisterUint64Pref(
197 const char* path, 194 const char* path,
198 uint64 default_value, 195 uint64 default_value,
199 PrefSyncStatus sync_status) { 196 PrefSyncStatus sync_status) {
200 RegisterSyncablePreference( 197 RegisterSyncablePreference(
201 path, 198 path,
202 base::Value::CreateStringValue(base::Uint64ToString(default_value)), 199 new base::StringValue(base::Uint64ToString(default_value)),
203 sync_status); 200 sync_status);
204 } 201 }
205 202
206 void PrefRegistrySyncable::RegisterSyncablePreference( 203 void PrefRegistrySyncable::RegisterSyncablePreference(
207 const char* path, 204 const char* path,
208 base::Value* default_value, 205 base::Value* default_value,
209 PrefSyncStatus sync_status) { 206 PrefSyncStatus sync_status) {
210 PrefRegistry::RegisterPreference(path, default_value); 207 PrefRegistry::RegisterPreference(path, default_value);
211 208
212 if (sync_status == PrefRegistrySyncable::SYNCABLE_PREF || 209 if (sync_status == PrefRegistrySyncable::SYNCABLE_PREF ||
213 sync_status == PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF) { 210 sync_status == PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF) {
214 syncable_preferences_[path] = sync_status; 211 syncable_preferences_[path] = sync_status;
215 212
216 if (!callback_.is_null()) 213 if (!callback_.is_null())
217 callback_.Run(path, sync_status); 214 callback_.Run(path, sync_status);
218 } 215 }
219 } 216 }
220 217
221 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { 218 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() {
222 // TODO(joi): We can directly reuse the same PrefRegistry once 219 // TODO(joi): We can directly reuse the same PrefRegistry once
223 // PrefService no longer registers for callbacks on registration and 220 // PrefService no longer registers for callbacks on registration and
224 // unregistration. 221 // unregistration.
225 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); 222 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable());
226 registry->defaults_ = defaults_; 223 registry->defaults_ = defaults_;
227 return registry; 224 return registry;
228 } 225 }
229 226
230 } // namespace user_prefs 227 } // namespace user_prefs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698