diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 22:14:15 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 22:14:15 +0000 |
commit | 3460228438564690022243511825894c9c600608 (patch) | |
tree | bada6636f1a8656ffb8ac481cad1c1d29bddf9f5 /net/base/static_cookie_policy.h | |
parent | e56e96f80ce491b23454a039ae5eba1a1c6ee3f9 (diff) | |
download | chromium_src-3460228438564690022243511825894c9c600608.zip chromium_src-3460228438564690022243511825894c9c600608.tar.gz chromium_src-3460228438564690022243511825894c9c600608.tar.bz2 |
Revert 38001 and 38002.
Modify CookiePolicy to work asynchronously
This change will enable us to prompt the user before setting a cookie. While
we only need to prompt before setting, we actually need to make both
CanSetCookie and CanGetCookies asynchronous. This is necessary in order to
preserve FIFO ordering since the value returned by GetCookies depends on the
changes made to the cookie DB by SetCookie.
This change also includes some simplification of CookieStore. Instead of N
virtual functions, I distilled it down to only 4. The remaining functions are
instead expressed in terms of those.
While studying all the places where we currently use CookiePolicy, I found that
some of them were not appropriate. After discussing with Amit, I decided to
remove the policy checks in URLRequestAutomationJob. See the comments in the
code regarding this.
I changed the signature of CookieMonster::GetRawCookies to GetAllCookiesForURL
to better match GetAllCookies. Related to this change webkit/glue/webcookie.h
grows a constructor that takes a CanonicalCookie to help clean up some code.
On the Chrome side, ChromeURLRequestContext now has a ChromeCookiePolicy
object. That object is threadsafe ref counted because it is passed between the
UI and IO threads. It is responsible for implementing the queuing logic
described above. It will also in the future trigger the Chrome UI code to
actually show the setcookie prompt.
Please review the state machinery changes in URLRequestHttpJob carefully.
R=eroman
BUG=34331
TEST=no tests yet for prompting.
Review URL: http://codereview.chromium.org/564045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/static_cookie_policy.h')
-rw-r--r-- | net/base/static_cookie_policy.h | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/net/base/static_cookie_policy.h b/net/base/static_cookie_policy.h index a16fd0c..4734d33 100644 --- a/net/base/static_cookie_policy.h +++ b/net/base/static_cookie_policy.h @@ -14,30 +14,18 @@ namespace net { // The StaticCookiePolicy class implements a static cookie policy that supports // three modes: allow all, deny all, or block third-party cookies. +// +// NOTE: This CookiePolicy implementation always completes synchronously. The +// callback parameter will be ignored if specified. Just pass NULL. +// class StaticCookiePolicy : public CookiePolicy { public: - // Consult the user's third-party cookie blocking preferences to determine - // whether the URL's cookies can be read. - bool CanGetCookies(const GURL& url, const GURL& first_party_for_cookies); - - // Consult the user's third-party cookie blocking preferences to determine - // whether the URL's cookies can be set. - bool CanSetCookie(const GURL& url, const GURL& first_party_for_cookies); - enum Type { ALLOW_ALL_COOKIES = 0, // Do not perform any cookie blocking. BLOCK_THIRD_PARTY_COOKIES, // Prevent third-party cookies from being set. BLOCK_ALL_COOKIES // Disable cookies. }; - // Sets the current policy to enforce. This should be called when the user's - // preferences change. - void set_type(Type type) { type_ = type; } - - Type type() const { - return type_; - } - StaticCookiePolicy() : type_(StaticCookiePolicy::ALLOW_ALL_COOKIES) { } @@ -46,6 +34,26 @@ class StaticCookiePolicy : public CookiePolicy { : type_(type) { } + // Sets the current policy to enforce. This should be called when the user's + // preferences change. + void set_type(Type type) { type_ = type; } + Type type() const { return type_; } + + // CookiePolicy methods: + + // Consults the user's third-party cookie blocking preferences to determine + // whether the URL's cookies can be read. + virtual int CanGetCookies(const GURL& url, + const GURL& first_party_for_cookies, + CompletionCallback* callback); + + // Consults the user's third-party cookie blocking preferences to determine + // whether the URL's cookies can be set. + virtual int CanSetCookie(const GURL& url, + const GURL& first_party_for_cookies, + const std::string& cookie_line, + CompletionCallback* callback); + private: Type type_; |