OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/prefs/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 // A helper function for RegisterLocalized*Pref that creates a Value* based on | 40 // A helper function for RegisterLocalized*Pref that creates a Value* based on |
41 // the string value in the locale dll. Because we control the values in a | 41 // the string value in the locale dll. Because we control the values in a |
42 // locale dll, this should always return a Value of the appropriate type. | 42 // locale dll, this should always return a Value of the appropriate type. |
43 Value* CreateLocaleDefaultValue(base::Value::Type type, int message_id) { | 43 Value* CreateLocaleDefaultValue(base::Value::Type type, int message_id) { |
44 std::string resource_string = l10n_util::GetStringUTF8(message_id); | 44 std::string resource_string = l10n_util::GetStringUTF8(message_id); |
45 DCHECK(!resource_string.empty()); | 45 DCHECK(!resource_string.empty()); |
46 switch (type) { | 46 switch (type) { |
47 case Value::TYPE_BOOLEAN: { | 47 case Value::TYPE_BOOLEAN: { |
48 if ("true" == resource_string) | 48 if ("true" == resource_string) |
49 return Value::CreateBooleanValue(true); | 49 return base::TrueValue(); |
50 if ("false" == resource_string) | 50 if ("false" == resource_string) |
51 return Value::CreateBooleanValue(false); | 51 return base::FalseValue(); |
52 break; | 52 break; |
53 } | 53 } |
54 | 54 |
55 case Value::TYPE_INTEGER: { | 55 case Value::TYPE_INTEGER: { |
56 int val; | 56 int val; |
57 base::StringToInt(resource_string, &val); | 57 base::StringToInt(resource_string, &val); |
58 return Value::CreateIntegerValue(val); | 58 return Value::CreateIntegerValue(val); |
59 } | 59 } |
60 | 60 |
61 case Value::TYPE_DOUBLE: { | 61 case Value::TYPE_DOUBLE: { |
62 double val; | 62 double val; |
63 base::StringToDouble(resource_string, &val); | 63 base::StringToDouble(resource_string, &val); |
64 return Value::CreateDoubleValue(val); | 64 return Value::CreateDoubleValue(val); |
65 } | 65 } |
66 | 66 |
67 case Value::TYPE_STRING: { | 67 case Value::TYPE_STRING: { |
68 return Value::CreateStringValue(resource_string); | 68 return Value::CreateStringValue(resource_string); |
69 } | 69 } |
70 | 70 |
71 default: { | 71 default: { |
72 NOTREACHED() << | 72 NOTREACHED() << |
73 "list and dictionary types cannot have default locale values"; | 73 "list and dictionary types cannot have default locale values"; |
74 } | 74 } |
75 } | 75 } |
76 NOTREACHED(); | 76 NOTREACHED(); |
77 return Value::CreateNullValue(); | 77 return base::NullValue(); |
78 } | 78 } |
79 | 79 |
80 // Forwards a notification after a PostMessage so that we can wait for the | 80 // Forwards a notification after a PostMessage so that we can wait for the |
81 // MessageLoop to run. | 81 // MessageLoop to run. |
82 void NotifyReadError(int message_id) { | 82 void NotifyReadError(int message_id) { |
83 ShowProfileErrorDialog(message_id); | 83 ShowProfileErrorDialog(message_id); |
84 } | 84 } |
85 | 85 |
86 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 86 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
87 class ReadErrorHandler : public PersistentPrefStore::ReadErrorDelegate { | 87 class ReadErrorHandler : public PersistentPrefStore::ReadErrorDelegate { |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); | 894 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); |
895 } | 895 } |
896 | 896 |
897 bool PrefService::Preference::IsUserModifiable() const { | 897 bool PrefService::Preference::IsUserModifiable() const { |
898 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); | 898 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); |
899 } | 899 } |
900 | 900 |
901 bool PrefService::Preference::IsExtensionModifiable() const { | 901 bool PrefService::Preference::IsExtensionModifiable() const { |
902 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); | 902 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); |
903 } | 903 } |
OLD | NEW |