| 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 <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/debug/dump_without_crashing.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 11 #include "content/browser/appcache/appcache_navigation_handle.h" | 12 #include "content/browser/appcache/appcache_navigation_handle.h" |
| 12 #include "content/browser/appcache/appcache_service_impl.h" | 13 #include "content/browser/appcache/appcache_service_impl.h" |
| 13 #include "content/browser/child_process_security_policy_impl.h" | 14 #include "content/browser/child_process_security_policy_impl.h" |
| 14 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 15 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 15 #include "content/browser/frame_host/ancestor_throttle.h" | 16 #include "content/browser/frame_host/ancestor_throttle.h" |
| 16 #include "content/browser/frame_host/data_url_navigation_throttle.h" | 17 #include "content/browser/frame_host/data_url_navigation_throttle.h" |
| 17 #include "content/browser/frame_host/debug_urls.h" | 18 #include "content/browser/frame_host/debug_urls.h" |
| 18 #include "content/browser/frame_host/form_submission_throttle.h" | 19 #include "content/browser/frame_host/form_submission_throttle.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 is_download_(false), | 117 is_download_(false), |
| 117 is_stream_(false), | 118 is_stream_(false), |
| 118 started_from_context_menu_(started_from_context_menu), | 119 started_from_context_menu_(started_from_context_menu), |
| 119 reload_type_(ReloadType::NONE), | 120 reload_type_(ReloadType::NONE), |
| 120 restore_type_(RestoreType::NONE), | 121 restore_type_(RestoreType::NONE), |
| 121 navigation_type_(NAVIGATION_TYPE_UNKNOWN), | 122 navigation_type_(NAVIGATION_TYPE_UNKNOWN), |
| 122 should_check_main_world_csp_(should_check_main_world_csp), | 123 should_check_main_world_csp_(should_check_main_world_csp), |
| 123 is_form_submission_(is_form_submission), | 124 is_form_submission_(is_form_submission), |
| 124 expected_render_process_host_id_(ChildProcessHost::kInvalidUniqueID), | 125 expected_render_process_host_id_(ChildProcessHost::kInvalidUniqueID), |
| 125 weak_factory_(this) { | 126 weak_factory_(this) { |
| 127 is_in_constructor = true; |
| 126 TRACE_EVENT_ASYNC_BEGIN2("navigation", "NavigationHandle", this, | 128 TRACE_EVENT_ASYNC_BEGIN2("navigation", "NavigationHandle", this, |
| 127 "frame_tree_node", | 129 "frame_tree_node", |
| 128 frame_tree_node_->frame_tree_node_id(), "url", | 130 frame_tree_node_->frame_tree_node_id(), "url", |
| 129 url_.possibly_invalid_spec()); | 131 url_.possibly_invalid_spec()); |
| 130 DCHECK(!navigation_start.is_null()); | 132 DCHECK(!navigation_start.is_null()); |
| 131 | 133 |
| 132 site_url_ = SiteInstance::GetSiteForURL(frame_tree_node_->current_frame_host() | 134 site_url_ = SiteInstance::GetSiteForURL(frame_tree_node_->current_frame_host() |
| 133 ->GetSiteInstance() | 135 ->GetSiteInstance() |
| 134 ->GetBrowserContext(), | 136 ->GetBrowserContext(), |
| 135 url_); | 137 url_); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (IsInMainFrame()) { | 171 if (IsInMainFrame()) { |
| 170 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 172 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 171 "navigation", "Navigation StartToCommit", this, | 173 "navigation", "Navigation StartToCommit", this, |
| 172 navigation_start, "Initial URL", url_.spec()); | 174 navigation_start, "Initial URL", url_.spec()); |
| 173 } | 175 } |
| 174 | 176 |
| 175 if (is_same_document_) { | 177 if (is_same_document_) { |
| 176 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, | 178 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 177 "Same document"); | 179 "Same document"); |
| 178 } | 180 } |
| 181 is_in_constructor = false; |
| 179 } | 182 } |
| 180 | 183 |
| 181 NavigationHandleImpl::~NavigationHandleImpl() { | 184 NavigationHandleImpl::~NavigationHandleImpl() { |
| 185 // TODO(arthursonzogni): Remove this when we understand the root cause behind |
| 186 // crbug.com/704892. |
| 187 if (is_in_constructor) |
| 188 base::debug::DumpWithoutCrashing(); |
| 189 |
| 182 // Inform the RenderProcessHost to no longer expect a navigation. | 190 // Inform the RenderProcessHost to no longer expect a navigation. |
| 183 if (expected_render_process_host_id_ != ChildProcessHost::kInvalidUniqueID) { | 191 if (expected_render_process_host_id_ != ChildProcessHost::kInvalidUniqueID) { |
| 184 RenderProcessHost* process = | 192 RenderProcessHost* process = |
| 185 RenderProcessHost::FromID(expected_render_process_host_id_); | 193 RenderProcessHost::FromID(expected_render_process_host_id_); |
| 186 if (process) { | 194 if (process) { |
| 187 RenderProcessHostImpl::RemoveExpectedNavigationToSite( | 195 RenderProcessHostImpl::RemoveExpectedNavigationToSite( |
| 188 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 196 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
| 189 process, site_url_); | 197 process, site_url_); |
| 190 } | 198 } |
| 191 } | 199 } |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 const GURL& new_referrer_url, | 646 const GURL& new_referrer_url, |
| 639 bool new_is_external_protocol, | 647 bool new_is_external_protocol, |
| 640 scoped_refptr<net::HttpResponseHeaders> response_headers, | 648 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 641 net::HttpResponseInfo::ConnectionInfo connection_info, | 649 net::HttpResponseInfo::ConnectionInfo connection_info, |
| 642 RenderProcessHost* post_redirect_process, | 650 RenderProcessHost* post_redirect_process, |
| 643 const ThrottleChecksFinishedCallback& callback) { | 651 const ThrottleChecksFinishedCallback& callback) { |
| 644 TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this, | 652 TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this, |
| 645 "WillRedirectRequest", "url", | 653 "WillRedirectRequest", "url", |
| 646 new_url.possibly_invalid_spec()); | 654 new_url.possibly_invalid_spec()); |
| 647 | 655 |
| 648 // |new_url| is not expected to be a "renderer debug" url. It should be | 656 // TODO(arthursonzogni): Remove this when we understand the root cause behind |
| 649 // blocked in NavigationRequest::OnRequestRedirected or in | 657 // crbug.com/704892 and crbug.com/736658 |
| 650 // ResourceLoader::OnReceivedRedirect. If it is not the case, | 658 if (IsRendererDebugURL(new_url)) |
| 651 // DidFinishNavigation will not be called. It could confuse some | 659 base::debug::DumpWithoutCrashing(); |
| 652 // WebContentsObserver because DidStartNavigation was called. | |
| 653 // See https://crbug.com/728398. | |
| 654 CHECK(!IsRendererDebugURL(new_url)); | |
| 655 | 660 |
| 656 // Update the navigation parameters. | 661 // Update the navigation parameters. |
| 657 url_ = new_url; | 662 url_ = new_url; |
| 658 method_ = new_method; | 663 method_ = new_method; |
| 659 UpdateSiteURL(post_redirect_process); | 664 UpdateSiteURL(post_redirect_process); |
| 660 | 665 |
| 661 if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) { | 666 if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) { |
| 662 sanitized_referrer_.url = new_referrer_url; | 667 sanitized_referrer_.url = new_referrer_url; |
| 663 sanitized_referrer_ = | 668 sanitized_referrer_ = |
| 664 Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 669 Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 // Stop expecting a navigation to the current site URL in the current expected | 1222 // Stop expecting a navigation to the current site URL in the current expected |
| 1218 // process. | 1223 // process. |
| 1219 SetExpectedProcess(nullptr); | 1224 SetExpectedProcess(nullptr); |
| 1220 | 1225 |
| 1221 // Update the site URL and the expected process. | 1226 // Update the site URL and the expected process. |
| 1222 site_url_ = new_site_url; | 1227 site_url_ = new_site_url; |
| 1223 SetExpectedProcess(post_redirect_process); | 1228 SetExpectedProcess(post_redirect_process); |
| 1224 } | 1229 } |
| 1225 | 1230 |
| 1226 } // namespace content | 1231 } // namespace content |
| OLD | NEW |