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