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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2419093002: Revert of Preserving Content-Type header from http request in OpenURL path. (Closed)
Patch Set: Manually resolved conflicts with r425338 in navigator_impl.cc. 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 blink::WebNavigationPolicy policy, 3156 blink::WebNavigationPolicy policy,
3157 const blink::WebString& suggested_name, 3157 const blink::WebString& suggested_name,
3158 bool should_replace_current_entry) { 3158 bool should_replace_current_entry) {
3159 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); 3159 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request));
3160 if (policy == blink::WebNavigationPolicyDownload) { 3160 if (policy == blink::WebNavigationPolicyDownload) {
3161 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), 3161 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(),
3162 GetRoutingID(), request.url(), referrer, 3162 GetRoutingID(), request.url(), referrer,
3163 suggested_name)); 3163 suggested_name));
3164 } else { 3164 } else {
3165 OpenURL(request.url(), IsHttpPost(request), 3165 OpenURL(request.url(), IsHttpPost(request),
3166 GetRequestBodyForWebURLRequest(request), 3166 GetRequestBodyForWebURLRequest(request), referrer, policy,
3167 GetWebURLRequestHeaders(request), referrer, policy,
3168 should_replace_current_entry, false); 3167 should_replace_current_entry, false);
3169 } 3168 }
3170 } 3169 }
3171 3170
3172 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { 3171 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() {
3173 // OOPIF enabled modes will punt this navigation to the browser in 3172 // OOPIF enabled modes will punt this navigation to the browser in
3174 // decidePolicyForNavigation. 3173 // decidePolicyForNavigation.
3175 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3174 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
3176 return WebHistoryItem(); 3175 return WebHistoryItem();
3177 3176
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after
5087 // Webkit is asking whether to navigate to a new URL. 5086 // Webkit is asking whether to navigate to a new URL.
5088 // This is fine normally, except if we're showing UI from one security 5087 // This is fine normally, except if we're showing UI from one security
5089 // context and they're trying to navigate to a different context. 5088 // context and they're trying to navigate to a different context.
5090 const GURL& url = info.urlRequest.url(); 5089 const GURL& url = info.urlRequest.url();
5091 5090
5092 // If the browser is interested, then give it a chance to look at the request. 5091 // If the browser is interested, then give it a chance to look at the request.
5093 if (is_content_initiated && IsTopLevelNavigation(frame_) && 5092 if (is_content_initiated && IsTopLevelNavigation(frame_) &&
5094 render_view_->renderer_preferences_ 5093 render_view_->renderer_preferences_
5095 .browser_handles_all_top_level_requests) { 5094 .browser_handles_all_top_level_requests) {
5096 OpenURL(url, IsHttpPost(info.urlRequest), 5095 OpenURL(url, IsHttpPost(info.urlRequest),
5097 GetRequestBodyForWebURLRequest(info.urlRequest), 5096 GetRequestBodyForWebURLRequest(info.urlRequest), referrer,
5098 GetWebURLRequestHeaders(info.urlRequest), referrer,
5099 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 5097 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
5100 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 5098 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
5101 } 5099 }
5102 5100
5103 // In OOPIF-enabled modes, back/forward navigations in newly created subframes 5101 // In OOPIF-enabled modes, back/forward navigations in newly created subframes
5104 // should be sent to the browser if there is a matching FrameNavigationEntry. 5102 // should be sent to the browser if there is a matching FrameNavigationEntry.
5105 // If this frame isn't on the list of unique names that have history items, 5103 // If this frame isn't on the list of unique names that have history items,
5106 // fall back to loading the default url. (We remove each name as we encounter 5104 // fall back to loading the default url. (We remove each name as we encounter
5107 // it, because it will only be used once as the frame is created.) 5105 // it, because it will only be used once as the frame is created.)
5108 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && 5106 if (SiteIsolationPolicy::UseSubframeNavigationEntries() &&
5109 info.isHistoryNavigationInNewChildFrame && is_content_initiated && 5107 info.isHistoryNavigationInNewChildFrame && is_content_initiated &&
5110 frame_->parent() && 5108 frame_->parent() &&
5111 RenderFrameImpl::FromWebFrame(frame_->parent()) 5109 RenderFrameImpl::FromWebFrame(frame_->parent())
5112 ->history_subframe_unique_names_.erase( 5110 ->history_subframe_unique_names_.erase(
5113 frame_->uniqueName().utf8()) > 0) { 5111 frame_->uniqueName().utf8()) > 0) {
5114 // Don't do this if |info| also says it is a client redirect, in which case 5112 // Don't do this if |info| also says it is a client redirect, in which case
5115 // JavaScript on the page is trying to interrupt the history navigation. 5113 // JavaScript on the page is trying to interrupt the history navigation.
5116 if (!info.isClientRedirect) { 5114 if (!info.isClientRedirect) {
5117 OpenURL(url, IsHttpPost(info.urlRequest), 5115 OpenURL(url, IsHttpPost(info.urlRequest),
5118 GetRequestBodyForWebURLRequest(info.urlRequest), 5116 GetRequestBodyForWebURLRequest(info.urlRequest), referrer,
5119 GetWebURLRequestHeaders(info.urlRequest), referrer,
5120 info.defaultPolicy, info.replacesCurrentHistoryItem, true); 5117 info.defaultPolicy, info.replacesCurrentHistoryItem, true);
5121 // Suppress the load in Blink but mark the frame as loading. 5118 // Suppress the load in Blink but mark the frame as loading.
5122 return blink::WebNavigationPolicyHandledByClient; 5119 return blink::WebNavigationPolicyHandledByClient;
5123 } else { 5120 } else {
5124 // Client redirects during an initial history load should attempt to 5121 // Client redirects during an initial history load should attempt to
5125 // cancel the history navigation. They will create a provisional document 5122 // cancel the history navigation. They will create a provisional document
5126 // loader, causing the history load to be ignored in NavigateInternal, and 5123 // loader, causing the history load to be ignored in NavigateInternal, and
5127 // this IPC will try to cancel any cross-process history load. 5124 // this IPC will try to cancel any cross-process history load.
5128 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); 5125 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_));
5129 } 5126 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5170 if (!should_fork) { 5167 if (!should_fork) {
5171 // Give the embedder a chance. 5168 // Give the embedder a chance.
5172 should_fork = GetContentClient()->renderer()->ShouldFork( 5169 should_fork = GetContentClient()->renderer()->ShouldFork(
5173 frame_, url, info.urlRequest.httpMethod().utf8(), 5170 frame_, url, info.urlRequest.httpMethod().utf8(),
5174 is_initial_navigation, is_redirect, &send_referrer); 5171 is_initial_navigation, is_redirect, &send_referrer);
5175 } 5172 }
5176 5173
5177 if (should_fork) { 5174 if (should_fork) {
5178 OpenURL(url, IsHttpPost(info.urlRequest), 5175 OpenURL(url, IsHttpPost(info.urlRequest),
5179 GetRequestBodyForWebURLRequest(info.urlRequest), 5176 GetRequestBodyForWebURLRequest(info.urlRequest),
5180 GetWebURLRequestHeaders(info.urlRequest),
5181 send_referrer ? referrer : Referrer(), info.defaultPolicy, 5177 send_referrer ? referrer : Referrer(), info.defaultPolicy,
5182 info.replacesCurrentHistoryItem, false); 5178 info.replacesCurrentHistoryItem, false);
5183 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 5179 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
5184 } 5180 }
5185 } 5181 }
5186 5182
5187 // Detect when a page is "forking" a new tab that can be safely rendered in 5183 // Detect when a page is "forking" a new tab that can be safely rendered in
5188 // its own process. This is done by sites like Gmail that try to open links 5184 // its own process. This is done by sites like Gmail that try to open links
5189 // in new windows without script connections back to the original page. We 5185 // in new windows without script connections back to the original page. We
5190 // treat such cases as browser navigations (in which we will create a new 5186 // treat such cases as browser navigations (in which we will create a new
(...skipping 21 matching lines...) Expand all
5212 // Must not have issued the request from this page. 5208 // Must not have issued the request from this page.
5213 is_content_initiated && 5209 is_content_initiated &&
5214 // Must be targeted at the current tab. 5210 // Must be targeted at the current tab.
5215 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5211 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5216 // Must be a JavaScript navigation, which appears as "other". 5212 // Must be a JavaScript navigation, which appears as "other".
5217 info.navigationType == blink::WebNavigationTypeOther; 5213 info.navigationType == blink::WebNavigationTypeOther;
5218 5214
5219 if (is_fork) { 5215 if (is_fork) {
5220 // Open the URL via the browser, not via WebKit. 5216 // Open the URL via the browser, not via WebKit.
5221 OpenURL(url, IsHttpPost(info.urlRequest), 5217 OpenURL(url, IsHttpPost(info.urlRequest),
5222 GetRequestBodyForWebURLRequest(info.urlRequest), 5218 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(),
5223 GetWebURLRequestHeaders(info.urlRequest), Referrer(),
5224 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 5219 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
5225 return blink::WebNavigationPolicyIgnore; 5220 return blink::WebNavigationPolicyIgnore;
5226 } 5221 }
5227 5222
5228 bool should_dispatch_before_unload = 5223 bool should_dispatch_before_unload =
5229 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5224 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5230 // There is no need to execute the BeforeUnload event during a redirect, 5225 // There is no need to execute the BeforeUnload event during a redirect,
5231 // since it was already executed at the start of the navigation. 5226 // since it was already executed at the start of the navigation.
5232 !is_redirect && 5227 !is_redirect &&
5233 // PlzNavigate: this should not be executed when commiting the navigation. 5228 // PlzNavigate: this should not be executed when commiting the navigation.
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
5550 external_popup_menu_->DidSelectItems(canceled, selected_indices); 5545 external_popup_menu_->DidSelectItems(canceled, selected_indices);
5551 external_popup_menu_.reset(); 5546 external_popup_menu_.reset();
5552 } 5547 }
5553 #endif 5548 #endif
5554 #endif 5549 #endif
5555 5550
5556 void RenderFrameImpl::OpenURL( 5551 void RenderFrameImpl::OpenURL(
5557 const GURL& url, 5552 const GURL& url,
5558 bool uses_post, 5553 bool uses_post,
5559 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, 5554 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body,
5560 const std::string& extra_headers,
5561 const Referrer& referrer, 5555 const Referrer& referrer,
5562 WebNavigationPolicy policy, 5556 WebNavigationPolicy policy,
5563 bool should_replace_current_entry, 5557 bool should_replace_current_entry,
5564 bool is_history_navigation_in_new_child) { 5558 bool is_history_navigation_in_new_child) {
5565 FrameHostMsg_OpenURL_Params params; 5559 FrameHostMsg_OpenURL_Params params;
5566 params.url = url; 5560 params.url = url;
5567 params.uses_post = uses_post; 5561 params.uses_post = uses_post;
5568 params.resource_request_body = resource_request_body; 5562 params.resource_request_body = resource_request_body;
5569 params.extra_headers = extra_headers;
5570 params.referrer = referrer; 5563 params.referrer = referrer;
5571 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); 5564 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
5572 5565
5573 if (IsBrowserInitiated(pending_navigation_params_.get())) { 5566 if (IsBrowserInitiated(pending_navigation_params_.get())) {
5574 // This is necessary to preserve the should_replace_current_entry value on 5567 // This is necessary to preserve the should_replace_current_entry value on
5575 // cross-process redirects, in the event it was set by a previous process. 5568 // cross-process redirects, in the event it was set by a previous process.
5576 WebDataSource* ds = frame_->provisionalDataSource(); 5569 WebDataSource* ds = frame_->provisionalDataSource();
5577 DCHECK(ds); 5570 DCHECK(ds);
5578 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); 5571 params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
5579 } else { 5572 } else {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
6051 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == 6044 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) ==
6052 FetchRedirectMode::MANUAL_MODE); 6045 FetchRedirectMode::MANUAL_MODE);
6053 DCHECK(frame_->parent() || 6046 DCHECK(frame_->parent() ||
6054 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 6047 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
6055 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 6048 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
6056 DCHECK(!frame_->parent() || 6049 DCHECK(!frame_->parent() ||
6057 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 6050 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
6058 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 6051 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
6059 6052
6060 Send(new FrameHostMsg_BeginNavigation( 6053 Send(new FrameHostMsg_BeginNavigation(
6061 routing_id_, MakeCommonNavigationParams(info), 6054 routing_id_,
6055 MakeCommonNavigationParams(info),
6062 BeginNavigationParams( 6056 BeginNavigationParams(
6063 GetWebURLRequestHeaders(info.urlRequest), 6057 GetWebURLRequestHeaders(info.urlRequest),
6064 GetLoadFlagsForWebURLRequest(info.urlRequest), 6058 GetLoadFlagsForWebURLRequest(info.urlRequest),
6065 info.urlRequest.hasUserGesture(), 6059 info.urlRequest.hasUserGesture(),
6066 info.urlRequest.skipServiceWorker() != 6060 info.urlRequest.skipServiceWorker() !=
6067 blink::WebURLRequest::SkipServiceWorker::None, 6061 blink::WebURLRequest::SkipServiceWorker::None,
6068 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); 6062 GetRequestContextTypeForWebURLRequest(info.urlRequest))));
6069 } 6063 }
6070 6064
6071 void RenderFrameImpl::LoadDataURL( 6065 void RenderFrameImpl::LoadDataURL(
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
6554 // event target. Potentially a Pepper plugin will receive the event. 6548 // event target. Potentially a Pepper plugin will receive the event.
6555 // In order to tell whether a plugin gets the last mouse event and which it 6549 // In order to tell whether a plugin gets the last mouse event and which it
6556 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6550 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6557 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6551 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6558 // |pepper_last_mouse_event_target_|. 6552 // |pepper_last_mouse_event_target_|.
6559 pepper_last_mouse_event_target_ = nullptr; 6553 pepper_last_mouse_event_target_ = nullptr;
6560 #endif 6554 #endif
6561 } 6555 }
6562 6556
6563 } // namespace content 6557 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698