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/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
12 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" | 15 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" |
15 #include "chrome/browser/extensions/api/preference/preference_helpers.h" | 16 #include "chrome/browser/extensions/api/preference/preference_helpers.h" |
16 #include "chrome/browser/extensions/api/proxy/proxy_api.h" | 17 #include "chrome/browser/extensions/api/proxy/proxy_api.h" |
17 #include "chrome/browser/extensions/extension_prefs.h" | 18 #include "chrome/browser/extensions/extension_prefs.h" |
18 #include "chrome/browser/extensions/extension_prefs_scope.h" | 19 #include "chrome/browser/extensions/extension_prefs_scope.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 315 } |
315 } | 316 } |
316 | 317 |
317 PreferenceAPI::~PreferenceAPI() { | 318 PreferenceAPI::~PreferenceAPI() { |
318 } | 319 } |
319 | 320 |
320 void PreferenceAPI::Shutdown() { | 321 void PreferenceAPI::Shutdown() { |
321 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 322 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
322 } | 323 } |
323 | 324 |
| 325 static base::LazyInstance<ProfileKeyedAPIFactory<PreferenceAPI> > |
| 326 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 327 |
| 328 // static |
| 329 ProfileKeyedAPIFactory<PreferenceAPI>* PreferenceAPI::GetFactoryInstance() { |
| 330 return &g_factory.Get(); |
| 331 } |
| 332 |
324 void PreferenceAPI::OnListenerAdded(const EventListenerInfo& details) { | 333 void PreferenceAPI::OnListenerAdded(const EventListenerInfo& details) { |
325 preference_event_router_.reset(new PreferenceEventRouter(profile_)); | 334 preference_event_router_.reset(new PreferenceEventRouter(profile_)); |
326 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 335 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
327 } | 336 } |
328 | 337 |
329 PreferenceFunction::~PreferenceFunction() { } | 338 PreferenceFunction::~PreferenceFunction() { } |
330 | 339 |
331 bool PreferenceFunction::ValidateBrowserPref( | 340 bool PreferenceFunction::ValidateBrowserPref( |
332 const std::string& extension_pref_key, | 341 const std::string& extension_pref_key, |
333 std::string* browser_pref_key) { | 342 std::string* browser_pref_key) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 if (!ValidateBrowserPref(pref_key, &browser_pref)) | 538 if (!ValidateBrowserPref(pref_key, &browser_pref)) |
530 return false; | 539 return false; |
531 | 540 |
532 ExtensionPrefs* prefs = | 541 ExtensionPrefs* prefs = |
533 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); | 542 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); |
534 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); | 543 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); |
535 return true; | 544 return true; |
536 } | 545 } |
537 | 546 |
538 } // namespace extensions | 547 } // namespace extensions |
OLD | NEW |