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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 #include "mojo/edk/js/core.h" | 148 #include "mojo/edk/js/core.h" |
149 #include "mojo/edk/js/support.h" | 149 #include "mojo/edk/js/support.h" |
150 #include "net/base/data_url.h" | 150 #include "net/base/data_url.h" |
151 #include "net/base/net_errors.h" | 151 #include "net/base/net_errors.h" |
152 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 152 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
153 #include "net/http/http_util.h" | 153 #include "net/http/http_util.h" |
154 #include "storage/common/data_element.h" | 154 #include "storage/common/data_element.h" |
155 #include "third_party/WebKit/public/platform/URLConversion.h" | 155 #include "third_party/WebKit/public/platform/URLConversion.h" |
156 #include "third_party/WebKit/public/platform/WebCachePolicy.h" | 156 #include "third_party/WebKit/public/platform/WebCachePolicy.h" |
157 #include "third_party/WebKit/public/platform/WebData.h" | 157 #include "third_party/WebKit/public/platform/WebData.h" |
| 158 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
158 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 159 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
159 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 160 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
160 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 161 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
161 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 162 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
162 #include "third_party/WebKit/public/platform/WebString.h" | 163 #include "third_party/WebKit/public/platform/WebString.h" |
163 #include "third_party/WebKit/public/platform/WebURL.h" | 164 #include "third_party/WebKit/public/platform/WebURL.h" |
164 #include "third_party/WebKit/public/platform/WebURLError.h" | 165 #include "third_party/WebKit/public/platform/WebURLError.h" |
165 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 166 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
166 #include "third_party/WebKit/public/platform/WebVector.h" | 167 #include "third_party/WebKit/public/platform/WebVector.h" |
167 #include "third_party/WebKit/public/web/WebColorSuggestion.h" | 168 #include "third_party/WebKit/public/web/WebColorSuggestion.h" |
(...skipping 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2953 blink::WebNavigationPolicy policy, | 2954 blink::WebNavigationPolicy policy, |
2954 const blink::WebString& suggested_name, | 2955 const blink::WebString& suggested_name, |
2955 bool should_replace_current_entry) { | 2956 bool should_replace_current_entry) { |
2956 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); | 2957 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); |
2957 if (policy == blink::WebNavigationPolicyDownload) { | 2958 if (policy == blink::WebNavigationPolicyDownload) { |
2958 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 2959 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
2959 GetRoutingID(), | 2960 GetRoutingID(), |
2960 request.url(), referrer, | 2961 request.url(), referrer, |
2961 suggested_name)); | 2962 suggested_name)); |
2962 } else { | 2963 } else { |
2963 OpenURL(request.url(), referrer, policy, should_replace_current_entry, | 2964 OpenURL(request.url(), "GET", nullptr, referrer, policy, |
2964 false); | 2965 should_replace_current_entry, false); |
2965 } | 2966 } |
2966 } | 2967 } |
2967 | 2968 |
2968 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { | 2969 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
2969 // OOPIF enabled modes will punt this navigation to the browser in | 2970 // OOPIF enabled modes will punt this navigation to the browser in |
2970 // decidePolicyForNavigation. | 2971 // decidePolicyForNavigation. |
2971 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2972 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
2972 return WebHistoryItem(); | 2973 return WebHistoryItem(); |
2973 | 2974 |
2974 return render_view_->history_controller()->GetItemForNewChildFrame(this); | 2975 return render_view_->history_controller()->GetItemForNewChildFrame(this); |
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4830 | 4831 |
4831 // Webkit is asking whether to navigate to a new URL. | 4832 // Webkit is asking whether to navigate to a new URL. |
4832 // This is fine normally, except if we're showing UI from one security | 4833 // This is fine normally, except if we're showing UI from one security |
4833 // context and they're trying to navigate to a different context. | 4834 // context and they're trying to navigate to a different context. |
4834 const GURL& url = info.urlRequest.url(); | 4835 const GURL& url = info.urlRequest.url(); |
4835 | 4836 |
4836 // If the browser is interested, then give it a chance to look at the request. | 4837 // If the browser is interested, then give it a chance to look at the request. |
4837 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 4838 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
4838 render_view_->renderer_preferences_ | 4839 render_view_->renderer_preferences_ |
4839 .browser_handles_all_top_level_requests) { | 4840 .browser_handles_all_top_level_requests) { |
4840 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, | 4841 OpenURL(url, info.urlRequest.httpMethod().utf8(), |
4841 false); | 4842 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
| 4843 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
4842 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4844 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4843 } | 4845 } |
4844 | 4846 |
4845 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 4847 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
4846 // should be sent to the browser in case there is a matching | 4848 // should be sent to the browser in case there is a matching |
4847 // FrameNavigationEntry. If none is found, fall back to the default url. | 4849 // FrameNavigationEntry. If none is found, fall back to the default url. |
4848 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | 4850 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
4849 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { | 4851 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { |
4850 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, | 4852 OpenURL(url, info.urlRequest.httpMethod().utf8(), |
4851 true); | 4853 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
| 4854 info.defaultPolicy, info.replacesCurrentHistoryItem, true); |
4852 // Suppress the load in Blink but mark the frame as loading. | 4855 // Suppress the load in Blink but mark the frame as loading. |
4853 return blink::WebNavigationPolicyHandledByClient; | 4856 return blink::WebNavigationPolicyHandledByClient; |
4854 } | 4857 } |
4855 | 4858 |
4856 // Use the frame's original request's URL rather than the document's URL for | 4859 // Use the frame's original request's URL rather than the document's URL for |
4857 // subsequent checks. For a popup, the document's URL may become the opener | 4860 // subsequent checks. For a popup, the document's URL may become the opener |
4858 // window's URL if the opener has called document.write(). | 4861 // window's URL if the opener has called document.write(). |
4859 // See http://crbug.com/93517. | 4862 // See http://crbug.com/93517. |
4860 GURL old_url(frame_->dataSource()->request().url()); | 4863 GURL old_url(frame_->dataSource()->request().url()); |
4861 | 4864 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4904 } | 4907 } |
4905 | 4908 |
4906 if (!should_fork) { | 4909 if (!should_fork) { |
4907 // Give the embedder a chance. | 4910 // Give the embedder a chance. |
4908 should_fork = GetContentClient()->renderer()->ShouldFork( | 4911 should_fork = GetContentClient()->renderer()->ShouldFork( |
4909 frame_, url, info.urlRequest.httpMethod().utf8(), | 4912 frame_, url, info.urlRequest.httpMethod().utf8(), |
4910 is_initial_navigation, is_redirect, &send_referrer); | 4913 is_initial_navigation, is_redirect, &send_referrer); |
4911 } | 4914 } |
4912 | 4915 |
4913 if (should_fork) { | 4916 if (should_fork) { |
4914 OpenURL(url, send_referrer ? referrer : Referrer(), info.defaultPolicy, | 4917 OpenURL(url, info.urlRequest.httpMethod().utf8(), |
| 4918 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 4919 send_referrer ? referrer : Referrer(), info.defaultPolicy, |
4915 info.replacesCurrentHistoryItem, false); | 4920 info.replacesCurrentHistoryItem, false); |
4916 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4921 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4917 } | 4922 } |
4918 } | 4923 } |
4919 | 4924 |
4920 // Detect when a page is "forking" a new tab that can be safely rendered in | 4925 // Detect when a page is "forking" a new tab that can be safely rendered in |
4921 // its own process. This is done by sites like Gmail that try to open links | 4926 // its own process. This is done by sites like Gmail that try to open links |
4922 // in new windows without script connections back to the original page. We | 4927 // in new windows without script connections back to the original page. We |
4923 // treat such cases as browser navigations (in which we will create a new | 4928 // treat such cases as browser navigations (in which we will create a new |
4924 // renderer for a cross-site navigation), rather than WebKit navigations. | 4929 // renderer for a cross-site navigation), rather than WebKit navigations. |
(...skipping 19 matching lines...) Expand all Loading... |
4944 frame_->parent() == NULL && | 4949 frame_->parent() == NULL && |
4945 // Must not have issued the request from this page. | 4950 // Must not have issued the request from this page. |
4946 is_content_initiated && | 4951 is_content_initiated && |
4947 // Must be targeted at the current tab. | 4952 // Must be targeted at the current tab. |
4948 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 4953 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
4949 // Must be a JavaScript navigation, which appears as "other". | 4954 // Must be a JavaScript navigation, which appears as "other". |
4950 info.navigationType == blink::WebNavigationTypeOther; | 4955 info.navigationType == blink::WebNavigationTypeOther; |
4951 | 4956 |
4952 if (is_fork) { | 4957 if (is_fork) { |
4953 // Open the URL via the browser, not via WebKit. | 4958 // Open the URL via the browser, not via WebKit. |
4954 OpenURL(url, Referrer(), info.defaultPolicy, | 4959 OpenURL(url, info.urlRequest.httpMethod().utf8(), |
4955 info.replacesCurrentHistoryItem, false); | 4960 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), |
| 4961 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
4956 return blink::WebNavigationPolicyIgnore; | 4962 return blink::WebNavigationPolicyIgnore; |
4957 } | 4963 } |
4958 | 4964 |
4959 // PlzNavigate: if the navigation is not synchronous, send it to the browser. | 4965 // PlzNavigate: if the navigation is not synchronous, send it to the browser. |
4960 // This includes navigations with no request being sent to the network stack. | 4966 // This includes navigations with no request being sent to the network stack. |
4961 if (IsBrowserSideNavigationEnabled() && | 4967 if (IsBrowserSideNavigationEnabled() && |
4962 info.urlRequest.checkForBrowserSideNavigation() && | 4968 info.urlRequest.checkForBrowserSideNavigation() && |
4963 ShouldMakeNetworkRequestForURL(url)) { | 4969 ShouldMakeNetworkRequestForURL(url)) { |
4964 BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, | 4970 BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, |
4965 info.isClientRedirect); | 4971 info.isClientRedirect); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5282 } | 5288 } |
5283 #elif defined(OS_MACOSX) | 5289 #elif defined(OS_MACOSX) |
5284 void RenderFrameImpl::OnSelectPopupMenuItem(int selected_index) { | 5290 void RenderFrameImpl::OnSelectPopupMenuItem(int selected_index) { |
5285 if (external_popup_menu_ == NULL) | 5291 if (external_popup_menu_ == NULL) |
5286 return; | 5292 return; |
5287 external_popup_menu_->DidSelectItem(selected_index); | 5293 external_popup_menu_->DidSelectItem(selected_index); |
5288 external_popup_menu_.reset(); | 5294 external_popup_menu_.reset(); |
5289 } | 5295 } |
5290 #endif | 5296 #endif |
5291 | 5297 |
5292 void RenderFrameImpl::OpenURL(const GURL& url, | 5298 void RenderFrameImpl::OpenURL( |
5293 const Referrer& referrer, | 5299 const GURL& url, |
5294 WebNavigationPolicy policy, | 5300 const std::string& method, |
5295 bool should_replace_current_entry, | 5301 const scoped_refptr<ResourceRequestBody>& resource_request_body, |
5296 bool is_history_navigation_in_new_child) { | 5302 const Referrer& referrer, |
| 5303 WebNavigationPolicy policy, |
| 5304 bool should_replace_current_entry, |
| 5305 bool is_history_navigation_in_new_child) { |
5297 FrameHostMsg_OpenURL_Params params; | 5306 FrameHostMsg_OpenURL_Params params; |
5298 params.url = url; | 5307 params.url = url; |
| 5308 params.method = method; |
| 5309 params.resource_request_body = resource_request_body; |
5299 params.referrer = referrer; | 5310 params.referrer = referrer; |
5300 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5311 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
5301 | 5312 |
5302 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5313 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
5303 // This is necessary to preserve the should_replace_current_entry value on | 5314 // This is necessary to preserve the should_replace_current_entry value on |
5304 // cross-process redirects, in the event it was set by a previous process. | 5315 // cross-process redirects, in the event it was set by a previous process. |
5305 WebDataSource* ds = frame_->provisionalDataSource(); | 5316 WebDataSource* ds = frame_->provisionalDataSource(); |
5306 DCHECK(ds); | 5317 DCHECK(ds); |
5307 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 5318 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
5308 } else { | 5319 } else { |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6193 // event target. Potentially a Pepper plugin will receive the event. | 6204 // event target. Potentially a Pepper plugin will receive the event. |
6194 // In order to tell whether a plugin gets the last mouse event and which it | 6205 // In order to tell whether a plugin gets the last mouse event and which it |
6195 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6206 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6196 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6207 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6197 // |pepper_last_mouse_event_target_|. | 6208 // |pepper_last_mouse_event_target_|. |
6198 pepper_last_mouse_event_target_ = nullptr; | 6209 pepper_last_mouse_event_target_ = nullptr; |
6199 #endif | 6210 #endif |
6200 } | 6211 } |
6201 | 6212 |
6202 } // namespace content | 6213 } // namespace content |
OLD | NEW |