OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 8 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
9 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 9 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
10 | 10 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 // Sets the content |setting| for the given patterns, |content_type| and | 134 // Sets the content |setting| for the given patterns, |content_type| and |
135 // |resource_identifier|. Setting the value to CONTENT_SETTING_DEFAULT causes | 135 // |resource_identifier|. Setting the value to CONTENT_SETTING_DEFAULT causes |
136 // the default setting for that type to be used when loading pages matching | 136 // the default setting for that type to be used when loading pages matching |
137 // this pattern. | 137 // this pattern. |
138 // NOTICE: This is just a convenience method for content types that use | 138 // NOTICE: This is just a convenience method for content types that use |
139 // |CONTENT_SETTING| as their data type. For content types that use other | 139 // |CONTENT_SETTING| as their data type. For content types that use other |
140 // data types please use the method SetWebsiteSettingDefaultScope(). | 140 // data types please use the method SetWebsiteSettingDefaultScope(). |
141 // | 141 // |
142 // This should only be called on the UI thread. | 142 // This should only be called on the UI thread. |
143 // TODO(raymes): Create a version of this function which uses the default | |
144 // scope. | |
145 void SetContentSetting(const ContentSettingsPattern& primary_pattern, | 143 void SetContentSetting(const ContentSettingsPattern& primary_pattern, |
146 const ContentSettingsPattern& secondary_pattern, | 144 const ContentSettingsPattern& secondary_pattern, |
147 ContentSettingsType content_type, | 145 ContentSettingsType content_type, |
148 const std::string& resource_identifier, | 146 const std::string& resource_identifier, |
149 ContentSetting setting); | 147 ContentSetting setting); |
150 | 148 |
| 149 // Sets the content |setting| for the default scope of the url that is |
| 150 // appropriate for the given |content_type| and |resource_identifier|. |
| 151 // Setting the value to CONTENT_SETTING_DEFAULT causes the default setting |
| 152 // for that type to be used. |
| 153 // |
| 154 // NOTICE: This is just a convenience method for content types that use |
| 155 // |CONTENT_SETTING| as their data type. For content types that use other |
| 156 // data types please use the method SetWebsiteSettingDefaultScope(). |
| 157 // |
| 158 // This should only be called on the UI thread. |
| 159 // |
| 160 // Internally this will call SetContentSettingCustomScope() with the default |
| 161 // scope patterns for the given |content_type|. Developers will generally want |
| 162 // to use this function instead of SetContentSettingCustomScope() unless they |
| 163 // need to specify custom scoping. |
| 164 void SetContentSettingDefaultScope(const GURL& primary_url, |
| 165 const GURL& secondary_url, |
| 166 ContentSettingsType content_type, |
| 167 const std::string& resource_identifier, |
| 168 ContentSetting setting); |
| 169 |
| 170 // Sets the content |setting| for the given patterns, |content_type| and |
| 171 // |resource_identifier|. Setting the value to CONTENT_SETTING_DEFAULT causes |
| 172 // the default setting for that type to be used when loading pages matching |
| 173 // this pattern. |
| 174 // NOTICE: This is just a convenience method for content types that use |
| 175 // |CONTENT_SETTING| as their data type. For content types that use other |
| 176 // data types please use the method SetWebsiteSettingDefaultScope(). |
| 177 // |
| 178 // This should only be called on the UI thread. |
| 179 // |
| 180 // Unless adding a custom-scoped setting, most developers will want to use |
| 181 // SetWebsiteSettingDefaultScope() instead. |
| 182 void SetContentSettingCustomScope( |
| 183 const ContentSettingsPattern& primary_pattern, |
| 184 const ContentSettingsPattern& secondary_pattern, |
| 185 ContentSettingsType content_type, |
| 186 const std::string& resource_identifier, |
| 187 ContentSetting setting); |
| 188 |
| 189 // Migrate old settings for those ContentSettingsType which previously |
| 190 // would use the same pattern twice instead of using |
| 191 // ContentSettingsPattern::Wildcard(). This has no impact on lookups using |
| 192 // GetContentSetting (because Wildcard matches everything) but it has an |
| 193 // impact when trying to change the existing content setting. We need to |
| 194 // migrate the old-format keys. |
| 195 // TODO(lshang): Remove this when clients have migrated. We should leave in |
| 196 // some code to remove old-format settings for a long time. |
| 197 void MigrateOldSettings(); |
| 198 |
151 // Sets the |value| for the default scope of the url that is appropriate for | 199 // Sets the |value| for the default scope of the url that is appropriate for |
152 // the given |content_type| and |resource_identifier|. Setting the value to | 200 // the given |content_type| and |resource_identifier|. Setting the value to |
153 // null removes the default pattern pair for this content type. | 201 // null removes the default pattern pair for this content type. |
154 // | 202 // |
155 // Internally this will call SetWebsiteSettingCustomScope() with the default | 203 // Internally this will call SetWebsiteSettingCustomScope() with the default |
156 // scope patterns for the given |content_type|. Developers will generally want | 204 // scope patterns for the given |content_type|. Developers will generally want |
157 // to use this function instead of SetWebsiteSettingCustomScope() unless they | 205 // to use this function instead of SetWebsiteSettingCustomScope() unless they |
158 // need to specify custom scoping. | 206 // need to specify custom scoping. |
159 void SetWebsiteSettingDefaultScope(const GURL& requesting_url, | 207 void SetWebsiteSettingDefaultScope(const GURL& requesting_url, |
160 const GURL& top_level_url, | 208 const GURL& top_level_url, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 ProviderMap content_settings_providers_; | 389 ProviderMap content_settings_providers_; |
342 | 390 |
343 base::ThreadChecker thread_checker_; | 391 base::ThreadChecker thread_checker_; |
344 | 392 |
345 base::ObserverList<content_settings::Observer> observers_; | 393 base::ObserverList<content_settings::Observer> observers_; |
346 | 394 |
347 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 395 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
348 }; | 396 }; |
349 | 397 |
350 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 398 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |