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

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

Issue 2004653002: OpenURL post data handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@post-data-my-stuff
Patch Set: Rebasing... Created 4 years, 6 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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 url::Origin(GURL(main_ds->request().url()))) || 801 url::Origin(GURL(main_ds->request().url()))) ||
802 main_resource_ssl_status.security_style != 802 main_resource_ssl_status.security_style !=
803 ssl_status.security_style || 803 ssl_status.security_style ||
804 main_resource_ssl_status.cert_id != ssl_status.cert_id || 804 main_resource_ssl_status.cert_id != ssl_status.cert_id ||
805 main_resource_ssl_status.cert_status != ssl_status.cert_status || 805 main_resource_ssl_status.cert_status != ssl_status.cert_status ||
806 main_resource_ssl_status.security_bits != ssl_status.security_bits || 806 main_resource_ssl_status.security_bits != ssl_status.security_bits ||
807 main_resource_ssl_status.connection_status != 807 main_resource_ssl_status.connection_status !=
808 ssl_status.connection_status); 808 ssl_status.connection_status);
809 } 809 }
810 810
811 bool IsHttpPost(const blink::WebURLRequest& request) {
812 return request.httpMethod().utf8() == "POST";
813 }
814
811 #if defined(OS_ANDROID) 815 #if defined(OS_ANDROID)
812 // Returns true if WMPI should be used for playback, false otherwise. 816 // Returns true if WMPI should be used for playback, false otherwise.
813 // 817 //
814 // Note that HLS and MP4 detection are pre-redirect and path-based. It is 818 // Note that HLS and MP4 detection are pre-redirect and path-based. It is
815 // possible to load such a URL and find different content. 819 // possible to load such a URL and find different content.
816 bool UseWebMediaPlayerImpl(const GURL& url) { 820 bool UseWebMediaPlayerImpl(const GURL& url) {
817 // WMPI does not support HLS. 821 // WMPI does not support HLS.
818 if (media::MediaCodecUtil::IsHLSURL(url)) 822 if (media::MediaCodecUtil::IsHLSURL(url))
819 return false; 823 return false;
820 824
(...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2980 blink::WebNavigationPolicy policy, 2984 blink::WebNavigationPolicy policy,
2981 const blink::WebString& suggested_name, 2985 const blink::WebString& suggested_name,
2982 bool should_replace_current_entry) { 2986 bool should_replace_current_entry) {
2983 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); 2987 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request));
2984 if (policy == blink::WebNavigationPolicyDownload) { 2988 if (policy == blink::WebNavigationPolicyDownload) {
2985 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 2989 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
2986 GetRoutingID(), 2990 GetRoutingID(),
2987 request.url(), referrer, 2991 request.url(), referrer,
2988 suggested_name)); 2992 suggested_name));
2989 } else { 2993 } else {
2990 OpenURL(request.url(), referrer, policy, should_replace_current_entry, 2994 OpenURL(request.url(), IsHttpPost(request),
2991 false); 2995 GetRequestBodyForWebURLRequest(request), referrer, policy,
2996 should_replace_current_entry, false);
2992 } 2997 }
2993 } 2998 }
2994 2999
2995 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { 3000 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() {
2996 // OOPIF enabled modes will punt this navigation to the browser in 3001 // OOPIF enabled modes will punt this navigation to the browser in
2997 // decidePolicyForNavigation. 3002 // decidePolicyForNavigation.
2998 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3003 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
2999 return WebHistoryItem(); 3004 return WebHistoryItem();
3000 3005
3001 return render_view_->history_controller()->GetItemForNewChildFrame(this); 3006 return render_view_->history_controller()->GetItemForNewChildFrame(this);
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
4881 4886
4882 // Webkit is asking whether to navigate to a new URL. 4887 // Webkit is asking whether to navigate to a new URL.
4883 // This is fine normally, except if we're showing UI from one security 4888 // This is fine normally, except if we're showing UI from one security
4884 // context and they're trying to navigate to a different context. 4889 // context and they're trying to navigate to a different context.
4885 const GURL& url = info.urlRequest.url(); 4890 const GURL& url = info.urlRequest.url();
4886 4891
4887 // If the browser is interested, then give it a chance to look at the request. 4892 // If the browser is interested, then give it a chance to look at the request.
4888 if (is_content_initiated && IsTopLevelNavigation(frame_) && 4893 if (is_content_initiated && IsTopLevelNavigation(frame_) &&
4889 render_view_->renderer_preferences_ 4894 render_view_->renderer_preferences_
4890 .browser_handles_all_top_level_requests) { 4895 .browser_handles_all_top_level_requests) {
4891 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, 4896 OpenURL(url, IsHttpPost(info.urlRequest),
4892 false); 4897 GetRequestBodyForWebURLRequest(info.urlRequest), referrer,
4898 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
4893 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 4899 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
4894 } 4900 }
4895 4901
4896 // In OOPIF-enabled modes, back/forward navigations in newly created subframes 4902 // In OOPIF-enabled modes, back/forward navigations in newly created subframes
4897 // should be sent to the browser in case there is a matching 4903 // should be sent to the browser in case there is a matching
4898 // FrameNavigationEntry. If none is found, fall back to the default url. 4904 // FrameNavigationEntry. If none is found, fall back to the default url.
4899 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && 4905 if (SiteIsolationPolicy::UseSubframeNavigationEntries() &&
4900 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { 4906 info.isHistoryNavigationInNewChildFrame && is_content_initiated) {
4901 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, 4907 OpenURL(url, IsHttpPost(info.urlRequest),
4902 true); 4908 GetRequestBodyForWebURLRequest(info.urlRequest), referrer,
4909 info.defaultPolicy, info.replacesCurrentHistoryItem, true);
4903 // Suppress the load in Blink but mark the frame as loading. 4910 // Suppress the load in Blink but mark the frame as loading.
4904 return blink::WebNavigationPolicyHandledByClient; 4911 return blink::WebNavigationPolicyHandledByClient;
4905 } 4912 }
4906 4913
4907 // Use the frame's original request's URL rather than the document's URL for 4914 // Use the frame's original request's URL rather than the document's URL for
4908 // subsequent checks. For a popup, the document's URL may become the opener 4915 // subsequent checks. For a popup, the document's URL may become the opener
4909 // window's URL if the opener has called document.write(). 4916 // window's URL if the opener has called document.write().
4910 // See http://crbug.com/93517. 4917 // See http://crbug.com/93517.
4911 GURL old_url(frame_->dataSource()->request().url()); 4918 GURL old_url(frame_->dataSource()->request().url());
4912 4919
4913 // Detect when we're crossing a permission-based boundary (e.g. into or out of 4920 // Detect when we're crossing a permission-based boundary (e.g. into or out of
4914 // an extension or app origin, leaving a WebUI page, etc). We only care about 4921 // an extension or app origin, leaving a WebUI page, etc). We only care about
4915 // top-level navigations (not iframes). But we sometimes navigate to 4922 // top-level navigations (not iframes). But we sometimes navigate to
4916 // about:blank to clear a tab, and we want to still allow that. 4923 // about:blank to clear a tab, and we want to still allow that.
4917 //
4918 // Note: this is known to break POST submissions when crossing process
4919 // boundaries until http://crbug.com/101395 is fixed. This is better for
4920 // security than loading a WebUI, extension or app page in the wrong process.
4921 // POST requests don't work because this mechanism does not preserve form
4922 // POST data. We will need to send the request's httpBody data up to the
4923 // browser process, and issue a special POST navigation in WebKit (via
4924 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl
4925 // for examples of how to send the httpBody data.
4926 if (!frame_->parent() && is_content_initiated && 4924 if (!frame_->parent() && is_content_initiated &&
4927 !url.SchemeIs(url::kAboutScheme)) { 4925 !url.SchemeIs(url::kAboutScheme)) {
4928 bool send_referrer = false; 4926 bool send_referrer = false;
4929 4927
4930 // All navigations to or from WebUI URLs or within WebUI-enabled 4928 // All navigations to or from WebUI URLs or within WebUI-enabled
4931 // RenderProcesses must be handled by the browser process so that the 4929 // RenderProcesses must be handled by the browser process so that the
4932 // correct bindings and data sources can be registered. 4930 // correct bindings and data sources can be registered.
4933 // Similarly, navigations to view-source URLs or within ViewSource mode 4931 // Similarly, navigations to view-source URLs or within ViewSource mode
4934 // must be handled by the browser process (except for reloads - those are 4932 // must be handled by the browser process (except for reloads - those are
4935 // safe to leave within the renderer). 4933 // safe to leave within the renderer).
(...skipping 19 matching lines...) Expand all
4955 } 4953 }
4956 4954
4957 if (!should_fork) { 4955 if (!should_fork) {
4958 // Give the embedder a chance. 4956 // Give the embedder a chance.
4959 should_fork = GetContentClient()->renderer()->ShouldFork( 4957 should_fork = GetContentClient()->renderer()->ShouldFork(
4960 frame_, url, info.urlRequest.httpMethod().utf8(), 4958 frame_, url, info.urlRequest.httpMethod().utf8(),
4961 is_initial_navigation, is_redirect, &send_referrer); 4959 is_initial_navigation, is_redirect, &send_referrer);
4962 } 4960 }
4963 4961
4964 if (should_fork) { 4962 if (should_fork) {
4965 OpenURL(url, send_referrer ? referrer : Referrer(), info.defaultPolicy, 4963 OpenURL(url, IsHttpPost(info.urlRequest),
4964 GetRequestBodyForWebURLRequest(info.urlRequest),
4965 send_referrer ? referrer : Referrer(), info.defaultPolicy,
4966 info.replacesCurrentHistoryItem, false); 4966 info.replacesCurrentHistoryItem, false);
4967 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 4967 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
4968 } 4968 }
4969 } 4969 }
4970 4970
4971 // Detect when a page is "forking" a new tab that can be safely rendered in 4971 // Detect when a page is "forking" a new tab that can be safely rendered in
4972 // its own process. This is done by sites like Gmail that try to open links 4972 // its own process. This is done by sites like Gmail that try to open links
4973 // in new windows without script connections back to the original page. We 4973 // in new windows without script connections back to the original page. We
4974 // treat such cases as browser navigations (in which we will create a new 4974 // treat such cases as browser navigations (in which we will create a new
4975 // renderer for a cross-site navigation), rather than WebKit navigations. 4975 // renderer for a cross-site navigation), rather than WebKit navigations.
(...skipping 19 matching lines...) Expand all
4995 frame_->parent() == NULL && 4995 frame_->parent() == NULL &&
4996 // Must not have issued the request from this page. 4996 // Must not have issued the request from this page.
4997 is_content_initiated && 4997 is_content_initiated &&
4998 // Must be targeted at the current tab. 4998 // Must be targeted at the current tab.
4999 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 4999 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5000 // Must be a JavaScript navigation, which appears as "other". 5000 // Must be a JavaScript navigation, which appears as "other".
5001 info.navigationType == blink::WebNavigationTypeOther; 5001 info.navigationType == blink::WebNavigationTypeOther;
5002 5002
5003 if (is_fork) { 5003 if (is_fork) {
5004 // Open the URL via the browser, not via WebKit. 5004 // Open the URL via the browser, not via WebKit.
5005 OpenURL(url, Referrer(), info.defaultPolicy, 5005 OpenURL(url, IsHttpPost(info.urlRequest),
5006 info.replacesCurrentHistoryItem, false); 5006 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(),
5007 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
5007 return blink::WebNavigationPolicyIgnore; 5008 return blink::WebNavigationPolicyIgnore;
5008 } 5009 }
5009 5010
5010 // Execute the BeforeUnload event. If asked not to proceed or the frame is 5011 // Execute the BeforeUnload event. If asked not to proceed or the frame is
5011 // destroyed, ignore the navigation. There is no need to execute the 5012 // destroyed, ignore the navigation. There is no need to execute the
5012 // BeforeUnload event during a redirect, since it was already executed at the 5013 // BeforeUnload event during a redirect, since it was already executed at the
5013 // start of the navigation. 5014 // start of the navigation.
5014 // PlzNavigate: this is not executed when commiting the navigation. 5015 // PlzNavigate: this is not executed when commiting the navigation.
5015 if (info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && 5016 if (info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
5016 !is_redirect && (!IsBrowserSideNavigationEnabled() || 5017 !is_redirect && (!IsBrowserSideNavigationEnabled() ||
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
5326 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. 5327 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug.
5327 if (!external_popup_menu_) 5328 if (!external_popup_menu_)
5328 return; 5329 return;
5329 5330
5330 external_popup_menu_->DidSelectItems(canceled, selected_indices); 5331 external_popup_menu_->DidSelectItems(canceled, selected_indices);
5331 external_popup_menu_.reset(); 5332 external_popup_menu_.reset();
5332 } 5333 }
5333 #endif 5334 #endif
5334 #endif 5335 #endif
5335 5336
5336 void RenderFrameImpl::OpenURL(const GURL& url, 5337 void RenderFrameImpl::OpenURL(
5337 const Referrer& referrer, 5338 const GURL& url,
5338 WebNavigationPolicy policy, 5339 bool uses_post,
5339 bool should_replace_current_entry, 5340 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body,
5340 bool is_history_navigation_in_new_child) { 5341 const Referrer& referrer,
5342 WebNavigationPolicy policy,
5343 bool should_replace_current_entry,
5344 bool is_history_navigation_in_new_child) {
5341 FrameHostMsg_OpenURL_Params params; 5345 FrameHostMsg_OpenURL_Params params;
5342 params.url = url; 5346 params.url = url;
5347 params.uses_post = uses_post;
5348 params.resource_request_body = resource_request_body;
5343 params.referrer = referrer; 5349 params.referrer = referrer;
5344 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); 5350 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
5345 5351
5346 if (IsBrowserInitiated(pending_navigation_params_.get())) { 5352 if (IsBrowserInitiated(pending_navigation_params_.get())) {
5347 // This is necessary to preserve the should_replace_current_entry value on 5353 // This is necessary to preserve the should_replace_current_entry value on
5348 // cross-process redirects, in the event it was set by a previous process. 5354 // cross-process redirects, in the event it was set by a previous process.
5349 WebDataSource* ds = frame_->provisionalDataSource(); 5355 WebDataSource* ds = frame_->provisionalDataSource();
5350 DCHECK(ds); 5356 DCHECK(ds);
5351 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); 5357 params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
5352 } else { 5358 } else {
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
6238 // event target. Potentially a Pepper plugin will receive the event. 6244 // event target. Potentially a Pepper plugin will receive the event.
6239 // In order to tell whether a plugin gets the last mouse event and which it 6245 // In order to tell whether a plugin gets the last mouse event and which it
6240 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6246 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6241 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6247 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6242 // |pepper_last_mouse_event_target_|. 6248 // |pepper_last_mouse_event_target_|.
6243 pepper_last_mouse_event_target_ = nullptr; 6249 pepper_last_mouse_event_target_ = nullptr;
6244 #endif 6250 #endif
6245 } 6251 }
6246 6252
6247 } // namespace content 6253 } // 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