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

Side by Side Diff: content/renderer/render_frame_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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 3053 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 blink::WebNavigationPolicy policy, 3064 blink::WebNavigationPolicy policy,
3065 const blink::WebString& suggested_name, 3065 const blink::WebString& suggested_name,
3066 bool should_replace_current_entry) { 3066 bool should_replace_current_entry) {
3067 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); 3067 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request));
3068 if (policy == blink::WebNavigationPolicyDownload) { 3068 if (policy == blink::WebNavigationPolicyDownload) {
3069 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), 3069 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(),
3070 GetRoutingID(), request.url(), referrer, 3070 GetRoutingID(), request.url(), referrer,
3071 suggested_name)); 3071 suggested_name));
3072 } else { 3072 } else {
3073 OpenURL(request.url(), IsHttpPost(request), 3073 OpenURL(request.url(), IsHttpPost(request),
3074 GetRequestBodyForWebURLRequest(request), referrer, policy, 3074 GetRequestBodyForWebURLRequest(request),
3075 GetWebURLRequestHeaders(request), referrer, policy,
3075 should_replace_current_entry, false); 3076 should_replace_current_entry, false);
3076 } 3077 }
3077 } 3078 }
3078 3079
3079 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { 3080 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() {
3080 // OOPIF enabled modes will punt this navigation to the browser in 3081 // OOPIF enabled modes will punt this navigation to the browser in
3081 // decidePolicyForNavigation. 3082 // decidePolicyForNavigation.
3082 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3083 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
3083 return WebHistoryItem(); 3084 return WebHistoryItem();
3084 3085
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
4977 // Webkit is asking whether to navigate to a new URL. 4978 // Webkit is asking whether to navigate to a new URL.
4978 // This is fine normally, except if we're showing UI from one security 4979 // This is fine normally, except if we're showing UI from one security
4979 // context and they're trying to navigate to a different context. 4980 // context and they're trying to navigate to a different context.
4980 const GURL& url = info.urlRequest.url(); 4981 const GURL& url = info.urlRequest.url();
4981 4982
4982 // If the browser is interested, then give it a chance to look at the request. 4983 // If the browser is interested, then give it a chance to look at the request.
4983 if (is_content_initiated && IsTopLevelNavigation(frame_) && 4984 if (is_content_initiated && IsTopLevelNavigation(frame_) &&
4984 render_view_->renderer_preferences_ 4985 render_view_->renderer_preferences_
4985 .browser_handles_all_top_level_requests) { 4986 .browser_handles_all_top_level_requests) {
4986 OpenURL(url, IsHttpPost(info.urlRequest), 4987 OpenURL(url, IsHttpPost(info.urlRequest),
4987 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, 4988 GetRequestBodyForWebURLRequest(info.urlRequest),
4989 GetWebURLRequestHeaders(info.urlRequest), referrer,
4988 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 4990 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
4989 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 4991 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
4990 } 4992 }
4991 4993
4992 // In OOPIF-enabled modes, back/forward navigations in newly created subframes 4994 // In OOPIF-enabled modes, back/forward navigations in newly created subframes
4993 // should be sent to the browser if there is a matching FrameNavigationEntry. 4995 // should be sent to the browser if there is a matching FrameNavigationEntry.
4994 // If this frame isn't on the list of unique names that have history items, 4996 // If this frame isn't on the list of unique names that have history items,
4995 // fall back to loading the default url. (We remove each name as we encounter 4997 // fall back to loading the default url. (We remove each name as we encounter
4996 // it, because it will only be used once as the frame is created.) 4998 // it, because it will only be used once as the frame is created.)
4997 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && 4999 if (SiteIsolationPolicy::UseSubframeNavigationEntries() &&
4998 info.isHistoryNavigationInNewChildFrame && is_content_initiated && 5000 info.isHistoryNavigationInNewChildFrame && is_content_initiated &&
4999 frame_->parent() && 5001 frame_->parent() &&
5000 RenderFrameImpl::FromWebFrame(frame_->parent()) 5002 RenderFrameImpl::FromWebFrame(frame_->parent())
5001 ->history_subframe_unique_names_.erase( 5003 ->history_subframe_unique_names_.erase(
5002 frame_->uniqueName().utf8()) > 0) { 5004 frame_->uniqueName().utf8()) > 0) {
5003 // Don't do this if |info| also says it is a client redirect, in which case 5005 // Don't do this if |info| also says it is a client redirect, in which case
5004 // JavaScript on the page is trying to interrupt the history navigation. 5006 // JavaScript on the page is trying to interrupt the history navigation.
5005 if (!info.isClientRedirect) { 5007 if (!info.isClientRedirect) {
5006 OpenURL(url, IsHttpPost(info.urlRequest), 5008 OpenURL(url, IsHttpPost(info.urlRequest),
5007 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, 5009 GetRequestBodyForWebURLRequest(info.urlRequest),
5010 GetWebURLRequestHeaders(info.urlRequest), referrer,
5008 info.defaultPolicy, info.replacesCurrentHistoryItem, true); 5011 info.defaultPolicy, info.replacesCurrentHistoryItem, true);
5009 // Suppress the load in Blink but mark the frame as loading. 5012 // Suppress the load in Blink but mark the frame as loading.
5010 return blink::WebNavigationPolicyHandledByClient; 5013 return blink::WebNavigationPolicyHandledByClient;
5011 } else { 5014 } else {
5012 // Client redirects during an initial history load should attempt to 5015 // Client redirects during an initial history load should attempt to
5013 // cancel the history navigation. They will create a provisional document 5016 // cancel the history navigation. They will create a provisional document
5014 // loader, causing the history load to be ignored in NavigateInternal, and 5017 // loader, causing the history load to be ignored in NavigateInternal, and
5015 // this IPC will try to cancel any cross-process history load. 5018 // this IPC will try to cancel any cross-process history load.
5016 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); 5019 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_));
5017 } 5020 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5058 if (!should_fork) { 5061 if (!should_fork) {
5059 // Give the embedder a chance. 5062 // Give the embedder a chance.
5060 should_fork = GetContentClient()->renderer()->ShouldFork( 5063 should_fork = GetContentClient()->renderer()->ShouldFork(
5061 frame_, url, info.urlRequest.httpMethod().utf8(), 5064 frame_, url, info.urlRequest.httpMethod().utf8(),
5062 is_initial_navigation, is_redirect, &send_referrer); 5065 is_initial_navigation, is_redirect, &send_referrer);
5063 } 5066 }
5064 5067
5065 if (should_fork) { 5068 if (should_fork) {
5066 OpenURL(url, IsHttpPost(info.urlRequest), 5069 OpenURL(url, IsHttpPost(info.urlRequest),
5067 GetRequestBodyForWebURLRequest(info.urlRequest), 5070 GetRequestBodyForWebURLRequest(info.urlRequest),
5071 GetWebURLRequestHeaders(info.urlRequest),
5068 send_referrer ? referrer : Referrer(), info.defaultPolicy, 5072 send_referrer ? referrer : Referrer(), info.defaultPolicy,
5069 info.replacesCurrentHistoryItem, false); 5073 info.replacesCurrentHistoryItem, false);
5070 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 5074 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
5071 } 5075 }
5072 } 5076 }
5073 5077
5074 // Detect when a page is "forking" a new tab that can be safely rendered in 5078 // Detect when a page is "forking" a new tab that can be safely rendered in
5075 // its own process. This is done by sites like Gmail that try to open links 5079 // its own process. This is done by sites like Gmail that try to open links
5076 // in new windows without script connections back to the original page. We 5080 // in new windows without script connections back to the original page. We
5077 // treat such cases as browser navigations (in which we will create a new 5081 // treat such cases as browser navigations (in which we will create a new
(...skipping 21 matching lines...) Expand all
5099 // Must not have issued the request from this page. 5103 // Must not have issued the request from this page.
5100 is_content_initiated && 5104 is_content_initiated &&
5101 // Must be targeted at the current tab. 5105 // Must be targeted at the current tab.
5102 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5106 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5103 // Must be a JavaScript navigation, which appears as "other". 5107 // Must be a JavaScript navigation, which appears as "other".
5104 info.navigationType == blink::WebNavigationTypeOther; 5108 info.navigationType == blink::WebNavigationTypeOther;
5105 5109
5106 if (is_fork) { 5110 if (is_fork) {
5107 // Open the URL via the browser, not via WebKit. 5111 // Open the URL via the browser, not via WebKit.
5108 OpenURL(url, IsHttpPost(info.urlRequest), 5112 OpenURL(url, IsHttpPost(info.urlRequest),
5109 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), 5113 GetRequestBodyForWebURLRequest(info.urlRequest),
5114 GetWebURLRequestHeaders(info.urlRequest), Referrer(),
5110 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 5115 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
5111 return blink::WebNavigationPolicyIgnore; 5116 return blink::WebNavigationPolicyIgnore;
5112 } 5117 }
5113 5118
5114 bool should_dispatch_before_unload = 5119 bool should_dispatch_before_unload =
5115 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5120 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5116 // There is no need to execute the BeforeUnload event during a redirect, 5121 // There is no need to execute the BeforeUnload event during a redirect,
5117 // since it was already executed at the start of the navigation. 5122 // since it was already executed at the start of the navigation.
5118 !is_redirect && 5123 !is_redirect &&
5119 // PlzNavigate: this should not be executed when commiting the navigation. 5124 // PlzNavigate: this should not be executed when commiting the navigation.
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
5421 external_popup_menu_->DidSelectItems(canceled, selected_indices); 5426 external_popup_menu_->DidSelectItems(canceled, selected_indices);
5422 external_popup_menu_.reset(); 5427 external_popup_menu_.reset();
5423 } 5428 }
5424 #endif 5429 #endif
5425 #endif 5430 #endif
5426 5431
5427 void RenderFrameImpl::OpenURL( 5432 void RenderFrameImpl::OpenURL(
5428 const GURL& url, 5433 const GURL& url,
5429 bool uses_post, 5434 bool uses_post,
5430 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, 5435 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body,
5436 const std::string& extra_headers,
5431 const Referrer& referrer, 5437 const Referrer& referrer,
5432 WebNavigationPolicy policy, 5438 WebNavigationPolicy policy,
5433 bool should_replace_current_entry, 5439 bool should_replace_current_entry,
5434 bool is_history_navigation_in_new_child) { 5440 bool is_history_navigation_in_new_child) {
5435 FrameHostMsg_OpenURL_Params params; 5441 FrameHostMsg_OpenURL_Params params;
5436 params.url = url; 5442 params.url = url;
5437 params.uses_post = uses_post; 5443 params.uses_post = uses_post;
5438 params.resource_request_body = resource_request_body; 5444 params.resource_request_body = resource_request_body;
5445 params.extra_headers = extra_headers;
5439 params.referrer = referrer; 5446 params.referrer = referrer;
5440 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); 5447 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
5441 5448
5442 if (IsBrowserInitiated(pending_navigation_params_.get())) { 5449 if (IsBrowserInitiated(pending_navigation_params_.get())) {
5443 // This is necessary to preserve the should_replace_current_entry value on 5450 // This is necessary to preserve the should_replace_current_entry value on
5444 // cross-process redirects, in the event it was set by a previous process. 5451 // cross-process redirects, in the event it was set by a previous process.
5445 WebDataSource* ds = frame_->provisionalDataSource(); 5452 WebDataSource* ds = frame_->provisionalDataSource();
5446 DCHECK(ds); 5453 DCHECK(ds);
5447 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); 5454 params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
5448 } else { 5455 } else {
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
5925 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == 5932 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) ==
5926 FetchRedirectMode::MANUAL_MODE); 5933 FetchRedirectMode::MANUAL_MODE);
5927 DCHECK(frame_->parent() || 5934 DCHECK(frame_->parent() ||
5928 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 5935 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
5929 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 5936 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
5930 DCHECK(!frame_->parent() || 5937 DCHECK(!frame_->parent() ||
5931 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 5938 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
5932 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 5939 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
5933 5940
5934 Send(new FrameHostMsg_BeginNavigation( 5941 Send(new FrameHostMsg_BeginNavigation(
5935 routing_id_, 5942 routing_id_, MakeCommonNavigationParams(info),
5936 MakeCommonNavigationParams(info),
5937 BeginNavigationParams( 5943 BeginNavigationParams(
5938 GetWebURLRequestHeaders(info.urlRequest), 5944 GetWebURLRequestHeaders(info.urlRequest),
5939 GetLoadFlagsForWebURLRequest(info.urlRequest), 5945 GetLoadFlagsForWebURLRequest(info.urlRequest),
5940 info.urlRequest.hasUserGesture(), 5946 info.urlRequest.hasUserGesture(),
5941 info.urlRequest.skipServiceWorker() != 5947 info.urlRequest.skipServiceWorker() !=
5942 blink::WebURLRequest::SkipServiceWorker::None, 5948 blink::WebURLRequest::SkipServiceWorker::None,
5943 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); 5949 GetRequestContextTypeForWebURLRequest(info.urlRequest))));
5944 } 5950 }
5945 5951
5946 void RenderFrameImpl::LoadDataURL( 5952 void RenderFrameImpl::LoadDataURL(
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
6434 // event target. Potentially a Pepper plugin will receive the event. 6440 // event target. Potentially a Pepper plugin will receive the event.
6435 // In order to tell whether a plugin gets the last mouse event and which it 6441 // In order to tell whether a plugin gets the last mouse event and which it
6436 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6442 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6437 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6443 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6438 // |pepper_last_mouse_event_target_|. 6444 // |pepper_last_mouse_event_target_|.
6439 pepper_last_mouse_event_target_ = nullptr; 6445 pepper_last_mouse_event_target_ = nullptr;
6440 #endif 6446 #endif
6441 } 6447 }
6442 6448
6443 } // namespace content 6449 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698