| 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/prefs/pref_change_registrar.h" | 18 #include "base/prefs/pref_change_registrar.h" |
| 19 #include "base/threading/platform_thread.h" | 19 #include "base/threading/platform_thread.h" |
| 20 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
| 21 #include "components/content_settings/core/browser/content_settings_observer.h" | 21 #include "components/content_settings/core/browser/content_settings_observer.h" |
| 22 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 22 #include "components/content_settings/core/common/content_settings.h" | 23 #include "components/content_settings/core/common/content_settings.h" |
| 23 #include "components/content_settings/core/common/content_settings_pattern.h" | 24 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 24 #include "components/content_settings/core/common/content_settings_types.h" | 25 #include "components/content_settings/core/common/content_settings_types.h" |
| 25 #include "components/keyed_service/core/refcounted_keyed_service.h" | 26 #include "components/keyed_service/core/refcounted_keyed_service.h" |
| 26 | 27 |
| 27 class ExtensionService; | 28 class ExtensionService; |
| 28 class GURL; | 29 class GURL; |
| 29 class PrefService; | 30 class PrefService; |
| 30 | 31 |
| 31 namespace base { | 32 namespace base { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 237 |
| 237 // Schedules any pending lossy website settings to be written to disk. | 238 // Schedules any pending lossy website settings to be written to disk. |
| 238 void FlushLossyWebsiteSettings(); | 239 void FlushLossyWebsiteSettings(); |
| 239 | 240 |
| 240 // Passes ownership of |clock|. | 241 // Passes ownership of |clock|. |
| 241 void SetPrefClockForTesting(scoped_ptr<base::Clock> clock); | 242 void SetPrefClockForTesting(scoped_ptr<base::Clock> clock); |
| 242 | 243 |
| 243 private: | 244 private: |
| 244 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; | 245 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
| 245 friend class HostContentSettingsMapTest_NonDefaultSettings_Test; | 246 friend class HostContentSettingsMapTest_NonDefaultSettings_Test; |
| 247 friend |
| 248 scoped_ptr<base::Value> content_settings::GetContentSettingValueAndPatterns( |
| 249 const content_settings::ProviderInterface* provider, |
| 250 const GURL& primary_url, |
| 251 const GURL& secondary_url, |
| 252 ContentSettingsType content_type, |
| 253 const std::string& resource_identifier, |
| 254 bool include_incognito, |
| 255 ContentSettingsPattern* primary_pattern, |
| 256 ContentSettingsPattern* secondary_pattern); |
| 246 | 257 |
| 247 typedef std::map<ProviderType, content_settings::ProviderInterface*> | 258 typedef std::map<ProviderType, content_settings::ProviderInterface*> |
| 248 ProviderMap; | 259 ProviderMap; |
| 249 typedef ProviderMap::iterator ProviderIterator; | 260 typedef ProviderMap::iterator ProviderIterator; |
| 250 typedef ProviderMap::const_iterator ConstProviderIterator; | 261 typedef ProviderMap::const_iterator ConstProviderIterator; |
| 251 | 262 |
| 252 ~HostContentSettingsMap() override; | 263 ~HostContentSettingsMap() override; |
| 253 | 264 |
| 254 // Sets a rule to apply the |value| for all sites matching |pattern|, | 265 // Sets a rule to apply the |value| for all sites matching |pattern|, |
| 255 // |content_type| and |resource_identifier|. Setting the value to null removes | 266 // |content_type| and |resource_identifier|. Setting the value to null removes |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // takes the global on/off switch into account. | 300 // takes the global on/off switch into account. |
| 290 scoped_ptr<base::Value> GetWebsiteSettingInternal( | 301 scoped_ptr<base::Value> GetWebsiteSettingInternal( |
| 291 const GURL& primary_url, | 302 const GURL& primary_url, |
| 292 const GURL& secondary_url, | 303 const GURL& secondary_url, |
| 293 ContentSettingsType content_type, | 304 ContentSettingsType content_type, |
| 294 const std::string& resource_identifier, | 305 const std::string& resource_identifier, |
| 295 content_settings::SettingInfo* info) const; | 306 content_settings::SettingInfo* info) const; |
| 296 | 307 |
| 297 content_settings::PrefProvider* GetPrefProvider(); | 308 content_settings::PrefProvider* GetPrefProvider(); |
| 298 | 309 |
| 310 // Prevents content settings marked INHERIT_IN_INCOGNITO_EXCEPT_ALLOW from |
| 311 // inheriting CONTENT_SETTING_ALLOW settings from regular to incognito. |
| 312 static ContentSetting CoerceSettingInheritedToIncognito( |
| 313 ContentSettingsType content_type, |
| 314 ContentSetting setting); |
| 315 |
| 299 #ifndef NDEBUG | 316 #ifndef NDEBUG |
| 300 // This starts as the thread ID of the thread that constructs this | 317 // This starts as the thread ID of the thread that constructs this |
| 301 // object, and remains until used by a different thread, at which | 318 // object, and remains until used by a different thread, at which |
| 302 // point it is set to base::kInvalidThreadId. This allows us to | 319 // point it is set to base::kInvalidThreadId. This allows us to |
| 303 // DCHECK on unsafe usage of content_settings_providers_ (they | 320 // DCHECK on unsafe usage of content_settings_providers_ (they |
| 304 // should be set up on a single thread, after which they are | 321 // should be set up on a single thread, after which they are |
| 305 // immutable). | 322 // immutable). |
| 306 mutable base::PlatformThreadId used_from_thread_id_; | 323 mutable base::PlatformThreadId used_from_thread_id_; |
| 307 #endif | 324 #endif |
| 308 | 325 |
| 309 // Weak; owned by the Profile. | 326 // Weak; owned by the Profile. |
| 310 PrefService* prefs_; | 327 PrefService* prefs_; |
| 311 | 328 |
| 312 // Whether this settings map is for an OTR session. | 329 // Whether this settings map is for an OTR session. |
| 313 bool is_off_the_record_; | 330 bool is_off_the_record_; |
| 314 | 331 |
| 315 // Content setting providers. This is only modified at construction | 332 // Content setting providers. This is only modified at construction |
| 316 // time and by RegisterExtensionService, both of which should happen | 333 // time and by RegisterExtensionService, both of which should happen |
| 317 // before any other uses of it. | 334 // before any other uses of it. |
| 318 ProviderMap content_settings_providers_; | 335 ProviderMap content_settings_providers_; |
| 319 | 336 |
| 320 base::ThreadChecker thread_checker_; | 337 base::ThreadChecker thread_checker_; |
| 321 | 338 |
| 322 base::ObserverList<content_settings::Observer> observers_; | 339 base::ObserverList<content_settings::Observer> observers_; |
| 323 | 340 |
| 324 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 341 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 325 }; | 342 }; |
| 326 | 343 |
| 327 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 344 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |