diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 09:15:04 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 09:15:04 +0000 |
commit | b0cad5d48859e6fb30f2d46bdf5f0aa1a6fa73d5 (patch) | |
tree | 7020f7d42fafc3f4594e0716d3badf3067e93375 /net | |
parent | 017ecde96cd5f6a28b6561404360241862c041b3 (diff) | |
download | chromium_src-b0cad5d48859e6fb30f2d46bdf5f0aa1a6fa73d5.zip chromium_src-b0cad5d48859e6fb30f2d46bdf5f0aa1a6fa73d5.tar.gz chromium_src-b0cad5d48859e6fb30f2d46bdf5f0aa1a6fa73d5.tar.bz2 |
Enable cookies per default in net. Add an API to disable them by default, and do that in Chrome
BUG=none
TEST=existing tests shouldn't break
Review URL: https://chromiumcodereview.appspot.com/9865018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/url_request.cc | 17 | ||||
-rw-r--r-- | net/url_request/url_request.h | 8 |
2 files changed, 23 insertions, 2 deletions
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index 4c2e2c3..3f51f3d 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -64,6 +64,12 @@ uint64 GenerateURLRequestIdentifier() { return g_next_url_request_identifier++; } +// True once the first URLRequest was started. +bool g_url_requests_started = false; + +// True if cookies are accepted by default. +bool g_default_can_use_cookies = true; + } // namespace URLRequest::ProtocolFactory* @@ -321,6 +327,12 @@ int URLRequest::GetResponseCode() { } // static +void URLRequest::SetDefaultCookiePolicyToBlock() { + CHECK(!g_url_requests_started); + g_default_can_use_cookies = false; +} + +// static bool URLRequest::IsHandledProtocol(const std::string& scheme) { return URLRequestJobManager::GetInstance()->SupportsScheme(scheme); } @@ -379,6 +391,7 @@ void URLRequest::set_delegate(Delegate* delegate) { } void URLRequest::Start() { + g_url_requests_started = true; response_info_.request_time = Time::Now(); // Only notify the delegate for the initial request. @@ -819,7 +832,7 @@ bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { return context_->network_delegate()->NotifyReadingCookies(this, cookie_list); } - return false; + return g_default_can_use_cookies; } bool URLRequest::CanSetCookie(const std::string& cookie_line, @@ -830,7 +843,7 @@ bool URLRequest::CanSetCookie(const std::string& cookie_line, cookie_line, options); } - return false; + return g_default_can_use_cookies; } diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index d73d2fe..e204c6b 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -291,6 +291,14 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), // will not have any more of its methods called. virtual ~URLRequest(); + // Changes the default cookie policy from allowing all cookies to blocking all + // cookies. Embedders that want to implement a more flexible policy should + // change the default to blocking all cookies, and provide a NetworkDelegate + // with the URLRequestContext that maintains the CookieStore. + // The cookie policy default has to be set before the first URLRequest is + // started. Once it was set to block all cookies, it cannot be changed back. + static void SetDefaultCookiePolicyToBlock(); + // Returns true if the scheme can be handled by URLRequest. False otherwise. static bool IsHandledProtocol(const std::string& scheme); |