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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 const bool pref_found = browser_pref->GetAsInteger(&int_value); | 206 const bool pref_found = browser_pref->GetAsInteger(&int_value); |
207 DCHECK(pref_found) << "Preference not found."; | 207 DCHECK(pref_found) << "Preference not found."; |
208 return new base::FundamentalValue( | 208 return new base::FundamentalValue( |
209 int_value != chrome_browser_net::NETWORK_PREDICTION_NEVER); | 209 int_value != chrome_browser_net::NETWORK_PREDICTION_NEVER); |
210 } | 210 } |
211 }; | 211 }; |
212 | 212 |
213 class PrefMapping { | 213 class PrefMapping { |
214 public: | 214 public: |
215 static PrefMapping* GetInstance() { | 215 static PrefMapping* GetInstance() { |
216 return Singleton<PrefMapping>::get(); | 216 return base::Singleton<PrefMapping>::get(); |
217 } | 217 } |
218 | 218 |
219 bool FindBrowserPrefForExtensionPref(const std::string& extension_pref, | 219 bool FindBrowserPrefForExtensionPref(const std::string& extension_pref, |
220 std::string* browser_pref, | 220 std::string* browser_pref, |
221 APIPermission::ID* read_permission, | 221 APIPermission::ID* read_permission, |
222 APIPermission::ID* write_permission) { | 222 APIPermission::ID* write_permission) { |
223 PrefMap::iterator it = mapping_.find(extension_pref); | 223 PrefMap::iterator it = mapping_.find(extension_pref); |
224 if (it != mapping_.end()) { | 224 if (it != mapping_.end()) { |
225 *browser_pref = it->second.pref_name; | 225 *browser_pref = it->second.pref_name; |
226 *read_permission = it->second.read_permission; | 226 *read_permission = it->second.read_permission; |
(...skipping 19 matching lines...) Expand all Loading... |
246 const std::string& browser_pref) { | 246 const std::string& browser_pref) { |
247 std::map<std::string, PrefTransformerInterface*>::iterator it = | 247 std::map<std::string, PrefTransformerInterface*>::iterator it = |
248 transformers_.find(browser_pref); | 248 transformers_.find(browser_pref); |
249 if (it != transformers_.end()) | 249 if (it != transformers_.end()) |
250 return it->second; | 250 return it->second; |
251 else | 251 else |
252 return identity_transformer_.get(); | 252 return identity_transformer_.get(); |
253 } | 253 } |
254 | 254 |
255 private: | 255 private: |
256 friend struct DefaultSingletonTraits<PrefMapping>; | 256 friend struct base::DefaultSingletonTraits<PrefMapping>; |
257 | 257 |
258 PrefMapping() { | 258 PrefMapping() { |
259 identity_transformer_.reset(new IdentityPrefTransformer()); | 259 identity_transformer_.reset(new IdentityPrefTransformer()); |
260 for (size_t i = 0; i < arraysize(kPrefMapping); ++i) { | 260 for (size_t i = 0; i < arraysize(kPrefMapping); ++i) { |
261 mapping_[kPrefMapping[i].extension_pref] = | 261 mapping_[kPrefMapping[i].extension_pref] = |
262 PrefMapData(kPrefMapping[i].browser_pref, | 262 PrefMapData(kPrefMapping[i].browser_pref, |
263 kPrefMapping[i].read_permission, | 263 kPrefMapping[i].read_permission, |
264 kPrefMapping[i].write_permission); | 264 kPrefMapping[i].write_permission); |
265 std::string event_name = | 265 std::string event_name = |
266 base::StringPrintf(kOnPrefChangeFormat, | 266 base::StringPrintf(kOnPrefChangeFormat, |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 pref_key, PreferenceFunction::PERMISSION_TYPE_WRITE, &browser_pref)) { | 776 pref_key, PreferenceFunction::PERMISSION_TYPE_WRITE, &browser_pref)) { |
777 return false; | 777 return false; |
778 } | 778 } |
779 | 779 |
780 PreferenceAPI::Get(GetProfile()) | 780 PreferenceAPI::Get(GetProfile()) |
781 ->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); | 781 ->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); |
782 return true; | 782 return true; |
783 } | 783 } |
784 | 784 |
785 } // namespace extensions | 785 } // namespace extensions |
OLD | NEW |