| 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 // Maps hostnames to custom content settings. Written on the UI thread and read | 5 // Maps hostnames to custom content settings. Written on the UI thread and read |
| 6 // on any thread. One instance per profile. | 6 // on any thread. One instance per profile. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 8 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| 9 #define CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 9 #define CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 const std::string& resource_identifier, | 102 const std::string& resource_identifier, |
| 103 ContentSettingsForOneType* settings) const; | 103 ContentSettingsForOneType* settings) const; |
| 104 | 104 |
| 105 // Sets the default setting for a particular content type. This method must | 105 // Sets the default setting for a particular content type. This method must |
| 106 // not be invoked on an incognito map. | 106 // not be invoked on an incognito map. |
| 107 // | 107 // |
| 108 // This should only be called on the UI thread. | 108 // This should only be called on the UI thread. |
| 109 void SetDefaultContentSetting(ContentSettingsType content_type, | 109 void SetDefaultContentSetting(ContentSettingsType content_type, |
| 110 ContentSetting setting); | 110 ContentSetting setting); |
| 111 | 111 |
| 112 // Sets the content setting for the given patterns and content type. | 112 // Sets the content |setting| for the given patterns, |content_type| and |
| 113 // Setting the value to CONTENT_SETTING_DEFAULT causes the default setting | 113 // |resource_identifier|. Setting the value to CONTENT_SETTING_DEFAULT causes |
| 114 // for that type to be used when loading pages matching this pattern. For | 114 // the default setting for that type to be used when loading pages matching |
| 115 // ContentSettingsTypes that require an resource identifier to be specified, | 115 // this pattern. |
| 116 // the |resource_identifier| must be non-empty. | 116 // NOTICE: This is just a convenience method for content types that use |
| 117 // |CONTENT_SETTING| as their data type. For content types that use other |
| 118 // data types please use the method SetWebsiteSetting. |
| 117 // | 119 // |
| 118 // This should only be called on the UI thread. | 120 // This should only be called on the UI thread. |
| 119 void SetContentSetting(const ContentSettingsPattern& primary_pattern, | 121 void SetContentSetting(const ContentSettingsPattern& primary_pattern, |
| 120 const ContentSettingsPattern& secondary_pattern, | 122 const ContentSettingsPattern& secondary_pattern, |
| 121 ContentSettingsType content_type, | 123 ContentSettingsType content_type, |
| 122 const std::string& resource_identifier, | 124 const std::string& resource_identifier, |
| 123 ContentSetting setting); | 125 ContentSetting setting); |
| 124 | 126 |
| 127 // Sets the |value| for the given patterns, |content_type| and |
| 128 // |resource_identifier|. Setting the value to NULL causes the default value |
| 129 // for that type to be used when loading pages matching this pattern. |
| 130 // |
| 131 // Takes ownership of the passed value. |
| 132 void SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, |
| 133 const ContentSettingsPattern& secondary_pattern, |
| 134 ContentSettingsType content_type, |
| 135 const std::string& resource_identifier, |
| 136 base::Value* value); |
| 137 |
| 125 // Convenience method to add a content setting for the given URLs, making sure | 138 // Convenience method to add a content setting for the given URLs, making sure |
| 126 // that there is no setting overriding it. For ContentSettingsTypes that | 139 // that there is no setting overriding it. For ContentSettingsTypes that |
| 127 // require an resource identifier to be specified, the |resource_identifier| | 140 // require an resource identifier to be specified, the |resource_identifier| |
| 128 // must be non-empty. | 141 // must be non-empty. |
| 129 // | 142 // |
| 130 // This should only be called on the UI thread. | 143 // This should only be called on the UI thread. |
| 131 void AddExceptionForURL(const GURL& primary_url, | 144 void AddExceptionForURL(const GURL& primary_url, |
| 132 const GURL& secondary_url, | 145 const GURL& secondary_url, |
| 133 ContentSettingsType content_type, | 146 ContentSettingsType content_type, |
| 134 const std::string& resource_identifier, | 147 const std::string& resource_identifier, |
| 135 ContentSetting setting); | 148 ContentSetting setting); |
| 136 | 149 |
| 137 // Clears all host-specific settings for one content type. | 150 // Clears all host-specific settings for one content type. |
| 138 // | 151 // |
| 139 // This should only be called on the UI thread. | 152 // This should only be called on the UI thread. |
| 140 void ClearSettingsForOneType(ContentSettingsType content_type); | 153 void ClearSettingsForOneType(ContentSettingsType content_type); |
| 141 | 154 |
| 155 static bool IsValueAllowedForType(const base::Value* value, |
| 156 ContentSettingsType content_type); |
| 142 static bool IsSettingAllowedForType(ContentSetting setting, | 157 static bool IsSettingAllowedForType(ContentSetting setting, |
| 143 ContentSettingsType content_type); | 158 ContentSettingsType content_type); |
| 144 | 159 |
| 145 // Detaches the HostContentSettingsMap from all Profile-related objects like | 160 // Detaches the HostContentSettingsMap from all Profile-related objects like |
| 146 // PrefService. This methods needs to be called before destroying the Profile. | 161 // PrefService. This methods needs to be called before destroying the Profile. |
| 147 // Afterwards, none of the methods above that should only be called on the UI | 162 // Afterwards, none of the methods above that should only be called on the UI |
| 148 // thread should be called anymore. | 163 // thread should be called anymore. |
| 149 void ShutdownOnUIThread(); | 164 void ShutdownOnUIThread(); |
| 150 | 165 |
| 151 // content_settings::Observer implementation. | 166 // content_settings::Observer implementation. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // Content setting providers. | 222 // Content setting providers. |
| 208 ProviderMap content_settings_providers_; | 223 ProviderMap content_settings_providers_; |
| 209 | 224 |
| 210 // Used around accesses to the following objects to guarantee thread safety. | 225 // Used around accesses to the following objects to guarantee thread safety. |
| 211 mutable base::Lock lock_; | 226 mutable base::Lock lock_; |
| 212 | 227 |
| 213 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 228 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 214 }; | 229 }; |
| 215 | 230 |
| 216 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 231 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |