OLD | NEW |
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 "chrome/browser/extensions/api/preference/preference_api.h" | 5 #include "chrome/browser/extensions/api/preference/preference_api.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 { "translationServiceEnabled", | 111 { "translationServiceEnabled", |
112 prefs::kEnableTranslate, | 112 prefs::kEnableTranslate, |
113 APIPermission::kPrivacy | 113 APIPermission::kPrivacy |
114 } | 114 } |
115 }; | 115 }; |
116 | 116 |
117 class IdentityPrefTransformer : public PrefTransformerInterface { | 117 class IdentityPrefTransformer : public PrefTransformerInterface { |
118 public: | 118 public: |
119 virtual Value* ExtensionToBrowserPref(const Value* extension_pref, | 119 virtual Value* ExtensionToBrowserPref(const Value* extension_pref, |
120 std::string* error, | 120 std::string* error, |
121 bool* bad_message) { | 121 bool* bad_message) OVERRIDE { |
122 return extension_pref->DeepCopy(); | 122 return extension_pref->DeepCopy(); |
123 } | 123 } |
124 | 124 |
125 virtual Value* BrowserToExtensionPref(const Value* browser_pref) { | 125 virtual Value* BrowserToExtensionPref(const Value* browser_pref) OVERRIDE { |
126 return browser_pref->DeepCopy(); | 126 return browser_pref->DeepCopy(); |
127 } | 127 } |
128 }; | 128 }; |
129 | 129 |
130 class InvertBooleanTransformer : public PrefTransformerInterface { | 130 class InvertBooleanTransformer : public PrefTransformerInterface { |
131 public: | 131 public: |
132 virtual Value* ExtensionToBrowserPref(const Value* extension_pref, | 132 virtual Value* ExtensionToBrowserPref(const Value* extension_pref, |
133 std::string* error, | 133 std::string* error, |
134 bool* bad_message) { | 134 bool* bad_message) OVERRIDE { |
135 return InvertBooleanValue(extension_pref); | 135 return InvertBooleanValue(extension_pref); |
136 } | 136 } |
137 | 137 |
138 virtual Value* BrowserToExtensionPref(const Value* browser_pref) { | 138 virtual Value* BrowserToExtensionPref(const Value* browser_pref) OVERRIDE { |
139 return InvertBooleanValue(browser_pref); | 139 return InvertBooleanValue(browser_pref); |
140 } | 140 } |
141 | 141 |
142 private: | 142 private: |
143 static Value* InvertBooleanValue(const Value* value) { | 143 static Value* InvertBooleanValue(const Value* value) { |
144 bool bool_value = false; | 144 bool bool_value = false; |
145 bool result = value->GetAsBoolean(&bool_value); | 145 bool result = value->GetAsBoolean(&bool_value); |
146 DCHECK(result); | 146 DCHECK(result); |
147 return Value::CreateBooleanValue(!bool_value); | 147 return Value::CreateBooleanValue(!bool_value); |
148 } | 148 } |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 if (!ValidateBrowserPref(pref_key, &browser_pref)) | 538 if (!ValidateBrowserPref(pref_key, &browser_pref)) |
539 return false; | 539 return false; |
540 | 540 |
541 ExtensionPrefs* prefs = | 541 ExtensionPrefs* prefs = |
542 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); | 542 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); |
543 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); | 543 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); |
544 return true; | 544 return true; |
545 } | 545 } |
546 | 546 |
547 } // namespace extensions | 547 } // namespace extensions |
OLD | NEW |