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