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 // 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 const std::string& resource_identifier, | 115 const std::string& resource_identifier, |
| 116 ContentSettingsForOneType* settings) const; | 116 ContentSettingsForOneType* settings) const; |
| 117 | 117 |
| 118 // Sets the default setting for a particular content type. This method must | 118 // Sets the default setting for a particular content type. This method must |
| 119 // not be invoked on an incognito map. | 119 // not be invoked on an incognito map. |
| 120 // | 120 // |
| 121 // This should only be called on the UI thread. | 121 // This should only be called on the UI thread. |
| 122 void SetDefaultContentSetting(ContentSettingsType content_type, | 122 void SetDefaultContentSetting(ContentSettingsType content_type, |
| 123 ContentSetting setting); | 123 ContentSetting setting); |
| 124 | 124 |
| 125 // Sets the content setting for the given patterns and content type. | 125 // Sets the content |setting| for the given patterns, |content_type| and |
| 126 // Setting the value to CONTENT_SETTING_DEFAULT causes the default setting | 126 // |resource_identifier|. Setting the value to CONTENT_SETTING_DEFAULT causes |
| 127 // for that type to be used when loading pages matching this pattern. For | 127 // the default setting for that type to be used when loading pages matching |
| 128 // ContentSettingsTypes that require an resource identifier to be specified, | 128 // this pattern. |
| 129 // the |resource_identifier| must be non-empty. | 129 // NOTICE: This is just a convenience method for content types that use |
| 130 // |CONTENT_SETTING| as their data type. For content types that user other | |
|
Bernhard Bauer
2011/11/15 15:40:28
Nit: "[...] that use other [...]"
markusheintz_
2011/11/15 17:36:58
Done.
| |
| 131 // data types please use the method SetWebsiteSetting. | |
| 130 // | 132 // |
| 131 // This should only be called on the UI thread. | 133 // This should only be called on the UI thread. |
| 132 void SetContentSetting(const ContentSettingsPattern& primary_pattern, | 134 void SetContentSetting(const ContentSettingsPattern& primary_pattern, |
| 133 const ContentSettingsPattern& secondary_pattern, | 135 const ContentSettingsPattern& secondary_pattern, |
| 134 ContentSettingsType content_type, | 136 ContentSettingsType content_type, |
| 135 const std::string& resource_identifier, | 137 const std::string& resource_identifier, |
| 136 ContentSetting setting); | 138 ContentSetting setting); |
| 137 | 139 |
| 140 // Sets the |value| for the given patterns, |content_type| and | |
| 141 // |resource_identifier|. Setting the value to NULL causes the default value | |
| 142 // for that type to be used when loading pages matching this pattern. | |
| 143 // | |
| 144 // Takes ownership of the passed value. | |
| 145 void SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, | |
| 146 const ContentSettingsPattern& secondary_pattern, | |
| 147 ContentSettingsType content_type, | |
| 148 const std::string& resource_identifier, | |
| 149 base::Value* value); | |
| 150 | |
| 138 // Convenience method to add a content setting for the given URLs, making sure | 151 // Convenience method to add a content setting for the given URLs, making sure |
| 139 // that there is no setting overriding it. For ContentSettingsTypes that | 152 // that there is no setting overriding it. For ContentSettingsTypes that |
| 140 // require an resource identifier to be specified, the |resource_identifier| | 153 // require an resource identifier to be specified, the |resource_identifier| |
| 141 // must be non-empty. | 154 // must be non-empty. |
| 142 // | 155 // |
| 143 // This should only be called on the UI thread. | 156 // This should only be called on the UI thread. |
| 144 void AddExceptionForURL(const GURL& primary_url, | 157 void AddExceptionForURL(const GURL& primary_url, |
| 145 const GURL& secondary_url, | 158 const GURL& secondary_url, |
| 146 ContentSettingsType content_type, | 159 ContentSettingsType content_type, |
| 147 const std::string& resource_identifier, | 160 const std::string& resource_identifier, |
| 148 ContentSetting setting); | 161 ContentSetting setting); |
| 149 | 162 |
| 150 // Clears all host-specific settings for one content type. | 163 // Clears all host-specific settings for one content type. |
| 151 // | 164 // |
| 152 // This should only be called on the UI thread. | 165 // This should only be called on the UI thread. |
| 153 void ClearSettingsForOneType(ContentSettingsType content_type); | 166 void ClearSettingsForOneType(ContentSettingsType content_type); |
| 154 | 167 |
| 168 static bool IsValueAllowedForType(const base::Value* value, | |
| 169 ContentSettingsType content_type); | |
| 155 static bool IsSettingAllowedForType(ContentSetting setting, | 170 static bool IsSettingAllowedForType(ContentSetting setting, |
| 156 ContentSettingsType content_type); | 171 ContentSettingsType content_type); |
| 157 | 172 |
| 158 // Detaches the HostContentSettingsMap from all Profile-related objects like | 173 // Detaches the HostContentSettingsMap from all Profile-related objects like |
| 159 // PrefService. This methods needs to be called before destroying the Profile. | 174 // PrefService. This methods needs to be called before destroying the Profile. |
| 160 // Afterwards, none of the methods above that should only be called on the UI | 175 // Afterwards, none of the methods above that should only be called on the UI |
| 161 // thread should be called anymore. | 176 // thread should be called anymore. |
| 162 void ShutdownOnUIThread(); | 177 void ShutdownOnUIThread(); |
| 163 | 178 |
| 164 // content_settings::Observer implementation. | 179 // content_settings::Observer implementation. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 // Content setting providers. | 235 // Content setting providers. |
| 221 ProviderMap content_settings_providers_; | 236 ProviderMap content_settings_providers_; |
| 222 | 237 |
| 223 // Used around accesses to the following objects to guarantee thread safety. | 238 // Used around accesses to the following objects to guarantee thread safety. |
| 224 mutable base::Lock lock_; | 239 mutable base::Lock lock_; |
| 225 | 240 |
| 226 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 241 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 227 }; | 242 }; |
| 228 | 243 |
| 229 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 244 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |