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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()), | 507 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()), |
506 frame_tree_node_->frame_tree_node_id()), | 508 frame_tree_node_->frame_tree_node_id()), |
507 std::move(navigation_ui_data), | 509 std::move(navigation_ui_data), |
508 navigation_handle_->service_worker_handle(), this); | 510 navigation_handle_->service_worker_handle(), this); |
509 } | 511 } |
510 | 512 |
511 void NavigationRequest::OnRedirectChecksComplete( | 513 void NavigationRequest::OnRedirectChecksComplete( |
512 NavigationThrottle::ThrottleCheckResult result) { | 514 NavigationThrottle::ThrottleCheckResult result) { |
513 CHECK(result != NavigationThrottle::DEFER); | 515 CHECK(result != NavigationThrottle::DEFER); |
514 | 516 |
517 // For non browser initiated navigations we need to check if the source and | |
518 // target site instances both have access to the URL. We always allow | |
519 // browser initiated requests. | |
520 bool source_can_request = true; | |
521 if (!browser_initiated_ && source_site_instance()) { | |
ananta
2016/10/22 03:47:32
Verified that the browser_initiated_ field is set
jam
2016/10/24 16:59:16
actually, we should probably do this before thrott
ananta
2016/10/24 19:53:19
Done
| |
522 source_can_request = | |
523 ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( | |
524 source_site_instance()->GetProcess()->GetID(), | |
525 common_params_.url); | |
526 } | |
527 | |
528 bool renderer_can_request = true; | |
529 if (!browser_initiated_) { | |
530 renderer_can_request = | |
531 ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( | |
532 frame_tree_node()->current_frame_host()->GetSiteInstance()-> | |
533 GetProcess()->GetID(), | |
534 common_params_.url); | |
535 } | |
536 | |
515 // Abort the request if needed. This will destroy the NavigationRequest. | 537 // Abort the request if needed. This will destroy the NavigationRequest. |
516 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 538 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
517 result == NavigationThrottle::CANCEL) { | 539 result == NavigationThrottle::CANCEL || |
540 !source_can_request || | |
541 !renderer_can_request) { | |
518 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 542 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
519 frame_tree_node_->ResetNavigationRequest(false); | 543 frame_tree_node_->ResetNavigationRequest(false); |
520 return; | 544 return; |
521 } | 545 } |
522 | 546 |
523 loader_->FollowRedirect(); | 547 loader_->FollowRedirect(); |
524 } | 548 } |
525 | 549 |
526 void NavigationRequest::OnWillProcessResponseChecksComplete( | 550 void NavigationRequest::OnWillProcessResponseChecksComplete( |
527 NavigationThrottle::ThrottleCheckResult result) { | 551 NavigationThrottle::ThrottleCheckResult result) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 585 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
562 | 586 |
563 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 587 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
564 common_params_, request_params_, | 588 common_params_, request_params_, |
565 is_view_source_); | 589 is_view_source_); |
566 | 590 |
567 frame_tree_node_->ResetNavigationRequest(true); | 591 frame_tree_node_->ResetNavigationRequest(true); |
568 } | 592 } |
569 | 593 |
570 } // namespace content | 594 } // namespace content |
OLD | NEW |