OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CONTENT_SETTINGS_CONTENT_SETTINGS_EXTENSION_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_EXTENSION_PROVIDER_H_ |
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_EXTENSION_PROVIDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_EXTENSION_PROVIDER_H_ |
7 | 7 |
8 #include "chrome/browser/content_settings/content_settings_provider.h" | 8 #include "chrome/browser/content_settings/content_settings_provider.h" |
9 #include "chrome/browser/extensions/extension_content_settings_store.h" | 9 #include "chrome/browser/extensions/extension_content_settings_store.h" |
10 | 10 |
11 class ContentSettingsDetails; | 11 class ContentSettingsDetails; |
12 class HostContentSettingsMap; | |
12 class Profile; | 13 class Profile; |
13 | 14 |
14 namespace content_settings { | 15 namespace content_settings { |
15 | 16 |
16 // A content settings provider which uses settings defined by extensions. | 17 // A content settings provider which uses settings defined by extensions. |
battre
2011/07/06 09:12:05
nit: can we replace "uses" by "manages"?
Bernhard Bauer
2011/07/06 12:06:51
Done.
| |
17 class ExtensionProvider : public ProviderInterface, | 18 class ExtensionProvider : public ProviderInterface, |
18 public ExtensionContentSettingsStore::Observer { | 19 public ExtensionContentSettingsStore::Observer { |
19 public: | 20 public: |
20 ExtensionProvider(Profile* profile, | 21 ExtensionProvider(HostContentSettingsMap* map, |
battre
2011/07/06 09:12:05
nit: For someone not familiar with the code, it wo
Bernhard Bauer
2011/07/06 12:06:51
I added comments to the member variables below.
| |
21 ExtensionContentSettingsStore* extensions_settings, | 22 ExtensionContentSettingsStore* extensions_settings, |
22 bool incognito); | 23 bool incognito); |
23 | 24 |
24 virtual ~ExtensionProvider(); | 25 virtual ~ExtensionProvider(); |
25 | 26 |
26 // ProviderInterface methods: | 27 // ProviderInterface methods: |
27 virtual ContentSetting GetContentSetting( | 28 virtual ContentSetting GetContentSetting( |
28 const GURL& embedded_url, | 29 const GURL& embedded_url, |
29 const GURL& top_level_url, | 30 const GURL& top_level_url, |
30 ContentSettingsType content_type, | 31 ContentSettingsType content_type, |
31 const ResourceIdentifier& resource_identifier) const; | 32 const ResourceIdentifier& resource_identifier) const; |
32 | 33 |
33 virtual void SetContentSetting( | 34 virtual void SetContentSetting( |
34 const ContentSettingsPattern& embedded_url_pattern, | 35 const ContentSettingsPattern& embedded_url_pattern, |
35 const ContentSettingsPattern& top_level_url_pattern, | 36 const ContentSettingsPattern& top_level_url_pattern, |
36 ContentSettingsType content_type, | 37 ContentSettingsType content_type, |
37 const ResourceIdentifier& resource_identifier, | 38 const ResourceIdentifier& resource_identifier, |
38 ContentSetting content_setting) {} | 39 ContentSetting content_setting) {} |
39 | 40 |
40 // TODO(markusheintz): The UI needs a way to discover that these rules are | |
41 // managed by an extension. | |
42 virtual void GetAllContentSettingsRules( | 41 virtual void GetAllContentSettingsRules( |
43 ContentSettingsType content_type, | 42 ContentSettingsType content_type, |
44 const ResourceIdentifier& resource_identifier, | 43 const ResourceIdentifier& resource_identifier, |
45 Rules* content_setting_rules) const; | 44 Rules* content_setting_rules) const; |
46 | 45 |
47 virtual void ClearAllContentSettingsRules(ContentSettingsType content_type) {} | 46 virtual void ClearAllContentSettingsRules(ContentSettingsType content_type) {} |
48 | 47 |
49 virtual void ResetToDefaults() {} | 48 virtual void ResetToDefaults() {} |
50 | 49 |
50 virtual void ShutdownOnUIThread(); | |
51 | |
51 // ExtensionContentSettingsStore::Observer methods: | 52 // ExtensionContentSettingsStore::Observer methods: |
52 virtual void OnContentSettingChanged(const std::string& extension_id, | 53 virtual void OnContentSettingChanged(const std::string& extension_id, |
53 bool incognito); | 54 bool incognito); |
54 | 55 |
55 virtual void OnDestruction(); | |
56 | |
57 private: | 56 private: |
58 void NotifyObservers(const ContentSettingsDetails& details); | 57 void NotifyObservers(const ContentSettingsDetails& details); |
59 | 58 |
60 // TODO(markusheintz): That's only needed to send Notifications about changed | 59 // TODO(markusheintz): Make the HCSM an Observer of the |
61 // ContentSettings. This will be changed for all ContentSettingsProviders. | 60 // ContentSettingsProvider and send out the Notifications itself. |
62 // The HCSM will become an Observer of the ContentSettings Provider and send | 61 HostContentSettingsMap* map_; |
63 // out the Notifications itself. | |
64 Profile* profile_; | |
65 | 62 |
66 bool incognito_; | 63 bool incognito_; |
67 | 64 |
68 ExtensionContentSettingsStore* extensions_settings_; // Weak Pointer | 65 scoped_refptr<ExtensionContentSettingsStore> extensions_settings_; |
69 | 66 |
70 DISALLOW_COPY_AND_ASSIGN(ExtensionProvider); | 67 DISALLOW_COPY_AND_ASSIGN(ExtensionProvider); |
71 }; | 68 }; |
72 | 69 |
73 } // namespace content_settings | 70 } // namespace content_settings |
74 | 71 |
75 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_EXTENSION_PROVIDER_H _ | 72 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_EXTENSION_PROVIDER_H _ |
OLD | NEW |