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 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_COOKIE_SETTINGS_H_ | 5 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_COOKIE_SETTINGS_H_ |
| 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_COOKIE_SETTINGS_H_ | 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_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 19 matching lines...) Expand all Loading... | |
| 30 public: | 30 public: |
| 31 // Creates a new CookieSettings instance. | 31 // Creates a new CookieSettings instance. |
| 32 // The caller is responsible for ensuring that |extension_scheme| is valid for | 32 // The caller is responsible for ensuring that |extension_scheme| is valid for |
| 33 // the whole lifetime of this instance. | 33 // the whole lifetime of this instance. |
| 34 CookieSettings(HostContentSettingsMap* host_content_settings_map, | 34 CookieSettings(HostContentSettingsMap* host_content_settings_map, |
| 35 PrefService* prefs, | 35 PrefService* prefs, |
| 36 const char* extension_scheme); | 36 const char* extension_scheme); |
| 37 | 37 |
| 38 // Returns the default content setting (CONTENT_SETTING_ALLOW, | 38 // Returns the default content setting (CONTENT_SETTING_ALLOW, |
| 39 // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies. If | 39 // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies. If |
| 40 // |provider_id| is not NULL, the id of the provider which provided the | 40 // |provider_id| is not nullptr, the id of the provider which provided the |
| 41 // default setting is assigned to it. | 41 // default setting is assigned to it. |
| 42 // | 42 // |
| 43 // This may be called on any thread. | 43 // This may be called on any thread. |
| 44 ContentSetting GetDefaultCookieSetting(std::string* provider_id) const; | 44 ContentSetting GetDefaultCookieSetting(std::string* provider_id) const; |
| 45 | 45 |
| 46 // Returns true if the page identified by (|url|, |first_party_url|) is | 46 // Returns true if the page identified by (|url|, |first_party_url|) is |
| 47 // allowed to read cookies. | 47 // allowed to read cookies. |
| 48 // | 48 // |
| 49 // This may be called on any thread. | 49 // This may be called on any thread. |
| 50 bool IsReadingCookieAllowed(const GURL& url, | 50 bool IsReadingCookieAllowed(const GURL& url, |
| 51 const GURL& first_party_url) const; | 51 const GURL& first_party_url) const; |
| 52 | 52 |
| 53 // Returns true if the page identified by (|url|, |first_party_url|) is | 53 // Returns true if the page identified by (|url|, |first_party_url|) is |
| 54 // allowed to set cookies (permanent or session only). | 54 // allowed to set cookies (permanent or session only). |
| 55 // | 55 // |
| 56 // This may be called on any thread. | 56 // This may be called on any thread. |
| 57 bool IsSettingCookieAllowed(const GURL& url, | 57 bool IsSettingCookieAllowed(const GURL& url, |
| 58 const GURL& first_party_url) const; | 58 const GURL& first_party_url) const; |
| 59 | 59 |
| 60 void GetReadingAndSettingCookieAllowed(const GURL& url, | |
|
Devlin
2016/11/16 20:12:00
drive-by - function comment? Particularly since t
Charlie Harrison
2016/11/16 22:04:15
Done.
| |
| 61 const GURL& first_party_url, | |
| 62 bool* reading_cookie_allowed, | |
| 63 bool* setting_cookie_allowed) const; | |
| 64 | |
| 60 // Returns true if the cookie set by a page identified by |url| should be | 65 // Returns true if the cookie set by a page identified by |url| should be |
| 61 // session only. Querying this only makes sense if |IsSettingCookieAllowed| | 66 // session only. Querying this only makes sense if |IsSettingCookieAllowed| |
| 62 // has returned true. | 67 // has returned true. |
| 63 // | 68 // |
| 64 // This may be called on any thread. | 69 // This may be called on any thread. |
| 65 bool IsCookieSessionOnly(const GURL& url) const; | 70 bool IsCookieSessionOnly(const GURL& url) const; |
| 66 | 71 |
| 67 // Returns all patterns with a non-default cookie setting, mapped to their | 72 // Returns all patterns with a non-default cookie setting, mapped to their |
| 68 // actual settings, in the precedence order of the setting rules. |settings| | 73 // actual settings, in the precedence order of the setting rules. |settings| |
| 69 // must be a non-NULL outparam. | 74 // must be a non-nullptr outparam. |
| 70 // | 75 // |
| 71 // This may be called on any thread. | 76 // This may be called on any thread. |
| 72 void GetCookieSettings(ContentSettingsForOneType* settings) const; | 77 void GetCookieSettings(ContentSettingsForOneType* settings) const; |
| 73 | 78 |
| 74 // Sets the default content setting (CONTENT_SETTING_ALLOW, | 79 // Sets the default content setting (CONTENT_SETTING_ALLOW, |
| 75 // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies. | 80 // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies. |
| 76 // | 81 // |
| 77 // This should only be called on the UI thread. | 82 // This should only be called on the UI thread. |
| 78 void SetDefaultCookieSetting(ContentSetting setting); | 83 void SetDefaultCookieSetting(ContentSetting setting); |
| 79 | 84 |
| 80 // Sets the cookie setting for the given url. | 85 // Sets the cookie setting for the given url. |
| 81 // | 86 // |
| 82 // This should only be called on the UI thread. | 87 // This should only be called on the UI thread. |
| 83 void SetCookieSetting(const GURL& primary_url, ContentSetting setting); | 88 void SetCookieSetting(const GURL& primary_url, ContentSetting setting); |
| 84 | 89 |
| 85 // Resets the cookie setting for the given url. | 90 // Resets the cookie setting for the given url. |
| 86 // | 91 // |
| 87 // This should only be called on the UI thread. | 92 // This should only be called on the UI thread. |
| 88 void ResetCookieSetting(const GURL& primary_url); | 93 void ResetCookieSetting(const GURL& primary_url); |
| 89 | 94 |
| 90 bool IsStorageDurable(const GURL& origin) const; | 95 bool IsStorageDurable(const GURL& origin) const; |
| 91 | 96 |
| 92 // Detaches the |CookieSettings| from |PrefService|. This methods needs to be | 97 // Detaches the |CookieSettings| from |PrefService|. This methods needs to be |
| 93 // called before destroying the service. Afterwards, only const methods can be | 98 // called before destroying the service. Afterwards, only const methods can be |
| 94 // called. | 99 // called. |
| 95 void ShutdownOnUIThread() override; | 100 void ShutdownOnUIThread() override; |
| 96 | 101 |
| 97 // A helper for applying third party cookie blocking rules. | 102 // A helper for applying third party cookie blocking rules. |
| 98 ContentSetting GetCookieSetting( | 103 void GetCookieSetting(const GURL& url, |
| 99 const GURL& url, | 104 const GURL& first_party_url, |
| 100 const GURL& first_party_url, | 105 content_settings::SettingSource* source, |
| 101 bool setting_cookie, | 106 ContentSetting* reading_cookie, |
| 102 content_settings::SettingSource* source) const; | 107 ContentSetting* setting_cookie) const; |
| 103 | 108 |
| 104 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 109 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 105 | 110 |
| 106 private: | 111 private: |
| 107 ~CookieSettings() override; | 112 ~CookieSettings() override; |
| 108 | 113 |
| 109 void OnBlockThirdPartyCookiesChanged(); | 114 void OnBlockThirdPartyCookiesChanged(); |
| 110 | 115 |
| 111 // Returns true if the "block third party cookies" preference is set. | 116 // Returns true if the "block third party cookies" preference is set. |
| 112 // | 117 // |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 123 mutable base::Lock lock_; | 128 mutable base::Lock lock_; |
| 124 | 129 |
| 125 bool block_third_party_cookies_; | 130 bool block_third_party_cookies_; |
| 126 | 131 |
| 127 DISALLOW_COPY_AND_ASSIGN(CookieSettings); | 132 DISALLOW_COPY_AND_ASSIGN(CookieSettings); |
| 128 }; | 133 }; |
| 129 | 134 |
| 130 } // namespace content_settings | 135 } // namespace content_settings |
| 131 | 136 |
| 132 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_COOKIE_SETTINGS_H_ | 137 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_COOKIE_SETTINGS_H_ |
| OLD | NEW |