| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 // The embedder will then have the opportunity to determine if the URL | 685 // The embedder will then have the opportunity to determine if the URL |
| 686 // should "use up" the SiteInstance. | 686 // should "use up" the SiteInstance. |
| 687 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); | 687 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); |
| 688 } | 688 } |
| 689 | 689 |
| 690 void NavigatorImpl::RequestOpenURL( | 690 void NavigatorImpl::RequestOpenURL( |
| 691 RenderFrameHostImpl* render_frame_host, | 691 RenderFrameHostImpl* render_frame_host, |
| 692 const GURL& url, | 692 const GURL& url, |
| 693 bool uses_post, | 693 bool uses_post, |
| 694 const scoped_refptr<ResourceRequestBodyImpl>& body, | 694 const scoped_refptr<ResourceRequestBodyImpl>& body, |
| 695 const std::string& extra_headers, | |
| 696 SiteInstance* source_site_instance, | 695 SiteInstance* source_site_instance, |
| 697 const Referrer& referrer, | 696 const Referrer& referrer, |
| 698 WindowOpenDisposition disposition, | 697 WindowOpenDisposition disposition, |
| 699 bool should_replace_current_entry, | 698 bool should_replace_current_entry, |
| 700 bool user_gesture) { | 699 bool user_gesture) { |
| 701 // Note: This can be called for subframes (even when OOPIFs are not possible) | 700 // Note: This can be called for subframes (even when OOPIFs are not possible) |
| 702 // if the disposition calls for a different window. | 701 // if the disposition calls for a different window. |
| 703 | 702 |
| 704 // Only the current RenderFrameHost should be sending an OpenURL request. | 703 // Only the current RenderFrameHost should be sending an OpenURL request. |
| 705 // Pending RenderFrameHost should know where it is navigating and pending | 704 // Pending RenderFrameHost should know where it is navigating and pending |
| (...skipping 25 matching lines...) Expand all Loading... |
| 731 render_frame_host->GetParent()) { | 730 render_frame_host->GetParent()) { |
| 732 frame_tree_node_id = | 731 frame_tree_node_id = |
| 733 render_frame_host->frame_tree_node()->frame_tree_node_id(); | 732 render_frame_host->frame_tree_node()->frame_tree_node_id(); |
| 734 } | 733 } |
| 735 | 734 |
| 736 OpenURLParams params(dest_url, referrer, frame_tree_node_id, disposition, | 735 OpenURLParams params(dest_url, referrer, frame_tree_node_id, disposition, |
| 737 ui::PAGE_TRANSITION_LINK, | 736 ui::PAGE_TRANSITION_LINK, |
| 738 true /* is_renderer_initiated */); | 737 true /* is_renderer_initiated */); |
| 739 params.uses_post = uses_post; | 738 params.uses_post = uses_post; |
| 740 params.post_data = body; | 739 params.post_data = body; |
| 741 params.extra_headers = extra_headers; | |
| 742 params.source_site_instance = source_site_instance; | 740 params.source_site_instance = source_site_instance; |
| 743 if (redirect_chain.size() > 0) | 741 if (redirect_chain.size() > 0) |
| 744 params.redirect_chain = redirect_chain; | 742 params.redirect_chain = redirect_chain; |
| 745 params.should_replace_current_entry = should_replace_current_entry; | 743 params.should_replace_current_entry = should_replace_current_entry; |
| 746 params.user_gesture = user_gesture; | 744 params.user_gesture = user_gesture; |
| 747 | 745 |
| 748 if (render_frame_host->web_ui()) { | 746 if (render_frame_host->web_ui()) { |
| 749 // Web UI pages sometimes want to override the page transition type for | 747 // Web UI pages sometimes want to override the page transition type for |
| 750 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 748 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
| 751 // automatically generated suggestions). We don't override other types | 749 // automatically generated suggestions). We don't override other types |
| (...skipping 22 matching lines...) Expand all Loading... |
| 774 void NavigatorImpl::RequestTransferURL( | 772 void NavigatorImpl::RequestTransferURL( |
| 775 RenderFrameHostImpl* render_frame_host, | 773 RenderFrameHostImpl* render_frame_host, |
| 776 const GURL& url, | 774 const GURL& url, |
| 777 SiteInstance* source_site_instance, | 775 SiteInstance* source_site_instance, |
| 778 const std::vector<GURL>& redirect_chain, | 776 const std::vector<GURL>& redirect_chain, |
| 779 const Referrer& referrer, | 777 const Referrer& referrer, |
| 780 ui::PageTransition page_transition, | 778 ui::PageTransition page_transition, |
| 781 const GlobalRequestID& transferred_global_request_id, | 779 const GlobalRequestID& transferred_global_request_id, |
| 782 bool should_replace_current_entry, | 780 bool should_replace_current_entry, |
| 783 const std::string& method, | 781 const std::string& method, |
| 784 scoped_refptr<ResourceRequestBodyImpl> post_body, | 782 scoped_refptr<ResourceRequestBodyImpl> post_body) { |
| 785 const std::string& extra_headers) { | |
| 786 // |method != "POST"| should imply absence of |post_body|. | 783 // |method != "POST"| should imply absence of |post_body|. |
| 787 if (method != "POST" && post_body) { | 784 if (method != "POST" && post_body) { |
| 788 NOTREACHED(); | 785 NOTREACHED(); |
| 789 post_body = nullptr; | 786 post_body = nullptr; |
| 790 } | 787 } |
| 791 | 788 |
| 792 // This call only makes sense for subframes if OOPIFs are possible. | 789 // This call only makes sense for subframes if OOPIFs are possible. |
| 793 DCHECK(!render_frame_host->GetParent() || | 790 DCHECK(!render_frame_host->GetParent() || |
| 794 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 791 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 795 | 792 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 // have a new NavigationEntry. | 832 // have a new NavigationEntry. |
| 836 // TODO(creis): Make this unnecessary by creating (and validating) the params | 833 // TODO(creis): Make this unnecessary by creating (and validating) the params |
| 837 // directly, passing them to the destination RenderFrameHost. See | 834 // directly, passing them to the destination RenderFrameHost. See |
| 838 // https://crbug.com/536906. | 835 // https://crbug.com/536906. |
| 839 std::unique_ptr<NavigationEntryImpl> entry; | 836 std::unique_ptr<NavigationEntryImpl> entry; |
| 840 if (!node->IsMainFrame()) { | 837 if (!node->IsMainFrame()) { |
| 841 // Subframe case: create FrameNavigationEntry. | 838 // Subframe case: create FrameNavigationEntry. |
| 842 CHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | 839 CHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 843 if (controller_->GetLastCommittedEntry()) { | 840 if (controller_->GetLastCommittedEntry()) { |
| 844 entry = controller_->GetLastCommittedEntry()->Clone(); | 841 entry = controller_->GetLastCommittedEntry()->Clone(); |
| 845 entry->set_extra_headers(extra_headers); | |
| 846 } else { | 842 } else { |
| 847 // If there's no last committed entry, create an entry for about:blank | 843 // If there's no last committed entry, create an entry for about:blank |
| 848 // with a subframe entry for our destination. | 844 // with a subframe entry for our destination. |
| 849 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. | 845 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. |
| 850 entry = NavigationEntryImpl::FromNavigationEntry( | 846 entry = NavigationEntryImpl::FromNavigationEntry( |
| 851 controller_->CreateNavigationEntry( | 847 controller_->CreateNavigationEntry( |
| 852 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, | 848 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, |
| 853 is_renderer_initiated, extra_headers, | 849 is_renderer_initiated, std::string(), |
| 854 controller_->GetBrowserContext())); | 850 controller_->GetBrowserContext())); |
| 855 } | 851 } |
| 856 entry->AddOrUpdateFrameEntry( | 852 entry->AddOrUpdateFrameEntry( |
| 857 node, -1, -1, nullptr, | 853 node, -1, -1, nullptr, |
| 858 static_cast<SiteInstanceImpl*>(source_site_instance), | 854 static_cast<SiteInstanceImpl*>(source_site_instance), |
| 859 dest_url, referrer_to_use, redirect_chain, PageState(), method, | 855 dest_url, referrer_to_use, redirect_chain, PageState(), method, |
| 860 -1); | 856 -1); |
| 861 } else { | 857 } else { |
| 862 // Main frame case. | 858 // Main frame case. |
| 863 entry = NavigationEntryImpl::FromNavigationEntry( | 859 entry = NavigationEntryImpl::FromNavigationEntry( |
| 864 controller_->CreateNavigationEntry( | 860 controller_->CreateNavigationEntry( |
| 865 dest_url, referrer_to_use, page_transition, is_renderer_initiated, | 861 dest_url, referrer_to_use, page_transition, is_renderer_initiated, |
| 866 extra_headers, controller_->GetBrowserContext())); | 862 std::string(), controller_->GetBrowserContext())); |
| 867 entry->root_node()->frame_entry->set_source_site_instance( | 863 entry->root_node()->frame_entry->set_source_site_instance( |
| 868 static_cast<SiteInstanceImpl*>(source_site_instance)); | 864 static_cast<SiteInstanceImpl*>(source_site_instance)); |
| 869 entry->SetRedirectChain(redirect_chain); | 865 entry->SetRedirectChain(redirect_chain); |
| 870 } | 866 } |
| 871 | 867 |
| 872 // Don't allow an entry replacement if there is no entry to replace. | 868 // Don't allow an entry replacement if there is no entry to replace. |
| 873 // http://crbug.com/457149 | 869 // http://crbug.com/457149 |
| 874 if (should_replace_current_entry && controller_->GetEntryCount() > 0) | 870 if (should_replace_current_entry && controller_->GetEntryCount() > 0) |
| 875 entry->set_should_replace_entry(true); | 871 entry->set_should_replace_entry(true); |
| 876 if (controller_->GetLastCommittedEntry() && | 872 if (controller_->GetLastCommittedEntry() && |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 if (navigation_handle) | 1237 if (navigation_handle) |
| 1242 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1238 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
| 1243 | 1239 |
| 1244 controller_->SetPendingEntry(std::move(entry)); | 1240 controller_->SetPendingEntry(std::move(entry)); |
| 1245 if (delegate_) | 1241 if (delegate_) |
| 1246 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1242 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1247 } | 1243 } |
| 1248 } | 1244 } |
| 1249 | 1245 |
| 1250 } // namespace content | 1246 } // namespace content |
| OLD | NEW |