OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame_host/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "content/browser/child_process_security_policy_impl.h" | |
9 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
11 #include "content/browser/frame_host/frame_tree_node.h" | 12 #include "content/browser/frame_host/frame_tree_node.h" |
12 #include "content/browser/frame_host/navigation_controller_impl.h" | 13 #include "content/browser/frame_host/navigation_controller_impl.h" |
13 #include "content/browser/frame_host/navigation_handle_impl.h" | 14 #include "content/browser/frame_host/navigation_handle_impl.h" |
14 #include "content/browser/frame_host/navigation_request_info.h" | 15 #include "content/browser/frame_host/navigation_request_info.h" |
15 #include "content/browser/frame_host/navigator.h" | 16 #include "content/browser/frame_host/navigator.h" |
16 #include "content/browser/frame_host/navigator_impl.h" | 17 #include "content/browser/frame_host/navigator_impl.h" |
17 #include "content/browser/loader/navigation_url_loader.h" | 18 #include "content/browser/loader/navigation_url_loader.h" |
19 #include "content/browser/renderer_host/render_process_host_impl.h" | |
18 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 20 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
19 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 21 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
20 #include "content/browser/site_instance_impl.h" | 22 #include "content/browser/site_instance_impl.h" |
21 #include "content/common/resource_request_body_impl.h" | 23 #include "content/common/resource_request_body_impl.h" |
22 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
23 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
24 #include "content/public/browser/navigation_controller.h" | 26 #include "content/public/browser/navigation_controller.h" |
25 #include "content/public/browser/navigation_data.h" | 27 #include "content/public/browser/navigation_data.h" |
26 #include "content/public/browser/navigation_ui_data.h" | 28 #include "content/public/browser/navigation_ui_data.h" |
27 #include "content/public/browser/storage_partition.h" | 29 #include "content/public/browser/storage_partition.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 request_params_.navigation_timing.redirect_end = base::TimeTicks::Now(); | 327 request_params_.navigation_timing.redirect_end = base::TimeTicks::Now(); |
326 request_params_.navigation_timing.fetch_start = base::TimeTicks::Now(); | 328 request_params_.navigation_timing.fetch_start = base::TimeTicks::Now(); |
327 | 329 |
328 request_params_.redirect_response.push_back(response->head); | 330 request_params_.redirect_response.push_back(response->head); |
329 | 331 |
330 request_params_.redirects.push_back(common_params_.url); | 332 request_params_.redirects.push_back(common_params_.url); |
331 common_params_.url = redirect_info.new_url; | 333 common_params_.url = redirect_info.new_url; |
332 common_params_.method = redirect_info.new_method; | 334 common_params_.method = redirect_info.new_method; |
333 common_params_.referrer.url = GURL(redirect_info.new_referrer); | 335 common_params_.referrer.url = GURL(redirect_info.new_referrer); |
334 | 336 |
335 // TODO(clamy): Have CSP + security upgrade checks here. | 337 // For non browser initiated navigations we need to check if the source and |
338 // target site instances both have access to the URL. We always allow | |
339 // browser initiated requests. | |
Charlie Reis
2016/10/24 22:04:36
I don't think it matters if the target (or rather,
ananta
2016/10/24 23:01:41
Thanks. Removed the check for the target.
| |
336 // TODO(clamy): Kill the renderer if FilterURL fails? | 340 // TODO(clamy): Kill the renderer if FilterURL fails? |
341 GURL url = common_params_.url; | |
342 if (!browser_initiated_ && source_site_instance()) { | |
343 source_site_instance()->GetProcess()->FilterURL(false, &url); | |
344 // FilterURL sets the URL to about:blank if the CSP checks prevent the | |
345 // renderer from accessing it. | |
346 if (url != common_params_.url) { | |
Charlie Reis
2016/10/24 22:04:36
This is making an assumption that FilterURL will o
ananta
2016/10/24 23:01:41
Thanks. Done.
| |
347 NavigationRequest::OnRedirectChecksComplete(NavigationThrottle::CANCEL); | |
348 return; | |
349 } | |
350 } | |
351 | |
352 if (!browser_initiated_) { | |
353 frame_tree_node()->current_frame_host()->GetSiteInstance()->GetProcess()-> | |
354 FilterURL(false, &url); | |
355 if (url != common_params_.url) { | |
356 // FilterURL sets the URL to about:blank if the CSP checks prevent the | |
357 // renderer from accessing it. | |
358 NavigationRequest::OnRedirectChecksComplete(NavigationThrottle::CANCEL); | |
359 return; | |
360 } | |
361 } | |
337 | 362 |
338 // It's safe to use base::Unretained because this NavigationRequest owns the | 363 // It's safe to use base::Unretained because this NavigationRequest owns the |
339 // NavigationHandle where the callback will be stored. | 364 // NavigationHandle where the callback will be stored. |
340 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 365 // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
341 navigation_handle_->WillRedirectRequest( | 366 navigation_handle_->WillRedirectRequest( |
342 common_params_.url, common_params_.method, common_params_.referrer.url, | 367 common_params_.url, common_params_.method, common_params_.referrer.url, |
343 false, response->head.headers, | 368 false, response->head.headers, |
344 base::Bind(&NavigationRequest::OnRedirectChecksComplete, | 369 base::Bind(&NavigationRequest::OnRedirectChecksComplete, |
345 base::Unretained(this))); | 370 base::Unretained(this))); |
346 } | 371 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 586 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
562 | 587 |
563 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 588 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
564 common_params_, request_params_, | 589 common_params_, request_params_, |
565 is_view_source_); | 590 is_view_source_); |
566 | 591 |
567 frame_tree_node_->ResetNavigationRequest(true); | 592 frame_tree_node_->ResetNavigationRequest(true); |
568 } | 593 } |
569 | 594 |
570 } // namespace content | 595 } // namespace content |
OLD | NEW |