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 | |
352 // Navigate in the desired RenderFrameHost. | 341 // Navigate in the desired RenderFrameHost. |
353 // We can skip this step in the rare case that this is a transfer navigation | 342 // We can skip this step in the rare case that this is a transfer navigation |
354 // which began in the chosen RenderFrameHost, since the request has already | 343 // which began in the chosen RenderFrameHost, since the request has already |
355 // been issued. In that case, simply resume the response. | 344 // been issued. In that case, simply resume the response. |
356 bool is_transfer_to_same = is_transfer && | 345 bool is_transfer_to_same = |
357 entry.transferred_global_request_id().child_id == | 346 entry.transferred_global_request_id().child_id != -1 && |
358 dest_render_frame_host->GetProcess()->GetID(); | 347 entry.transferred_global_request_id().child_id == |
| 348 dest_render_frame_host->GetProcess()->GetID(); |
359 if (!is_transfer_to_same) { | 349 if (!is_transfer_to_same) { |
360 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, | 350 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, |
361 entry.restore_type())); | 351 entry.restore_type())); |
362 // Create the navigation parameters. | 352 // Create the navigation parameters. |
363 FrameMsg_Navigate_Type::Value navigation_type = | 353 FrameMsg_Navigate_Type::Value navigation_type = |
364 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 354 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
365 LoFiState lofi_state = | 355 LoFiState lofi_state = |
366 (reload_type == | 356 (reload_type == |
367 NavigationController::ReloadType::RELOAD_DISABLE_LOFI_MODE | 357 NavigationController::ReloadType::RELOAD_DISABLE_LOFI_MODE |
368 ? LOFI_OFF | 358 ? LOFI_OFF |
369 : LOFI_UNSPECIFIED); | 359 : LOFI_UNSPECIFIED); |
370 dest_render_frame_host->Navigate( | 360 dest_render_frame_host->Navigate( |
371 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, | 361 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, |
372 navigation_type, lofi_state, | 362 navigation_type, lofi_state, |
373 navigation_start), | 363 navigation_start), |
374 entry.ConstructStartNavigationParams(), | 364 entry.ConstructStartNavigationParams(), |
375 entry.ConstructRequestNavigationParams( | 365 entry.ConstructRequestNavigationParams( |
376 frame_entry, is_same_document_history_load, | 366 frame_entry, is_same_document_history_load, |
377 frame_tree_node->has_committed_real_load(), | 367 frame_tree_node->has_committed_real_load(), |
378 controller_->GetPendingEntryIndex() == -1, | 368 controller_->GetPendingEntryIndex() == -1, |
379 controller_->GetIndexOfEntry(&entry), | 369 controller_->GetIndexOfEntry(&entry), |
380 controller_->GetLastCommittedEntryIndex(), | 370 controller_->GetLastCommittedEntryIndex(), |
381 controller_->GetEntryCount())); | 371 controller_->GetEntryCount())); |
382 } else { | 372 } else { |
383 // No need to navigate again. Just resume the deferred request. | 373 // No need to navigate again. Just resume the deferred request. |
384 // Also sets the RenderFrameHost back to a loading state again. | |
385 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( | 374 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( |
386 entry.transferred_global_request_id()); | 375 entry.transferred_global_request_id()); |
387 } | 376 } |
388 | 377 |
389 // Make sure no code called via RFH::Navigate clears the pending entry. | 378 // Make sure no code called via RFH::Navigate clears the pending entry. |
390 if (is_pending_entry) | 379 if (is_pending_entry) |
391 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 380 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
392 | 381 |
393 if (controller_->GetPendingEntryIndex() == -1 && | 382 if (controller_->GetPendingEntryIndex() == -1 && |
394 dest_url.SchemeIs(url::kJavaScriptScheme)) { | 383 dest_url.SchemeIs(url::kJavaScriptScheme)) { |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 1041 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
1053 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 1042 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
1054 } | 1043 } |
1055 controller_->SetPendingEntry(std::move(entry)); | 1044 controller_->SetPendingEntry(std::move(entry)); |
1056 if (delegate_) | 1045 if (delegate_) |
1057 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1046 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1058 } | 1047 } |
1059 } | 1048 } |
1060 | 1049 |
1061 } // namespace content | 1050 } // namespace content |
OLD | NEW |