| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_
H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_
H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_
H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_API_
H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
| 13 #include "chrome/browser/search_engines/template_url_service.h" | 12 #include "chrome/browser/search_engines/template_url_service.h" |
| 14 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 16 | 16 |
| 17 class TemplateURL; | 17 class TemplateURL; |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 class SettingsOverridesAPI : public ProfileKeyedAPI, | 21 class SettingsOverridesAPI : public BrowserContextKeyedAPI, |
| 22 public content::NotificationObserver { | 22 public content::NotificationObserver { |
| 23 public: | 23 public: |
| 24 explicit SettingsOverridesAPI(content::BrowserContext* context); | 24 explicit SettingsOverridesAPI(content::BrowserContext* context); |
| 25 virtual ~SettingsOverridesAPI(); | 25 virtual ~SettingsOverridesAPI(); |
| 26 | 26 |
| 27 // ProfileKeyedAPI implementation. | 27 // BrowserContextKeyedAPI implementation. |
| 28 static ProfileKeyedAPIFactory<SettingsOverridesAPI>* GetFactoryInstance(); | 28 static BrowserContextKeyedAPIFactory<SettingsOverridesAPI>* |
| 29 GetFactoryInstance(); |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 friend class ProfileKeyedAPIFactory<SettingsOverridesAPI>; | 32 friend class BrowserContextKeyedAPIFactory<SettingsOverridesAPI>; |
| 32 | 33 |
| 33 typedef std::set<scoped_refptr<const Extension> > PendingExtensions; | 34 typedef std::set<scoped_refptr<const Extension> > PendingExtensions; |
| 34 | 35 |
| 35 // Wrappers around PreferenceAPI. | 36 // Wrappers around PreferenceAPI. |
| 36 void SetPref(const std::string& extension_id, | 37 void SetPref(const std::string& extension_id, |
| 37 const std::string& pref_key, | 38 const std::string& pref_key, |
| 38 base::Value* value); | 39 base::Value* value); |
| 39 void UnsetPref(const std::string& extension_id, | 40 void UnsetPref(const std::string& extension_id, |
| 40 const std::string& pref_key); | 41 const std::string& pref_key); |
| 41 // content::NotificationObserver implementation. | 42 // content::NotificationObserver implementation. |
| 42 virtual void Observe(int type, | 43 virtual void Observe(int type, |
| 43 const content::NotificationSource& source, | 44 const content::NotificationSource& source, |
| 44 const content::NotificationDetails& details) OVERRIDE; | 45 const content::NotificationDetails& details) OVERRIDE; |
| 45 // BrowserContextKeyedService implementation. | 46 // BrowserContextKeyedService implementation. |
| 46 virtual void Shutdown() OVERRIDE; | 47 virtual void Shutdown() OVERRIDE; |
| 47 | 48 |
| 48 void OnTemplateURLsLoaded(); | 49 void OnTemplateURLsLoaded(); |
| 49 | 50 |
| 50 void RegisterSearchProvider(const Extension* extension) const; | 51 void RegisterSearchProvider(const Extension* extension) const; |
| 51 // ProfileKeyedAPI implementation. | 52 // BrowserContextKeyedAPI implementation. |
| 52 static const char* service_name() { return "SettingsOverridesAPI"; } | 53 static const char* service_name() { return "SettingsOverridesAPI"; } |
| 53 | 54 |
| 54 Profile* profile_; | 55 Profile* profile_; |
| 55 TemplateURLService* url_service_; | 56 TemplateURLService* url_service_; |
| 56 | 57 |
| 57 // List of extensions waiting for the TemplateURLService to Load to | 58 // List of extensions waiting for the TemplateURLService to Load to |
| 58 // have search provider registered. | 59 // have search provider registered. |
| 59 PendingExtensions pending_extensions_; | 60 PendingExtensions pending_extensions_; |
| 60 | 61 |
| 61 content::NotificationRegistrar registrar_; | 62 content::NotificationRegistrar registrar_; |
| 62 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; | 63 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; |
| 63 | 64 |
| 64 DISALLOW_COPY_AND_ASSIGN(SettingsOverridesAPI); | 65 DISALLOW_COPY_AND_ASSIGN(SettingsOverridesAPI); |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 template <> | 68 template <> |
| 68 void ProfileKeyedAPIFactory<SettingsOverridesAPI>::DeclareFactoryDependencies(); | 69 void BrowserContextKeyedAPIFactory< |
| 70 SettingsOverridesAPI>::DeclareFactoryDependencies(); |
| 69 | 71 |
| 70 } // namespace extensions | 72 } // namespace extensions |
| 71 | 73 |
| 72 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_A
PI_H_ | 74 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_OVERRIDES_SETTINGS_OVERRIDES_A
PI_H_ |
| OLD | NEW |