| 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_PREFERENCE_CHROME_DIRECT_SETTING_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__ |
| 7 | 7 |
| 8 #include "base/prefs/pref_change_registrar.h" | 8 #include "base/prefs/pref_change_registrar.h" |
| 9 #include "extensions/browser/browser_context_keyed_api_factory.h" | 9 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 10 #include "extensions/browser/event_router.h" | 10 #include "extensions/browser/event_router.h" |
| 11 | 11 |
| 12 class Profile; | 12 class Profile; |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class BrowserContext; | 15 class BrowserContext; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 namespace chromedirectsetting { | 19 namespace chromedirectsetting { |
| 20 | 20 |
| 21 class ChromeDirectSettingAPI : public BrowserContextKeyedAPI, | 21 class ChromeDirectSettingAPI : public BrowserContextKeyedAPI, |
| 22 public EventRouter::Observer { | 22 public EventRouter::Observer { |
| 23 public: | 23 public: |
| 24 explicit ChromeDirectSettingAPI(content::BrowserContext* context); | 24 explicit ChromeDirectSettingAPI(content::BrowserContext* context); |
| 25 | 25 |
| 26 virtual ~ChromeDirectSettingAPI(); | 26 virtual ~ChromeDirectSettingAPI(); |
| 27 | 27 |
| 28 // KeyedService implementation. | 28 // KeyedService implementation. |
| 29 virtual void Shutdown() OVERRIDE; | 29 virtual void Shutdown() override; |
| 30 | 30 |
| 31 // BrowserContextKeyedAPI implementation. | 31 // BrowserContextKeyedAPI implementation. |
| 32 static BrowserContextKeyedAPIFactory<ChromeDirectSettingAPI>* | 32 static BrowserContextKeyedAPIFactory<ChromeDirectSettingAPI>* |
| 33 GetFactoryInstance(); | 33 GetFactoryInstance(); |
| 34 | 34 |
| 35 // EventRouter::Observer implementation. | 35 // EventRouter::Observer implementation. |
| 36 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 36 virtual void OnListenerAdded(const EventListenerInfo& details) override; |
| 37 | 37 |
| 38 // Returns true if the preference is on the whitelist. | 38 // Returns true if the preference is on the whitelist. |
| 39 bool IsPreferenceOnWhitelist(const std::string& pref_key); | 39 bool IsPreferenceOnWhitelist(const std::string& pref_key); |
| 40 | 40 |
| 41 // Convenience method to get the ChromeDirectSettingAPI for a profile. | 41 // Convenience method to get the ChromeDirectSettingAPI for a profile. |
| 42 static ChromeDirectSettingAPI* Get(content::BrowserContext* context); | 42 static ChromeDirectSettingAPI* Get(content::BrowserContext* context); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 friend class BrowserContextKeyedAPIFactory<ChromeDirectSettingAPI>; | 45 friend class BrowserContextKeyedAPIFactory<ChromeDirectSettingAPI>; |
| 46 | 46 |
| 47 // BrowserContextKeyedAPI implementation. | 47 // BrowserContextKeyedAPI implementation. |
| 48 static const char* service_name(); | 48 static const char* service_name(); |
| 49 | 49 |
| 50 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key); | 50 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key); |
| 51 | 51 |
| 52 static const bool kServiceIsNULLWhileTesting = true; | 52 static const bool kServiceIsNULLWhileTesting = true; |
| 53 static const bool kServiceRedirectedInIncognito = false; | 53 static const bool kServiceRedirectedInIncognito = false; |
| 54 | 54 |
| 55 PrefChangeRegistrar registrar_; | 55 PrefChangeRegistrar registrar_; |
| 56 Profile* profile_; | 56 Profile* profile_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(ChromeDirectSettingAPI); | 58 DISALLOW_COPY_AND_ASSIGN(ChromeDirectSettingAPI); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace chromedirectsetting | 61 } // namespace chromedirectsetting |
| 62 } // namespace extensions | 62 } // namespace extensions |
| 63 | 63 |
| 64 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H_
_ | 64 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H_
_ |
| OLD | NEW |