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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 error_description, was_ignored_by_handler); | 262 error_description, was_ignored_by_handler); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 bool NavigatorImpl::NavigateToEntry( | 266 bool NavigatorImpl::NavigateToEntry( |
| 267 FrameTreeNode* frame_tree_node, | 267 FrameTreeNode* frame_tree_node, |
| 268 const FrameNavigationEntry& frame_entry, | 268 const FrameNavigationEntry& frame_entry, |
| 269 const NavigationEntryImpl& entry, | 269 const NavigationEntryImpl& entry, |
| 270 NavigationController::ReloadType reload_type, | 270 NavigationController::ReloadType reload_type, |
| 271 bool is_same_document_history_load, | 271 bool is_same_document_history_load, |
| 272 bool is_pending_entry) { | 272 bool is_pending_entry, |
| 273 const scoped_refptr<ResourceRequestBody>& post_body) { | |
| 273 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); | 274 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); |
| 274 | 275 |
| 275 GURL dest_url = frame_entry.url(); | 276 GURL dest_url = frame_entry.url(); |
| 276 Referrer dest_referrer = frame_entry.referrer(); | 277 Referrer dest_referrer = frame_entry.referrer(); |
| 277 if (reload_type == | 278 if (reload_type == |
| 278 NavigationController::ReloadType::RELOAD_ORIGINAL_REQUEST_URL && | 279 NavigationController::ReloadType::RELOAD_ORIGINAL_REQUEST_URL && |
| 279 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { | 280 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { |
| 280 // We may have been redirected when navigating to the current URL. | 281 // We may have been redirected when navigating to the current URL. |
| 281 // Use the URL the user originally intended to visit, if it's valid and if a | 282 // Use the URL the user originally intended to visit, if it's valid and if a |
| 282 // POST wasn't involved; the latter case avoids issues with sending data to | 283 // POST wasn't involved; the latter case avoids issues with sending data to |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 is_transfer && | 381 is_transfer && |
| 381 entry.transferred_global_request_id().child_id == | 382 entry.transferred_global_request_id().child_id == |
| 382 dest_render_frame_host->GetProcess()->GetID(); | 383 dest_render_frame_host->GetProcess()->GetID(); |
| 383 if (!is_transfer_to_same) { | 384 if (!is_transfer_to_same) { |
| 384 navigation_data_.reset(new NavigationMetricsData( | 385 navigation_data_.reset(new NavigationMetricsData( |
| 385 navigation_start, dest_url, entry.restore_type())); | 386 navigation_start, dest_url, entry.restore_type())); |
| 386 // Create the navigation parameters. | 387 // Create the navigation parameters. |
| 387 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( | 388 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( |
| 388 controller_->GetBrowserContext(), entry, reload_type); | 389 controller_->GetBrowserContext(), entry, reload_type); |
| 389 dest_render_frame_host->Navigate( | 390 dest_render_frame_host->Navigate( |
| 390 entry.ConstructCommonNavigationParams(frame_entry, nullptr, dest_url, | 391 entry.ConstructCommonNavigationParams( |
| 391 dest_referrer, navigation_type, | 392 frame_entry, post_body, dest_url, dest_referrer, navigation_type, |
|
clamy
2016/05/23 15:32:28
Right now this is only used for transfers right? I
Łukasz Anforowicz
2016/05/23 16:25:10
Yes, I believe so.
| |
| 392 lofi_state, navigation_start), | 393 lofi_state, navigation_start), |
| 393 entry.ConstructStartNavigationParams(), | 394 entry.ConstructStartNavigationParams(), |
| 394 entry.ConstructRequestNavigationParams( | 395 entry.ConstructRequestNavigationParams( |
| 395 frame_entry, is_same_document_history_load, | 396 frame_entry, is_same_document_history_load, |
| 396 frame_tree_node->has_committed_real_load(), | 397 frame_tree_node->has_committed_real_load(), |
| 397 controller_->GetPendingEntryIndex() == -1, | 398 controller_->GetPendingEntryIndex() == -1, |
| 398 controller_->GetIndexOfEntry(&entry), | 399 controller_->GetIndexOfEntry(&entry), |
| 399 controller_->GetLastCommittedEntryIndex(), | 400 controller_->GetLastCommittedEntryIndex(), |
| 400 controller_->GetEntryCount())); | 401 controller_->GetEntryCount())); |
| 401 } else { | 402 } else { |
| 402 // No need to navigate again. Just resume the deferred request. | 403 // No need to navigate again. Just resume the deferred request. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 429 return true; | 430 return true; |
| 430 } | 431 } |
| 431 | 432 |
| 432 bool NavigatorImpl::NavigateToPendingEntry( | 433 bool NavigatorImpl::NavigateToPendingEntry( |
| 433 FrameTreeNode* frame_tree_node, | 434 FrameTreeNode* frame_tree_node, |
| 434 const FrameNavigationEntry& frame_entry, | 435 const FrameNavigationEntry& frame_entry, |
| 435 NavigationController::ReloadType reload_type, | 436 NavigationController::ReloadType reload_type, |
| 436 bool is_same_document_history_load) { | 437 bool is_same_document_history_load) { |
| 437 return NavigateToEntry(frame_tree_node, frame_entry, | 438 return NavigateToEntry(frame_tree_node, frame_entry, |
| 438 *controller_->GetPendingEntry(), reload_type, | 439 *controller_->GetPendingEntry(), reload_type, |
| 439 is_same_document_history_load, true); | 440 is_same_document_history_load, true, nullptr); |
| 440 } | 441 } |
| 441 | 442 |
| 442 bool NavigatorImpl::NavigateNewChildFrame( | 443 bool NavigatorImpl::NavigateNewChildFrame( |
| 443 RenderFrameHostImpl* render_frame_host, | 444 RenderFrameHostImpl* render_frame_host, |
| 444 const std::string& unique_name) { | 445 const std::string& unique_name) { |
| 445 NavigationEntryImpl* entry = | 446 NavigationEntryImpl* entry = |
| 446 controller_->GetEntryWithUniqueID(render_frame_host->nav_entry_id()); | 447 controller_->GetEntryWithUniqueID(render_frame_host->nav_entry_id()); |
| 447 if (!entry) | 448 if (!entry) |
| 448 return false; | 449 return false; |
| 449 | 450 |
| 450 // TODO(creis): Remove unique_name from the IPC, now that we can rely on the | 451 // TODO(creis): Remove unique_name from the IPC, now that we can rely on the |
| 451 // replication state. | 452 // replication state. |
| 452 DCHECK_EQ(render_frame_host->frame_tree_node()->unique_name(), unique_name); | 453 DCHECK_EQ(render_frame_host->frame_tree_node()->unique_name(), unique_name); |
| 453 FrameNavigationEntry* frame_entry = | 454 FrameNavigationEntry* frame_entry = |
| 454 entry->GetFrameEntry(render_frame_host->frame_tree_node()); | 455 entry->GetFrameEntry(render_frame_host->frame_tree_node()); |
| 455 if (!frame_entry) | 456 if (!frame_entry) |
| 456 return false; | 457 return false; |
| 457 | 458 |
| 458 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, | 459 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, |
| 459 *entry, NavigationControllerImpl::NO_RELOAD, false, | 460 *entry, NavigationControllerImpl::NO_RELOAD, false, |
| 460 false); | 461 false, nullptr); |
| 461 } | 462 } |
| 462 | 463 |
| 463 void NavigatorImpl::DidNavigate( | 464 void NavigatorImpl::DidNavigate( |
| 464 RenderFrameHostImpl* render_frame_host, | 465 RenderFrameHostImpl* render_frame_host, |
| 465 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 466 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 466 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); | 467 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); |
| 467 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); | 468 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
| 468 | 469 |
| 469 bool has_embedded_credentials = | 470 bool has_embedded_credentials = |
| 470 params.url.has_username() || params.url.has_password(); | 471 params.url.has_username() || params.url.has_password(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 } | 718 } |
| 718 | 719 |
| 719 void NavigatorImpl::RequestTransferURL( | 720 void NavigatorImpl::RequestTransferURL( |
| 720 RenderFrameHostImpl* render_frame_host, | 721 RenderFrameHostImpl* render_frame_host, |
| 721 const GURL& url, | 722 const GURL& url, |
| 722 SiteInstance* source_site_instance, | 723 SiteInstance* source_site_instance, |
| 723 const std::vector<GURL>& redirect_chain, | 724 const std::vector<GURL>& redirect_chain, |
| 724 const Referrer& referrer, | 725 const Referrer& referrer, |
| 725 ui::PageTransition page_transition, | 726 ui::PageTransition page_transition, |
| 726 const GlobalRequestID& transferred_global_request_id, | 727 const GlobalRequestID& transferred_global_request_id, |
| 727 bool should_replace_current_entry) { | 728 bool should_replace_current_entry, |
| 729 const std::string& method, | |
| 730 const scoped_refptr<ResourceRequestBody>& post_body) { | |
| 728 // This call only makes sense for subframes if OOPIFs are possible. | 731 // This call only makes sense for subframes if OOPIFs are possible. |
| 729 DCHECK(!render_frame_host->GetParent() || | 732 DCHECK(!render_frame_host->GetParent() || |
| 730 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 733 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 731 | 734 |
| 732 // Allow the delegate to cancel the transfer. | 735 // Allow the delegate to cancel the transfer. |
| 733 if (!delegate_->ShouldTransferNavigation()) | 736 if (!delegate_->ShouldTransferNavigation()) |
| 734 return; | 737 return; |
| 735 | 738 |
| 736 GURL dest_url(url); | 739 GURL dest_url(url); |
| 737 Referrer referrer_to_use(referrer); | 740 Referrer referrer_to_use(referrer); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 } else { | 784 } else { |
| 782 // If there's no last committed entry, create an entry for about:blank | 785 // If there's no last committed entry, create an entry for about:blank |
| 783 // with a subframe entry for our destination. | 786 // with a subframe entry for our destination. |
| 784 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. | 787 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. |
| 785 entry = NavigationEntryImpl::FromNavigationEntry( | 788 entry = NavigationEntryImpl::FromNavigationEntry( |
| 786 controller_->CreateNavigationEntry( | 789 controller_->CreateNavigationEntry( |
| 787 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, | 790 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, |
| 788 is_renderer_initiated, std::string(), | 791 is_renderer_initiated, std::string(), |
| 789 controller_->GetBrowserContext())); | 792 controller_->GetBrowserContext())); |
| 790 } | 793 } |
| 791 // TODO(creis): Handle POST submissions. See https://crbug.com/582211 and | |
| 792 // https://crbug.com/101395. | |
| 793 entry->AddOrUpdateFrameEntry( | 794 entry->AddOrUpdateFrameEntry( |
| 794 node, -1, -1, nullptr, | 795 node, -1, -1, nullptr, |
| 795 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, | 796 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, |
| 796 referrer_to_use, PageState(), "GET", -1); | 797 referrer_to_use, PageState(), method, -1); |
| 797 } else { | 798 } else { |
| 798 // Main frame case. | 799 // Main frame case. |
| 799 entry = NavigationEntryImpl::FromNavigationEntry( | 800 entry = NavigationEntryImpl::FromNavigationEntry( |
| 800 controller_->CreateNavigationEntry( | 801 controller_->CreateNavigationEntry( |
| 801 dest_url, referrer_to_use, page_transition, is_renderer_initiated, | 802 dest_url, referrer_to_use, page_transition, is_renderer_initiated, |
| 802 std::string(), controller_->GetBrowserContext())); | 803 std::string(), controller_->GetBrowserContext())); |
| 803 entry->root_node()->frame_entry->set_source_site_instance( | 804 entry->root_node()->frame_entry->set_source_site_instance( |
| 804 static_cast<SiteInstanceImpl*>(source_site_instance)); | 805 static_cast<SiteInstanceImpl*>(source_site_instance)); |
| 805 } | 806 } |
| 806 | 807 |
| 807 entry->SetRedirectChain(redirect_chain); | 808 entry->SetRedirectChain(redirect_chain); |
| 808 // Don't allow an entry replacement if there is no entry to replace. | 809 // Don't allow an entry replacement if there is no entry to replace. |
| 809 // http://crbug.com/457149 | 810 // http://crbug.com/457149 |
| 810 if (should_replace_current_entry && controller_->GetEntryCount() > 0) | 811 if (should_replace_current_entry && controller_->GetEntryCount() > 0) |
| 811 entry->set_should_replace_entry(true); | 812 entry->set_should_replace_entry(true); |
| 812 if (controller_->GetLastCommittedEntry() && | 813 if (controller_->GetLastCommittedEntry() && |
| 813 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) { | 814 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) { |
| 814 entry->SetIsOverridingUserAgent(true); | 815 entry->SetIsOverridingUserAgent(true); |
| 815 } | 816 } |
| 816 entry->set_transferred_global_request_id(transferred_global_request_id); | 817 entry->set_transferred_global_request_id(transferred_global_request_id); |
| 817 // TODO(creis): Set user gesture and intent received timestamp on Android. | 818 // TODO(creis): Set user gesture and intent received timestamp on Android. |
| 818 | 819 |
| 819 // We may not have successfully added the FrameNavigationEntry to |entry| | 820 // We may not have successfully added the FrameNavigationEntry to |entry| |
| 820 // above (per https://crbug.com/608402), in which case we create it from | 821 // above (per https://crbug.com/608402), in which case we create it from |
| 821 // scratch. This works because we do not depend on |frame_entry| being inside | 822 // scratch. This works because we do not depend on |frame_entry| being inside |
| 822 // |entry| during NavigateToEntry. This will go away when we shortcut this | 823 // |entry| during NavigateToEntry. This will go away when we shortcut this |
| 823 // further in https://crbug.com/536906. | 824 // further in https://crbug.com/536906. |
| 824 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); | 825 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); |
| 825 if (!frame_entry) { | 826 if (!frame_entry) { |
| 826 // TODO(creis): Handle POST submissions here, as above. | |
| 827 frame_entry = new FrameNavigationEntry( | 827 frame_entry = new FrameNavigationEntry( |
| 828 node->unique_name(), -1, -1, nullptr, | 828 node->unique_name(), -1, -1, nullptr, |
| 829 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, | 829 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, |
| 830 referrer_to_use, "GET", -1); | 830 referrer_to_use, method, -1); |
| 831 } | 831 } |
| 832 NavigateToEntry(node, *frame_entry, *entry.get(), | 832 NavigateToEntry(node, *frame_entry, *entry.get(), |
| 833 NavigationController::NO_RELOAD, false, false); | 833 NavigationController::NO_RELOAD, false, false, post_body); |
| 834 } | 834 } |
| 835 | 835 |
| 836 // PlzNavigate | 836 // PlzNavigate |
| 837 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, | 837 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, |
| 838 bool proceed) { | 838 bool proceed) { |
| 839 CHECK(IsBrowserSideNavigationEnabled()); | 839 CHECK(IsBrowserSideNavigationEnabled()); |
| 840 DCHECK(frame_tree_node); | 840 DCHECK(frame_tree_node); |
| 841 | 841 |
| 842 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 842 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| 843 | 843 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1163 if (pending_entry != controller_->GetVisibleEntry() || | 1163 if (pending_entry != controller_->GetVisibleEntry() || |
| 1164 !should_preserve_entry) { | 1164 !should_preserve_entry) { |
| 1165 controller_->DiscardPendingEntry(true); | 1165 controller_->DiscardPendingEntry(true); |
| 1166 | 1166 |
| 1167 // Also force the UI to refresh. | 1167 // Also force the UI to refresh. |
| 1168 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1168 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 1169 } | 1169 } |
| 1170 } | 1170 } |
| 1171 | 1171 |
| 1172 } // namespace content | 1172 } // namespace content |
| OLD | NEW |