From 041b0bbba0efec8bd026aee1165e4be697cbf8ce Mon Sep 17 00:00:00 2001 From: "wtc@chromium.org" Date: Wed, 18 Nov 2009 02:27:34 +0000 Subject: Use an explicit boolean has_new_first_party_for_cookies instead of an empty, invalid URL to indicate whether the first party for cookies URL needs changing when following a redirect. R=eroman BUG=25133 TEST=none Review URL: http://codereview.chromium.org/405011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32260 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/media/buffered_data_source.cc | 4 +++- webkit/glue/media/buffered_data_source.h | 1 + webkit/glue/media/simple_data_source.cc | 4 +++- webkit/glue/media/simple_data_source.h | 1 + webkit/glue/resource_loader_bridge.h | 16 ++++++++-------- webkit/glue/weburlloader_impl.cc | 3 +++ webkit/tools/test_shell/simple_resource_loader_bridge.cc | 9 ++++++--- 7 files changed, 25 insertions(+), 13 deletions(-) (limited to 'webkit') diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc index 3d2c73f..cfc2d7c 100644 --- a/webkit/glue/media/buffered_data_source.cc +++ b/webkit/glue/media/buffered_data_source.cc @@ -231,12 +231,14 @@ int64 BufferedResourceLoader::GetBufferedLastBytePosition() { bool BufferedResourceLoader::OnReceivedRedirect( const GURL& new_url, const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, + bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies) { DCHECK(bridge_.get()); // Save the new URL. url_ = new_url; - *new_first_party_for_cookies = GURL(); + // TODO(wtc): should we return a new first party for cookies URL? + *has_new_first_party_for_cookies = false; // The load may have been stopped and |start_callback| is destroyed. // In this case we shouldn't do anything. diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h index 627f84d..0972c2d 100644 --- a/webkit/glue/media/buffered_data_source.h +++ b/webkit/glue/media/buffered_data_source.h @@ -110,6 +110,7 @@ class BufferedResourceLoader : virtual bool OnReceivedRedirect( const GURL& new_url, const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, + bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies); virtual void OnReceivedResponse( const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc index ed2a594..57b294a 100644 --- a/webkit/glue/media/simple_data_source.cc +++ b/webkit/glue/media/simple_data_source.cc @@ -123,9 +123,11 @@ void SimpleDataSource::OnUploadProgress(uint64 position, uint64 size) {} bool SimpleDataSource::OnReceivedRedirect( const GURL& new_url, const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, + bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies) { SetURL(new_url); - *new_first_party_for_cookies = GURL(); + // TODO(wtc): should we return a new first party for cookies URL? + *has_new_first_party_for_cookies = false; return true; } diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h index 3aac41b..10bbb7d 100644 --- a/webkit/glue/media/simple_data_source.h +++ b/webkit/glue/media/simple_data_source.h @@ -56,6 +56,7 @@ class SimpleDataSource : public media::DataSource, virtual bool OnReceivedRedirect( const GURL& new_url, const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, + bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies); virtual void OnReceivedResponse( const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index 48f5129..aac2331 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -110,13 +110,13 @@ class ResourceLoaderBridge { // Called when a redirect occurs. The implementation may return false to // suppress the redirect. The given ResponseInfo provides complete // information about the redirect, and new_url is the URL that will be - // loaded if this method returns true. If this method returns true, it - // stores in *new_first_party_for_cookies the new URL that should be - // consulted for the third-party cookie blocking policy. If the cookie - // policy URL doesn't need changing, it stores an empty, invalid URL in - // *new_first_party_for_cookies. + // loaded if this method returns true. If this method returns true, the + // output parameter *has_new_first_party_for_cookies indicates whether the + // output parameter *new_first_party_for_cookies contains the new URL that + // should be consulted for the third-party cookie blocking policy. virtual bool OnReceivedRedirect(const GURL& new_url, const ResponseInfo& info, + bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies) = 0; // Called when response headers are available (after all redirects have @@ -158,8 +158,8 @@ class ResourceLoaderBridge { // the standard MIME header encoding rules. The headers parameter can also // be null if no extra request headers need to be set. // - // policy_url is the URL of the document in the top-level window, which may be - // checked by the third-party cookie blocking policy. + // first_party_for_cookies is the URL of the document in the top-level + // window, which may be checked by the third-party cookie blocking policy. // // load_flags is composed of the values defined in url_request_load_flags.h // @@ -173,7 +173,7 @@ class ResourceLoaderBridge { // frame's network context. static ResourceLoaderBridge* Create(const std::string& method, const GURL& url, - const GURL& policy_url, + const GURL& first_party_for_cookies, const GURL& referrer, const std::string& frame_origin, const std::string& main_frame_origin, diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 7683014..7a85214 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -211,6 +211,7 @@ class WebURLLoaderImpl::Context : public base::RefCounted, virtual bool OnReceivedRedirect( const GURL& new_url, const ResourceLoaderBridge::ResponseInfo& info, + bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies); virtual void OnReceivedResponse( const ResourceLoaderBridge::ResponseInfo& info, bool content_filtered); @@ -391,6 +392,7 @@ void WebURLLoaderImpl::Context::OnUploadProgress(uint64 position, uint64 size) { bool WebURLLoaderImpl::Context::OnReceivedRedirect( const GURL& new_url, const ResourceLoaderBridge::ResponseInfo& info, + bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies) { if (!client_) return false; @@ -408,6 +410,7 @@ bool WebURLLoaderImpl::Context::OnReceivedRedirect( client_->willSendRequest(loader_, new_request, response); request_ = new_request; + *has_new_first_party_for_cookies = true; *new_first_party_for_cookies = request_.firstPartyForCookies(); // Only follow the redirect if WebKit left the URL unmodified. diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index 65f1640..512802a 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -153,12 +153,14 @@ class RequestProxy : public URLRequest::Delegate, void NotifyReceivedRedirect(const GURL& new_url, const ResourceLoaderBridge::ResponseInfo& info) { + bool has_new_first_party_for_cookies = false; GURL new_first_party_for_cookies; if (peer_ && peer_->OnReceivedRedirect(new_url, info, + &has_new_first_party_for_cookies, &new_first_party_for_cookies)) { io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( this, &RequestProxy::AsyncFollowDeferredRedirect, - new_first_party_for_cookies)); + has_new_first_party_for_cookies, new_first_party_for_cookies)); } else { Cancel(); } @@ -241,12 +243,13 @@ class RequestProxy : public URLRequest::Delegate, Done(); } - void AsyncFollowDeferredRedirect(const GURL& new_first_party_for_cookies) { + void AsyncFollowDeferredRedirect(bool has_new_first_party_for_cookies, + const GURL& new_first_party_for_cookies) { // This can be null in cases where the request is already done. if (!request_.get()) return; - if (!new_first_party_for_cookies.is_empty()) + if (has_new_first_party_for_cookies) request_->set_first_party_for_cookies(new_first_party_for_cookies); request_->FollowDeferredRedirect(); } -- cgit v1.1