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