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

Side by Side Diff: chrome/browser/extensions/api/preference/preference_api.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add blank lines Created 5 years, 3 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
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 "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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 const bool pref_found = browser_pref->GetAsInteger(&int_value); 204 const bool pref_found = browser_pref->GetAsInteger(&int_value);
205 DCHECK(pref_found) << "Preference not found."; 205 DCHECK(pref_found) << "Preference not found.";
206 return new base::FundamentalValue( 206 return new base::FundamentalValue(
207 int_value != chrome_browser_net::NETWORK_PREDICTION_NEVER); 207 int_value != chrome_browser_net::NETWORK_PREDICTION_NEVER);
208 } 208 }
209 }; 209 };
210 210
211 class PrefMapping { 211 class PrefMapping {
212 public: 212 public:
213 static PrefMapping* GetInstance() { 213 static PrefMapping* GetInstance() {
214 return Singleton<PrefMapping>::get(); 214 return base::Singleton<PrefMapping>::get();
215 } 215 }
216 216
217 bool FindBrowserPrefForExtensionPref(const std::string& extension_pref, 217 bool FindBrowserPrefForExtensionPref(const std::string& extension_pref,
218 std::string* browser_pref, 218 std::string* browser_pref,
219 APIPermission::ID* read_permission, 219 APIPermission::ID* read_permission,
220 APIPermission::ID* write_permission) { 220 APIPermission::ID* write_permission) {
221 PrefMap::iterator it = mapping_.find(extension_pref); 221 PrefMap::iterator it = mapping_.find(extension_pref);
222 if (it != mapping_.end()) { 222 if (it != mapping_.end()) {
223 *browser_pref = it->second.pref_name; 223 *browser_pref = it->second.pref_name;
224 *read_permission = it->second.read_permission; 224 *read_permission = it->second.read_permission;
(...skipping 19 matching lines...) Expand all
244 const std::string& browser_pref) { 244 const std::string& browser_pref) {
245 std::map<std::string, PrefTransformerInterface*>::iterator it = 245 std::map<std::string, PrefTransformerInterface*>::iterator it =
246 transformers_.find(browser_pref); 246 transformers_.find(browser_pref);
247 if (it != transformers_.end()) 247 if (it != transformers_.end())
248 return it->second; 248 return it->second;
249 else 249 else
250 return identity_transformer_.get(); 250 return identity_transformer_.get();
251 } 251 }
252 252
253 private: 253 private:
254 friend struct DefaultSingletonTraits<PrefMapping>; 254 friend struct base::DefaultSingletonTraits<PrefMapping>;
255 255
256 PrefMapping() { 256 PrefMapping() {
257 identity_transformer_.reset(new IdentityPrefTransformer()); 257 identity_transformer_.reset(new IdentityPrefTransformer());
258 for (size_t i = 0; i < arraysize(kPrefMapping); ++i) { 258 for (size_t i = 0; i < arraysize(kPrefMapping); ++i) {
259 mapping_[kPrefMapping[i].extension_pref] = 259 mapping_[kPrefMapping[i].extension_pref] =
260 PrefMapData(kPrefMapping[i].browser_pref, 260 PrefMapData(kPrefMapping[i].browser_pref,
261 kPrefMapping[i].read_permission, 261 kPrefMapping[i].read_permission,
262 kPrefMapping[i].write_permission); 262 kPrefMapping[i].write_permission);
263 std::string event_name = 263 std::string event_name =
264 base::StringPrintf(kOnPrefChangeFormat, 264 base::StringPrintf(kOnPrefChangeFormat,
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 pref_key, PreferenceFunction::PERMISSION_TYPE_WRITE, &browser_pref)) { 773 pref_key, PreferenceFunction::PERMISSION_TYPE_WRITE, &browser_pref)) {
774 return false; 774 return false;
775 } 775 }
776 776
777 PreferenceAPI::Get(GetProfile()) 777 PreferenceAPI::Get(GetProfile())
778 ->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); 778 ->RemoveExtensionControlledPref(extension_id(), browser_pref, scope);
779 return true; 779 return true;
780 } 780 }
781 781
782 } // namespace extensions 782 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698