| 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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4878 | 4883 |
| 4879 // Webkit is asking whether to navigate to a new URL. | 4884 // Webkit is asking whether to navigate to a new URL. |
| 4880 // This is fine normally, except if we're showing UI from one security | 4885 // This is fine normally, except if we're showing UI from one security |
| 4881 // context and they're trying to navigate to a different context. | 4886 // context and they're trying to navigate to a different context. |
| 4882 const GURL& url = info.urlRequest.url(); | 4887 const GURL& url = info.urlRequest.url(); |
| 4883 | 4888 |
| 4884 // If the browser is interested, then give it a chance to look at the request. | 4889 // If the browser is interested, then give it a chance to look at the request. |
| 4885 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 4890 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
| 4886 render_view_->renderer_preferences_ | 4891 render_view_->renderer_preferences_ |
| 4887 .browser_handles_all_top_level_requests) { | 4892 .browser_handles_all_top_level_requests) { |
| 4888 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, | 4893 OpenURL(url, IsHttpPost(info.urlRequest), |
| 4889 false); | 4894 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
| 4895 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 4890 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4896 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 4891 } | 4897 } |
| 4892 | 4898 |
| 4893 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 4899 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
| 4894 // should be sent to the browser in case there is a matching | 4900 // should be sent to the browser in case there is a matching |
| 4895 // FrameNavigationEntry. If none is found, fall back to the default url. | 4901 // FrameNavigationEntry. If none is found, fall back to the default url. |
| 4896 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | 4902 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
| 4897 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { | 4903 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { |
| 4898 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, | 4904 OpenURL(url, IsHttpPost(info.urlRequest), |
| 4899 true); | 4905 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
| 4906 info.defaultPolicy, info.replacesCurrentHistoryItem, true); |
| 4900 // Suppress the load in Blink but mark the frame as loading. | 4907 // Suppress the load in Blink but mark the frame as loading. |
| 4901 return blink::WebNavigationPolicyHandledByClient; | 4908 return blink::WebNavigationPolicyHandledByClient; |
| 4902 } | 4909 } |
| 4903 | 4910 |
| 4904 // Use the frame's original request's URL rather than the document's URL for | 4911 // Use the frame's original request's URL rather than the document's URL for |
| 4905 // subsequent checks. For a popup, the document's URL may become the opener | 4912 // subsequent checks. For a popup, the document's URL may become the opener |
| 4906 // window's URL if the opener has called document.write(). | 4913 // window's URL if the opener has called document.write(). |
| 4907 // See http://crbug.com/93517. | 4914 // See http://crbug.com/93517. |
| 4908 GURL old_url(frame_->dataSource()->request().url()); | 4915 GURL old_url(frame_->dataSource()->request().url()); |
| 4909 | 4916 |
| 4910 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 4917 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
| 4911 // an extension or app origin, leaving a WebUI page, etc). We only care about | 4918 // an extension or app origin, leaving a WebUI page, etc). We only care about |
| 4912 // top-level navigations (not iframes). But we sometimes navigate to | 4919 // top-level navigations (not iframes). But we sometimes navigate to |
| 4913 // about:blank to clear a tab, and we want to still allow that. | 4920 // about:blank to clear a tab, and we want to still allow that. |
| 4914 // | |
| 4915 // Note: this is known to break POST submissions when crossing process | |
| 4916 // boundaries until http://crbug.com/101395 is fixed. This is better for | |
| 4917 // security than loading a WebUI, extension or app page in the wrong process. | |
| 4918 // POST requests don't work because this mechanism does not preserve form | |
| 4919 // POST data. We will need to send the request's httpBody data up to the | |
| 4920 // browser process, and issue a special POST navigation in WebKit (via | |
| 4921 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl | |
| 4922 // for examples of how to send the httpBody data. | |
| 4923 if (!frame_->parent() && is_content_initiated && | 4921 if (!frame_->parent() && is_content_initiated && |
| 4924 !url.SchemeIs(url::kAboutScheme)) { | 4922 !url.SchemeIs(url::kAboutScheme)) { |
| 4925 bool send_referrer = false; | 4923 bool send_referrer = false; |
| 4926 | 4924 |
| 4927 // All navigations to or from WebUI URLs or within WebUI-enabled | 4925 // All navigations to or from WebUI URLs or within WebUI-enabled |
| 4928 // RenderProcesses must be handled by the browser process so that the | 4926 // RenderProcesses must be handled by the browser process so that the |
| 4929 // correct bindings and data sources can be registered. | 4927 // correct bindings and data sources can be registered. |
| 4930 // Similarly, navigations to view-source URLs or within ViewSource mode | 4928 // Similarly, navigations to view-source URLs or within ViewSource mode |
| 4931 // must be handled by the browser process (except for reloads - those are | 4929 // must be handled by the browser process (except for reloads - those are |
| 4932 // safe to leave within the renderer). | 4930 // safe to leave within the renderer). |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4952 } | 4950 } |
| 4953 | 4951 |
| 4954 if (!should_fork) { | 4952 if (!should_fork) { |
| 4955 // Give the embedder a chance. | 4953 // Give the embedder a chance. |
| 4956 should_fork = GetContentClient()->renderer()->ShouldFork( | 4954 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 4957 frame_, url, info.urlRequest.httpMethod().utf8(), | 4955 frame_, url, info.urlRequest.httpMethod().utf8(), |
| 4958 is_initial_navigation, is_redirect, &send_referrer); | 4956 is_initial_navigation, is_redirect, &send_referrer); |
| 4959 } | 4957 } |
| 4960 | 4958 |
| 4961 if (should_fork) { | 4959 if (should_fork) { |
| 4962 OpenURL(url, send_referrer ? referrer : Referrer(), info.defaultPolicy, | 4960 OpenURL(url, IsHttpPost(info.urlRequest), |
| 4961 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 4962 send_referrer ? referrer : Referrer(), info.defaultPolicy, |
| 4963 info.replacesCurrentHistoryItem, false); | 4963 info.replacesCurrentHistoryItem, false); |
| 4964 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4964 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 4965 } | 4965 } |
| 4966 } | 4966 } |
| 4967 | 4967 |
| 4968 // Detect when a page is "forking" a new tab that can be safely rendered in | 4968 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 4969 // its own process. This is done by sites like Gmail that try to open links | 4969 // its own process. This is done by sites like Gmail that try to open links |
| 4970 // in new windows without script connections back to the original page. We | 4970 // in new windows without script connections back to the original page. We |
| 4971 // treat such cases as browser navigations (in which we will create a new | 4971 // treat such cases as browser navigations (in which we will create a new |
| 4972 // renderer for a cross-site navigation), rather than WebKit navigations. | 4972 // renderer for a cross-site navigation), rather than WebKit navigations. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4992 frame_->parent() == NULL && | 4992 frame_->parent() == NULL && |
| 4993 // Must not have issued the request from this page. | 4993 // Must not have issued the request from this page. |
| 4994 is_content_initiated && | 4994 is_content_initiated && |
| 4995 // Must be targeted at the current tab. | 4995 // Must be targeted at the current tab. |
| 4996 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 4996 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 4997 // Must be a JavaScript navigation, which appears as "other". | 4997 // Must be a JavaScript navigation, which appears as "other". |
| 4998 info.navigationType == blink::WebNavigationTypeOther; | 4998 info.navigationType == blink::WebNavigationTypeOther; |
| 4999 | 4999 |
| 5000 if (is_fork) { | 5000 if (is_fork) { |
| 5001 // Open the URL via the browser, not via WebKit. | 5001 // Open the URL via the browser, not via WebKit. |
| 5002 OpenURL(url, Referrer(), info.defaultPolicy, | 5002 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5003 info.replacesCurrentHistoryItem, false); | 5003 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), |
| 5004 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 5004 return blink::WebNavigationPolicyIgnore; | 5005 return blink::WebNavigationPolicyIgnore; |
| 5005 } | 5006 } |
| 5006 | 5007 |
| 5007 // Execute the BeforeUnload event. If asked not to proceed or the frame is | 5008 // Execute the BeforeUnload event. If asked not to proceed or the frame is |
| 5008 // destroyed, ignore the navigation. There is no need to execute the | 5009 // destroyed, ignore the navigation. There is no need to execute the |
| 5009 // BeforeUnload event during a redirect, since it was already executed at the | 5010 // BeforeUnload event during a redirect, since it was already executed at the |
| 5010 // start of the navigation. | 5011 // start of the navigation. |
| 5011 // PlzNavigate: this is not executed when commiting the navigation. | 5012 // PlzNavigate: this is not executed when commiting the navigation. |
| 5012 if (info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5013 if (info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5013 !is_redirect && (!IsBrowserSideNavigationEnabled() || | 5014 !is_redirect && (!IsBrowserSideNavigationEnabled() || |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5323 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | 5324 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. |
| 5324 if (!external_popup_menu_) | 5325 if (!external_popup_menu_) |
| 5325 return; | 5326 return; |
| 5326 | 5327 |
| 5327 external_popup_menu_->DidSelectItems(canceled, selected_indices); | 5328 external_popup_menu_->DidSelectItems(canceled, selected_indices); |
| 5328 external_popup_menu_.reset(); | 5329 external_popup_menu_.reset(); |
| 5329 } | 5330 } |
| 5330 #endif | 5331 #endif |
| 5331 #endif | 5332 #endif |
| 5332 | 5333 |
| 5333 void RenderFrameImpl::OpenURL(const GURL& url, | 5334 void RenderFrameImpl::OpenURL( |
| 5334 const Referrer& referrer, | 5335 const GURL& url, |
| 5335 WebNavigationPolicy policy, | 5336 bool uses_post, |
| 5336 bool should_replace_current_entry, | 5337 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, |
| 5337 bool is_history_navigation_in_new_child) { | 5338 const Referrer& referrer, |
| 5339 WebNavigationPolicy policy, |
| 5340 bool should_replace_current_entry, |
| 5341 bool is_history_navigation_in_new_child) { |
| 5338 FrameHostMsg_OpenURL_Params params; | 5342 FrameHostMsg_OpenURL_Params params; |
| 5339 params.url = url; | 5343 params.url = url; |
| 5344 params.uses_post = uses_post; |
| 5345 params.resource_request_body = resource_request_body; |
| 5340 params.referrer = referrer; | 5346 params.referrer = referrer; |
| 5341 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5347 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
| 5342 | 5348 |
| 5343 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5349 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
| 5344 // This is necessary to preserve the should_replace_current_entry value on | 5350 // This is necessary to preserve the should_replace_current_entry value on |
| 5345 // cross-process redirects, in the event it was set by a previous process. | 5351 // cross-process redirects, in the event it was set by a previous process. |
| 5346 WebDataSource* ds = frame_->provisionalDataSource(); | 5352 WebDataSource* ds = frame_->provisionalDataSource(); |
| 5347 DCHECK(ds); | 5353 DCHECK(ds); |
| 5348 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 5354 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
| 5349 } else { | 5355 } else { |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6235 // event target. Potentially a Pepper plugin will receive the event. | 6241 // event target. Potentially a Pepper plugin will receive the event. |
| 6236 // In order to tell whether a plugin gets the last mouse event and which it | 6242 // In order to tell whether a plugin gets the last mouse event and which it |
| 6237 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6243 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6238 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6244 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6239 // |pepper_last_mouse_event_target_|. | 6245 // |pepper_last_mouse_event_target_|. |
| 6240 pepper_last_mouse_event_target_ = nullptr; | 6246 pepper_last_mouse_event_target_ = nullptr; |
| 6241 #endif | 6247 #endif |
| 6242 } | 6248 } |
| 6243 | 6249 |
| 6244 } // namespace content | 6250 } // namespace content |
| OLD | NEW |