Chromium Code Reviews| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 #include "content/public/browser/navigation_controller.h" | 37 #include "content/public/browser/navigation_controller.h" |
| 38 #include "content/public/browser/navigation_details.h" | 38 #include "content/public/browser/navigation_details.h" |
| 39 #include "content/public/browser/page_navigator.h" | 39 #include "content/public/browser/page_navigator.h" |
| 40 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
| 41 #include "content/public/browser/stream_handle.h" | 41 #include "content/public/browser/stream_handle.h" |
| 42 #include "content/public/browser/user_metrics.h" | 42 #include "content/public/browser/user_metrics.h" |
| 43 #include "content/public/common/bindings_policy.h" | 43 #include "content/public/common/bindings_policy.h" |
| 44 #include "content/public/common/browser_side_navigation_policy.h" | 44 #include "content/public/common/browser_side_navigation_policy.h" |
| 45 #include "content/public/common/content_client.h" | 45 #include "content/public/common/content_client.h" |
| 46 #include "content/public/common/content_constants.h" | 46 #include "content/public/common/content_constants.h" |
| 47 #include "content/public/common/previews_state.h" | |
| 47 #include "content/public/common/resource_response.h" | 48 #include "content/public/common/resource_response.h" |
| 48 #include "content/public/common/url_constants.h" | 49 #include "content/public/common/url_constants.h" |
| 49 #include "net/base/net_errors.h" | 50 #include "net/base/net_errors.h" |
| 50 #include "url/gurl.h" | 51 #include "url/gurl.h" |
| 51 #include "url/url_constants.h" | 52 #include "url/url_constants.h" |
| 52 | 53 |
| 53 namespace content { | 54 namespace content { |
| 54 | 55 |
| 55 namespace { | 56 namespace { |
| 56 | 57 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 | 332 |
| 332 // This will be used to set the Navigation Timing API navigationStart | 333 // This will be used to set the Navigation Timing API navigationStart |
| 333 // parameter for browser navigations in new tabs (intents, tabs opened through | 334 // parameter for browser navigations in new tabs (intents, tabs opened through |
| 334 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to | 335 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to |
| 335 // capture the time needed for the RenderFrameHost initialization. | 336 // capture the time needed for the RenderFrameHost initialization. |
| 336 base::TimeTicks navigation_start = base::TimeTicks::Now(); | 337 base::TimeTicks navigation_start = base::TimeTicks::Now(); |
| 337 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( | 338 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( |
| 338 "navigation,rail", "NavigationTiming navigationStart", | 339 "navigation,rail", "NavigationTiming navigationStart", |
| 339 TRACE_EVENT_SCOPE_GLOBAL, navigation_start); | 340 TRACE_EVENT_SCOPE_GLOBAL, navigation_start); |
| 340 | 341 |
| 341 // Determine if LoFi should be used for the navigation. | 342 // Determine if previews should be used for the navigation. |
| 342 LoFiState lofi_state = LOFI_UNSPECIFIED; | 343 int previews_state = PREVIEWS_UNSPECIFIED; |
|
nasko
2016/12/08 22:19:32
PreviewsState
megjablon
2016/12/09 20:35:53
Done.
| |
| 343 if (!frame_tree_node->IsMainFrame()) { | 344 if (!frame_tree_node->IsMainFrame()) { |
| 344 // For subframes, use the state of the top-level frame. | 345 // For subframes, use the state of the top-level frame. |
| 345 lofi_state = frame_tree_node->frame_tree() | 346 previews_state = frame_tree_node->frame_tree() |
| 346 ->root() | 347 ->root() |
| 347 ->current_frame_host() | 348 ->current_frame_host() |
| 348 ->last_navigation_lofi_state(); | 349 ->last_navigation_previews_state(); |
| 349 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) { | 350 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) { |
| 350 // Disable LoFi when asked for it explicitly. | 351 // Disable LoFi when asked for it explicitly. |
| 351 lofi_state = LOFI_OFF; | 352 previews_state = PREVIEWS_OFF; |
| 352 } | 353 } |
| 353 | 354 |
| 354 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. | 355 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. |
| 355 if (IsBrowserSideNavigationEnabled()) { | 356 if (IsBrowserSideNavigationEnabled()) { |
| 356 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, | 357 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, |
| 357 entry.restore_type())); | 358 entry.restore_type())); |
| 358 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, | 359 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, |
| 359 entry, reload_type, lofi_state, | 360 entry, reload_type, previews_state, |
| 360 is_same_document_history_load, | 361 is_same_document_history_load, |
| 361 is_history_navigation_in_new_child, navigation_start); | 362 is_history_navigation_in_new_child, navigation_start); |
| 362 if (frame_tree_node->IsMainFrame() && | 363 if (frame_tree_node->IsMainFrame() && |
| 363 frame_tree_node->navigation_request()) { | 364 frame_tree_node->navigation_request()) { |
| 364 // TODO(carlosk): extend these traces to support subframes and | 365 // TODO(carlosk): extend these traces to support subframes and |
| 365 // non-PlzNavigate navigations. | 366 // non-PlzNavigate navigations. |
| 366 // For the trace below we're using the navigation handle as the async | 367 // For the trace below we're using the navigation handle as the async |
| 367 // trace id, |navigation_start| as the timestamp and reporting the | 368 // trace id, |navigation_start| as the timestamp and reporting the |
| 368 // FrameTreeNode id as a parameter. For navigations where no network | 369 // FrameTreeNode id as a parameter. For navigations where no network |
| 369 // request is made (data URLs, JavaScript URLs, etc) there is no handle | 370 // request is made (data URLs, JavaScript URLs, etc) there is no handle |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 dest_render_frame_host->GetProcess()->GetID(); | 420 dest_render_frame_host->GetProcess()->GetID(); |
| 420 if (!is_transfer_to_same) { | 421 if (!is_transfer_to_same) { |
| 421 navigation_data_.reset(new NavigationMetricsData( | 422 navigation_data_.reset(new NavigationMetricsData( |
| 422 navigation_start, dest_url, entry.restore_type())); | 423 navigation_start, dest_url, entry.restore_type())); |
| 423 // Create the navigation parameters. | 424 // Create the navigation parameters. |
| 424 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( | 425 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( |
| 425 controller_->GetBrowserContext(), entry, reload_type); | 426 controller_->GetBrowserContext(), entry, reload_type); |
| 426 dest_render_frame_host->Navigate( | 427 dest_render_frame_host->Navigate( |
| 427 entry.ConstructCommonNavigationParams( | 428 entry.ConstructCommonNavigationParams( |
| 428 frame_entry, post_body, dest_url, dest_referrer, navigation_type, | 429 frame_entry, post_body, dest_url, dest_referrer, navigation_type, |
| 429 lofi_state, navigation_start), | 430 previews_state, navigation_start), |
| 430 entry.ConstructStartNavigationParams(), | 431 entry.ConstructStartNavigationParams(), |
| 431 entry.ConstructRequestNavigationParams( | 432 entry.ConstructRequestNavigationParams( |
| 432 frame_entry, is_same_document_history_load, | 433 frame_entry, is_same_document_history_load, |
| 433 is_history_navigation_in_new_child, | 434 is_history_navigation_in_new_child, |
| 434 entry.GetSubframeUniqueNames(frame_tree_node), | 435 entry.GetSubframeUniqueNames(frame_tree_node), |
| 435 frame_tree_node->has_committed_real_load(), | 436 frame_tree_node->has_committed_real_load(), |
| 436 controller_->GetPendingEntryIndex() == -1, | 437 controller_->GetPendingEntryIndex() == -1, |
| 437 controller_->GetIndexOfEntry(&entry), | 438 controller_->GetIndexOfEntry(&entry), |
| 438 controller_->GetLastCommittedEntryIndex(), | 439 controller_->GetLastCommittedEntryIndex(), |
| 439 controller_->GetEntryCount())); | 440 controller_->GetEntryCount())); |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 } | 1120 } |
| 1120 } | 1121 } |
| 1121 | 1122 |
| 1122 // PlzNavigate | 1123 // PlzNavigate |
| 1123 void NavigatorImpl::RequestNavigation(FrameTreeNode* frame_tree_node, | 1124 void NavigatorImpl::RequestNavigation(FrameTreeNode* frame_tree_node, |
| 1124 const GURL& dest_url, | 1125 const GURL& dest_url, |
| 1125 const Referrer& dest_referrer, | 1126 const Referrer& dest_referrer, |
| 1126 const FrameNavigationEntry& frame_entry, | 1127 const FrameNavigationEntry& frame_entry, |
| 1127 const NavigationEntryImpl& entry, | 1128 const NavigationEntryImpl& entry, |
| 1128 ReloadType reload_type, | 1129 ReloadType reload_type, |
| 1129 LoFiState lofi_state, | 1130 int previews_state, |
|
nasko
2016/12/08 22:19:32
PreviewsState
megjablon
2016/12/09 20:35:54
Done.
| |
| 1130 bool is_same_document_history_load, | 1131 bool is_same_document_history_load, |
| 1131 bool is_history_navigation_in_new_child, | 1132 bool is_history_navigation_in_new_child, |
| 1132 base::TimeTicks navigation_start) { | 1133 base::TimeTicks navigation_start) { |
| 1133 CHECK(IsBrowserSideNavigationEnabled()); | 1134 CHECK(IsBrowserSideNavigationEnabled()); |
| 1134 DCHECK(frame_tree_node); | 1135 DCHECK(frame_tree_node); |
| 1135 | 1136 |
| 1136 // This value must be set here because creating a NavigationRequest might | 1137 // This value must be set here because creating a NavigationRequest might |
| 1137 // change the renderer live/non-live status and change this result. | 1138 // change the renderer live/non-live status and change this result. |
| 1138 bool should_dispatch_beforeunload = | 1139 bool should_dispatch_beforeunload = |
| 1139 !is_same_document_history_load && | 1140 !is_same_document_history_load && |
| 1140 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); | 1141 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); |
| 1141 FrameMsg_Navigate_Type::Value navigation_type = | 1142 FrameMsg_Navigate_Type::Value navigation_type = |
| 1142 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 1143 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| 1143 std::unique_ptr<NavigationRequest> scoped_request = | 1144 std::unique_ptr<NavigationRequest> scoped_request = |
| 1144 NavigationRequest::CreateBrowserInitiated( | 1145 NavigationRequest::CreateBrowserInitiated( |
| 1145 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, | 1146 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, |
| 1146 navigation_type, lofi_state, is_same_document_history_load, | 1147 navigation_type, previews_state, is_same_document_history_load, |
| 1147 is_history_navigation_in_new_child, navigation_start, controller_); | 1148 is_history_navigation_in_new_child, navigation_start, controller_); |
| 1148 NavigationRequest* navigation_request = scoped_request.get(); | 1149 NavigationRequest* navigation_request = scoped_request.get(); |
| 1149 | 1150 |
| 1150 // Navigation to a javascript URL is not a "real" navigation so there is no | 1151 // Navigation to a javascript URL is not a "real" navigation so there is no |
| 1151 // need to create a NavigationHandle. The navigation commits immediately and | 1152 // need to create a NavigationHandle. The navigation commits immediately and |
| 1152 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to | 1153 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to |
| 1153 // a Javascript URL should not interrupt a previous navigation. | 1154 // a Javascript URL should not interrupt a previous navigation. |
| 1154 // Note: The scoped_request will be destroyed at the end of this function. | 1155 // Note: The scoped_request will be destroyed at the end of this function. |
| 1155 if (dest_url.SchemeIs(url::kJavaScriptScheme)) { | 1156 if (dest_url.SchemeIs(url::kJavaScriptScheme)) { |
| 1156 RenderFrameHostImpl* render_frame_host = | 1157 RenderFrameHostImpl* render_frame_host = |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1271 if (navigation_handle) | 1272 if (navigation_handle) |
| 1272 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1273 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
| 1273 | 1274 |
| 1274 controller_->SetPendingEntry(std::move(entry)); | 1275 controller_->SetPendingEntry(std::move(entry)); |
| 1275 if (delegate_) | 1276 if (delegate_) |
| 1276 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1277 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1277 } | 1278 } |
| 1278 } | 1279 } |
| 1279 | 1280 |
| 1280 } // namespace content | 1281 } // namespace content |
| OLD | NEW |