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, |
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); |
Charlie Reis
2016/05/31 21:08:36
Sanity check: Will we need to change this when we
Łukasz Anforowicz
2016/05/31 22:40:55
I don't really know :-( AFAIK, we don't need to s
clamy
2016/06/01 13:22:37
In the current architecture, the POST body should
Charlie Reis
2016/06/01 23:46:32
Yeah, this answers my question. The PageState sho
| |
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) { | |
731 // |method != "POST"| should imply absence of |post_body|. | |
732 DCHECK(method == "POST" || !post_body); | |
Charlie Reis
2016/05/31 21:08:36
Should we be concerned if this fails in practice?
Łukasz Anforowicz
2016/05/31 22:40:55
Yes, we should be concerned, but I don't know how
Charlie Reis
2016/06/01 23:46:32
Doesn't sound like a crashable offense, but maybe
Łukasz Anforowicz
2016/06/02 22:07:04
Done. To reset the parameter we need to make it n
| |
733 | |
728 // This call only makes sense for subframes if OOPIFs are possible. | 734 // This call only makes sense for subframes if OOPIFs are possible. |
729 DCHECK(!render_frame_host->GetParent() || | 735 DCHECK(!render_frame_host->GetParent() || |
730 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 736 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
731 | 737 |
732 // Allow the delegate to cancel the transfer. | 738 // Allow the delegate to cancel the transfer. |
733 if (!delegate_->ShouldTransferNavigation()) | 739 if (!delegate_->ShouldTransferNavigation()) |
734 return; | 740 return; |
735 | 741 |
736 GURL dest_url(url); | 742 GURL dest_url(url); |
737 Referrer referrer_to_use(referrer); | 743 Referrer referrer_to_use(referrer); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 } else { | 787 } else { |
782 // If there's no last committed entry, create an entry for about:blank | 788 // If there's no last committed entry, create an entry for about:blank |
783 // with a subframe entry for our destination. | 789 // with a subframe entry for our destination. |
784 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. | 790 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. |
785 entry = NavigationEntryImpl::FromNavigationEntry( | 791 entry = NavigationEntryImpl::FromNavigationEntry( |
786 controller_->CreateNavigationEntry( | 792 controller_->CreateNavigationEntry( |
787 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, | 793 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, |
788 is_renderer_initiated, std::string(), | 794 is_renderer_initiated, std::string(), |
789 controller_->GetBrowserContext())); | 795 controller_->GetBrowserContext())); |
790 } | 796 } |
791 // TODO(creis): Handle POST submissions. See https://crbug.com/582211 and | |
792 // https://crbug.com/101395. | |
793 entry->AddOrUpdateFrameEntry( | 797 entry->AddOrUpdateFrameEntry( |
794 node, -1, -1, nullptr, | 798 node, -1, -1, nullptr, |
795 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, | 799 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, |
796 referrer_to_use, PageState(), "GET", -1); | 800 referrer_to_use, PageState(), method, -1); |
797 } else { | 801 } else { |
798 // Main frame case. | 802 // Main frame case. |
799 entry = NavigationEntryImpl::FromNavigationEntry( | 803 entry = NavigationEntryImpl::FromNavigationEntry( |
800 controller_->CreateNavigationEntry( | 804 controller_->CreateNavigationEntry( |
801 dest_url, referrer_to_use, page_transition, is_renderer_initiated, | 805 dest_url, referrer_to_use, page_transition, is_renderer_initiated, |
802 std::string(), controller_->GetBrowserContext())); | 806 std::string(), controller_->GetBrowserContext())); |
803 entry->root_node()->frame_entry->set_source_site_instance( | 807 entry->root_node()->frame_entry->set_source_site_instance( |
804 static_cast<SiteInstanceImpl*>(source_site_instance)); | 808 static_cast<SiteInstanceImpl*>(source_site_instance)); |
805 } | 809 } |
806 | 810 |
807 entry->SetRedirectChain(redirect_chain); | 811 entry->SetRedirectChain(redirect_chain); |
808 // Don't allow an entry replacement if there is no entry to replace. | 812 // Don't allow an entry replacement if there is no entry to replace. |
809 // http://crbug.com/457149 | 813 // http://crbug.com/457149 |
810 if (should_replace_current_entry && controller_->GetEntryCount() > 0) | 814 if (should_replace_current_entry && controller_->GetEntryCount() > 0) |
811 entry->set_should_replace_entry(true); | 815 entry->set_should_replace_entry(true); |
812 if (controller_->GetLastCommittedEntry() && | 816 if (controller_->GetLastCommittedEntry() && |
813 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) { | 817 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) { |
814 entry->SetIsOverridingUserAgent(true); | 818 entry->SetIsOverridingUserAgent(true); |
815 } | 819 } |
816 entry->set_transferred_global_request_id(transferred_global_request_id); | 820 entry->set_transferred_global_request_id(transferred_global_request_id); |
817 // TODO(creis): Set user gesture and intent received timestamp on Android. | 821 // TODO(creis): Set user gesture and intent received timestamp on Android. |
818 | 822 |
819 // We may not have successfully added the FrameNavigationEntry to |entry| | 823 // We may not have successfully added the FrameNavigationEntry to |entry| |
820 // above (per https://crbug.com/608402), in which case we create it from | 824 // 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 | 825 // 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 | 826 // |entry| during NavigateToEntry. This will go away when we shortcut this |
823 // further in https://crbug.com/536906. | 827 // further in https://crbug.com/536906. |
824 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); | 828 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); |
825 if (!frame_entry) { | 829 if (!frame_entry) { |
826 // TODO(creis): Handle POST submissions here, as above. | |
827 frame_entry = new FrameNavigationEntry( | 830 frame_entry = new FrameNavigationEntry( |
828 node->unique_name(), -1, -1, nullptr, | 831 node->unique_name(), -1, -1, nullptr, |
829 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, | 832 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, |
830 referrer_to_use, "GET", -1); | 833 referrer_to_use, method, -1); |
831 } | 834 } |
832 NavigateToEntry(node, *frame_entry, *entry.get(), | 835 NavigateToEntry(node, *frame_entry, *entry.get(), |
833 NavigationController::NO_RELOAD, false, false); | 836 NavigationController::NO_RELOAD, false, false, post_body); |
834 } | 837 } |
835 | 838 |
836 // PlzNavigate | 839 // PlzNavigate |
837 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, | 840 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, |
838 bool proceed) { | 841 bool proceed) { |
839 CHECK(IsBrowserSideNavigationEnabled()); | 842 CHECK(IsBrowserSideNavigationEnabled()); |
840 DCHECK(frame_tree_node); | 843 DCHECK(frame_tree_node); |
841 | 844 |
842 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 845 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
843 | 846 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1163 if (pending_entry != controller_->GetVisibleEntry() || | 1166 if (pending_entry != controller_->GetVisibleEntry() || |
1164 !should_preserve_entry) { | 1167 !should_preserve_entry) { |
1165 controller_->DiscardPendingEntry(true); | 1168 controller_->DiscardPendingEntry(true); |
1166 | 1169 |
1167 // Also force the UI to refresh. | 1170 // Also force the UI to refresh. |
1168 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1171 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
1169 } | 1172 } |
1170 } | 1173 } |
1171 | 1174 |
1172 } // namespace content | 1175 } // namespace content |
OLD | NEW |