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

Side by Side Diff: content/browser/loader/resource_loader.cc

Issue 2436253002: PlzNavigate: Fix the FindInPageControllerTest.SearchWithinSpecialURL browser test. (Closed)
Patch Set: Use FilterURL to validate access from the renderer for a URL being redirected. Created 4 years, 1 month 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/loader/resource_loader.h" 5 #include "content/browser/loader/resource_loader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/profiler/scoped_tracker.h" 13 #include "base/profiler/scoped_tracker.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "content/browser/appcache/appcache_interceptor.h" 18 #include "content/browser/appcache/appcache_interceptor.h"
19 #include "content/browser/child_process_security_policy_impl.h" 19 #include "content/browser/child_process_security_policy_impl.h"
20 #include "content/browser/loader/detachable_resource_handler.h" 20 #include "content/browser/loader/detachable_resource_handler.h"
21 #include "content/browser/loader/resource_loader_delegate.h" 21 #include "content/browser/loader/resource_loader_delegate.h"
22 #include "content/browser/loader/resource_request_info_impl.h" 22 #include "content/browser/loader/resource_request_info_impl.h"
23 #include "content/browser/service_worker/service_worker_request_handler.h" 23 #include "content/browser/service_worker/service_worker_request_handler.h"
24 #include "content/browser/service_worker/service_worker_response_info.h" 24 #include "content/browser/service_worker/service_worker_response_info.h"
25 #include "content/browser/ssl/ssl_client_auth_handler.h" 25 #include "content/browser/ssl/ssl_client_auth_handler.h"
26 #include "content/browser/ssl/ssl_manager.h" 26 #include "content/browser/ssl/ssl_manager.h"
27 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 27 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
28 #include "content/public/common/browser_side_navigation_policy.h"
28 #include "content/public/common/content_client.h" 29 #include "content/public/common/content_client.h"
29 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
30 #include "content/public/common/process_type.h" 31 #include "content/public/common/process_type.h"
31 #include "content/public/common/resource_response.h" 32 #include "content/public/common/resource_response.h"
32 #include "content/public/common/resource_type.h" 33 #include "content/public/common/resource_type.h"
33 #include "net/base/io_buffer.h" 34 #include "net/base/io_buffer.h"
34 #include "net/base/load_flags.h" 35 #include "net/base/load_flags.h"
35 #include "net/http/http_response_headers.h" 36 #include "net/http/http_response_headers.h"
36 #include "net/nqe/effective_connection_type.h" 37 #include "net/nqe/effective_connection_type.h"
37 #include "net/nqe/network_quality_estimator.h" 38 #include "net/nqe/network_quality_estimator.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 bool* defer) { 250 bool* defer) {
250 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("loading"), 251 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("loading"),
251 "ResourceLoader::OnReceivedRedirect"); 252 "ResourceLoader::OnReceivedRedirect");
252 DCHECK_EQ(request_.get(), unused); 253 DCHECK_EQ(request_.get(), unused);
253 254
254 DVLOG(1) << "OnReceivedRedirect: " << request_->url().spec(); 255 DVLOG(1) << "OnReceivedRedirect: " << request_->url().spec();
255 DCHECK(request_->status().is_success()); 256 DCHECK(request_->status().is_success());
256 257
257 ResourceRequestInfoImpl* info = GetRequestInfo(); 258 ResourceRequestInfoImpl* info = GetRequestInfo();
258 259
259 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( 260 // With PlzNavigate for frame navigations this check is done in the
260 info->GetChildID(), redirect_info.new_url)) { 261 // NavigationRequest::OnRedirectChecksComplete() function.
Charlie Reis 2016/10/24 22:04:36 Should this comment say OnRequestRedirected instea
ananta 2016/10/24 23:01:41 Yes. Thanks for pointing this out.
261 DVLOG(1) << "Denied unauthorized request for " 262 if (!IsBrowserSideNavigationEnabled() ||
262 << redirect_info.new_url.possibly_invalid_spec(); 263 !IsResourceTypeFrame(info->GetResourceType())) {
264 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(
265 info->GetChildID(), redirect_info.new_url)) {
266 DVLOG(1) << "Denied unauthorized request for "
267 << redirect_info.new_url.possibly_invalid_spec();
263 268
264 // Tell the renderer that this request was disallowed. 269 // Tell the renderer that this request was disallowed.
265 Cancel(); 270 Cancel();
266 return; 271 return;
272 }
267 } 273 }
268 274
269 if (delegate_->HandleExternalProtocol(this, redirect_info.new_url)) { 275 if (delegate_->HandleExternalProtocol(this, redirect_info.new_url)) {
270 // The request is complete so we can remove it. 276 // The request is complete so we can remove it.
271 CancelAndIgnore(); 277 CancelAndIgnore();
272 return; 278 return;
273 } 279 }
274 280
275 scoped_refptr<ResourceResponse> response = new ResourceResponse(); 281 scoped_refptr<ResourceResponse> response = new ResourceResponse();
276 PopulateResourceResponse(info, request_.get(), response.get()); 282 PopulateResourceResponse(info, request_.get(), response.get());
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 719 }
714 720
715 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); 721 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX);
716 } else if (request_->response_info().unused_since_prefetch) { 722 } else if (request_->response_info().unused_since_prefetch) {
717 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); 723 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time();
718 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time); 724 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time);
719 } 725 }
720 } 726 }
721 727
722 } // namespace content 728 } // namespace content
OLDNEW
« content/browser/frame_host/navigation_request.cc ('K') | « content/browser/loader/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698