| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/content_settings/content_settings_provider.h" | 10 #include "chrome/browser/content_settings/content_settings_observable_provider.h
" |
| 11 #include "chrome/browser/extensions/extension_content_settings_store.h" | 11 #include "chrome/browser/extensions/extension_content_settings_store.h" |
| 12 | 12 |
| 13 class ContentSettingsDetails; | 13 class ContentSettingsDetails; |
| 14 class HostContentSettingsMap; | 14 class HostContentSettingsMap; |
| 15 class Profile; | 15 class Profile; |
| 16 | 16 |
| 17 namespace content_settings { | 17 namespace content_settings { |
| 18 | 18 |
| 19 class Observer; |
| 20 |
| 19 // A content settings provider which manages settings defined by extensions. | 21 // A content settings provider which manages settings defined by extensions. |
| 20 class ExtensionProvider : public ProviderInterface, | 22 class ExtensionProvider : public ObservableProvider, |
| 21 public ExtensionContentSettingsStore::Observer { | 23 public ExtensionContentSettingsStore::Observer { |
| 22 public: | 24 public: |
| 23 ExtensionProvider(HostContentSettingsMap* map, | 25 ExtensionProvider(ExtensionContentSettingsStore* extensions_settings, |
| 24 ExtensionContentSettingsStore* extensions_settings, | |
| 25 bool incognito); | 26 bool incognito); |
| 26 | 27 |
| 27 virtual ~ExtensionProvider(); | 28 virtual ~ExtensionProvider(); |
| 28 | 29 |
| 29 // ProviderInterface methods: | 30 // Provider Interface implementations. |
| 30 virtual ContentSetting GetContentSetting( | 31 virtual ContentSetting GetContentSetting( |
| 31 const GURL& embedded_url, | 32 const GURL& embedded_url, |
| 32 const GURL& top_level_url, | 33 const GURL& top_level_url, |
| 33 ContentSettingsType content_type, | 34 ContentSettingsType content_type, |
| 34 const ResourceIdentifier& resource_identifier) const; | 35 const ResourceIdentifier& resource_identifier) const; |
| 35 | 36 |
| 36 virtual void SetContentSetting( | 37 virtual void SetContentSetting( |
| 37 const ContentSettingsPattern& embedded_url_pattern, | 38 const ContentSettingsPattern& embedded_url_pattern, |
| 38 const ContentSettingsPattern& top_level_url_pattern, | 39 const ContentSettingsPattern& top_level_url_pattern, |
| 39 ContentSettingsType content_type, | 40 ContentSettingsType content_type, |
| 40 const ResourceIdentifier& resource_identifier, | 41 const ResourceIdentifier& resource_identifier, |
| 41 ContentSetting content_setting) {} | 42 ContentSetting content_setting) {} |
| 42 | 43 |
| 43 virtual void GetAllContentSettingsRules( | 44 virtual void GetAllContentSettingsRules( |
| 44 ContentSettingsType content_type, | 45 ContentSettingsType content_type, |
| 45 const ResourceIdentifier& resource_identifier, | 46 const ResourceIdentifier& resource_identifier, |
| 46 Rules* content_setting_rules) const; | 47 Rules* content_setting_rules) const; |
| 47 | 48 |
| 48 virtual void ClearAllContentSettingsRules(ContentSettingsType content_type) {} | 49 virtual void ClearAllContentSettingsRules(ContentSettingsType content_type) {} |
| 49 | 50 |
| 50 virtual void ResetToDefaults() {} | 51 virtual void ResetToDefaults() {} |
| 51 | 52 |
| 52 virtual void ShutdownOnUIThread(); | 53 virtual void ShutdownOnUIThread(); |
| 53 | 54 |
| 54 // ExtensionContentSettingsStore::Observer methods: | 55 // ExtensionContentSettingsStore::Observer methods: |
| 55 virtual void OnContentSettingChanged(const std::string& extension_id, | 56 virtual void OnContentSettingChanged(const std::string& extension_id, |
| 56 bool incognito); | 57 bool incognito); |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 void NotifyObservers(const ContentSettingsDetails& details); | |
| 60 | |
| 61 // The HostContentSettingsMap this provider belongs to. It is only | |
| 62 // used as the source for notifications. | |
| 63 // TODO(markusheintz): Make the HCSM an Observer of the | |
| 64 // ContentSettingsProvider and send out the Notifications itself. | |
| 65 HostContentSettingsMap* map_; | |
| 66 | |
| 67 // Specifies whether this provider manages settings for incognito or regular | 60 // Specifies whether this provider manages settings for incognito or regular |
| 68 // sessions. | 61 // sessions. |
| 69 bool incognito_; | 62 bool incognito_; |
| 70 | 63 |
| 71 // The backend storing content setting rules defined by extensions. | 64 // The backend storing content setting rules defined by extensions. |
| 72 scoped_refptr<ExtensionContentSettingsStore> extensions_settings_; | 65 scoped_refptr<ExtensionContentSettingsStore> extensions_settings_; |
| 73 | 66 |
| 74 DISALLOW_COPY_AND_ASSIGN(ExtensionProvider); | 67 DISALLOW_COPY_AND_ASSIGN(ExtensionProvider); |
| 75 }; | 68 }; |
| 76 | 69 |
| 77 } // namespace content_settings | 70 } // namespace content_settings |
| 78 | 71 |
| 79 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_EXTENSION_PROVIDER_H
_ | 72 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_EXTENSION_PROVIDER_H
_ |
| OLD | NEW |