Chromium Code Reviews| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 const ContentSettingsPattern& secondary_pattern, | 231 const ContentSettingsPattern& secondary_pattern, |
| 231 ContentSettingsType content_type); | 232 ContentSettingsType content_type); |
| 232 | 233 |
| 233 // Adds/removes an observer for content settings changes. | 234 // Adds/removes an observer for content settings changes. |
| 234 void AddObserver(content_settings::Observer* observer); | 235 void AddObserver(content_settings::Observer* observer); |
| 235 void RemoveObserver(content_settings::Observer* observer); | 236 void RemoveObserver(content_settings::Observer* observer); |
| 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 |
| 241 // For internal use only, except in tests. | |
| 242 static scoped_ptr<base::Value> GetContentSettingValueAndPatternsInternal( | |
| 243 const content_settings::ProviderInterface* provider, | |
| 244 const GURL& primary_url, | |
| 245 const GURL& secondary_url, | |
| 246 ContentSettingsType content_type, | |
| 247 const std::string& resource_identifier, | |
| 248 bool include_incognito, | |
| 249 ContentSettingsPattern* primary_pattern, | |
| 250 ContentSettingsPattern* secondary_pattern); | |
| 251 | |
| 252 // For internal use only, except in tests. | |
| 253 static scoped_ptr<base::Value> GetContentSettingValueAndPatternsInternal( | |
|
raymes
2015/12/03 01:56:49
It's strange to have public functions that are cal
johnme
2015/12/03 19:06:40
I can do that for GetContentSettingValueAndPattern
raymes
2015/12/03 22:19:42
Yeah it's annoying isn't it - you would have to mo
johnme
2015/12/04 17:14:32
Done #1 (called the class content_settings::TestUt
| |
| 254 content_settings::RuleIterator* rule_iterator, | |
| 255 const GURL& primary_url, | |
| 256 const GURL& secondary_url, | |
| 257 ContentSettingsPattern* primary_pattern, | |
| 258 ContentSettingsPattern* secondary_pattern); | |
| 259 | |
| 240 // Passes ownership of |clock|. | 260 // Passes ownership of |clock|. |
| 241 void SetPrefClockForTesting(scoped_ptr<base::Clock> clock); | 261 void SetPrefClockForTesting(scoped_ptr<base::Clock> clock); |
| 242 | 262 |
| 243 private: | 263 private: |
| 244 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; | 264 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
| 245 friend class HostContentSettingsMapTest_NonDefaultSettings_Test; | 265 friend class HostContentSettingsMapTest_NonDefaultSettings_Test; |
| 246 | 266 |
| 247 typedef std::map<ProviderType, content_settings::ProviderInterface*> | 267 typedef std::map<ProviderType, content_settings::ProviderInterface*> |
| 248 ProviderMap; | 268 ProviderMap; |
| 249 typedef ProviderMap::iterator ProviderIterator; | 269 typedef ProviderMap::iterator ProviderIterator; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 307 |
| 288 // Returns the single content setting |value| with a toggle for if it | 308 // Returns the single content setting |value| with a toggle for if it |
| 289 // takes the global on/off switch into account. | 309 // takes the global on/off switch into account. |
| 290 scoped_ptr<base::Value> GetWebsiteSettingInternal( | 310 scoped_ptr<base::Value> GetWebsiteSettingInternal( |
| 291 const GURL& primary_url, | 311 const GURL& primary_url, |
| 292 const GURL& secondary_url, | 312 const GURL& secondary_url, |
| 293 ContentSettingsType content_type, | 313 ContentSettingsType content_type, |
| 294 const std::string& resource_identifier, | 314 const std::string& resource_identifier, |
| 295 content_settings::SettingInfo* info) const; | 315 content_settings::SettingInfo* info) const; |
| 296 | 316 |
| 317 // Prevents content settings marked INHERIT_IN_INCOGNITO_EXCEPT_ALLOW from | |
| 318 // inheriting CONTENT_SETTING_ALLOW settings from regular to incognito. | |
| 319 static ContentSetting CoerceSettingInheritedToIncognito( | |
| 320 ContentSettingsType content_type, | |
| 321 ContentSetting setting); | |
| 322 | |
| 297 content_settings::PrefProvider* GetPrefProvider(); | 323 content_settings::PrefProvider* GetPrefProvider(); |
| 298 | 324 |
| 299 #ifndef NDEBUG | 325 #ifndef NDEBUG |
| 300 // This starts as the thread ID of the thread that constructs this | 326 // This starts as the thread ID of the thread that constructs this |
| 301 // object, and remains until used by a different thread, at which | 327 // object, and remains until used by a different thread, at which |
| 302 // point it is set to base::kInvalidThreadId. This allows us to | 328 // point it is set to base::kInvalidThreadId. This allows us to |
| 303 // DCHECK on unsafe usage of content_settings_providers_ (they | 329 // DCHECK on unsafe usage of content_settings_providers_ (they |
| 304 // should be set up on a single thread, after which they are | 330 // should be set up on a single thread, after which they are |
| 305 // immutable). | 331 // immutable). |
| 306 mutable base::PlatformThreadId used_from_thread_id_; | 332 mutable base::PlatformThreadId used_from_thread_id_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 318 ProviderMap content_settings_providers_; | 344 ProviderMap content_settings_providers_; |
| 319 | 345 |
| 320 base::ThreadChecker thread_checker_; | 346 base::ThreadChecker thread_checker_; |
| 321 | 347 |
| 322 base::ObserverList<content_settings::Observer> observers_; | 348 base::ObserverList<content_settings::Observer> observers_; |
| 323 | 349 |
| 324 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 350 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 325 }; | 351 }; |
| 326 | 352 |
| 327 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 353 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |