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

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: Reordered fields of FrameHostMsg_OpenURL_Params to match order in content::OpenURLParams. 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 3044 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 blink::WebNavigationPolicy policy, 3055 blink::WebNavigationPolicy policy,
3056 const blink::WebString& suggested_name, 3056 const blink::WebString& suggested_name,
3057 bool should_replace_current_entry) { 3057 bool should_replace_current_entry) {
3058 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); 3058 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request));
3059 if (policy == blink::WebNavigationPolicyDownload) { 3059 if (policy == blink::WebNavigationPolicyDownload) {
3060 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), 3060 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(),
3061 GetRoutingID(), request.url(), referrer, 3061 GetRoutingID(), request.url(), referrer,
3062 suggested_name)); 3062 suggested_name));
3063 } else { 3063 } else {
3064 OpenURL(request.url(), IsHttpPost(request), 3064 OpenURL(request.url(), IsHttpPost(request),
3065 GetRequestBodyForWebURLRequest(request), referrer, policy, 3065 GetRequestBodyForWebURLRequest(request),
3066 GetWebURLRequestHeaders(request), referrer, policy,
3066 should_replace_current_entry, false); 3067 should_replace_current_entry, false);
3067 } 3068 }
3068 } 3069 }
3069 3070
3070 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { 3071 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() {
3071 // OOPIF enabled modes will punt this navigation to the browser in 3072 // OOPIF enabled modes will punt this navigation to the browser in
3072 // decidePolicyForNavigation. 3073 // decidePolicyForNavigation.
3073 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3074 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
3074 return WebHistoryItem(); 3075 return WebHistoryItem();
3075 3076
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
4969 // Webkit is asking whether to navigate to a new URL. 4970 // Webkit is asking whether to navigate to a new URL.
4970 // This is fine normally, except if we're showing UI from one security 4971 // This is fine normally, except if we're showing UI from one security
4971 // context and they're trying to navigate to a different context. 4972 // context and they're trying to navigate to a different context.
4972 const GURL& url = info.urlRequest.url(); 4973 const GURL& url = info.urlRequest.url();
4973 4974
4974 // If the browser is interested, then give it a chance to look at the request. 4975 // If the browser is interested, then give it a chance to look at the request.
4975 if (is_content_initiated && IsTopLevelNavigation(frame_) && 4976 if (is_content_initiated && IsTopLevelNavigation(frame_) &&
4976 render_view_->renderer_preferences_ 4977 render_view_->renderer_preferences_
4977 .browser_handles_all_top_level_requests) { 4978 .browser_handles_all_top_level_requests) {
4978 OpenURL(url, IsHttpPost(info.urlRequest), 4979 OpenURL(url, IsHttpPost(info.urlRequest),
4979 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, 4980 GetRequestBodyForWebURLRequest(info.urlRequest),
4981 GetWebURLRequestHeaders(info.urlRequest), referrer,
4980 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 4982 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
4981 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 4983 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
4982 } 4984 }
4983 4985
4984 // In OOPIF-enabled modes, back/forward navigations in newly created subframes 4986 // In OOPIF-enabled modes, back/forward navigations in newly created subframes
4985 // should be sent to the browser if there is a matching FrameNavigationEntry. 4987 // should be sent to the browser if there is a matching FrameNavigationEntry.
4986 // If this frame isn't on the list of unique names that have history items, 4988 // If this frame isn't on the list of unique names that have history items,
4987 // fall back to loading the default url. (We remove each name as we encounter 4989 // fall back to loading the default url. (We remove each name as we encounter
4988 // it, because it will only be used once as the frame is created.) 4990 // it, because it will only be used once as the frame is created.)
4989 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && 4991 if (SiteIsolationPolicy::UseSubframeNavigationEntries() &&
4990 info.isHistoryNavigationInNewChildFrame && is_content_initiated && 4992 info.isHistoryNavigationInNewChildFrame && is_content_initiated &&
4991 frame_->parent() && 4993 frame_->parent() &&
4992 RenderFrameImpl::FromWebFrame(frame_->parent()) 4994 RenderFrameImpl::FromWebFrame(frame_->parent())
4993 ->history_subframe_unique_names_.erase( 4995 ->history_subframe_unique_names_.erase(
4994 frame_->uniqueName().utf8()) > 0) { 4996 frame_->uniqueName().utf8()) > 0) {
4995 // Don't do this if |info| also says it is a client redirect, in which case 4997 // Don't do this if |info| also says it is a client redirect, in which case
4996 // JavaScript on the page is trying to interrupt the history navigation. 4998 // JavaScript on the page is trying to interrupt the history navigation.
4997 if (!info.isClientRedirect) { 4999 if (!info.isClientRedirect) {
4998 OpenURL(url, IsHttpPost(info.urlRequest), 5000 OpenURL(url, IsHttpPost(info.urlRequest),
4999 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, 5001 GetRequestBodyForWebURLRequest(info.urlRequest),
5002 GetWebURLRequestHeaders(info.urlRequest), referrer,
5000 info.defaultPolicy, info.replacesCurrentHistoryItem, true); 5003 info.defaultPolicy, info.replacesCurrentHistoryItem, true);
5001 // Suppress the load in Blink but mark the frame as loading. 5004 // Suppress the load in Blink but mark the frame as loading.
5002 return blink::WebNavigationPolicyHandledByClient; 5005 return blink::WebNavigationPolicyHandledByClient;
5003 } else { 5006 } else {
5004 // Client redirects during an initial history load should attempt to 5007 // Client redirects during an initial history load should attempt to
5005 // cancel the history navigation. They will create a provisional document 5008 // cancel the history navigation. They will create a provisional document
5006 // loader, causing the history load to be ignored in NavigateInternal, and 5009 // loader, causing the history load to be ignored in NavigateInternal, and
5007 // this IPC will try to cancel any cross-process history load. 5010 // this IPC will try to cancel any cross-process history load.
5008 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); 5011 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_));
5009 } 5012 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5050 if (!should_fork) { 5053 if (!should_fork) {
5051 // Give the embedder a chance. 5054 // Give the embedder a chance.
5052 should_fork = GetContentClient()->renderer()->ShouldFork( 5055 should_fork = GetContentClient()->renderer()->ShouldFork(
5053 frame_, url, info.urlRequest.httpMethod().utf8(), 5056 frame_, url, info.urlRequest.httpMethod().utf8(),
5054 is_initial_navigation, is_redirect, &send_referrer); 5057 is_initial_navigation, is_redirect, &send_referrer);
5055 } 5058 }
5056 5059
5057 if (should_fork) { 5060 if (should_fork) {
5058 OpenURL(url, IsHttpPost(info.urlRequest), 5061 OpenURL(url, IsHttpPost(info.urlRequest),
5059 GetRequestBodyForWebURLRequest(info.urlRequest), 5062 GetRequestBodyForWebURLRequest(info.urlRequest),
5063 GetWebURLRequestHeaders(info.urlRequest),
5060 send_referrer ? referrer : Referrer(), info.defaultPolicy, 5064 send_referrer ? referrer : Referrer(), info.defaultPolicy,
5061 info.replacesCurrentHistoryItem, false); 5065 info.replacesCurrentHistoryItem, false);
5062 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 5066 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
5063 } 5067 }
5064 } 5068 }
5065 5069
5066 // Detect when a page is "forking" a new tab that can be safely rendered in 5070 // Detect when a page is "forking" a new tab that can be safely rendered in
5067 // its own process. This is done by sites like Gmail that try to open links 5071 // its own process. This is done by sites like Gmail that try to open links
5068 // in new windows without script connections back to the original page. We 5072 // in new windows without script connections back to the original page. We
5069 // treat such cases as browser navigations (in which we will create a new 5073 // treat such cases as browser navigations (in which we will create a new
(...skipping 21 matching lines...) Expand all
5091 // Must not have issued the request from this page. 5095 // Must not have issued the request from this page.
5092 is_content_initiated && 5096 is_content_initiated &&
5093 // Must be targeted at the current tab. 5097 // Must be targeted at the current tab.
5094 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5098 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5095 // Must be a JavaScript navigation, which appears as "other". 5099 // Must be a JavaScript navigation, which appears as "other".
5096 info.navigationType == blink::WebNavigationTypeOther; 5100 info.navigationType == blink::WebNavigationTypeOther;
5097 5101
5098 if (is_fork) { 5102 if (is_fork) {
5099 // Open the URL via the browser, not via WebKit. 5103 // Open the URL via the browser, not via WebKit.
5100 OpenURL(url, IsHttpPost(info.urlRequest), 5104 OpenURL(url, IsHttpPost(info.urlRequest),
5101 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), 5105 GetRequestBodyForWebURLRequest(info.urlRequest),
5106 GetWebURLRequestHeaders(info.urlRequest), Referrer(),
5102 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 5107 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
5103 return blink::WebNavigationPolicyIgnore; 5108 return blink::WebNavigationPolicyIgnore;
5104 } 5109 }
5105 5110
5106 bool should_dispatch_before_unload = 5111 bool should_dispatch_before_unload =
5107 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5112 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5108 // There is no need to execute the BeforeUnload event during a redirect, 5113 // There is no need to execute the BeforeUnload event during a redirect,
5109 // since it was already executed at the start of the navigation. 5114 // since it was already executed at the start of the navigation.
5110 !is_redirect && 5115 !is_redirect &&
5111 // PlzNavigate: this should not be executed when commiting the navigation. 5116 // PlzNavigate: this should not be executed when commiting the navigation.
(...skipping 309 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
5929 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == 5936 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) ==
5930 FetchRedirectMode::MANUAL_MODE); 5937 FetchRedirectMode::MANUAL_MODE);
5931 DCHECK(frame_->parent() || 5938 DCHECK(frame_->parent() ||
5932 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 5939 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
5933 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 5940 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
5934 DCHECK(!frame_->parent() || 5941 DCHECK(!frame_->parent() ||
5935 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 5942 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
5936 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 5943 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
5937 5944
5938 Send(new FrameHostMsg_BeginNavigation( 5945 Send(new FrameHostMsg_BeginNavigation(
5939 routing_id_, 5946 routing_id_, MakeCommonNavigationParams(info),
5940 MakeCommonNavigationParams(info),
5941 BeginNavigationParams( 5947 BeginNavigationParams(
5942 GetWebURLRequestHeaders(info.urlRequest), 5948 GetWebURLRequestHeaders(info.urlRequest),
5943 GetLoadFlagsForWebURLRequest(info.urlRequest), 5949 GetLoadFlagsForWebURLRequest(info.urlRequest),
5944 info.urlRequest.hasUserGesture(), 5950 info.urlRequest.hasUserGesture(),
5945 info.urlRequest.skipServiceWorker() != 5951 info.urlRequest.skipServiceWorker() !=
5946 blink::WebURLRequest::SkipServiceWorker::None, 5952 blink::WebURLRequest::SkipServiceWorker::None,
5947 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); 5953 GetRequestContextTypeForWebURLRequest(info.urlRequest))));
5948 } 5954 }
5949 5955
5950 void RenderFrameImpl::LoadDataURL( 5956 void RenderFrameImpl::LoadDataURL(
(...skipping 483 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