Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698