Chromium Code Reviews| 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, |
|
dcheng
2016/06/12 05:29:00
Two questions:
1) Is there another CL that changes
Łukasz Anforowicz
2016/06/13 18:26:23
There is no pending CL related to the current one
| |
| 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 // | |
| 4813 // Note: this is known to break POST submissions when crossing process | |
| 4814 // 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. | |
| 4816 // 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 | |
| 4818 // browser process, and issue a special POST navigation in WebKit (via | |
| 4819 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl | |
| 4820 // for examples of how to send the httpBody data. | |
| 4821 if (!frame_->parent() && is_content_initiated && | 4819 if (!frame_->parent() && is_content_initiated && |
| 4822 !url.SchemeIs(url::kAboutScheme)) { | 4820 !url.SchemeIs(url::kAboutScheme)) { |
| 4823 bool send_referrer = false; | 4821 bool send_referrer = false; |
| 4824 | 4822 |
| 4825 // All navigations to or from WebUI URLs or within WebUI-enabled | 4823 // All navigations to or from WebUI URLs or within WebUI-enabled |
| 4826 // RenderProcesses must be handled by the browser process so that the | 4824 // RenderProcesses must be handled by the browser process so that the |
| 4827 // correct bindings and data sources can be registered. | 4825 // correct bindings and data sources can be registered. |
| 4828 // Similarly, navigations to view-source URLs or within ViewSource mode | 4826 // Similarly, navigations to view-source URLs or within ViewSource mode |
| 4829 // must be handled by the browser process (except for reloads - those are | 4827 // must be handled by the browser process (except for reloads - those are |
| 4830 // safe to leave within the renderer). | 4828 // safe to leave within the renderer). |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 4850 } | 4848 } |
| 4851 | 4849 |
| 4852 if (!should_fork) { | 4850 if (!should_fork) { |
| 4853 // Give the embedder a chance. | 4851 // Give the embedder a chance. |
| 4854 should_fork = GetContentClient()->renderer()->ShouldFork( | 4852 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 4855 frame_, url, info.urlRequest.httpMethod().utf8(), | 4853 frame_, url, info.urlRequest.httpMethod().utf8(), |
| 4856 is_initial_navigation, is_redirect, &send_referrer); | 4854 is_initial_navigation, is_redirect, &send_referrer); |
| 4857 } | 4855 } |
| 4858 | 4856 |
| 4859 if (should_fork) { | 4857 if (should_fork) { |
| 4860 OpenURL(url, send_referrer ? referrer : Referrer(), info.defaultPolicy, | 4858 OpenURL(url, IsHttpPost(info.urlRequest), |
| 4859 GetRequestBodyForWebURLRequest(info.urlRequest), | |
| 4860 send_referrer ? referrer : Referrer(), info.defaultPolicy, | |
| 4861 info.replacesCurrentHistoryItem, false); | 4861 info.replacesCurrentHistoryItem, false); |
| 4862 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4862 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 4863 } | 4863 } |
| 4864 } | 4864 } |
| 4865 | 4865 |
| 4866 // Detect when a page is "forking" a new tab that can be safely rendered in | 4866 // 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 | 4867 // 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 | 4868 // 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 | 4869 // treat such cases as browser navigations (in which we will create a new |
| 4870 // renderer for a cross-site navigation), rather than WebKit navigations. | 4870 // renderer for a cross-site navigation), rather than WebKit navigations. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 4890 frame_->parent() == NULL && | 4890 frame_->parent() == NULL && |
| 4891 // Must not have issued the request from this page. | 4891 // Must not have issued the request from this page. |
| 4892 is_content_initiated && | 4892 is_content_initiated && |
| 4893 // Must be targeted at the current tab. | 4893 // Must be targeted at the current tab. |
| 4894 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 4894 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 4895 // Must be a JavaScript navigation, which appears as "other". | 4895 // Must be a JavaScript navigation, which appears as "other". |
| 4896 info.navigationType == blink::WebNavigationTypeOther; | 4896 info.navigationType == blink::WebNavigationTypeOther; |
| 4897 | 4897 |
| 4898 if (is_fork) { | 4898 if (is_fork) { |
| 4899 // Open the URL via the browser, not via WebKit. | 4899 // Open the URL via the browser, not via WebKit. |
| 4900 OpenURL(url, Referrer(), info.defaultPolicy, | 4900 OpenURL(url, IsHttpPost(info.urlRequest), |
| 4901 info.replacesCurrentHistoryItem, false); | 4901 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), |
| 4902 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | |
| 4902 return blink::WebNavigationPolicyIgnore; | 4903 return blink::WebNavigationPolicyIgnore; |
| 4903 } | 4904 } |
| 4904 | 4905 |
| 4905 // Execute the BeforeUnload event. If asked not to proceed or the frame is | 4906 // 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 | 4907 // destroyed, ignore the navigation. There is no need to execute the |
| 4907 // BeforeUnload event during a redirect, since it was already executed at the | 4908 // BeforeUnload event during a redirect, since it was already executed at the |
| 4908 // start of the navigation. | 4909 // start of the navigation. |
| 4909 // PlzNavigate: this is not executed when commiting the navigation. | 4910 // PlzNavigate: this is not executed when commiting the navigation. |
| 4910 if (info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 4911 if (info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 4911 !is_redirect && (!IsBrowserSideNavigationEnabled() || | 4912 !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. | 5258 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. |
| 5258 if (!external_popup_menu_) | 5259 if (!external_popup_menu_) |
| 5259 return; | 5260 return; |
| 5260 | 5261 |
| 5261 external_popup_menu_->DidSelectItems(canceled, selected_indices); | 5262 external_popup_menu_->DidSelectItems(canceled, selected_indices); |
| 5262 external_popup_menu_.reset(); | 5263 external_popup_menu_.reset(); |
| 5263 } | 5264 } |
| 5264 #endif | 5265 #endif |
| 5265 #endif | 5266 #endif |
| 5266 | 5267 |
| 5267 void RenderFrameImpl::OpenURL(const GURL& url, | 5268 void RenderFrameImpl::OpenURL( |
| 5268 const Referrer& referrer, | 5269 const GURL& url, |
| 5269 WebNavigationPolicy policy, | 5270 bool uses_post, |
| 5270 bool should_replace_current_entry, | 5271 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, |
| 5271 bool is_history_navigation_in_new_child) { | 5272 const Referrer& referrer, |
| 5273 WebNavigationPolicy policy, | |
| 5274 bool should_replace_current_entry, | |
| 5275 bool is_history_navigation_in_new_child) { | |
| 5272 FrameHostMsg_OpenURL_Params params; | 5276 FrameHostMsg_OpenURL_Params params; |
| 5273 params.url = url; | 5277 params.url = url; |
| 5278 params.uses_post = uses_post; | |
| 5279 params.resource_request_body = resource_request_body; | |
| 5274 params.referrer = referrer; | 5280 params.referrer = referrer; |
| 5275 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5281 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
| 5276 | 5282 |
| 5277 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5283 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
| 5278 // This is necessary to preserve the should_replace_current_entry value on | 5284 // 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. | 5285 // cross-process redirects, in the event it was set by a previous process. |
| 5280 WebDataSource* ds = frame_->provisionalDataSource(); | 5286 WebDataSource* ds = frame_->provisionalDataSource(); |
| 5281 DCHECK(ds); | 5287 DCHECK(ds); |
| 5282 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 5288 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
| 5283 } else { | 5289 } 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. | 6172 // 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 | 6173 // 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 | 6174 // 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 | 6175 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6170 // |pepper_last_mouse_event_target_|. | 6176 // |pepper_last_mouse_event_target_|. |
| 6171 pepper_last_mouse_event_target_ = nullptr; | 6177 pepper_last_mouse_event_target_ = nullptr; |
| 6172 #endif | 6178 #endif |
| 6173 } | 6179 } |
| 6174 | 6180 |
| 6175 } // namespace content | 6181 } // namespace content |
| OLD | NEW |