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 <vector> | |
| 13 | |
| 14 #include "chrome/browser/content_settings/content_settings_pattern.h" | |
| 11 #include "chrome/common/content_settings.h" | 15 #include "chrome/common/content_settings.h" |
| 12 | 16 |
| 17 class GURL; | |
| 18 | |
| 13 namespace content_settings { | 19 namespace content_settings { |
| 14 | 20 |
| 15 class DefaultProviderInterface { | 21 class DefaultProviderInterface { |
| 16 public: | 22 public: |
| 17 virtual ~DefaultProviderInterface() {} | 23 virtual ~DefaultProviderInterface() {} |
| 18 | 24 |
| 19 // True if this provider can provide a default setting for the |content_type|. | 25 // True if this provider can provide a default setting for the |content_type|. |
| 20 virtual bool CanProvideDefaultSetting( | 26 virtual bool CanProvideDefaultSetting( |
| 21 ContentSettingsType content_type) const = 0; | 27 ContentSettingsType content_type) const = 0; |
| 22 | 28 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 34 | 40 |
| 35 // Resets the state of the provider to the default. | 41 // Resets the state of the provider to the default. |
| 36 virtual void ResetToDefaults() = 0; | 42 virtual void ResetToDefaults() = 0; |
| 37 | 43 |
| 38 // True if the default setting for the |content_type| is policy managed, i.e., | 44 // True if the default setting for the |content_type| is policy managed, i.e., |
| 39 // there shouldn't be any UI shown to modify this setting. | 45 // there shouldn't be any UI shown to modify this setting. |
| 40 virtual bool DefaultSettingIsManaged( | 46 virtual bool DefaultSettingIsManaged( |
| 41 ContentSettingsType content_type) const = 0; | 47 ContentSettingsType content_type) const = 0; |
| 42 }; | 48 }; |
| 43 | 49 |
| 50 class ProviderInterface { | |
| 51 public: | |
| 52 typedef std::string ResourceIdentifier; | |
| 53 | |
| 54 struct Rule { | |
| 55 Rule() {} | |
| 56 Rule(const ContentSettingsPattern& requesting_url_pattern, | |
| 57 const ContentSettingsPattern& embedding_url_pattern, | |
| 58 ContentSetting& setting) | |
| 59 : requesting_url_pattern_(requesting_url_pattern), | |
|
jochen (gone - plz use gerrit)
2011/02/01 11:38:39
also remove the underscores here
markusheintz_
2011/02/01 12:17:12
Done.
| |
| 60 embedding_url_pattern_(embedding_url_pattern), | |
| 61 content_setting_(setting) {} | |
| 62 | |
| 63 const ContentSettingsPattern requesting_url_pattern; | |
| 64 const ContentSettingsPattern embedding_url_pattern; | |
| 65 ContentSetting content_setting; | |
| 66 }; | |
| 67 | |
| 68 typedef std::vector<Rule> Rules; | |
| 69 | |
| 70 virtual ~ProviderInterface() {} | |
| 71 | |
| 72 // Returns a single ContentSetting which applies to a given |requesting_url|, | |
| 73 // |embedding_url| pair or CONTENT_SETTING_DEFAULT, if no rule applies. For | |
| 74 // ContentSettingsTypes that require a resource identifier to be specified, | |
| 75 // the |resource_identifier| must be non-empty. | |
| 76 // | |
| 77 // This may be called on any thread. | |
| 78 virtual ContentSetting GetContentSetting( | |
| 79 const GURL& requesting_url, | |
| 80 const GURL& embedding_url, | |
| 81 ContentSettingsType content_type, | |
| 82 const ResourceIdentifier& resource_identifier) const = 0; | |
| 83 | |
| 84 // Sets the content setting for a particular |requesting_pattern|, | |
| 85 // |embedding_pattern|, |content_type| tuple. For ContentSettingsTypes that | |
| 86 // require a resource identifier to be specified, the |resource_identifier| | |
| 87 // must be non-empty. | |
| 88 // | |
| 89 // This should only be called on the UI thread. | |
| 90 virtual void SetContentSetting( | |
| 91 const ContentSettingsPattern& requesting_pattern, | |
| 92 const ContentSettingsPattern& embedding_pattern, | |
| 93 ContentSettingsType content_type, | |
| 94 const ResourceIdentifier& resource_identifier, | |
| 95 ContentSetting content_setting) = 0; | |
| 96 | |
| 97 // For a given content type, returns all content setting rules with a | |
| 98 // non-default setting, mapped to their actual settings. | |
| 99 // |content_settings_rules| must be non-NULL. If this provider was created for | |
| 100 // the off-the-record profile, it will only return those settings differing | |
| 101 // from the corresponding regular provider. For ContentSettingsTypes that | |
| 102 // require a resource identifier to be specified, the |resource_identifier| | |
| 103 // must be non-empty. | |
| 104 // | |
| 105 // This may be called on any thread. | |
| 106 virtual void GetAllContentSettingsRules( | |
| 107 ContentSettingsType content_type, | |
| 108 const ResourceIdentifier& resource_identifier, | |
| 109 Rules* content_setting_rules) const = 0; | |
| 110 | |
| 111 // Resets all content settings to CONTENT_SETTING_DEFAULT. | |
| 112 // | |
| 113 // This should only be called on the UI thread. | |
| 114 virtual void ClearAllContentSettingsRules() = 0; | |
| 115 }; | |
| 116 | |
| 44 } // namespace content_settings | 117 } // namespace content_settings |
| 45 | 118 |
| 46 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ | 119 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ |
| OLD | NEW |