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 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 |
| 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/tuple.h" | 20 #include "base/tuple.h" |
| 21 #include "chrome/browser/content_settings/content_settings_observer.h" | 21 #include "chrome/browser/content_settings/content_settings_observer.h" |
| 22 #include "chrome/browser/content_settings/content_settings_override_provider.h" | |
| 22 #include "chrome/common/content_settings.h" | 23 #include "chrome/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 | 26 |
| 26 class ExtensionService; | 27 class ExtensionService; |
| 27 class GURL; | 28 class GURL; |
| 28 class PrefService; | 29 class PrefService; |
| 29 | 30 |
| 30 namespace base { | 31 namespace base { |
| 31 class Clock; | 32 class Clock; |
| 32 class Value; | 33 class Value; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace content_settings { | 36 namespace content_settings { |
| 37 class OverrideProvider; | |
| 36 class ProviderInterface; | 38 class ProviderInterface; |
| 37 class PrefProvider; | 39 class PrefProvider; |
| 38 } | 40 } |
| 39 | 41 |
| 40 namespace user_prefs { | 42 namespace user_prefs { |
| 41 class PrefRegistrySyncable; | 43 class PrefRegistrySyncable; |
| 42 } | 44 } |
| 43 | 45 |
| 44 class HostContentSettingsMap | 46 class HostContentSettingsMap |
| 45 : public content_settings::Observer, | 47 : public content_settings::Observer, |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 const GURL& secondary_url, | 243 const GURL& secondary_url, |
| 242 ContentSettingsType content_type); | 244 ContentSettingsType content_type); |
| 243 | 245 |
| 244 // Returns the last time the pattern has requested permission for the | 246 // Returns the last time the pattern has requested permission for the |
| 245 // |content_type| setting. | 247 // |content_type| setting. |
| 246 base::Time GetLastUsageByPattern( | 248 base::Time GetLastUsageByPattern( |
| 247 const ContentSettingsPattern& primary_pattern, | 249 const ContentSettingsPattern& primary_pattern, |
| 248 const ContentSettingsPattern& secondary_pattern, | 250 const ContentSettingsPattern& secondary_pattern, |
| 249 ContentSettingsType content_type); | 251 ContentSettingsType content_type); |
| 250 | 252 |
| 253 // Returns the content setting without considering the global on/off toggle | |
| 254 // for the content setting that matches the URLs. | |
| 255 ContentSetting GetContentSettingWithoutOverride( | |
| 256 const GURL& primary_url, | |
| 257 const GURL& secondary_url, | |
| 258 ContentSettingsType content_type, | |
| 259 const std::string& resource_identifier); | |
| 260 | |
| 261 // Returns the single content setting |value| without considering the | |
| 262 // global on/off toggle for the content setting that matches the given | |
| 263 // patterns. | |
| 264 // The ownership of the resulting |Value| is transfered to the caller. | |
|
Bernhard Bauer
2014/09/10 09:07:18
If you transfer ownership, consider returning a sc
Daniel Nishi
2014/09/10 16:38:29
This made me realize that GetWebsiteSetting() was
| |
| 265 base::Value* GetWebsiteSettingWithoutOverride( | |
| 266 const GURL& primary_url, | |
| 267 const GURL& secondary_url, | |
| 268 ContentSettingsType content_type, | |
| 269 const std::string& resource_identifier, | |
| 270 content_settings::SettingInfo* info) const; | |
| 271 | |
| 272 // Sets globally if a given |content_type| |is_enabled|. | |
| 273 void SetContentSettingOverride(ContentSettingsType content_type, | |
| 274 bool is_enabled); | |
| 275 | |
| 276 // Returns if a given |content_type| is enabled. | |
| 277 bool GetContentSettingOverride(ContentSettingsType content_type); | |
| 278 | |
| 251 // Adds/removes an observer for content settings changes. | 279 // Adds/removes an observer for content settings changes. |
| 252 void AddObserver(content_settings::Observer* observer); | 280 void AddObserver(content_settings::Observer* observer); |
| 253 void RemoveObserver(content_settings::Observer* observer); | 281 void RemoveObserver(content_settings::Observer* observer); |
| 254 | 282 |
| 255 // Passes ownership of |clock|. | 283 // Passes ownership of |clock|. |
| 256 void SetPrefClockForTesting(scoped_ptr<base::Clock> clock); | 284 void SetPrefClockForTesting(scoped_ptr<base::Clock> clock); |
| 257 | 285 |
| 258 private: | 286 private: |
| 259 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; | 287 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
| 260 friend class HostContentSettingsMapTest_NonDefaultSettings_Test; | 288 friend class HostContentSettingsMapTest_NonDefaultSettings_Test; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 // Weak; owned by the Profile. | 335 // Weak; owned by the Profile. |
| 308 PrefService* prefs_; | 336 PrefService* prefs_; |
| 309 | 337 |
| 310 // Whether this settings map is for an OTR session. | 338 // Whether this settings map is for an OTR session. |
| 311 bool is_off_the_record_; | 339 bool is_off_the_record_; |
| 312 | 340 |
| 313 // Content setting providers. This is only modified at construction | 341 // Content setting providers. This is only modified at construction |
| 314 // time and by RegisterExtensionService, both of which should happen | 342 // time and by RegisterExtensionService, both of which should happen |
| 315 // before any other uses of it. | 343 // before any other uses of it. |
| 316 ProviderMap content_settings_providers_; | 344 ProviderMap content_settings_providers_; |
| 345 content_settings::OverrideProvider override_; | |
| 317 | 346 |
| 318 ObserverList<content_settings::Observer> observers_; | 347 ObserverList<content_settings::Observer> observers_; |
| 319 | 348 |
| 320 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 349 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 321 }; | 350 }; |
| 322 | 351 |
| 323 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 352 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |