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