Chromium Code Reviews| 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 // Interface for objects providing content setting rules. | 5 // Interface for objects providing content setting rules. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ | 7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ |
| 8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ | 8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| 11 #include <string> | |
| 12 #include <utility> | |
| 13 #include <vector> | |
| 14 | |
| 15 #include "chrome/browser/content_settings/content_settings_pattern.h" | |
| 11 #include "chrome/common/content_settings.h" | 16 #include "chrome/common/content_settings.h" |
| 12 | 17 |
| 18 class GURL; | |
| 19 | |
| 20 namespace content_settings { | |
| 21 | |
| 13 class DefaultContentSettingsProvider { | 22 class DefaultContentSettingsProvider { |
| 14 public: | 23 public: |
| 15 virtual ~DefaultContentSettingsProvider() {} | 24 virtual ~DefaultContentSettingsProvider() {} |
| 16 | 25 |
| 17 // True if this provider can provide a default setting for the |content_type|. | 26 // True if this provider can provide a default setting for the |content_type|. |
| 18 virtual bool CanProvideDefaultSetting( | 27 virtual bool CanProvideDefaultSetting( |
| 19 ContentSettingsType content_type) const = 0; | 28 ContentSettingsType content_type) const = 0; |
| 20 | 29 |
| 21 // Returns the default content setting this provider has for the given | 30 // Returns the default content setting this provider has for the given |
| 22 // |content_type|, or CONTENT_SETTING_DEFAULT if nothing be provided for this | 31 // |content_type|, or CONTENT_SETTING_DEFAULT if nothing be provided for this |
| 23 // type. | 32 // type. |
| 24 virtual ContentSetting ProvideDefaultSetting( | 33 virtual ContentSetting ProvideDefaultSetting( |
| 25 ContentSettingsType content_type) const = 0; | 34 ContentSettingsType content_type) const = 0; |
| 26 | 35 |
| 27 // Notifies the provider that the host content settings map would like to | 36 // Notifies the provider that the host content settings map would like to |
| 28 // update the default setting for the given |content_type|. The provider may | 37 // update the default setting for the given |content_type|. The provider may |
| 29 // ignore this. | 38 // ignore this. |
| 30 virtual void UpdateDefaultSetting(ContentSettingsType content_type, | 39 virtual void UpdateDefaultSetting(ContentSettingsType content_type, |
| 31 ContentSetting setting) = 0; | 40 ContentSetting setting) = 0; |
| 32 | 41 |
| 33 // Resets the state of the provider to the default. | 42 // Resets the state of the provider to the default. |
| 34 virtual void ResetToDefaults() = 0; | 43 virtual void ResetToDefaults() = 0; |
| 35 | 44 |
| 36 // True if the default setting for the |content_type| is policy managed, i.e., | 45 // True if the default setting for the |content_type| is policy managed, i.e., |
| 37 // there shouldn't be any UI shown to modify this setting. | 46 // there shouldn't be any UI shown to modify this setting. |
| 38 virtual bool DefaultSettingIsManaged( | 47 virtual bool DefaultSettingIsManaged( |
| 39 ContentSettingsType content_type) const = 0; | 48 ContentSettingsType content_type) const = 0; |
| 40 }; | 49 }; |
| 41 | 50 |
| 51 struct ContentSettingsRule { | |
| 52 ContentSettingsRule() {} | |
| 53 ContentSettingsRule(const ContentSettingsPattern& requesting_url_pattern, | |
| 54 const ContentSettingsPattern& embedding_url_pattern, | |
| 55 ContentSetting& setting) | |
| 56 : requesting_url_pattern_(requesting_url_pattern), | |
|
Bernhard Bauer
2011/01/27 09:54:26
Nit: The colon should be indented four spaces w/r/
markusheintz_
2011/01/27 10:24:37
Done.
| |
| 57 embedding_url_pattern_(embedding_url_pattern), | |
| 58 content_setting_(setting) {} | |
| 59 | |
| 60 const ContentSettingsPattern requesting_url_pattern_; | |
| 61 const ContentSettingsPattern embedding_url_pattern_; | |
| 62 ContentSetting content_setting_; | |
| 63 }; | |
| 64 | |
| 65 typedef std::vector<ContentSettingsRule> ContentSettingsRules; | |
| 66 | |
| 67 class ContentSettingsProvider { | |
| 68 public: | |
| 69 typedef std::string ResourceIdentifier; | |
| 70 | |
| 71 virtual ~ContentSettingsProvider() {} | |
| 72 | |
| 73 virtual bool ContentSettingsTypeIsManaged( | |
| 74 ContentSettingsType content_type) = 0; | |
| 75 | |
| 76 // This may be called on any thread. | |
| 77 virtual ContentSetting GetContentSetting( | |
| 78 const GURL requesting_url, | |
| 79 const GURL embedding_url, | |
| 80 const ContentSettingsType& content_type, | |
| 81 const ResourceIdentifier& resource_identifier) const = 0; | |
| 82 | |
| 83 // This should only be called on the UI thread. | |
| 84 virtual void SetContentSetting( | |
| 85 const ContentSettingsPattern& requesting_pattern, | |
| 86 const ContentSettingsPattern& embedding_pattern, | |
| 87 const ContentSettingsType& content_type, | |
| 88 const ResourceIdentifier& resource_identifier, | |
| 89 ContentSetting content_setting) = 0; | |
| 90 | |
| 91 // This may be called on any thread. | |
| 92 virtual void GetAllContentSettingsRules( | |
| 93 const ContentSettingsType& content_type, | |
| 94 const ResourceIdentifier& resource_identifier, | |
| 95 ContentSettingsRules* content_setting_rules) const = 0; | |
| 96 | |
| 97 // This should only be called on the UI thread. | |
| 98 virtual void ClearAllContentSettingsRules() = 0; | |
| 99 }; | |
| 100 | |
| 101 } // namespace content_settings | |
| 102 | |
| 42 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ | 103 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ |
| OLD | NEW |