diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 21:54:55 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 21:54:55 +0000 |
commit | 2581e577597dd0f435ae1e6fe918df912bb98248 (patch) | |
tree | 5d1edc9fe3d12eb1d7da8d8361bc57e5ad4dc397 /chrome | |
parent | dec173b814e09f0633bdfefad7e1d89c50fa4919 (diff) | |
download | chromium_src-2581e577597dd0f435ae1e6fe918df912bb98248.zip chromium_src-2581e577597dd0f435ae1e6fe918df912bb98248.tar.gz chromium_src-2581e577597dd0f435ae1e6fe918df912bb98248.tar.bz2 |
Propagate the "first party for cookies" from WebKit to the network stack
when we follow a redirect, because WebKit's
MainResourceLoader::willSendRequest method may change the "first party for
cookies" URL of the resource request.
R=abarth
BUG=25133
TEST=In Options menu, change cookie policy to "Accept cookies only from
sites I visit" and then follow the instructions in issue 25133 comment 20.
Review URL: http://codereview.chromium.org/385024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.cc | 16 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.h | 10 | ||||
-rw-r--r-- | chrome/browser/renderer_host/safe_browsing_resource_handler.cc | 6 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 5 | ||||
-rw-r--r-- | chrome/common/resource_dispatcher.cc | 7 | ||||
-rw-r--r-- | chrome/common/resource_dispatcher_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/common/security_filter_peer.cc | 3 | ||||
-rw-r--r-- | chrome/common/security_filter_peer.h | 3 | ||||
-rw-r--r-- | chrome/plugin/chrome_plugin_host.cc | 4 |
9 files changed, 44 insertions, 18 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 35ba9be..7c192ec 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -62,7 +62,6 @@ #if defined(OS_POSIX) #include "chrome/common/temp_scaffolding_stubs.h" #elif defined(OS_WIN) -#include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #endif @@ -657,8 +656,11 @@ void ResourceDispatcherHost::OnCancelRequest(int request_id) { CancelRequest(receiver_->id(), request_id, true, true); } -void ResourceDispatcherHost::OnFollowRedirect(int request_id) { - FollowDeferredRedirect(receiver_->id(), request_id); +void ResourceDispatcherHost::OnFollowRedirect( + int request_id, + const GURL& new_first_party_for_cookies) { + FollowDeferredRedirect(receiver_->id(), request_id, + new_first_party_for_cookies); } void ResourceDispatcherHost::OnClosePageACK( @@ -829,8 +831,10 @@ void ResourceDispatcherHost::CancelRequest(int child_id, CancelRequest(child_id, request_id, from_renderer, true); } -void ResourceDispatcherHost::FollowDeferredRedirect(int child_id, - int request_id) { +void ResourceDispatcherHost::FollowDeferredRedirect( + int child_id, + int request_id, + const GURL& new_first_party_for_cookies) { PendingRequestList::iterator i = pending_requests_.find( GlobalRequestID(child_id, request_id)); if (i == pending_requests_.end()) { @@ -838,6 +842,8 @@ void ResourceDispatcherHost::FollowDeferredRedirect(int child_id, return; } + if (!new_first_party_for_cookies.is_empty()) + i->second->set_first_party_for_cookies(new_first_party_for_cookies); i->second->FollowDeferredRedirect(); } diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h index c354b0a..9796e80 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.h +++ b/chrome/browser/renderer_host/resource_dispatcher_host.h @@ -142,8 +142,13 @@ class ResourceDispatcherHost : public URLRequest::Delegate { bool from_renderer); // Follows a deferred redirect for the given request. + // new_first_party_for_cookies, if non-empty, is the new cookie policy URL + // for the redirected URL. Pass an empty, invalid URL as + // new_first_party_for_cookies to indicate that the cookie policy URL + // doesn't need changing. void FollowDeferredRedirect(int process_unique_id, - int request_id); + int request_id, + const GURL& new_first_party_for_cookies); // Returns true if it's ok to send the data. If there are already too many // data messages pending, it pauses the request and returns false. In this @@ -400,7 +405,8 @@ class ResourceDispatcherHost : public URLRequest::Delegate { void OnDataReceivedACK(int request_id); void OnUploadProgressACK(int request_id); void OnCancelRequest(int request_id); - void OnFollowRedirect(int request_id); + void OnFollowRedirect(int request_id, + const GURL& new_first_party_for_cookies); // Returns true if the message passed in is a resource related message. static bool IsResourceDispatcherHostMessage(const IPC::Message&); diff --git a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc index e33e796..ad3105d 100644 --- a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc +++ b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc @@ -241,8 +241,10 @@ void SafeBrowsingResourceHandler::ResumeRedirect() { bool defer = false; next_handler_->OnRequestRedirected(redirect_id_, redirect_url_, redirect_response_, &defer); - if (!defer) - rdh_->FollowDeferredRedirect(render_process_host_id_, redirect_id_); + if (!defer) { + rdh_->FollowDeferredRedirect(render_process_host_id_, redirect_id_, + GURL()); + } redirect_response_ = NULL; redirect_id_ = -1; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 866d9aa..3240bf63 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1054,8 +1054,9 @@ IPC_BEGIN_MESSAGES(ViewHost) // Follows a redirect that occured for the resource request with the ID given // as the parameter. - IPC_MESSAGE_ROUTED1(ViewHostMsg_FollowRedirect, - int /* request_id */) + IPC_MESSAGE_ROUTED2(ViewHostMsg_FollowRedirect, + int /* request_id */, + GURL /* new_first_party_for_cookies */) // Makes a synchronous resource request via the browser. IPC_SYNC_MESSAGE_ROUTED2_1(ViewHostMsg_SyncLoad, diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc index 36c66a9..ed0365a 100644 --- a/chrome/common/resource_dispatcher.cc +++ b/chrome/common/resource_dispatcher.cc @@ -421,9 +421,12 @@ void ResourceDispatcher::OnReceivedRedirect( RESOURCE_LOG("Dispatching redirect for " << request_info.peer->GetURLForDebugging().possibly_invalid_spec()); - if (request_info.peer->OnReceivedRedirect(new_url, info)) { + GURL new_first_party_for_cookies; + if (request_info.peer->OnReceivedRedirect(new_url, info, + &new_first_party_for_cookies)) { message_sender()->Send( - new ViewHostMsg_FollowRedirect(message.routing_id(), request_id)); + new ViewHostMsg_FollowRedirect(message.routing_id(), request_id, + new_first_party_for_cookies)); } else { CancelPendingRequest(message.routing_id(), request_id); } diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc index b8503ce..1652ad9 100644 --- a/chrome/common/resource_dispatcher_unittest.cc +++ b/chrome/common/resource_dispatcher_unittest.cc @@ -34,7 +34,9 @@ class TestRequestCallback : public ResourceLoaderBridge::Peer { virtual bool OnReceivedRedirect( const GURL& new_url, - const ResourceLoaderBridge::ResponseInfo& info) { + const ResourceLoaderBridge::ResponseInfo& info, + GURL* new_first_party_for_cookies) { + *new_first_party_for_cookies = GURL(); return true; } @@ -243,7 +245,9 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest, virtual bool OnReceivedRedirect( const GURL& new_url, - const ResourceLoaderBridge::ResponseInfo& info) { + const ResourceLoaderBridge::ResponseInfo& info, + GURL* new_first_party_for_cookies) { + *new_first_party_for_cookies = GURL(); return true; } diff --git a/chrome/common/security_filter_peer.cc b/chrome/common/security_filter_peer.cc index 2f21385..6b2b427 100644 --- a/chrome/common/security_filter_peer.cc +++ b/chrome/common/security_filter_peer.cc @@ -106,7 +106,8 @@ void SecurityFilterPeer::OnUploadProgress(uint64 position, uint64 size) { bool SecurityFilterPeer::OnReceivedRedirect( const GURL& new_url, - const webkit_glue::ResourceLoaderBridge::ResponseInfo& info) { + const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, + GURL* new_first_party_for_cookies) { NOTREACHED(); return false; } diff --git a/chrome/common/security_filter_peer.h b/chrome/common/security_filter_peer.h index 5594376..3bd4fcf 100644 --- a/chrome/common/security_filter_peer.h +++ b/chrome/common/security_filter_peer.h @@ -41,7 +41,8 @@ class SecurityFilterPeer : public webkit_glue::ResourceLoaderBridge::Peer { virtual void OnUploadProgress(uint64 position, uint64 size); virtual bool OnReceivedRedirect( const GURL& new_url, - const webkit_glue::ResourceLoaderBridge::ResponseInfo& info); + const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, + GURL* new_first_party_for_cookies); virtual void OnReceivedResponse( const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, bool content_filtered); diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index 6c3e71a..23f0e5b 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -68,9 +68,11 @@ class PluginRequestHandlerProxy virtual bool OnReceivedRedirect( const GURL& new_url, - const ResourceLoaderBridge::ResponseInfo& info) { + const ResourceLoaderBridge::ResponseInfo& info, + GURL* new_first_party_for_cookies) { plugin_->functions().response_funcs->received_redirect( cprequest_.get(), new_url.spec().c_str()); + *new_first_party_for_cookies = GURL(); return true; } |