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

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: Rebasing... Created 4 years, 3 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 3043 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 blink::WebNavigationPolicy policy, 3054 blink::WebNavigationPolicy policy,
3055 const blink::WebString& suggested_name, 3055 const blink::WebString& suggested_name,
3056 bool should_replace_current_entry) { 3056 bool should_replace_current_entry) {
3057 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); 3057 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request));
3058 if (policy == blink::WebNavigationPolicyDownload) { 3058 if (policy == blink::WebNavigationPolicyDownload) {
3059 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), 3059 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(),
3060 GetRoutingID(), request.url(), referrer, 3060 GetRoutingID(), request.url(), referrer,
3061 suggested_name)); 3061 suggested_name));
3062 } else { 3062 } else {
3063 OpenURL(request.url(), IsHttpPost(request), 3063 OpenURL(request.url(), IsHttpPost(request),
3064 GetRequestBodyForWebURLRequest(request), referrer, policy, 3064 GetRequestBodyForWebURLRequest(request),
3065 GetWebURLRequestHeadersForOpenURLParams(request), referrer, policy,
3065 should_replace_current_entry, false); 3066 should_replace_current_entry, false);
3066 } 3067 }
3067 } 3068 }
3068 3069
3069 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { 3070 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() {
3070 // OOPIF enabled modes will punt this navigation to the browser in 3071 // OOPIF enabled modes will punt this navigation to the browser in
3071 // decidePolicyForNavigation. 3072 // decidePolicyForNavigation.
3072 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3073 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
3073 return WebHistoryItem(); 3074 return WebHistoryItem();
3074 3075
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after
4951 // Webkit is asking whether to navigate to a new URL. 4952 // Webkit is asking whether to navigate to a new URL.
4952 // This is fine normally, except if we're showing UI from one security 4953 // This is fine normally, except if we're showing UI from one security
4953 // context and they're trying to navigate to a different context. 4954 // context and they're trying to navigate to a different context.
4954 const GURL& url = info.urlRequest.url(); 4955 const GURL& url = info.urlRequest.url();
4955 4956
4956 // If the browser is interested, then give it a chance to look at the request. 4957 // If the browser is interested, then give it a chance to look at the request.
4957 if (is_content_initiated && IsTopLevelNavigation(frame_) && 4958 if (is_content_initiated && IsTopLevelNavigation(frame_) &&
4958 render_view_->renderer_preferences_ 4959 render_view_->renderer_preferences_
4959 .browser_handles_all_top_level_requests) { 4960 .browser_handles_all_top_level_requests) {
4960 OpenURL(url, IsHttpPost(info.urlRequest), 4961 OpenURL(url, IsHttpPost(info.urlRequest),
4961 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, 4962 GetRequestBodyForWebURLRequest(info.urlRequest),
4963 GetWebURLRequestHeadersForOpenURLParams(info.urlRequest), referrer,
4962 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 4964 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
4963 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 4965 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
4964 } 4966 }
4965 4967
4966 // In OOPIF-enabled modes, back/forward navigations in newly created subframes 4968 // In OOPIF-enabled modes, back/forward navigations in newly created subframes
4967 // should be sent to the browser in case there is a matching 4969 // should be sent to the browser in case there is a matching
4968 // FrameNavigationEntry. If none is found, fall back to the default url. 4970 // FrameNavigationEntry. If none is found, fall back to the default url.
4969 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && 4971 if (SiteIsolationPolicy::UseSubframeNavigationEntries() &&
4970 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { 4972 info.isHistoryNavigationInNewChildFrame && is_content_initiated) {
4971 // Don't do this if |info| also says it is a client redirect, in which case 4973 // Don't do this if |info| also says it is a client redirect, in which case
4972 // JavaScript on the page is trying to interrupt the history navigation. 4974 // JavaScript on the page is trying to interrupt the history navigation.
4973 if (!info.isClientRedirect) { 4975 if (!info.isClientRedirect) {
4974 OpenURL(url, IsHttpPost(info.urlRequest), 4976 OpenURL(url, IsHttpPost(info.urlRequest),
4975 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, 4977 GetRequestBodyForWebURLRequest(info.urlRequest),
4976 info.defaultPolicy, info.replacesCurrentHistoryItem, true); 4978 GetWebURLRequestHeadersForOpenURLParams(info.urlRequest),
4979 referrer, info.defaultPolicy, info.replacesCurrentHistoryItem,
4980 true);
4977 // Suppress the load in Blink but mark the frame as loading. 4981 // Suppress the load in Blink but mark the frame as loading.
4978 return blink::WebNavigationPolicyHandledByClient; 4982 return blink::WebNavigationPolicyHandledByClient;
4979 } else { 4983 } else {
4980 // Client redirects during an initial history load should attempt to 4984 // Client redirects during an initial history load should attempt to
4981 // cancel the history navigation. They will create a provisional document 4985 // cancel the history navigation. They will create a provisional document
4982 // loader, causing the history load to be ignored in NavigateInternal, and 4986 // loader, causing the history load to be ignored in NavigateInternal, and
4983 // this IPC will try to cancel any cross-process history load. 4987 // this IPC will try to cancel any cross-process history load.
4984 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); 4988 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_));
4985 } 4989 }
4986 } 4990 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5026 if (!should_fork) { 5030 if (!should_fork) {
5027 // Give the embedder a chance. 5031 // Give the embedder a chance.
5028 should_fork = GetContentClient()->renderer()->ShouldFork( 5032 should_fork = GetContentClient()->renderer()->ShouldFork(
5029 frame_, url, info.urlRequest.httpMethod().utf8(), 5033 frame_, url, info.urlRequest.httpMethod().utf8(),
5030 is_initial_navigation, is_redirect, &send_referrer); 5034 is_initial_navigation, is_redirect, &send_referrer);
5031 } 5035 }
5032 5036
5033 if (should_fork) { 5037 if (should_fork) {
5034 OpenURL(url, IsHttpPost(info.urlRequest), 5038 OpenURL(url, IsHttpPost(info.urlRequest),
5035 GetRequestBodyForWebURLRequest(info.urlRequest), 5039 GetRequestBodyForWebURLRequest(info.urlRequest),
5040 GetWebURLRequestHeadersForOpenURLParams(info.urlRequest),
5036 send_referrer ? referrer : Referrer(), info.defaultPolicy, 5041 send_referrer ? referrer : Referrer(), info.defaultPolicy,
5037 info.replacesCurrentHistoryItem, false); 5042 info.replacesCurrentHistoryItem, false);
5038 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 5043 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
5039 } 5044 }
5040 } 5045 }
5041 5046
5042 // Detect when a page is "forking" a new tab that can be safely rendered in 5047 // Detect when a page is "forking" a new tab that can be safely rendered in
5043 // its own process. This is done by sites like Gmail that try to open links 5048 // its own process. This is done by sites like Gmail that try to open links
5044 // in new windows without script connections back to the original page. We 5049 // in new windows without script connections back to the original page. We
5045 // treat such cases as browser navigations (in which we will create a new 5050 // treat such cases as browser navigations (in which we will create a new
(...skipping 21 matching lines...) Expand all
5067 // Must not have issued the request from this page. 5072 // Must not have issued the request from this page.
5068 is_content_initiated && 5073 is_content_initiated &&
5069 // Must be targeted at the current tab. 5074 // Must be targeted at the current tab.
5070 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5075 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5071 // Must be a JavaScript navigation, which appears as "other". 5076 // Must be a JavaScript navigation, which appears as "other".
5072 info.navigationType == blink::WebNavigationTypeOther; 5077 info.navigationType == blink::WebNavigationTypeOther;
5073 5078
5074 if (is_fork) { 5079 if (is_fork) {
5075 // Open the URL via the browser, not via WebKit. 5080 // Open the URL via the browser, not via WebKit.
5076 OpenURL(url, IsHttpPost(info.urlRequest), 5081 OpenURL(url, IsHttpPost(info.urlRequest),
5077 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), 5082 GetRequestBodyForWebURLRequest(info.urlRequest),
5078 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 5083 GetWebURLRequestHeadersForOpenURLParams(info.urlRequest),
5084 Referrer(), info.defaultPolicy, info.replacesCurrentHistoryItem,
5085 false);
5079 return blink::WebNavigationPolicyIgnore; 5086 return blink::WebNavigationPolicyIgnore;
5080 } 5087 }
5081 5088
5082 bool should_dispatch_before_unload = 5089 bool should_dispatch_before_unload =
5083 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5090 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5084 // There is no need to execute the BeforeUnload event during a redirect, 5091 // There is no need to execute the BeforeUnload event during a redirect,
5085 // since it was already executed at the start of the navigation. 5092 // since it was already executed at the start of the navigation.
5086 !is_redirect && 5093 !is_redirect &&
5087 // PlzNavigate: this should not be executed when commiting the navigation. 5094 // PlzNavigate: this should not be executed when commiting the navigation.
5088 (!IsBrowserSideNavigationEnabled() || 5095 (!IsBrowserSideNavigationEnabled() ||
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
5389 external_popup_menu_->DidSelectItems(canceled, selected_indices); 5396 external_popup_menu_->DidSelectItems(canceled, selected_indices);
5390 external_popup_menu_.reset(); 5397 external_popup_menu_.reset();
5391 } 5398 }
5392 #endif 5399 #endif
5393 #endif 5400 #endif
5394 5401
5395 void RenderFrameImpl::OpenURL( 5402 void RenderFrameImpl::OpenURL(
5396 const GURL& url, 5403 const GURL& url,
5397 bool uses_post, 5404 bool uses_post,
5398 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, 5405 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body,
5406 const std::string& extra_headers,
5399 const Referrer& referrer, 5407 const Referrer& referrer,
5400 WebNavigationPolicy policy, 5408 WebNavigationPolicy policy,
5401 bool should_replace_current_entry, 5409 bool should_replace_current_entry,
5402 bool is_history_navigation_in_new_child) { 5410 bool is_history_navigation_in_new_child) {
5403 FrameHostMsg_OpenURL_Params params; 5411 FrameHostMsg_OpenURL_Params params;
5404 params.url = url; 5412 params.url = url;
5405 params.uses_post = uses_post; 5413 params.uses_post = uses_post;
5406 params.resource_request_body = resource_request_body; 5414 params.resource_request_body = resource_request_body;
5415 params.extra_headers = extra_headers;
5407 params.referrer = referrer; 5416 params.referrer = referrer;
5408 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); 5417 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
5409 5418
5410 if (IsBrowserInitiated(pending_navigation_params_.get())) { 5419 if (IsBrowserInitiated(pending_navigation_params_.get())) {
5411 // This is necessary to preserve the should_replace_current_entry value on 5420 // This is necessary to preserve the should_replace_current_entry value on
5412 // cross-process redirects, in the event it was set by a previous process. 5421 // cross-process redirects, in the event it was set by a previous process.
5413 WebDataSource* ds = frame_->provisionalDataSource(); 5422 WebDataSource* ds = frame_->provisionalDataSource();
5414 DCHECK(ds); 5423 DCHECK(ds);
5415 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); 5424 params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
5416 } else { 5425 } else {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
5889 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == 5898 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) ==
5890 FetchRedirectMode::MANUAL_MODE); 5899 FetchRedirectMode::MANUAL_MODE);
5891 DCHECK(frame_->parent() || 5900 DCHECK(frame_->parent() ||
5892 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 5901 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
5893 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 5902 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
5894 DCHECK(!frame_->parent() || 5903 DCHECK(!frame_->parent() ||
5895 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 5904 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
5896 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 5905 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
5897 5906
5898 Send(new FrameHostMsg_BeginNavigation( 5907 Send(new FrameHostMsg_BeginNavigation(
5899 routing_id_, 5908 routing_id_, MakeCommonNavigationParams(info),
5900 MakeCommonNavigationParams(info),
5901 BeginNavigationParams( 5909 BeginNavigationParams(
5902 GetWebURLRequestHeaders(info.urlRequest), 5910 GetWebURLRequestHeadersForResourceRequest(info.urlRequest),
Łukasz Anforowicz 2016/09/22 21:23:17 The change above preserves the old behavior for Pl
Charlie Reis 2016/09/30 21:31:55 Acknowledged.
5903 GetLoadFlagsForWebURLRequest(info.urlRequest), 5911 GetLoadFlagsForWebURLRequest(info.urlRequest),
5904 info.urlRequest.hasUserGesture(), 5912 info.urlRequest.hasUserGesture(),
5905 info.urlRequest.skipServiceWorker() != 5913 info.urlRequest.skipServiceWorker() !=
5906 blink::WebURLRequest::SkipServiceWorker::None, 5914 blink::WebURLRequest::SkipServiceWorker::None,
5907 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); 5915 GetRequestContextTypeForWebURLRequest(info.urlRequest))));
5908 } 5916 }
5909 5917
5910 void RenderFrameImpl::LoadDataURL( 5918 void RenderFrameImpl::LoadDataURL(
5911 const CommonNavigationParams& params, 5919 const CommonNavigationParams& params,
5912 const RequestNavigationParams& request_params, 5920 const RequestNavigationParams& request_params,
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
6392 // event target. Potentially a Pepper plugin will receive the event. 6400 // event target. Potentially a Pepper plugin will receive the event.
6393 // In order to tell whether a plugin gets the last mouse event and which it 6401 // In order to tell whether a plugin gets the last mouse event and which it
6394 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6402 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6395 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6403 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6396 // |pepper_last_mouse_event_target_|. 6404 // |pepper_last_mouse_event_target_|.
6397 pepper_last_mouse_event_target_ = nullptr; 6405 pepper_last_mouse_event_target_ = nullptr;
6398 #endif 6406 #endif
6399 } 6407 }
6400 6408
6401 } // namespace content 6409 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698