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

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

Issue 2355023002: Preserving Content-Type header from http request in OpenURL path. (Closed)
Patch Set: Simplified AreExtraHeadersCompatibleWithPrerenderContents as suggested by mmenke@. 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 entry->SetPageID(-1); 846 entry->SetPageID(-1);
843 } else { 847 } else {
844 // If there's no last committed entry, create an entry for about:blank 848 // If there's no last committed entry, create an entry for about:blank
845 // with a subframe entry for our destination. 849 // with a subframe entry for our destination.
846 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. 850 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208.
847 entry = NavigationEntryImpl::FromNavigationEntry( 851 entry = NavigationEntryImpl::FromNavigationEntry(
848 controller_->CreateNavigationEntry( 852 controller_->CreateNavigationEntry(
849 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, 853 GURL(url::kAboutBlankURL), referrer_to_use, page_transition,
850 is_renderer_initiated, std::string(), 854 is_renderer_initiated, extra_headers,
851 controller_->GetBrowserContext())); 855 controller_->GetBrowserContext()));
852 } 856 }
853 entry->AddOrUpdateFrameEntry( 857 entry->AddOrUpdateFrameEntry(
854 node, -1, -1, nullptr, 858 node, -1, -1, nullptr,
855 static_cast<SiteInstanceImpl*>(source_site_instance), 859 static_cast<SiteInstanceImpl*>(source_site_instance),
856 dest_url, referrer_to_use, redirect_chain, PageState(), method, 860 dest_url, referrer_to_use, redirect_chain, PageState(), method,
857 -1); 861 -1);
858 } else { 862 } else {
859 // Main frame case. 863 // Main frame case.
860 entry = NavigationEntryImpl::FromNavigationEntry( 864 entry = NavigationEntryImpl::FromNavigationEntry(
861 controller_->CreateNavigationEntry( 865 controller_->CreateNavigationEntry(
862 dest_url, referrer_to_use, page_transition, is_renderer_initiated, 866 dest_url, referrer_to_use, page_transition, is_renderer_initiated,
863 std::string(), controller_->GetBrowserContext())); 867 extra_headers, controller_->GetBrowserContext()));
864 entry->root_node()->frame_entry->set_source_site_instance( 868 entry->root_node()->frame_entry->set_source_site_instance(
865 static_cast<SiteInstanceImpl*>(source_site_instance)); 869 static_cast<SiteInstanceImpl*>(source_site_instance));
866 entry->SetRedirectChain(redirect_chain); 870 entry->SetRedirectChain(redirect_chain);
867 } 871 }
868 872
869 // Don't allow an entry replacement if there is no entry to replace. 873 // Don't allow an entry replacement if there is no entry to replace.
870 // http://crbug.com/457149 874 // http://crbug.com/457149
871 if (should_replace_current_entry && controller_->GetEntryCount() > 0) 875 if (should_replace_current_entry && controller_->GetEntryCount() > 0)
872 entry->set_should_replace_entry(true); 876 entry->set_should_replace_entry(true);
873 if (controller_->GetLastCommittedEntry() && 877 if (controller_->GetLastCommittedEntry() &&
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 if (navigation_handle) 1237 if (navigation_handle)
1234 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1238 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1235 1239
1236 controller_->SetPendingEntry(std::move(entry)); 1240 controller_->SetPendingEntry(std::move(entry));
1237 if (delegate_) 1241 if (delegate_)
1238 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1242 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1239 } 1243 }
1240 } 1244 }
1241 1245
1242 } // namespace content 1246 } // 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