OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CONTENT_SETTINGS_CONTENT_SETTINGS_SERVICE_
H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_SERVICE_
H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_SERVICE_
H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_SERVICE_
H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.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/extension_prefs_observer.h" | 10 #include "extensions/browser/extension_prefs_observer.h" |
11 | 11 |
12 namespace extensions { | 12 namespace extensions { |
13 | 13 |
14 class ContentSettingsStore; | 14 class ContentSettingsStore; |
15 class ExtensionPrefs; | 15 class ExtensionPrefs; |
16 | 16 |
17 // This service hosts a single ContentSettingsStore for the | 17 // This service hosts a single ContentSettingsStore for the |
18 // chrome.contentSettings API. | 18 // chrome.contentSettings API. |
19 class ContentSettingsService : public BrowserContextKeyedAPI, | 19 class ContentSettingsService : public BrowserContextKeyedAPI, |
20 public ExtensionPrefsObserver { | 20 public ExtensionPrefsObserver { |
21 public: | 21 public: |
22 explicit ContentSettingsService(content::BrowserContext* context); | 22 explicit ContentSettingsService(content::BrowserContext* context); |
23 virtual ~ContentSettingsService(); | 23 ~ContentSettingsService() override; |
24 | 24 |
25 scoped_refptr<ContentSettingsStore> content_settings_store() const { | 25 scoped_refptr<ContentSettingsStore> content_settings_store() const { |
26 return content_settings_store_; | 26 return content_settings_store_; |
27 } | 27 } |
28 | 28 |
29 // Convenience function to get the service for some browser context. | 29 // Convenience function to get the service for some browser context. |
30 static ContentSettingsService* Get(content::BrowserContext* context); | 30 static ContentSettingsService* Get(content::BrowserContext* context); |
31 | 31 |
32 // BrowserContextKeyedAPI implementation. | 32 // BrowserContextKeyedAPI implementation. |
33 static BrowserContextKeyedAPIFactory<ContentSettingsService>* | 33 static BrowserContextKeyedAPIFactory<ContentSettingsService>* |
34 GetFactoryInstance(); | 34 GetFactoryInstance(); |
35 | 35 |
36 // ExtensionPrefsObserver implementation. | 36 // ExtensionPrefsObserver implementation. |
37 virtual void OnExtensionRegistered(const std::string& extension_id, | 37 void OnExtensionRegistered(const std::string& extension_id, |
38 const base::Time& install_time, | 38 const base::Time& install_time, |
39 bool is_enabled) override; | 39 bool is_enabled) override; |
40 virtual void OnExtensionPrefsLoaded(const std::string& extension_id, | 40 void OnExtensionPrefsLoaded(const std::string& extension_id, |
41 const ExtensionPrefs* prefs) override; | 41 const ExtensionPrefs* prefs) override; |
42 virtual void OnExtensionPrefsDeleted(const std::string& extension_id) | 42 void OnExtensionPrefsDeleted(const std::string& extension_id) override; |
43 override; | 43 void OnExtensionStateChanged(const std::string& extension_id, |
44 virtual void OnExtensionStateChanged(const std::string& extension_id, | 44 bool state) override; |
45 bool state) override; | |
46 | 45 |
47 private: | 46 private: |
48 friend class BrowserContextKeyedAPIFactory<ContentSettingsService>; | 47 friend class BrowserContextKeyedAPIFactory<ContentSettingsService>; |
49 | 48 |
50 // BrowserContextKeyedAPI implementation. | 49 // BrowserContextKeyedAPI implementation. |
51 static const char* service_name() { return "ContentSettingsService"; } | 50 static const char* service_name() { return "ContentSettingsService"; } |
52 | 51 |
53 scoped_refptr<ContentSettingsStore> content_settings_store_; | 52 scoped_refptr<ContentSettingsStore> content_settings_store_; |
54 | 53 |
55 DISALLOW_COPY_AND_ASSIGN(ContentSettingsService); | 54 DISALLOW_COPY_AND_ASSIGN(ContentSettingsService); |
56 }; | 55 }; |
57 | 56 |
58 } // namespace extensions | 57 } // namespace extensions |
59 | 58 |
60 #endif // CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_SERVI
CE_H_ | 59 #endif // CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_SERVI
CE_H_ |
OLD | NEW |