OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 const base::TimeTicks& navigation_start) { | 118 const base::TimeTicks& navigation_start) { |
119 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); | 119 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); |
120 bool is_error_page = (url.spec() == kUnreachableWebDataURL); | 120 bool is_error_page = (url.spec() == kUnreachableWebDataURL); |
121 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); | 121 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); |
122 GURL validated_url(url); | 122 GURL validated_url(url); |
123 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); | 123 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); |
124 render_process_host->FilterURL(false, &validated_url); | 124 render_process_host->FilterURL(false, &validated_url); |
125 | 125 |
126 if (is_main_frame && !is_error_page) { | 126 if (is_main_frame && !is_error_page) { |
127 DidStartMainFrameNavigation(validated_url, | 127 DidStartMainFrameNavigation(validated_url, |
128 render_frame_host->GetSiteInstance()); | 128 render_frame_host->GetSiteInstance(), |
129 render_frame_host->navigation_handle()); | |
129 } | 130 } |
130 | 131 |
131 if (delegate_) { | 132 if (delegate_) { |
132 // Notify the observer about the start of the provisional load. | 133 // Notify the observer about the start of the provisional load. |
133 delegate_->DidStartProvisionalLoad(render_frame_host, validated_url, | 134 delegate_->DidStartProvisionalLoad(render_frame_host, validated_url, |
134 is_error_page, is_iframe_srcdoc); | 135 is_error_page, is_iframe_srcdoc); |
135 } | 136 } |
136 | 137 |
137 if (is_error_page || IsBrowserSideNavigationEnabled()) | 138 if (is_error_page || IsBrowserSideNavigationEnabled()) |
138 return; | 139 return; |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
839 if (frame_tree_node->IsMainFrame()) { | 840 if (frame_tree_node->IsMainFrame()) { |
840 // Renderer-initiated main-frame navigations that need to swap processes | 841 // Renderer-initiated main-frame navigations that need to swap processes |
841 // will go to the browser via a OpenURL call, and then be handled by the | 842 // will go to the browser via a OpenURL call, and then be handled by the |
842 // same code path as browser-initiated navigations. For renderer-initiated | 843 // same code path as browser-initiated navigations. For renderer-initiated |
843 // main frame navigation that start via a BeginNavigation IPC, the | 844 // main frame navigation that start via a BeginNavigation IPC, the |
844 // RenderFrameHost will not be swapped. Therefore it is safe to call | 845 // RenderFrameHost will not be swapped. Therefore it is safe to call |
845 // DidStartMainFrameNavigation with the SiteInstance from the current | 846 // DidStartMainFrameNavigation with the SiteInstance from the current |
846 // RenderFrameHost. | 847 // RenderFrameHost. |
847 DidStartMainFrameNavigation( | 848 DidStartMainFrameNavigation( |
848 common_params.url, | 849 common_params.url, |
849 frame_tree_node->current_frame_host()->GetSiteInstance()); | 850 frame_tree_node->current_frame_host()->GetSiteInstance(), nullptr); |
850 navigation_data_.reset(); | 851 navigation_data_.reset(); |
851 } | 852 } |
852 | 853 |
853 // For main frames, NavigationHandle will be created after the call to | 854 // For main frames, NavigationHandle will be created after the call to |
854 // |DidStartMainFrameNavigation|, so it receives the most up to date pending | 855 // |DidStartMainFrameNavigation|, so it receives the most up to date pending |
855 // entry from the NavigationController. | 856 // entry from the NavigationController. |
856 NavigationEntry* pending_entry = controller_->GetPendingEntry(); | 857 NavigationEntry* pending_entry = controller_->GetPendingEntry(); |
857 navigation_request->CreateNavigationHandle( | 858 navigation_request->CreateNavigationHandle( |
858 pending_entry ? pending_entry->GetUniqueID() : 0); | 859 pending_entry ? pending_entry->GetUniqueID() : 0); |
859 navigation_request->BeginNavigation(); | 860 navigation_request->BeginNavigation(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1083 time_to_commit); | 1084 time_to_commit); |
1084 UMA_HISTOGRAM_TIMES( | 1085 UMA_HISTOGRAM_TIMES( |
1085 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 1086 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
1086 time_to_network); | 1087 time_to_network); |
1087 } | 1088 } |
1088 navigation_data_.reset(); | 1089 navigation_data_.reset(); |
1089 } | 1090 } |
1090 | 1091 |
1091 void NavigatorImpl::DidStartMainFrameNavigation( | 1092 void NavigatorImpl::DidStartMainFrameNavigation( |
1092 const GURL& url, | 1093 const GURL& url, |
1093 SiteInstanceImpl* site_instance) { | 1094 SiteInstanceImpl* site_instance, |
1095 NavigationHandleImpl* navigation_handle) { | |
1094 // If there is no browser-initiated pending entry for this navigation and it | 1096 // If there is no browser-initiated pending entry for this navigation and it |
1095 // is not for the error URL, create a pending entry using the current | 1097 // is not for the error URL, create a pending entry using the current |
1096 // SiteInstance, and ensure the address bar updates accordingly. We don't | 1098 // SiteInstance, and ensure the address bar updates accordingly. We don't |
1097 // know the referrer or extra headers at this point, but the referrer will | 1099 // know the referrer or extra headers at this point, but the referrer will |
1098 // be set properly upon commit. | 1100 // be set properly upon commit. |
1099 NavigationEntryImpl* pending_entry = controller_->GetPendingEntry(); | 1101 NavigationEntryImpl* pending_entry = controller_->GetPendingEntry(); |
1100 bool has_browser_initiated_pending_entry = | 1102 bool has_browser_initiated_pending_entry = |
1101 pending_entry && !pending_entry->is_renderer_initiated(); | 1103 pending_entry && !pending_entry->is_renderer_initiated(); |
1102 if (!has_browser_initiated_pending_entry) { | 1104 if (!has_browser_initiated_pending_entry) { |
1103 scoped_ptr<NavigationEntryImpl> entry = | 1105 scoped_ptr<NavigationEntryImpl> entry = |
1104 NavigationEntryImpl::FromNavigationEntry( | 1106 NavigationEntryImpl::FromNavigationEntry( |
1105 controller_->CreateNavigationEntry( | 1107 controller_->CreateNavigationEntry( |
1106 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 1108 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
1107 true /* is_renderer_initiated */, std::string(), | 1109 true /* is_renderer_initiated */, std::string(), |
1108 controller_->GetBrowserContext())); | 1110 controller_->GetBrowserContext())); |
1109 entry->set_site_instance(site_instance); | 1111 entry->set_site_instance(site_instance); |
1110 // TODO(creis): If there's a pending entry already, find a safe way to | 1112 // TODO(creis): If there's a pending entry already, find a safe way to |
1111 // update it instead of replacing it and copying over things like this. | 1113 // update it instead of replacing it and copying over things like this. |
1114 // That will allow us to skip the NavigationHandle update below as well. | |
1112 if (pending_entry) { | 1115 if (pending_entry) { |
1113 entry->set_transferred_global_request_id( | 1116 entry->set_transferred_global_request_id( |
1114 pending_entry->transferred_global_request_id()); | 1117 pending_entry->transferred_global_request_id()); |
1115 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 1118 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
1116 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 1119 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
1117 } | 1120 } |
1121 | |
1122 // If there's a current NavigationHandle, update its pending NavEntry ID. | |
Charlie Harrison
2016/03/11 15:15:14
Good catch.
| |
1123 // This is necessary for transfer navigations. The handle may be null in | |
1124 // PlzNavigate. | |
1125 if (navigation_handle) | |
1126 navigation_handle->set_pending_nav_entry_id(entry->GetUniqueID()); | |
1127 | |
1118 controller_->SetPendingEntry(std::move(entry)); | 1128 controller_->SetPendingEntry(std::move(entry)); |
1119 if (delegate_) | 1129 if (delegate_) |
1120 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1130 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1121 } | 1131 } |
1122 } | 1132 } |
1123 | 1133 |
1124 } // namespace content | 1134 } // namespace content |
OLD | NEW |