Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1258)

Side by Side Diff: content/browser/webui/url_data_manager_backend.cc

Issue 2002633002: PlzNavigate: fix issue preventing navigations to WebUIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now checking when ready to commit Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/webui/url_data_manager_backend.h" 5 #include "content/browser/webui/url_data_manager_backend.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 12 matching lines...) Expand all
23 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/trace_event/trace_event.h" 25 #include "base/trace_event/trace_event.h"
26 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 26 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
27 #include "content/browser/histogram_internals_request_job.h" 27 #include "content/browser/histogram_internals_request_job.h"
28 #include "content/browser/net/view_blob_internals_job_factory.h" 28 #include "content/browser/net/view_blob_internals_job_factory.h"
29 #include "content/browser/net/view_http_cache_job_factory.h" 29 #include "content/browser/net/view_http_cache_job_factory.h"
30 #include "content/browser/resource_context_impl.h" 30 #include "content/browser/resource_context_impl.h"
31 #include "content/browser/webui/shared_resources_data_source.h" 31 #include "content/browser/webui/shared_resources_data_source.h"
32 #include "content/browser/webui/url_data_source_impl.h" 32 #include "content/browser/webui/url_data_source_impl.h"
33 #include "content/browser/webui/web_ui_impl.h"
33 #include "content/public/browser/browser_context.h" 34 #include "content/public/browser/browser_context.h"
34 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/content_browser_client.h" 36 #include "content/public/browser/content_browser_client.h"
36 #include "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
37 #include "content/public/browser/resource_request_info.h" 38 #include "content/public/browser/resource_request_info.h"
39 #include "content/public/common/browser_side_navigation_policy.h"
38 #include "content/public/common/url_constants.h" 40 #include "content/public/common/url_constants.h"
39 #include "net/base/io_buffer.h" 41 #include "net/base/io_buffer.h"
40 #include "net/base/net_errors.h" 42 #include "net/base/net_errors.h"
41 #include "net/http/http_response_headers.h" 43 #include "net/http/http_response_headers.h"
42 #include "net/http/http_status_code.h" 44 #include "net/http/http_status_code.h"
43 #include "net/log/net_log_util.h" 45 #include "net/log/net_log_util.h"
44 #include "net/url_request/url_request.h" 46 #include "net/url_request/url_request.h"
45 #include "net/url_request/url_request_context.h" 47 #include "net/url_request/url_request_context.h"
46 #include "net/url_request/url_request_error_job.h" 48 #include "net/url_request/url_request_error_job.h"
47 #include "net/url_request/url_request_job.h" 49 #include "net/url_request/url_request_job.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 void URLRequestChromeJob::Start() { 267 void URLRequestChromeJob::Start() {
266 const GURL url = request_->url(); 268 const GURL url = request_->url();
267 269
268 TRACE_EVENT_ASYNC_BEGIN1("browser", "DataManager:Request", this, "URL", 270 TRACE_EVENT_ASYNC_BEGIN1("browser", "DataManager:Request", this, "URL",
269 url.possibly_invalid_spec()); 271 url.possibly_invalid_spec());
270 272
271 int render_process_id, unused; 273 int render_process_id, unused;
272 bool is_renderer_request = ResourceRequestInfo::GetRenderFrameForRequest( 274 bool is_renderer_request = ResourceRequestInfo::GetRenderFrameForRequest(
273 request_, &render_process_id, &unused); 275 request_, &render_process_id, &unused);
274 276
275 if (!is_renderer_request) { 277 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
Charlie Reis 2016/05/25 21:38:02 Wasn't this null in your previous patch set during
278
279 if (!is_renderer_request || (IsBrowserSideNavigationEnabled() &&
280 IsResourceTypeFrame(info->GetResourceType()))) {
281 // PlzNavigate: the check for navigations is performed by the
282 // NavigationRequest.
276 StartAsync(true); 283 StartAsync(true);
277 return; 284 return;
278 } 285 }
279 286
280 if (url.SchemeIs(kChromeUIScheme)) { 287 if (url.SchemeIs(kChromeUIScheme)) {
281 // TODO(dbeam): it's not clear that partition checking is needed or used. It 288 // TODO(dbeam): it's not clear that partition checking is needed or used. It
282 // was added for iframe-based signin (http://crbug.com/338127), which has 289 // was added for iframe-based signin (http://crbug.com/338127), which has
283 // since changed. We should remove if no longer necessary. 290 // since changed. We should remove if no longer necessary.
284 std::vector<std::string> hosts; 291 std::vector<std::string> hosts;
285 hosts.push_back(content::kChromeUIResourcesHost); 292 hosts.push_back(content::kChromeUIResourcesHost);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 415
409 void URLRequestChromeJob::CheckStoragePartitionMatches( 416 void URLRequestChromeJob::CheckStoragePartitionMatches(
410 int render_process_id, 417 int render_process_id,
411 const GURL& url, 418 const GURL& url,
412 const base::WeakPtr<URLRequestChromeJob>& job) { 419 const base::WeakPtr<URLRequestChromeJob>& job) {
413 // The embedder could put some webui pages in separate storage partition. 420 // The embedder could put some webui pages in separate storage partition.
414 // RenderProcessHostImpl::IsSuitableHost would guard against top level pages 421 // RenderProcessHostImpl::IsSuitableHost would guard against top level pages
415 // being in the same process. We do an extra check to guard against an 422 // being in the same process. We do an extra check to guard against an
416 // exploited renderer pretending to add them as a subframe. We skip this check 423 // exploited renderer pretending to add them as a subframe. We skip this check
417 // for resources. 424 // for resources.
418 bool allowed = false; 425 bool allowed = WebUIImpl::RenderProcessAllowedForURL(
419 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id); 426 RenderProcessHost::FromID(render_process_id), url);
420 if (process) {
421 StoragePartition* partition = BrowserContext::GetStoragePartitionForSite(
422 process->GetBrowserContext(), url);
423 allowed = partition == process->GetStoragePartition();
424 }
425 BrowserThread::PostTask( 427 BrowserThread::PostTask(
426 BrowserThread::IO, 428 BrowserThread::IO,
427 FROM_HERE, 429 FROM_HERE,
428 base::Bind(&URLRequestChromeJob::StartAsync, job, allowed)); 430 base::Bind(&URLRequestChromeJob::StartAsync, job, allowed));
429 } 431 }
430 432
431 void URLRequestChromeJob::StartAsync(bool allowed) { 433 void URLRequestChromeJob::StartAsync(bool allowed) {
432 if (!request_) 434 if (!request_)
433 return; 435 return;
434 436
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 805
804 } // namespace 806 } // namespace
805 807
806 net::URLRequestJobFactory::ProtocolHandler* 808 net::URLRequestJobFactory::ProtocolHandler*
807 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, 809 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context,
808 bool is_incognito) { 810 bool is_incognito) {
809 return new DevToolsJobFactory(resource_context, is_incognito); 811 return new DevToolsJobFactory(resource_context, is_incognito);
810 } 812 }
811 813
812 } // namespace content 814 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698