| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/dump_without_crashing.h" | 7 #include "base/debug/dump_without_crashing.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/browser/browsing_data/clear_site_data_throttle.h" | 9 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| 11 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 11 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 12 #include "content/browser/frame_host/debug_urls.h" | 12 #include "content/browser/frame_host/debug_urls.h" |
| 13 #include "content/browser/frame_host/frame_tree_node.h" | 13 #include "content/browser/frame_host/frame_tree_node.h" |
| 14 #include "content/browser/frame_host/navigator.h" | 14 #include "content/browser/frame_host/navigator.h" |
| 15 #include "content/browser/frame_host/navigator_delegate.h" | 15 #include "content/browser/frame_host/navigator_delegate.h" |
| 16 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 16 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 17 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 18 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| 18 #include "content/common/frame_messages.h" | 19 #include "content/common/frame_messages.h" |
| 19 #include "content/common/resource_request_body_impl.h" | 20 #include "content/common/resource_request_body_impl.h" |
| 20 #include "content/common/site_isolation_policy.h" | 21 #include "content/common/site_isolation_policy.h" |
| 21 #include "content/public/browser/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
| 22 #include "content/public/browser/navigation_ui_data.h" | 23 #include "content/public/browser/navigation_ui_data.h" |
| 23 #include "content/public/browser/site_instance.h" | 24 #include "content/public/browser/site_instance.h" |
| 24 #include "content/public/common/browser_side_navigation_policy.h" | 25 #include "content/public/common/browser_side_navigation_policy.h" |
| 25 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
| 26 #include "content/public/common/url_constants.h" | 27 #include "content/public/common/url_constants.h" |
| 27 #include "net/url_request/redirect_info.h" | 28 #include "net/url_request/redirect_info.h" |
| 28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 29 #include "url/url_constants.h" | 30 #include "url/url_constants.h" |
| 30 | 31 |
| 31 namespace content { | 32 namespace content { |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 void UpdateThrottleCheckResult( | 36 void UpdateThrottleCheckResult( |
| 36 NavigationThrottle::ThrottleCheckResult* to_update, | 37 NavigationThrottle::ThrottleCheckResult* to_update, |
| 37 NavigationThrottle::ThrottleCheckResult result) { | 38 NavigationThrottle::ThrottleCheckResult result) { |
| 38 *to_update = result; | 39 *to_update = result; |
| 39 } | 40 } |
| 40 | 41 |
| 42 void NotifyAbandonedTransferNavigation(const GlobalRequestID& id) { |
| 43 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 44 if (ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get()) |
| 45 rdh->CancelRequest(id.child_id, id.request_id); |
| 46 } |
| 47 |
| 41 } // namespace | 48 } // namespace |
| 42 | 49 |
| 43 // static | 50 // static |
| 44 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 51 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
| 45 const GURL& url, | 52 const GURL& url, |
| 46 FrameTreeNode* frame_tree_node, | 53 FrameTreeNode* frame_tree_node, |
| 47 bool is_renderer_initiated, | 54 bool is_renderer_initiated, |
| 48 bool is_same_page, | 55 bool is_same_page, |
| 49 bool is_srcdoc, | 56 bool is_srcdoc, |
| 50 const base::TimeTicks& navigation_start, | 57 const base::TimeTicks& navigation_start, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 GetDelegate()->DidStartNavigation(this); | 105 GetDelegate()->DidStartNavigation(this); |
| 99 | 106 |
| 100 if (IsInMainFrame()) { | 107 if (IsInMainFrame()) { |
| 101 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 108 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 102 "navigation", "Navigation StartToCommit", this, | 109 "navigation", "Navigation StartToCommit", this, |
| 103 navigation_start, "Initial URL", url_.spec()); | 110 navigation_start, "Initial URL", url_.spec()); |
| 104 } | 111 } |
| 105 } | 112 } |
| 106 | 113 |
| 107 NavigationHandleImpl::~NavigationHandleImpl() { | 114 NavigationHandleImpl::~NavigationHandleImpl() { |
| 115 // Transfer requests that have not matched up with another navigation request |
| 116 // from the renderer need to be cleaned up. These are marked as protected in |
| 117 // the RDHI, so they do not get cancelled when frames are destroyed. |
| 118 if (is_transferring()) { |
| 119 BrowserThread::PostTask( |
| 120 BrowserThread::IO, FROM_HERE, |
| 121 base::Bind(&NotifyAbandonedTransferNavigation, GetGlobalRequestID())); |
| 122 } |
| 123 |
| 108 if (!IsRendererDebugURL(url_)) | 124 if (!IsRendererDebugURL(url_)) |
| 109 GetDelegate()->DidFinishNavigation(this); | 125 GetDelegate()->DidFinishNavigation(this); |
| 110 | 126 |
| 111 // Cancel the navigation on the IO thread if the NavigationHandle is being | 127 // Cancel the navigation on the IO thread if the NavigationHandle is being |
| 112 // destroyed in the middle of the NavigationThrottles checks. | 128 // destroyed in the middle of the NavigationThrottles checks. |
| 113 if (!IsBrowserSideNavigationEnabled() && !complete_callback_.is_null()) | 129 if (!IsBrowserSideNavigationEnabled() && !complete_callback_.is_null()) |
| 114 RunCompleteCallback(NavigationThrottle::CANCEL_AND_IGNORE); | 130 RunCompleteCallback(NavigationThrottle::CANCEL_AND_IGNORE); |
| 115 | 131 |
| 116 if (IsInMainFrame()) { | 132 if (IsInMainFrame()) { |
| 117 TRACE_EVENT_ASYNC_END2("navigation", "Navigation StartToCommit", this, | 133 TRACE_EVENT_ASYNC_END2("navigation", "Navigation StartToCommit", this, |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 throttles_to_register.push_back(std::move(clear_site_data_throttle)); | 787 throttles_to_register.push_back(std::move(clear_site_data_throttle)); |
| 772 | 788 |
| 773 if (throttles_to_register.size() > 0) { | 789 if (throttles_to_register.size() > 0) { |
| 774 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), | 790 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), |
| 775 throttles_to_register.end()); | 791 throttles_to_register.end()); |
| 776 throttles_to_register.weak_clear(); | 792 throttles_to_register.weak_clear(); |
| 777 } | 793 } |
| 778 } | 794 } |
| 779 | 795 |
| 780 } // namespace content | 796 } // namespace content |
| OLD | NEW |