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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 return false; // Unable to create the desired RenderFrameHost. | 328 return false; // Unable to create the desired RenderFrameHost. |
| 329 | 329 |
| 330 // Make sure no code called via RFHM::Navigate clears the pending entry. | 330 // Make sure no code called via RFHM::Navigate clears the pending entry. |
| 331 if (is_pending_entry) | 331 if (is_pending_entry) |
| 332 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 332 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
| 333 | 333 |
| 334 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 334 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 335 // Double check that here. | 335 // Double check that here. |
| 336 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); | 336 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); |
| 337 | 337 |
| 338 // In the case of a transfer navigation, set the destination RenderFrameHost | |
| 339 // as loading. This ensures that the RenderFrameHost gets in a loading state | |
| 340 // without emitting a spurrious DidStartLoading notification at the | |
| 341 // FrameTreeNode level (since the FrameTreeNode was already loading). Note | |
| 342 // that this works both for a transfer to a different RenderFrameHost in the | |
|
nasko
2016/02/09 17:15:24
Missing an "and" after "different RenderFrameHost"
clamy
2016/02/10 12:03:31
Done.
| |
| 343 // rare case where the navigation is transferred back to the same | |
| 344 // RenderFrameHost. | |
| 345 bool is_transfer = entry.transferred_global_request_id().child_id != -1; | |
| 346 if (is_transfer) | |
| 347 dest_render_frame_host->set_is_loading(true); | |
| 348 | |
| 338 // Navigate in the desired RenderFrameHost. | 349 // Navigate in the desired RenderFrameHost. |
| 339 // We can skip this step in the rare case that this is a transfer navigation | 350 // We can skip this step in the rare case that this is a transfer navigation |
| 340 // which began in the chosen RenderFrameHost, since the request has already | 351 // which began in the chosen RenderFrameHost, since the request has already |
| 341 // been issued. In that case, simply resume the response. | 352 // been issued. In that case, simply resume the response. |
| 342 bool is_transfer_to_same = | 353 bool is_transfer_to_same = is_transfer && |
| 343 entry.transferred_global_request_id().child_id != -1 && | 354 entry.transferred_global_request_id().child_id == |
| 344 entry.transferred_global_request_id().child_id == | 355 dest_render_frame_host->GetProcess()->GetID(); |
| 345 dest_render_frame_host->GetProcess()->GetID(); | |
| 346 if (!is_transfer_to_same) { | 356 if (!is_transfer_to_same) { |
| 347 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, | 357 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, |
| 348 entry.restore_type())); | 358 entry.restore_type())); |
| 349 // Create the navigation parameters. | 359 // Create the navigation parameters. |
| 350 FrameMsg_Navigate_Type::Value navigation_type = | 360 FrameMsg_Navigate_Type::Value navigation_type = |
| 351 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 361 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| 352 LoFiState lofi_state = | 362 LoFiState lofi_state = |
| 353 (reload_type == | 363 (reload_type == |
| 354 NavigationController::ReloadType::RELOAD_DISABLE_LOFI_MODE | 364 NavigationController::ReloadType::RELOAD_DISABLE_LOFI_MODE |
| 355 ? LOFI_OFF | 365 ? LOFI_OFF |
| 356 : LOFI_UNSPECIFIED); | 366 : LOFI_UNSPECIFIED); |
| 357 dest_render_frame_host->Navigate( | 367 dest_render_frame_host->Navigate( |
| 358 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, | 368 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, |
| 359 navigation_type, lofi_state, | 369 navigation_type, lofi_state, |
| 360 navigation_start), | 370 navigation_start), |
| 361 entry.ConstructStartNavigationParams(), | 371 entry.ConstructStartNavigationParams(), |
| 362 entry.ConstructRequestNavigationParams( | 372 entry.ConstructRequestNavigationParams( |
| 363 frame_entry, is_same_document_history_load, | 373 frame_entry, is_same_document_history_load, |
| 364 frame_tree_node->has_committed_real_load(), | 374 frame_tree_node->has_committed_real_load(), |
| 365 controller_->GetPendingEntryIndex() == -1, | 375 controller_->GetPendingEntryIndex() == -1, |
| 366 controller_->GetIndexOfEntry(&entry), | 376 controller_->GetIndexOfEntry(&entry), |
| 367 controller_->GetLastCommittedEntryIndex(), | 377 controller_->GetLastCommittedEntryIndex(), |
| 368 controller_->GetEntryCount())); | 378 controller_->GetEntryCount())); |
| 369 } else { | 379 } else { |
| 370 // No need to navigate again. Just resume the deferred request. | 380 // No need to navigate again. Just resume the deferred request. |
| 381 // Also sets the RenderFrameHost back to a loading state again. | |
| 371 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( | 382 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( |
| 372 entry.transferred_global_request_id()); | 383 entry.transferred_global_request_id()); |
| 373 } | 384 } |
| 374 | 385 |
| 375 // Make sure no code called via RFH::Navigate clears the pending entry. | 386 // Make sure no code called via RFH::Navigate clears the pending entry. |
| 376 if (is_pending_entry) | 387 if (is_pending_entry) |
| 377 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 388 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
| 378 | 389 |
| 379 if (controller_->GetPendingEntryIndex() == -1 && | 390 if (controller_->GetPendingEntryIndex() == -1 && |
| 380 dest_url.SchemeIs(url::kJavaScriptScheme)) { | 391 dest_url.SchemeIs(url::kJavaScriptScheme)) { |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 1049 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
| 1039 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 1050 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
| 1040 } | 1051 } |
| 1041 controller_->SetPendingEntry(std::move(entry)); | 1052 controller_->SetPendingEntry(std::move(entry)); |
| 1042 if (delegate_) | 1053 if (delegate_) |
| 1043 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1054 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1044 } | 1055 } |
| 1045 } | 1056 } |
| 1046 | 1057 |
| 1047 } // namespace content | 1058 } // namespace content |
| OLD | NEW |