| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 // The embedder will then have the opportunity to determine if the URL | 653 // The embedder will then have the opportunity to determine if the URL |
| 654 // should "use up" the SiteInstance. | 654 // should "use up" the SiteInstance. |
| 655 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); | 655 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); |
| 656 } | 656 } |
| 657 | 657 |
| 658 void NavigatorImpl::RequestOpenURL( | 658 void NavigatorImpl::RequestOpenURL( |
| 659 RenderFrameHostImpl* render_frame_host, | 659 RenderFrameHostImpl* render_frame_host, |
| 660 const GURL& url, | 660 const GURL& url, |
| 661 bool uses_post, | 661 bool uses_post, |
| 662 const scoped_refptr<ResourceRequestBodyImpl>& body, | 662 const scoped_refptr<ResourceRequestBodyImpl>& body, |
| 663 const std::string& extra_headers, |
| 663 SiteInstance* source_site_instance, | 664 SiteInstance* source_site_instance, |
| 664 const Referrer& referrer, | 665 const Referrer& referrer, |
| 665 WindowOpenDisposition disposition, | 666 WindowOpenDisposition disposition, |
| 666 bool should_replace_current_entry, | 667 bool should_replace_current_entry, |
| 667 bool user_gesture) { | 668 bool user_gesture) { |
| 668 // Note: This can be called for subframes (even when OOPIFs are not possible) | 669 // Note: This can be called for subframes (even when OOPIFs are not possible) |
| 669 // if the disposition calls for a different window. | 670 // if the disposition calls for a different window. |
| 670 | 671 |
| 671 // Only the current RenderFrameHost should be sending an OpenURL request. | 672 // Only the current RenderFrameHost should be sending an OpenURL request. |
| 672 // Pending RenderFrameHost should know where it is navigating and pending | 673 // Pending RenderFrameHost should know where it is navigating and pending |
| (...skipping 25 matching lines...) Expand all Loading... |
| 698 render_frame_host->GetParent()) { | 699 render_frame_host->GetParent()) { |
| 699 frame_tree_node_id = | 700 frame_tree_node_id = |
| 700 render_frame_host->frame_tree_node()->frame_tree_node_id(); | 701 render_frame_host->frame_tree_node()->frame_tree_node_id(); |
| 701 } | 702 } |
| 702 | 703 |
| 703 OpenURLParams params(dest_url, referrer, frame_tree_node_id, disposition, | 704 OpenURLParams params(dest_url, referrer, frame_tree_node_id, disposition, |
| 704 ui::PAGE_TRANSITION_LINK, | 705 ui::PAGE_TRANSITION_LINK, |
| 705 true /* is_renderer_initiated */); | 706 true /* is_renderer_initiated */); |
| 706 params.uses_post = uses_post; | 707 params.uses_post = uses_post; |
| 707 params.post_data = body; | 708 params.post_data = body; |
| 709 params.extra_headers = extra_headers; |
| 708 params.source_site_instance = source_site_instance; | 710 params.source_site_instance = source_site_instance; |
| 709 if (redirect_chain.size() > 0) | 711 if (redirect_chain.size() > 0) |
| 710 params.redirect_chain = redirect_chain; | 712 params.redirect_chain = redirect_chain; |
| 711 params.should_replace_current_entry = should_replace_current_entry; | 713 params.should_replace_current_entry = should_replace_current_entry; |
| 712 params.user_gesture = user_gesture; | 714 params.user_gesture = user_gesture; |
| 713 | 715 |
| 714 if (render_frame_host->web_ui()) { | 716 if (render_frame_host->web_ui()) { |
| 715 // Web UI pages sometimes want to override the page transition type for | 717 // Web UI pages sometimes want to override the page transition type for |
| 716 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 718 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
| 717 // automatically generated suggestions). We don't override other types | 719 // automatically generated suggestions). We don't override other types |
| (...skipping 22 matching lines...) Expand all Loading... |
| 740 void NavigatorImpl::RequestTransferURL( | 742 void NavigatorImpl::RequestTransferURL( |
| 741 RenderFrameHostImpl* render_frame_host, | 743 RenderFrameHostImpl* render_frame_host, |
| 742 const GURL& url, | 744 const GURL& url, |
| 743 SiteInstance* source_site_instance, | 745 SiteInstance* source_site_instance, |
| 744 const std::vector<GURL>& redirect_chain, | 746 const std::vector<GURL>& redirect_chain, |
| 745 const Referrer& referrer, | 747 const Referrer& referrer, |
| 746 ui::PageTransition page_transition, | 748 ui::PageTransition page_transition, |
| 747 const GlobalRequestID& transferred_global_request_id, | 749 const GlobalRequestID& transferred_global_request_id, |
| 748 bool should_replace_current_entry, | 750 bool should_replace_current_entry, |
| 749 const std::string& method, | 751 const std::string& method, |
| 750 scoped_refptr<ResourceRequestBodyImpl> post_body) { | 752 scoped_refptr<ResourceRequestBodyImpl> post_body, |
| 753 const std::string& extra_headers) { |
| 751 // |method != "POST"| should imply absence of |post_body|. | 754 // |method != "POST"| should imply absence of |post_body|. |
| 752 if (method != "POST" && post_body) { | 755 if (method != "POST" && post_body) { |
| 753 NOTREACHED(); | 756 NOTREACHED(); |
| 754 post_body = nullptr; | 757 post_body = nullptr; |
| 755 } | 758 } |
| 756 | 759 |
| 757 // This call only makes sense for subframes if OOPIFs are possible. | 760 // This call only makes sense for subframes if OOPIFs are possible. |
| 758 DCHECK(!render_frame_host->GetParent() || | 761 DCHECK(!render_frame_host->GetParent() || |
| 759 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 762 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 760 | 763 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 // have a new NavigationEntry. | 802 // have a new NavigationEntry. |
| 800 // TODO(creis): Make this unnecessary by creating (and validating) the params | 803 // TODO(creis): Make this unnecessary by creating (and validating) the params |
| 801 // directly, passing them to the destination RenderFrameHost. See | 804 // directly, passing them to the destination RenderFrameHost. See |
| 802 // https://crbug.com/536906. | 805 // https://crbug.com/536906. |
| 803 std::unique_ptr<NavigationEntryImpl> entry; | 806 std::unique_ptr<NavigationEntryImpl> entry; |
| 804 if (!node->IsMainFrame()) { | 807 if (!node->IsMainFrame()) { |
| 805 // Subframe case: create FrameNavigationEntry. | 808 // Subframe case: create FrameNavigationEntry. |
| 806 CHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | 809 CHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 807 if (controller_->GetLastCommittedEntry()) { | 810 if (controller_->GetLastCommittedEntry()) { |
| 808 entry = controller_->GetLastCommittedEntry()->Clone(); | 811 entry = controller_->GetLastCommittedEntry()->Clone(); |
| 812 entry->set_extra_headers(extra_headers); |
| 809 entry->SetPageID(-1); | 813 entry->SetPageID(-1); |
| 810 } else { | 814 } else { |
| 811 // If there's no last committed entry, create an entry for about:blank | 815 // If there's no last committed entry, create an entry for about:blank |
| 812 // with a subframe entry for our destination. | 816 // with a subframe entry for our destination. |
| 813 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. | 817 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. |
| 814 entry = NavigationEntryImpl::FromNavigationEntry( | 818 entry = NavigationEntryImpl::FromNavigationEntry( |
| 815 controller_->CreateNavigationEntry( | 819 controller_->CreateNavigationEntry( |
| 816 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, | 820 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, |
| 817 is_renderer_initiated, std::string(), | 821 is_renderer_initiated, extra_headers, |
| 818 controller_->GetBrowserContext())); | 822 controller_->GetBrowserContext())); |
| 819 } | 823 } |
| 820 entry->AddOrUpdateFrameEntry( | 824 entry->AddOrUpdateFrameEntry( |
| 821 node, -1, -1, nullptr, | 825 node, -1, -1, nullptr, |
| 822 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, | 826 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, |
| 823 referrer_to_use, PageState(), method, -1); | 827 referrer_to_use, PageState(), method, -1); |
| 824 } else { | 828 } else { |
| 825 // Main frame case. | 829 // Main frame case. |
| 826 entry = NavigationEntryImpl::FromNavigationEntry( | 830 entry = NavigationEntryImpl::FromNavigationEntry( |
| 827 controller_->CreateNavigationEntry( | 831 controller_->CreateNavigationEntry( |
| 828 dest_url, referrer_to_use, page_transition, is_renderer_initiated, | 832 dest_url, referrer_to_use, page_transition, is_renderer_initiated, |
| 829 std::string(), controller_->GetBrowserContext())); | 833 extra_headers, controller_->GetBrowserContext())); |
| 830 entry->root_node()->frame_entry->set_source_site_instance( | 834 entry->root_node()->frame_entry->set_source_site_instance( |
| 831 static_cast<SiteInstanceImpl*>(source_site_instance)); | 835 static_cast<SiteInstanceImpl*>(source_site_instance)); |
| 832 } | 836 } |
| 833 | 837 |
| 834 entry->SetRedirectChain(redirect_chain); | 838 entry->SetRedirectChain(redirect_chain); |
| 835 // Don't allow an entry replacement if there is no entry to replace. | 839 // Don't allow an entry replacement if there is no entry to replace. |
| 836 // http://crbug.com/457149 | 840 // http://crbug.com/457149 |
| 837 if (should_replace_current_entry && controller_->GetEntryCount() > 0) | 841 if (should_replace_current_entry && controller_->GetEntryCount() > 0) |
| 838 entry->set_should_replace_entry(true); | 842 entry->set_should_replace_entry(true); |
| 839 if (controller_->GetLastCommittedEntry() && | 843 if (controller_->GetLastCommittedEntry() && |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 if (pending_entry != controller_->GetVisibleEntry() || | 1202 if (pending_entry != controller_->GetVisibleEntry() || |
| 1199 !should_preserve_entry) { | 1203 !should_preserve_entry) { |
| 1200 controller_->DiscardPendingEntry(true); | 1204 controller_->DiscardPendingEntry(true); |
| 1201 | 1205 |
| 1202 // Also force the UI to refresh. | 1206 // Also force the UI to refresh. |
| 1203 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1207 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 1204 } | 1208 } |
| 1205 } | 1209 } |
| 1206 | 1210 |
| 1207 } // namespace content | 1211 } // namespace content |
| OLD | NEW |