Index: chrome/browser/extensions/extension_content_settings_provider.h |
diff --git a/chrome/browser/extensions/extension_content_settings_provider.h b/chrome/browser/extensions/extension_content_settings_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aba83cda72fcfe2b7012f5fee06a0434fb883901 |
--- /dev/null |
+++ b/chrome/browser/extensions/extension_content_settings_provider.h |
@@ -0,0 +1,138 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_PROVIDER_H_ |
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_PROVIDER_H_ |
+ |
+#include "chrome/browser/content_settings/content_settings_base.h" |
+#include "chrome/browser/content_settings/content_settings_provider.h" |
+#include "chrome/browser/extensions/extension_content_settings_store.h" |
+#include "content/common/notification_details.h" |
+ |
+class ContentSettingsDetails; |
+class Profile; |
+ |
+class ExtensionDefaultContentSettingsProvider |
+ : content_settings::DefaultProviderInterface, |
+ ExtensionContentSettingsStore::Observer { |
+ public: |
+ ExtensionDefaultContentSettingsProvider( |
+ Profile* profile, |
+ ExtensionContentSettingsStore* extensions_settings, |
+ bool incognito); |
+ |
+ virtual ~ExtensionDefaultContentSettingsProvider(); |
+ |
+ // content_settings::DefaultProviderInterface |
+ virtual ContentSetting ProvideDefaultSetting( |
+ ContentSettingsType content_type) const; |
+ |
+ virtual void UpdateDefaultSetting(ContentSettingsType content_type, |
+ ContentSetting setting) {} |
+ |
+ virtual void ResetToDefaults() {} |
+ |
+ virtual bool DefaultSettingIsManaged( |
+ ContentSettingsType content_type) const; |
+ |
+ // ExtensionContentSettingsStore::Observer |
+ void OnDefaultContentSettingChanged( |
+ const ContentSettingsType& type, |
+ ContentSetting setting, |
+ bool incognito); |
+ |
+ void OnContentSettingChanged( |
+ const ContentSettingsPattern& pattern, |
+ const ContentSettingsPattern& embedder_pattern, |
+ const ContentSettingsType& type, |
+ const content_settings::ResourceIdentifier& identifier, |
+ ContentSetting setting, |
+ bool incognito); |
+ |
+ void OnDestruction(); |
+ |
+ private: |
+ void NotifyObservers(const ContentSettingsDetails& details); |
+ |
+ Profile* profile_; |
+ |
+ bool incognito_; |
+ |
+ ExtensionContentSettingsStore* extensions_settings_; // Weak Pointer |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ExtensionDefaultContentSettingsProvider); |
+}; |
+ |
+class ExtensionContentSettingsProvider |
+ : content_settings::ProviderInterface, |
+ ExtensionContentSettingsStore::Observer { |
+ public: |
+ ExtensionContentSettingsProvider( |
+ Profile* profile, |
+ ExtensionContentSettingsStore* extensions_settings, |
+ bool incognito); |
+ |
+ virtual ~ExtensionContentSettingsProvider(); |
+ |
+ // Overrides from content_settings::ProviderInterface |
+ virtual bool ContentSettingsTypeIsManaged(ContentSettingsType content_type); |
+ |
+ virtual ContentSetting GetContentSetting( |
+ const GURL& requesting_url, |
+ const GURL& embedding_url, |
+ ContentSettingsType content_type, |
+ const ResourceIdentifier& resource_identifier) const; |
+ |
+ virtual void SetContentSetting( |
+ const ContentSettingsPattern& requesting_url_pattern, |
+ const ContentSettingsPattern& embedding_url_pattern, |
+ ContentSettingsType content_type, |
+ const ResourceIdentifier& resource_identifier, |
+ ContentSetting content_setting) {} |
+ |
+ // TODO(markusheintz): The UI needs a way to discover that these rules are |
+ // managed by an extension. |
+ virtual void GetAllContentSettingsRules( |
+ ContentSettingsType content_type, |
+ const ResourceIdentifier& resource_identifier, |
+ Rules* content_setting_rules) const; |
+ |
+ virtual void ClearAllContentSettingsRules( |
+ ContentSettingsType content_type) {} |
+ |
+ virtual void ResetToDefaults() {} |
+ |
+ // Overrides from ExtensionContentSettingsStore::Observer |
+ virtual void OnDefaultContentSettingChanged( |
+ const ContentSettingsType& type, |
+ ContentSetting setting, |
+ bool incognito); |
+ |
+ virtual void OnContentSettingChanged( |
+ const ContentSettingsPattern& pattern, |
+ const ContentSettingsPattern& embedder_pattern, |
+ const ContentSettingsType& type, |
+ const content_settings::ResourceIdentifier& identifier, |
+ ContentSetting setting, |
+ bool incognito); |
+ |
+ virtual void OnDestruction(); |
+ |
+ private: |
+ void NotifyObservers(const ContentSettingsDetails& details); |
+ |
+ // TODO(markusheintz): That's only needed to send Notifications about changed |
+ // ContentSettings. This will be changed for all ContentSettingsProviders. |
+ // The HCSM will become an Observer of the ContentSettings Provider and send |
+ // out the Notifications itselve. |
+ Profile* profile_; |
+ |
+ bool incognito_; |
+ |
+ ExtensionContentSettingsStore* extensions_settings_; // Weak Pointer |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ExtensionContentSettingsProvider); |
+}; |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_PROVIDER_H_ |