OLD | NEW |
---|---|
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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 url::Origin(GURL(main_ds->request().url()))) || | 793 url::Origin(GURL(main_ds->request().url()))) || |
794 main_resource_ssl_status.security_style != | 794 main_resource_ssl_status.security_style != |
795 ssl_status.security_style || | 795 ssl_status.security_style || |
796 main_resource_ssl_status.cert_id != ssl_status.cert_id || | 796 main_resource_ssl_status.cert_id != ssl_status.cert_id || |
797 main_resource_ssl_status.cert_status != ssl_status.cert_status || | 797 main_resource_ssl_status.cert_status != ssl_status.cert_status || |
798 main_resource_ssl_status.security_bits != ssl_status.security_bits || | 798 main_resource_ssl_status.security_bits != ssl_status.security_bits || |
799 main_resource_ssl_status.connection_status != | 799 main_resource_ssl_status.connection_status != |
800 ssl_status.connection_status); | 800 ssl_status.connection_status); |
801 } | 801 } |
802 | 802 |
803 bool IsHttpPost(const blink::WebURLRequest& request) { | |
804 return request.httpMethod().utf8() == "POST"; | |
805 } | |
806 | |
803 #if defined(OS_ANDROID) | 807 #if defined(OS_ANDROID) |
804 // Returns true if WMPI should be used for playback, false otherwise. | 808 // Returns true if WMPI should be used for playback, false otherwise. |
805 // | 809 // |
806 // Note that HLS and MP4 detection are pre-redirect and path-based. It is | 810 // Note that HLS and MP4 detection are pre-redirect and path-based. It is |
807 // possible to load such a URL and find different content. | 811 // possible to load such a URL and find different content. |
808 bool UseWebMediaPlayerImpl(const GURL& url) { | 812 bool UseWebMediaPlayerImpl(const GURL& url) { |
809 // WMPI does not support HLS. | 813 // WMPI does not support HLS. |
810 if (media::MediaCodecUtil::IsHLSURL(url)) | 814 if (media::MediaCodecUtil::IsHLSURL(url)) |
811 return false; | 815 return false; |
812 | 816 |
(...skipping 2096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2909 blink::WebNavigationPolicy policy, | 2913 blink::WebNavigationPolicy policy, |
2910 const blink::WebString& suggested_name, | 2914 const blink::WebString& suggested_name, |
2911 bool should_replace_current_entry) { | 2915 bool should_replace_current_entry) { |
2912 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); | 2916 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); |
2913 if (policy == blink::WebNavigationPolicyDownload) { | 2917 if (policy == blink::WebNavigationPolicyDownload) { |
2914 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 2918 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
2915 GetRoutingID(), | 2919 GetRoutingID(), |
2916 request.url(), referrer, | 2920 request.url(), referrer, |
2917 suggested_name)); | 2921 suggested_name)); |
2918 } else { | 2922 } else { |
2919 OpenURL(request.url(), referrer, policy, should_replace_current_entry, | 2923 OpenURL(request.url(), IsHttpPost(request), |
2920 false); | 2924 GetRequestBodyForWebURLRequest(request), referrer, policy, |
2925 should_replace_current_entry, false); | |
2921 } | 2926 } |
2922 } | 2927 } |
2923 | 2928 |
2924 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { | 2929 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
2925 // OOPIF enabled modes will punt this navigation to the browser in | 2930 // OOPIF enabled modes will punt this navigation to the browser in |
2926 // decidePolicyForNavigation. | 2931 // decidePolicyForNavigation. |
2927 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2932 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
2928 return WebHistoryItem(); | 2933 return WebHistoryItem(); |
2929 | 2934 |
2930 return render_view_->history_controller()->GetItemForNewChildFrame(this); | 2935 return render_view_->history_controller()->GetItemForNewChildFrame(this); |
(...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4776 | 4781 |
4777 // Webkit is asking whether to navigate to a new URL. | 4782 // Webkit is asking whether to navigate to a new URL. |
4778 // This is fine normally, except if we're showing UI from one security | 4783 // This is fine normally, except if we're showing UI from one security |
4779 // context and they're trying to navigate to a different context. | 4784 // context and they're trying to navigate to a different context. |
4780 const GURL& url = info.urlRequest.url(); | 4785 const GURL& url = info.urlRequest.url(); |
4781 | 4786 |
4782 // If the browser is interested, then give it a chance to look at the request. | 4787 // If the browser is interested, then give it a chance to look at the request. |
4783 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 4788 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
4784 render_view_->renderer_preferences_ | 4789 render_view_->renderer_preferences_ |
4785 .browser_handles_all_top_level_requests) { | 4790 .browser_handles_all_top_level_requests) { |
4786 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, | 4791 OpenURL(url, IsHttpPost(info.urlRequest), |
4787 false); | 4792 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
4793 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | |
4788 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4794 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4789 } | 4795 } |
4790 | 4796 |
4791 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 4797 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
4792 // should be sent to the browser in case there is a matching | 4798 // should be sent to the browser in case there is a matching |
4793 // FrameNavigationEntry. If none is found, fall back to the default url. | 4799 // FrameNavigationEntry. If none is found, fall back to the default url. |
4794 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | 4800 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
4795 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { | 4801 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { |
4796 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, | 4802 OpenURL(url, IsHttpPost(info.urlRequest), |
4797 true); | 4803 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
4804 info.defaultPolicy, info.replacesCurrentHistoryItem, true); | |
4798 // Suppress the load in Blink but mark the frame as loading. | 4805 // Suppress the load in Blink but mark the frame as loading. |
4799 return blink::WebNavigationPolicyHandledByClient; | 4806 return blink::WebNavigationPolicyHandledByClient; |
4800 } | 4807 } |
4801 | 4808 |
4802 // Use the frame's original request's URL rather than the document's URL for | 4809 // Use the frame's original request's URL rather than the document's URL for |
4803 // subsequent checks. For a popup, the document's URL may become the opener | 4810 // subsequent checks. For a popup, the document's URL may become the opener |
4804 // window's URL if the opener has called document.write(). | 4811 // window's URL if the opener has called document.write(). |
4805 // See http://crbug.com/93517. | 4812 // See http://crbug.com/93517. |
4806 GURL old_url(frame_->dataSource()->request().url()); | 4813 GURL old_url(frame_->dataSource()->request().url()); |
4807 | 4814 |
4808 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 4815 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
4809 // an extension or app origin, leaving a WebUI page, etc). We only care about | 4816 // an extension or app origin, leaving a WebUI page, etc). We only care about |
4810 // top-level navigations (not iframes). But we sometimes navigate to | 4817 // top-level navigations (not iframes). But we sometimes navigate to |
4811 // about:blank to clear a tab, and we want to still allow that. | 4818 // about:blank to clear a tab, and we want to still allow that. |
4812 // | 4819 // |
4813 // Note: this is known to break POST submissions when crossing process | 4820 // Note: this is known to break POST submissions when crossing process |
4814 // boundaries until http://crbug.com/101395 is fixed. This is better for | 4821 // boundaries until http://crbug.com/101395 is fixed. This is better for |
4815 // security than loading a WebUI, extension or app page in the wrong process. | 4822 // security than loading a WebUI, extension or app page in the wrong process. |
4816 // POST requests don't work because this mechanism does not preserve form | 4823 // POST requests don't work because this mechanism does not preserve form |
4817 // POST data. We will need to send the request's httpBody data up to the | 4824 // POST data. We will need to send the request's httpBody data up to the |
4818 // browser process, and issue a special POST navigation in WebKit (via | 4825 // browser process, and issue a special POST navigation in WebKit (via |
4819 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl | 4826 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl |
4820 // for examples of how to send the httpBody data. | 4827 // for examples of how to send the httpBody data. |
Łukasz Anforowicz
2016/06/10 19:53:52
One extra change here (one that wasn't solicited b
Charlie Reis
2016/06/10 21:14:18
Good catch! That reminded me to do a search for 1
Charlie Reis
2016/06/16 22:27:40
SGTM.
| |
4821 if (!frame_->parent() && is_content_initiated && | 4828 if (!frame_->parent() && is_content_initiated && |
4822 !url.SchemeIs(url::kAboutScheme)) { | 4829 !url.SchemeIs(url::kAboutScheme)) { |
4823 bool send_referrer = false; | 4830 bool send_referrer = false; |
4824 | 4831 |
4825 // All navigations to or from WebUI URLs or within WebUI-enabled | 4832 // All navigations to or from WebUI URLs or within WebUI-enabled |
4826 // RenderProcesses must be handled by the browser process so that the | 4833 // RenderProcesses must be handled by the browser process so that the |
4827 // correct bindings and data sources can be registered. | 4834 // correct bindings and data sources can be registered. |
4828 // Similarly, navigations to view-source URLs or within ViewSource mode | 4835 // Similarly, navigations to view-source URLs or within ViewSource mode |
4829 // must be handled by the browser process (except for reloads - those are | 4836 // must be handled by the browser process (except for reloads - those are |
4830 // safe to leave within the renderer). | 4837 // safe to leave within the renderer). |
(...skipping 19 matching lines...) Expand all Loading... | |
4850 } | 4857 } |
4851 | 4858 |
4852 if (!should_fork) { | 4859 if (!should_fork) { |
4853 // Give the embedder a chance. | 4860 // Give the embedder a chance. |
4854 should_fork = GetContentClient()->renderer()->ShouldFork( | 4861 should_fork = GetContentClient()->renderer()->ShouldFork( |
4855 frame_, url, info.urlRequest.httpMethod().utf8(), | 4862 frame_, url, info.urlRequest.httpMethod().utf8(), |
4856 is_initial_navigation, is_redirect, &send_referrer); | 4863 is_initial_navigation, is_redirect, &send_referrer); |
4857 } | 4864 } |
4858 | 4865 |
4859 if (should_fork) { | 4866 if (should_fork) { |
4860 OpenURL(url, send_referrer ? referrer : Referrer(), info.defaultPolicy, | 4867 OpenURL(url, IsHttpPost(info.urlRequest), |
4868 GetRequestBodyForWebURLRequest(info.urlRequest), | |
4869 send_referrer ? referrer : Referrer(), info.defaultPolicy, | |
4861 info.replacesCurrentHistoryItem, false); | 4870 info.replacesCurrentHistoryItem, false); |
4862 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4871 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4863 } | 4872 } |
4864 } | 4873 } |
4865 | 4874 |
4866 // Detect when a page is "forking" a new tab that can be safely rendered in | 4875 // Detect when a page is "forking" a new tab that can be safely rendered in |
4867 // its own process. This is done by sites like Gmail that try to open links | 4876 // its own process. This is done by sites like Gmail that try to open links |
4868 // in new windows without script connections back to the original page. We | 4877 // in new windows without script connections back to the original page. We |
4869 // treat such cases as browser navigations (in which we will create a new | 4878 // treat such cases as browser navigations (in which we will create a new |
4870 // renderer for a cross-site navigation), rather than WebKit navigations. | 4879 // renderer for a cross-site navigation), rather than WebKit navigations. |
(...skipping 19 matching lines...) Expand all Loading... | |
4890 frame_->parent() == NULL && | 4899 frame_->parent() == NULL && |
4891 // Must not have issued the request from this page. | 4900 // Must not have issued the request from this page. |
4892 is_content_initiated && | 4901 is_content_initiated && |
4893 // Must be targeted at the current tab. | 4902 // Must be targeted at the current tab. |
4894 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 4903 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
4895 // Must be a JavaScript navigation, which appears as "other". | 4904 // Must be a JavaScript navigation, which appears as "other". |
4896 info.navigationType == blink::WebNavigationTypeOther; | 4905 info.navigationType == blink::WebNavigationTypeOther; |
4897 | 4906 |
4898 if (is_fork) { | 4907 if (is_fork) { |
4899 // Open the URL via the browser, not via WebKit. | 4908 // Open the URL via the browser, not via WebKit. |
4900 OpenURL(url, Referrer(), info.defaultPolicy, | 4909 OpenURL(url, IsHttpPost(info.urlRequest), |
4901 info.replacesCurrentHistoryItem, false); | 4910 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), |
4911 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | |
4902 return blink::WebNavigationPolicyIgnore; | 4912 return blink::WebNavigationPolicyIgnore; |
4903 } | 4913 } |
4904 | 4914 |
4905 // Execute the BeforeUnload event. If asked not to proceed or the frame is | 4915 // Execute the BeforeUnload event. If asked not to proceed or the frame is |
4906 // destroyed, ignore the navigation. There is no need to execute the | 4916 // destroyed, ignore the navigation. There is no need to execute the |
4907 // BeforeUnload event during a redirect, since it was already executed at the | 4917 // BeforeUnload event during a redirect, since it was already executed at the |
4908 // start of the navigation. | 4918 // start of the navigation. |
4909 // PlzNavigate: this is not executed when commiting the navigation. | 4919 // PlzNavigate: this is not executed when commiting the navigation. |
4910 if (info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 4920 if (info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
4911 !is_redirect && (!IsBrowserSideNavigationEnabled() || | 4921 !is_redirect && (!IsBrowserSideNavigationEnabled() || |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5257 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | 5267 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. |
5258 if (!external_popup_menu_) | 5268 if (!external_popup_menu_) |
5259 return; | 5269 return; |
5260 | 5270 |
5261 external_popup_menu_->DidSelectItems(canceled, selected_indices); | 5271 external_popup_menu_->DidSelectItems(canceled, selected_indices); |
5262 external_popup_menu_.reset(); | 5272 external_popup_menu_.reset(); |
5263 } | 5273 } |
5264 #endif | 5274 #endif |
5265 #endif | 5275 #endif |
5266 | 5276 |
5267 void RenderFrameImpl::OpenURL(const GURL& url, | 5277 void RenderFrameImpl::OpenURL( |
5268 const Referrer& referrer, | 5278 const GURL& url, |
5269 WebNavigationPolicy policy, | 5279 bool uses_post, |
5270 bool should_replace_current_entry, | 5280 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, |
5271 bool is_history_navigation_in_new_child) { | 5281 const Referrer& referrer, |
5282 WebNavigationPolicy policy, | |
5283 bool should_replace_current_entry, | |
5284 bool is_history_navigation_in_new_child) { | |
5272 FrameHostMsg_OpenURL_Params params; | 5285 FrameHostMsg_OpenURL_Params params; |
5273 params.url = url; | 5286 params.url = url; |
5287 params.uses_post = uses_post; | |
5288 params.resource_request_body = resource_request_body; | |
5274 params.referrer = referrer; | 5289 params.referrer = referrer; |
5275 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5290 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
5276 | 5291 |
5277 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5292 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
5278 // This is necessary to preserve the should_replace_current_entry value on | 5293 // This is necessary to preserve the should_replace_current_entry value on |
5279 // cross-process redirects, in the event it was set by a previous process. | 5294 // cross-process redirects, in the event it was set by a previous process. |
5280 WebDataSource* ds = frame_->provisionalDataSource(); | 5295 WebDataSource* ds = frame_->provisionalDataSource(); |
5281 DCHECK(ds); | 5296 DCHECK(ds); |
5282 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 5297 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
5283 } else { | 5298 } else { |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6166 // event target. Potentially a Pepper plugin will receive the event. | 6181 // event target. Potentially a Pepper plugin will receive the event. |
6167 // In order to tell whether a plugin gets the last mouse event and which it | 6182 // In order to tell whether a plugin gets the last mouse event and which it |
6168 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6183 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6169 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6184 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6170 // |pepper_last_mouse_event_target_|. | 6185 // |pepper_last_mouse_event_target_|. |
6171 pepper_last_mouse_event_target_ = nullptr; | 6186 pepper_last_mouse_event_target_ = nullptr; |
6172 #endif | 6187 #endif |
6173 } | 6188 } |
6174 | 6189 |
6175 } // namespace content | 6190 } // namespace content |
OLD | NEW |