| 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 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 // Resets the cookie setting for the given patterns. | 84 // Resets the cookie setting for the given patterns. |
| 85 // | 85 // |
| 86 // This should only be called on the UI thread. | 86 // This should only be called on the UI thread. |
| 87 void ResetCookieSetting(const ContentSettingsPattern& primary_pattern, | 87 void ResetCookieSetting(const ContentSettingsPattern& primary_pattern, |
| 88 const ContentSettingsPattern& secondary_pattern); | 88 const ContentSettingsPattern& secondary_pattern); |
| 89 | 89 |
| 90 // Detaches the |CookieSettings| from all |Profile|-related objects like | 90 // Detaches the |CookieSettings| from all |Profile|-related objects like |
| 91 // |PrefService|. This methods needs to be called before destroying the | 91 // |PrefService|. This methods needs to be called before destroying the |
| 92 // |Profile|. Afterwards, only const methods can be called. | 92 // |Profile|. Afterwards, only const methods can be called. |
| 93 virtual void ShutdownOnUIThread() OVERRIDE; | 93 virtual void ShutdownOnUIThread() override; |
| 94 | 94 |
| 95 // A helper for applying third party cookie blocking rules. | 95 // A helper for applying third party cookie blocking rules. |
| 96 ContentSetting GetCookieSetting( | 96 ContentSetting GetCookieSetting( |
| 97 const GURL& url, | 97 const GURL& url, |
| 98 const GURL& first_party_url, | 98 const GURL& first_party_url, |
| 99 bool setting_cookie, | 99 bool setting_cookie, |
| 100 content_settings::SettingSource* source) const; | 100 content_settings::SettingSource* source) const; |
| 101 | 101 |
| 102 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 102 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 103 | 103 |
| 104 class Factory : public RefcountedBrowserContextKeyedServiceFactory { | 104 class Factory : public RefcountedBrowserContextKeyedServiceFactory { |
| 105 public: | 105 public: |
| 106 // Returns the |CookieSettings| associated with the |profile|. | 106 // Returns the |CookieSettings| associated with the |profile|. |
| 107 // | 107 // |
| 108 // This should only be called on the UI thread. | 108 // This should only be called on the UI thread. |
| 109 static scoped_refptr<CookieSettings> GetForProfile(Profile* profile); | 109 static scoped_refptr<CookieSettings> GetForProfile(Profile* profile); |
| 110 | 110 |
| 111 static Factory* GetInstance(); | 111 static Factory* GetInstance(); |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 friend struct DefaultSingletonTraits<Factory>; | 114 friend struct DefaultSingletonTraits<Factory>; |
| 115 | 115 |
| 116 Factory(); | 116 Factory(); |
| 117 virtual ~Factory(); | 117 virtual ~Factory(); |
| 118 | 118 |
| 119 // |BrowserContextKeyedBaseFactory| methods: | 119 // |BrowserContextKeyedBaseFactory| methods: |
| 120 virtual void RegisterProfilePrefs( | 120 virtual void RegisterProfilePrefs( |
| 121 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; | 121 user_prefs::PrefRegistrySyncable* registry) override; |
| 122 virtual content::BrowserContext* GetBrowserContextToUse( | 122 virtual content::BrowserContext* GetBrowserContextToUse( |
| 123 content::BrowserContext* context) const OVERRIDE; | 123 content::BrowserContext* context) const override; |
| 124 virtual scoped_refptr<RefcountedKeyedService> BuildServiceInstanceFor( | 124 virtual scoped_refptr<RefcountedKeyedService> BuildServiceInstanceFor( |
| 125 content::BrowserContext* context) const OVERRIDE; | 125 content::BrowserContext* context) const override; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 virtual ~CookieSettings(); | 129 virtual ~CookieSettings(); |
| 130 | 130 |
| 131 void OnBlockThirdPartyCookiesChanged(); | 131 void OnBlockThirdPartyCookiesChanged(); |
| 132 | 132 |
| 133 // Returns true if the "block third party cookies" preference is set. | 133 // Returns true if the "block third party cookies" preference is set. |
| 134 // | 134 // |
| 135 // This method may be called on any thread. | 135 // This method may be called on any thread. |
| 136 bool ShouldBlockThirdPartyCookies() const; | 136 bool ShouldBlockThirdPartyCookies() const; |
| 137 | 137 |
| 138 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 138 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 139 PrefChangeRegistrar pref_change_registrar_; | 139 PrefChangeRegistrar pref_change_registrar_; |
| 140 | 140 |
| 141 // Used around accesses to |block_third_party_cookies_| to guarantee thread | 141 // Used around accesses to |block_third_party_cookies_| to guarantee thread |
| 142 // safety. | 142 // safety. |
| 143 mutable base::Lock lock_; | 143 mutable base::Lock lock_; |
| 144 | 144 |
| 145 bool block_third_party_cookies_; | 145 bool block_third_party_cookies_; |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 #endif // CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ | 148 #endif // CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ |
| OLD | NEW |