Chromium Code Reviews| Index: content/browser/webui/url_data_manager_backend.cc |
| diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc |
| index fe1015f87e445c77ae396386df9182b94fc81cd0..d3d9c30ac4dd44792bcf8a590c665de998ed37f3 100644 |
| --- a/content/browser/webui/url_data_manager_backend.cc |
| +++ b/content/browser/webui/url_data_manager_backend.cc |
| @@ -24,7 +24,11 @@ |
| #include "base/strings/stringprintf.h" |
| #include "base/trace_event/trace_event.h" |
| #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| +#include "content/browser/frame_host/frame_tree_node.h" |
| +#include "content/browser/frame_host/navigation_request.h" |
| +#include "content/browser/frame_host/navigator.h" |
| #include "content/browser/histogram_internals_request_job.h" |
| +#include "content/browser/loader/resource_request_info_impl.h" |
| #include "content/browser/net/view_blob_internals_job_factory.h" |
| #include "content/browser/net/view_http_cache_job_factory.h" |
| #include "content/browser/resource_context_impl.h" |
| @@ -35,6 +39,7 @@ |
| #include "content/public/browser/content_browser_client.h" |
| #include "content/public/browser/render_process_host.h" |
| #include "content/public/browser/resource_request_info.h" |
| +#include "content/public/common/browser_side_navigation_policy.h" |
| #include "content/public/common/url_constants.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/net_errors.h" |
| @@ -185,6 +190,7 @@ class URLRequestChromeJob : public net::URLRequestJob { |
| // Called on the UI thread to check if this request is allowed. |
| static void CheckStoragePartitionMatches( |
| int render_process_id, |
| + int frame_tree_node_id, |
| const GURL& url, |
| const base::WeakPtr<URLRequestChromeJob>& job); |
| @@ -291,11 +297,13 @@ void URLRequestChromeJob::Start() { |
| } |
| } |
| + const ResourceRequestInfoImpl* info = |
| + ResourceRequestInfoImpl::ForRequest(request_); |
| + DCHECK(info); |
| BrowserThread::PostTask( |
| - BrowserThread::UI, |
| - FROM_HERE, |
| + BrowserThread::UI, FROM_HERE, |
| base::Bind(&URLRequestChromeJob::CheckStoragePartitionMatches, |
| - render_process_id, url, |
| + render_process_id, info->frame_tree_node_id(), request_->url(), |
| weak_factory_.GetWeakPtr())); |
| } |
| @@ -408,6 +416,7 @@ int URLRequestChromeJob::CompleteRead(net::IOBuffer* buf, int buf_size) { |
| void URLRequestChromeJob::CheckStoragePartitionMatches( |
| int render_process_id, |
| + int frame_tree_node_id, |
| const GURL& url, |
| const base::WeakPtr<URLRequestChromeJob>& job) { |
| // The embedder could put some webui pages in separate storage partition. |
| @@ -421,6 +430,23 @@ void URLRequestChromeJob::CheckStoragePartitionMatches( |
| StoragePartition* partition = BrowserContext::GetStoragePartitionForSite( |
| process->GetBrowserContext(), url); |
| allowed = partition == process->GetStoragePartition(); |
| + } else if (render_process_id == -1 && IsBrowserSideNavigationEnabled()) { |
|
Dan Beam
2016/05/23 19:02:58
when will render_process_id be -1 here?
Charlie Reis
2016/05/23 19:11:16
With PlzNavigate, the renderer process may not be
Dan Beam
2016/05/23 19:17:09
are you saying that ResourceRequestInfo::GetRender
Charlie Reis
2016/05/23 19:50:10
That's what patch set 1 implies. I agree that see
Dan Beam
2016/05/23 20:41:09
I removed a constant in my previous CL that might
clamy
2016/05/24 11:18:32
PlzNavigate does indeed creates a URLRequestUserDa
Charlie Reis
2016/05/24 22:14:32
Yeah, we could reintroduce that old path for allow
clamy
2016/05/25 14:30:11
I'm a bit wary of changing the behavior of Resourc
|
| + // PlzNavigate: there should be no process associated to the navigation. |
| + // Instead, lookup the FrameTreeNode to access the NavigationRequest. |
| + FrameTreeNode* frame_tree_node = |
| + FrameTreeNode::GloballyFindByID(frame_tree_node_id); |
| + if (frame_tree_node) { |
| + NavigationRequest* request = frame_tree_node->navigation_request(); |
| + if (request) { |
| + StoragePartition* partition = |
| + BrowserContext::GetStoragePartitionForSite( |
| + frame_tree_node->navigator() |
| + ->GetController() |
| + ->GetBrowserContext(), |
| + url); |
| + allowed = partition == request->GetStoragePartitionForNavigation(); |
| + } |
| + } |
| } |
| BrowserThread::PostTask( |
| BrowserThread::IO, |