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

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: Filtering headers in PrerenderManager instead. 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 // have a new NavigationEntry. 803 // have a new NavigationEntry.
801 // TODO(creis): Make this unnecessary by creating (and validating) the params 804 // TODO(creis): Make this unnecessary by creating (and validating) the params
802 // directly, passing them to the destination RenderFrameHost. See 805 // directly, passing them to the destination RenderFrameHost. See
803 // https://crbug.com/536906. 806 // https://crbug.com/536906.
804 std::unique_ptr<NavigationEntryImpl> entry; 807 std::unique_ptr<NavigationEntryImpl> entry;
805 if (!node->IsMainFrame()) { 808 if (!node->IsMainFrame()) {
806 // Subframe case: create FrameNavigationEntry. 809 // Subframe case: create FrameNavigationEntry.
807 CHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); 810 CHECK(SiteIsolationPolicy::UseSubframeNavigationEntries());
808 if (controller_->GetLastCommittedEntry()) { 811 if (controller_->GetLastCommittedEntry()) {
809 entry = controller_->GetLastCommittedEntry()->Clone(); 812 entry = controller_->GetLastCommittedEntry()->Clone();
813 entry->set_extra_headers(extra_headers);
810 entry->SetPageID(-1); 814 entry->SetPageID(-1);
811 } else { 815 } else {
812 // If there's no last committed entry, create an entry for about:blank 816 // If there's no last committed entry, create an entry for about:blank
813 // with a subframe entry for our destination. 817 // with a subframe entry for our destination.
814 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. 818 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208.
815 entry = NavigationEntryImpl::FromNavigationEntry( 819 entry = NavigationEntryImpl::FromNavigationEntry(
816 controller_->CreateNavigationEntry( 820 controller_->CreateNavigationEntry(
817 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, 821 GURL(url::kAboutBlankURL), referrer_to_use, page_transition,
818 is_renderer_initiated, std::string(), 822 is_renderer_initiated, extra_headers,
819 controller_->GetBrowserContext())); 823 controller_->GetBrowserContext()));
820 } 824 }
821 entry->AddOrUpdateFrameEntry( 825 entry->AddOrUpdateFrameEntry(
822 node, -1, -1, nullptr, 826 node, -1, -1, nullptr,
823 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, 827 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url,
824 referrer_to_use, PageState(), method, -1); 828 referrer_to_use, PageState(), method, -1);
825 } else { 829 } else {
826 // Main frame case. 830 // Main frame case.
827 entry = NavigationEntryImpl::FromNavigationEntry( 831 entry = NavigationEntryImpl::FromNavigationEntry(
828 controller_->CreateNavigationEntry( 832 controller_->CreateNavigationEntry(
829 dest_url, referrer_to_use, page_transition, is_renderer_initiated, 833 dest_url, referrer_to_use, page_transition, is_renderer_initiated,
830 std::string(), controller_->GetBrowserContext())); 834 extra_headers, controller_->GetBrowserContext()));
831 entry->root_node()->frame_entry->set_source_site_instance( 835 entry->root_node()->frame_entry->set_source_site_instance(
832 static_cast<SiteInstanceImpl*>(source_site_instance)); 836 static_cast<SiteInstanceImpl*>(source_site_instance));
833 } 837 }
834 838
835 entry->SetRedirectChain(redirect_chain); 839 entry->SetRedirectChain(redirect_chain);
836 // Don't allow an entry replacement if there is no entry to replace. 840 // Don't allow an entry replacement if there is no entry to replace.
837 // http://crbug.com/457149 841 // http://crbug.com/457149
838 if (should_replace_current_entry && controller_->GetEntryCount() > 0) 842 if (should_replace_current_entry && controller_->GetEntryCount() > 0)
839 entry->set_should_replace_entry(true); 843 entry->set_should_replace_entry(true);
840 if (controller_->GetLastCommittedEntry() && 844 if (controller_->GetLastCommittedEntry() &&
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 if (pending_entry != controller_->GetVisibleEntry() || 1208 if (pending_entry != controller_->GetVisibleEntry() ||
1205 !should_preserve_entry) { 1209 !should_preserve_entry) {
1206 controller_->DiscardPendingEntry(true); 1210 controller_->DiscardPendingEntry(true);
1207 1211
1208 // Also force the UI to refresh. 1212 // Also force the UI to refresh.
1209 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 1213 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
1210 } 1214 }
1211 } 1215 }
1212 1216
1213 } // namespace content 1217 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698