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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 if (!is_transfer_to_same) { | 371 if (!is_transfer_to_same) { |
372 navigation_data_.reset(new NavigationMetricsData( | 372 navigation_data_.reset(new NavigationMetricsData( |
373 navigation_start, dest_url, entry.restore_type())); | 373 navigation_start, dest_url, entry.restore_type())); |
374 // Create the navigation parameters. | 374 // Create the navigation parameters. |
375 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( | 375 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( |
376 controller_->GetBrowserContext(), entry, reload_type); | 376 controller_->GetBrowserContext(), entry, reload_type); |
377 dest_render_frame_host->Navigate( | 377 dest_render_frame_host->Navigate( |
378 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, | 378 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, |
379 navigation_type, lofi_state, | 379 navigation_type, lofi_state, |
380 navigation_start), | 380 navigation_start), |
381 entry.ConstructStartNavigationParams(), | 381 entry.ConstructStartNavigationParams( |
382 *dest_render_frame_host->navigation_handle()), | |
clamy
2016/05/12 05:32:48
This is unsafe. In non transfer cases the dest RFH
Łukasz Anforowicz
2016/05/17 23:52:56
Done. In subsequent patchsets I've added |const N
| |
382 entry.ConstructRequestNavigationParams( | 383 entry.ConstructRequestNavigationParams( |
383 frame_entry, is_same_document_history_load, | 384 frame_entry, is_same_document_history_load, |
384 frame_tree_node->has_committed_real_load(), | 385 frame_tree_node->has_committed_real_load(), |
385 controller_->GetPendingEntryIndex() == -1, | 386 controller_->GetPendingEntryIndex() == -1, |
386 controller_->GetIndexOfEntry(&entry), | 387 controller_->GetIndexOfEntry(&entry), |
387 controller_->GetLastCommittedEntryIndex(), | 388 controller_->GetLastCommittedEntryIndex(), |
388 controller_->GetEntryCount())); | 389 controller_->GetEntryCount())); |
389 } else { | 390 } else { |
390 // No need to navigate again. Just resume the deferred request. | 391 // No need to navigate again. Just resume the deferred request. |
391 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( | 392 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
764 } else { | 765 } else { |
765 // If there's no last committed entry, create an entry for about:blank | 766 // If there's no last committed entry, create an entry for about:blank |
766 // with a subframe entry for our destination. | 767 // with a subframe entry for our destination. |
767 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. | 768 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. |
768 entry = NavigationEntryImpl::FromNavigationEntry( | 769 entry = NavigationEntryImpl::FromNavigationEntry( |
769 controller_->CreateNavigationEntry( | 770 controller_->CreateNavigationEntry( |
770 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, | 771 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, |
771 is_renderer_initiated, std::string(), | 772 is_renderer_initiated, std::string(), |
772 controller_->GetBrowserContext())); | 773 controller_->GetBrowserContext())); |
773 } | 774 } |
775 // TODO(lukasza): DO NOT SUBMIT: This seems very wrong: | |
776 // 1. This ignores methods other than GET and POST | |
777 // 2. This feels like a wrong place to do stuff. | |
778 // 3. This doesn't touch PageState at all... | |
779 bool is_post = static_cast<bool>( | |
clamy
2016/05/12 05:32:48
Suggestion: add the method as a parameter of Reque
Łukasz Anforowicz
2016/05/17 23:52:56
I've ended up passing |const NavigationHandleImpl*
| |
780 render_frame_host->navigation_handle()->resource_request_body()); | |
781 | |
774 // TODO(creis): Handle POST submissions. See https://crbug.com/582211 and | 782 // TODO(creis): Handle POST submissions. See https://crbug.com/582211 and |
775 // https://crbug.com/101395. | 783 // https://crbug.com/101395. |
776 entry->AddOrUpdateFrameEntry( | 784 entry->AddOrUpdateFrameEntry( |
777 node, -1, -1, nullptr, | 785 node, -1, -1, nullptr, |
778 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, | 786 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, |
779 referrer_to_use, PageState(), "GET", -1); | 787 referrer_to_use, |
788 // TODO(lukasza): DO NOT SUBMIT: Should I populate a real PageState here | |
789 // (using NavigationHandleImpl::resource_request_body() I've introduced) | |
clamy
2016/05/12 05:32:48
If you populate the PageState the RenderFrame will
Łukasz Anforowicz
2016/05/17 23:52:56
Acknowledged.
| |
790 PageState(), is_post ? "POST" : "GET", -1); | |
780 } else { | 791 } else { |
781 // Main frame case. | 792 // Main frame case. |
782 entry = NavigationEntryImpl::FromNavigationEntry( | 793 entry = NavigationEntryImpl::FromNavigationEntry( |
783 controller_->CreateNavigationEntry( | 794 controller_->CreateNavigationEntry( |
784 dest_url, referrer_to_use, page_transition, is_renderer_initiated, | 795 dest_url, referrer_to_use, page_transition, is_renderer_initiated, |
785 std::string(), controller_->GetBrowserContext())); | 796 std::string(), controller_->GetBrowserContext())); |
786 entry->root_node()->frame_entry->set_source_site_instance( | 797 entry->root_node()->frame_entry->set_source_site_instance( |
787 static_cast<SiteInstanceImpl*>(source_site_instance)); | 798 static_cast<SiteInstanceImpl*>(source_site_instance)); |
788 } | 799 } |
789 | 800 |
(...skipping 10 matching lines...) Expand all Loading... | |
800 // TODO(creis): Set user gesture and intent received timestamp on Android. | 811 // TODO(creis): Set user gesture and intent received timestamp on Android. |
801 | 812 |
802 // We may not have successfully added the FrameNavigationEntry to |entry| | 813 // We may not have successfully added the FrameNavigationEntry to |entry| |
803 // above (per https://crbug.com/608402), in which case we create it from | 814 // above (per https://crbug.com/608402), in which case we create it from |
804 // scratch. This works because we do not depend on |frame_entry| being inside | 815 // scratch. This works because we do not depend on |frame_entry| being inside |
805 // |entry| during NavigateToEntry. This will go away when we shortcut this | 816 // |entry| during NavigateToEntry. This will go away when we shortcut this |
806 // further in https://crbug.com/536906. | 817 // further in https://crbug.com/536906. |
807 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); | 818 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); |
808 if (!frame_entry) { | 819 if (!frame_entry) { |
809 // TODO(creis): Handle POST submissions here, as above. | 820 // TODO(creis): Handle POST submissions here, as above. |
821 // TODO(lukasza): DO NOT SUBMIT: Need to do something here as well. | |
810 frame_entry = new FrameNavigationEntry( | 822 frame_entry = new FrameNavigationEntry( |
811 node->unique_name(), -1, -1, nullptr, | 823 node->unique_name(), -1, -1, nullptr, |
812 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, | 824 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, |
813 referrer_to_use, "GET", -1); | 825 referrer_to_use, "GET", -1); |
814 } | 826 } |
815 NavigateToEntry(node, *frame_entry, *entry.get(), | 827 NavigateToEntry(node, *frame_entry, *entry.get(), |
816 NavigationController::NO_RELOAD, false, false); | 828 NavigationController::NO_RELOAD, false, false); |
817 } | 829 } |
818 | 830 |
819 // PlzNavigate | 831 // PlzNavigate |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1147 if (pending_entry != controller_->GetVisibleEntry() || | 1159 if (pending_entry != controller_->GetVisibleEntry() || |
1148 !should_preserve_entry) { | 1160 !should_preserve_entry) { |
1149 controller_->DiscardPendingEntry(true); | 1161 controller_->DiscardPendingEntry(true); |
1150 | 1162 |
1151 // Also force the UI to refresh. | 1163 // Also force the UI to refresh. |
1152 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1164 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
1153 } | 1165 } |
1154 } | 1166 } |
1155 | 1167 |
1156 } // namespace content | 1168 } // namespace content |
OLD | NEW |