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 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 | 10 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 const GURL& secondary_url, | 211 const GURL& secondary_url, |
212 ContentSettingsType content_type, | 212 ContentSettingsType content_type, |
213 const std::string& resource_identifier); | 213 const std::string& resource_identifier); |
214 | 214 |
215 // Sets the last time that a given content type has been used for the pattern | 215 // Sets the last time that a given content type has been used for the pattern |
216 // which matches the URLs to the current time. | 216 // which matches the URLs to the current time. |
217 void UpdateLastUsage(const GURL& primary_url, | 217 void UpdateLastUsage(const GURL& primary_url, |
218 const GURL& secondary_url, | 218 const GURL& secondary_url, |
219 ContentSettingsType content_type); | 219 ContentSettingsType content_type); |
220 | 220 |
| 221 // Sets the last time that a given content type has been used for a pattern |
| 222 // pair to the current time. |
| 223 void UpdateLastUsageByPattern(const ContentSettingsPattern& primary_pattern, |
| 224 const ContentSettingsPattern& secondary_pattern, |
| 225 ContentSettingsType content_type); |
| 226 |
221 // Returns the last time the pattern that matches the URL has requested | 227 // Returns the last time the pattern that matches the URL has requested |
222 // permission for the |content_type| setting. | 228 // permission for the |content_type| setting. |
223 base::Time GetLastUsage(const GURL& primary_url, | 229 base::Time GetLastUsage(const GURL& primary_url, |
224 const GURL& secondary_url, | 230 const GURL& secondary_url, |
225 ContentSettingsType content_type); | 231 ContentSettingsType content_type); |
226 | 232 |
227 // Returns the last time the pattern has requested permission for the | 233 // Returns the last time the pattern has requested permission for the |
228 // |content_type| setting. | 234 // |content_type| setting. |
229 base::Time GetLastUsageByPattern( | 235 base::Time GetLastUsageByPattern( |
230 const ContentSettingsPattern& primary_pattern, | 236 const ContentSettingsPattern& primary_pattern, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 const std::string& resource_identifier, | 270 const std::string& resource_identifier, |
265 ContentSettingsForOneType* settings, | 271 ContentSettingsForOneType* settings, |
266 bool incognito) const; | 272 bool incognito) const; |
267 | 273 |
268 // Call UsedContentSettingsProviders() whenever you access | 274 // Call UsedContentSettingsProviders() whenever you access |
269 // content_settings_providers_ (apart from initialization and | 275 // content_settings_providers_ (apart from initialization and |
270 // teardown), so that we can DCHECK in RegisterExtensionService that | 276 // teardown), so that we can DCHECK in RegisterExtensionService that |
271 // it is not being called too late. | 277 // it is not being called too late. |
272 void UsedContentSettingsProviders() const; | 278 void UsedContentSettingsProviders() const; |
273 | 279 |
274 // Convenience method for updating the last usage of a content type for a | |
275 // pattern. | |
276 void UpdateLastUsageByPattern(const ContentSettingsPattern& primary_pattern, | |
277 const ContentSettingsPattern& secondary_pattern, | |
278 ContentSettingsType content_type); | |
279 | |
280 content_settings::PrefProvider* GetPrefProvider(); | 280 content_settings::PrefProvider* GetPrefProvider(); |
281 | 281 |
282 #ifndef NDEBUG | 282 #ifndef NDEBUG |
283 // This starts as the thread ID of the thread that constructs this | 283 // This starts as the thread ID of the thread that constructs this |
284 // object, and remains until used by a different thread, at which | 284 // object, and remains until used by a different thread, at which |
285 // point it is set to base::kInvalidThreadId. This allows us to | 285 // point it is set to base::kInvalidThreadId. This allows us to |
286 // DCHECK on unsafe usage of content_settings_providers_ (they | 286 // DCHECK on unsafe usage of content_settings_providers_ (they |
287 // should be set up on a single thread, after which they are | 287 // should be set up on a single thread, after which they are |
288 // immutable). | 288 // immutable). |
289 mutable base::PlatformThreadId used_from_thread_id_; | 289 mutable base::PlatformThreadId used_from_thread_id_; |
290 #endif | 290 #endif |
291 | 291 |
292 // Weak; owned by the Profile. | 292 // Weak; owned by the Profile. |
293 PrefService* prefs_; | 293 PrefService* prefs_; |
294 | 294 |
295 // Whether this settings map is for an OTR session. | 295 // Whether this settings map is for an OTR session. |
296 bool is_off_the_record_; | 296 bool is_off_the_record_; |
297 | 297 |
298 // Content setting providers. This is only modified at construction | 298 // Content setting providers. This is only modified at construction |
299 // time and by RegisterExtensionService, both of which should happen | 299 // time and by RegisterExtensionService, both of which should happen |
300 // before any other uses of it. | 300 // before any other uses of it. |
301 ProviderMap content_settings_providers_; | 301 ProviderMap content_settings_providers_; |
302 | 302 |
303 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 303 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
304 }; | 304 }; |
305 | 305 |
306 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 306 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |