| 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 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3156 blink::WebNavigationPolicy policy, | 3156 blink::WebNavigationPolicy policy, |
| 3157 const blink::WebString& suggested_name, | 3157 const blink::WebString& suggested_name, |
| 3158 bool should_replace_current_entry) { | 3158 bool should_replace_current_entry) { |
| 3159 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); | 3159 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); |
| 3160 if (policy == blink::WebNavigationPolicyDownload) { | 3160 if (policy == blink::WebNavigationPolicyDownload) { |
| 3161 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 3161 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
| 3162 GetRoutingID(), request.url(), referrer, | 3162 GetRoutingID(), request.url(), referrer, |
| 3163 suggested_name)); | 3163 suggested_name)); |
| 3164 } else { | 3164 } else { |
| 3165 OpenURL(request.url(), IsHttpPost(request), | 3165 OpenURL(request.url(), IsHttpPost(request), |
| 3166 GetRequestBodyForWebURLRequest(request), referrer, policy, | 3166 GetRequestBodyForWebURLRequest(request), |
| 3167 GetWebURLRequestHeaders(request), referrer, policy, |
| 3167 should_replace_current_entry, false); | 3168 should_replace_current_entry, false); |
| 3168 } | 3169 } |
| 3169 } | 3170 } |
| 3170 | 3171 |
| 3171 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { | 3172 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
| 3172 // OOPIF enabled modes will punt this navigation to the browser in | 3173 // OOPIF enabled modes will punt this navigation to the browser in |
| 3173 // decidePolicyForNavigation. | 3174 // decidePolicyForNavigation. |
| 3174 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3175 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 3175 return WebHistoryItem(); | 3176 return WebHistoryItem(); |
| 3176 | 3177 |
| (...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5085 // Webkit is asking whether to navigate to a new URL. | 5086 // Webkit is asking whether to navigate to a new URL. |
| 5086 // This is fine normally, except if we're showing UI from one security | 5087 // This is fine normally, except if we're showing UI from one security |
| 5087 // context and they're trying to navigate to a different context. | 5088 // context and they're trying to navigate to a different context. |
| 5088 const GURL& url = info.urlRequest.url(); | 5089 const GURL& url = info.urlRequest.url(); |
| 5089 | 5090 |
| 5090 // If the browser is interested, then give it a chance to look at the request. | 5091 // If the browser is interested, then give it a chance to look at the request. |
| 5091 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 5092 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
| 5092 render_view_->renderer_preferences_ | 5093 render_view_->renderer_preferences_ |
| 5093 .browser_handles_all_top_level_requests) { | 5094 .browser_handles_all_top_level_requests) { |
| 5094 OpenURL(url, IsHttpPost(info.urlRequest), | 5095 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5095 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 5096 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5097 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| 5096 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5098 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 5097 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5099 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5098 } | 5100 } |
| 5099 | 5101 |
| 5100 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 5102 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
| 5101 // should be sent to the browser if there is a matching FrameNavigationEntry. | 5103 // should be sent to the browser if there is a matching FrameNavigationEntry. |
| 5102 // If this frame isn't on the list of unique names that have history items, | 5104 // If this frame isn't on the list of unique names that have history items, |
| 5103 // fall back to loading the default url. (We remove each name as we encounter | 5105 // fall back to loading the default url. (We remove each name as we encounter |
| 5104 // it, because it will only be used once as the frame is created.) | 5106 // it, because it will only be used once as the frame is created.) |
| 5105 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | 5107 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
| 5106 info.isHistoryNavigationInNewChildFrame && is_content_initiated && | 5108 info.isHistoryNavigationInNewChildFrame && is_content_initiated && |
| 5107 frame_->parent() && | 5109 frame_->parent() && |
| 5108 RenderFrameImpl::FromWebFrame(frame_->parent()) | 5110 RenderFrameImpl::FromWebFrame(frame_->parent()) |
| 5109 ->history_subframe_unique_names_.erase( | 5111 ->history_subframe_unique_names_.erase( |
| 5110 frame_->uniqueName().utf8()) > 0) { | 5112 frame_->uniqueName().utf8()) > 0) { |
| 5111 // Don't do this if |info| also says it is a client redirect, in which case | 5113 // Don't do this if |info| also says it is a client redirect, in which case |
| 5112 // JavaScript on the page is trying to interrupt the history navigation. | 5114 // JavaScript on the page is trying to interrupt the history navigation. |
| 5113 if (!info.isClientRedirect) { | 5115 if (!info.isClientRedirect) { |
| 5114 OpenURL(url, IsHttpPost(info.urlRequest), | 5116 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5115 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 5117 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5118 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| 5116 info.defaultPolicy, info.replacesCurrentHistoryItem, true); | 5119 info.defaultPolicy, info.replacesCurrentHistoryItem, true); |
| 5117 // Suppress the load in Blink but mark the frame as loading. | 5120 // Suppress the load in Blink but mark the frame as loading. |
| 5118 return blink::WebNavigationPolicyHandledByClient; | 5121 return blink::WebNavigationPolicyHandledByClient; |
| 5119 } else { | 5122 } else { |
| 5120 // Client redirects during an initial history load should attempt to | 5123 // Client redirects during an initial history load should attempt to |
| 5121 // cancel the history navigation. They will create a provisional document | 5124 // cancel the history navigation. They will create a provisional document |
| 5122 // loader, causing the history load to be ignored in NavigateInternal, and | 5125 // loader, causing the history load to be ignored in NavigateInternal, and |
| 5123 // this IPC will try to cancel any cross-process history load. | 5126 // this IPC will try to cancel any cross-process history load. |
| 5124 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); | 5127 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); |
| 5125 } | 5128 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5166 if (!should_fork) { | 5169 if (!should_fork) { |
| 5167 // Give the embedder a chance. | 5170 // Give the embedder a chance. |
| 5168 should_fork = GetContentClient()->renderer()->ShouldFork( | 5171 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 5169 frame_, url, info.urlRequest.httpMethod().utf8(), | 5172 frame_, url, info.urlRequest.httpMethod().utf8(), |
| 5170 is_initial_navigation, is_redirect, &send_referrer); | 5173 is_initial_navigation, is_redirect, &send_referrer); |
| 5171 } | 5174 } |
| 5172 | 5175 |
| 5173 if (should_fork) { | 5176 if (should_fork) { |
| 5174 OpenURL(url, IsHttpPost(info.urlRequest), | 5177 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5175 GetRequestBodyForWebURLRequest(info.urlRequest), | 5178 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5179 GetWebURLRequestHeaders(info.urlRequest), |
| 5176 send_referrer ? referrer : Referrer(), info.defaultPolicy, | 5180 send_referrer ? referrer : Referrer(), info.defaultPolicy, |
| 5177 info.replacesCurrentHistoryItem, false); | 5181 info.replacesCurrentHistoryItem, false); |
| 5178 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5182 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5179 } | 5183 } |
| 5180 } | 5184 } |
| 5181 | 5185 |
| 5182 // Detect when a page is "forking" a new tab that can be safely rendered in | 5186 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 5183 // its own process. This is done by sites like Gmail that try to open links | 5187 // its own process. This is done by sites like Gmail that try to open links |
| 5184 // in new windows without script connections back to the original page. We | 5188 // in new windows without script connections back to the original page. We |
| 5185 // treat such cases as browser navigations (in which we will create a new | 5189 // treat such cases as browser navigations (in which we will create a new |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5207 // Must not have issued the request from this page. | 5211 // Must not have issued the request from this page. |
| 5208 is_content_initiated && | 5212 is_content_initiated && |
| 5209 // Must be targeted at the current tab. | 5213 // Must be targeted at the current tab. |
| 5210 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5214 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5211 // Must be a JavaScript navigation, which appears as "other". | 5215 // Must be a JavaScript navigation, which appears as "other". |
| 5212 info.navigationType == blink::WebNavigationTypeOther; | 5216 info.navigationType == blink::WebNavigationTypeOther; |
| 5213 | 5217 |
| 5214 if (is_fork) { | 5218 if (is_fork) { |
| 5215 // Open the URL via the browser, not via WebKit. | 5219 // Open the URL via the browser, not via WebKit. |
| 5216 OpenURL(url, IsHttpPost(info.urlRequest), | 5220 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5217 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), | 5221 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5222 GetWebURLRequestHeaders(info.urlRequest), Referrer(), |
| 5218 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5223 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 5219 return blink::WebNavigationPolicyIgnore; | 5224 return blink::WebNavigationPolicyIgnore; |
| 5220 } | 5225 } |
| 5221 | 5226 |
| 5222 bool should_dispatch_before_unload = | 5227 bool should_dispatch_before_unload = |
| 5223 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5228 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5224 // There is no need to execute the BeforeUnload event during a redirect, | 5229 // There is no need to execute the BeforeUnload event during a redirect, |
| 5225 // since it was already executed at the start of the navigation. | 5230 // since it was already executed at the start of the navigation. |
| 5226 !is_redirect && | 5231 !is_redirect && |
| 5227 // PlzNavigate: this should not be executed when commiting the navigation. | 5232 // PlzNavigate: this should not be executed when commiting the navigation. |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5544 external_popup_menu_->DidSelectItems(canceled, selected_indices); | 5549 external_popup_menu_->DidSelectItems(canceled, selected_indices); |
| 5545 external_popup_menu_.reset(); | 5550 external_popup_menu_.reset(); |
| 5546 } | 5551 } |
| 5547 #endif | 5552 #endif |
| 5548 #endif | 5553 #endif |
| 5549 | 5554 |
| 5550 void RenderFrameImpl::OpenURL( | 5555 void RenderFrameImpl::OpenURL( |
| 5551 const GURL& url, | 5556 const GURL& url, |
| 5552 bool uses_post, | 5557 bool uses_post, |
| 5553 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, | 5558 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, |
| 5559 const std::string& extra_headers, |
| 5554 const Referrer& referrer, | 5560 const Referrer& referrer, |
| 5555 WebNavigationPolicy policy, | 5561 WebNavigationPolicy policy, |
| 5556 bool should_replace_current_entry, | 5562 bool should_replace_current_entry, |
| 5557 bool is_history_navigation_in_new_child) { | 5563 bool is_history_navigation_in_new_child) { |
| 5558 FrameHostMsg_OpenURL_Params params; | 5564 FrameHostMsg_OpenURL_Params params; |
| 5559 params.url = url; | 5565 params.url = url; |
| 5560 params.uses_post = uses_post; | 5566 params.uses_post = uses_post; |
| 5561 params.resource_request_body = resource_request_body; | 5567 params.resource_request_body = resource_request_body; |
| 5568 params.extra_headers = extra_headers; |
| 5562 params.referrer = referrer; | 5569 params.referrer = referrer; |
| 5563 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5570 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
| 5564 | 5571 |
| 5565 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5572 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
| 5566 // This is necessary to preserve the should_replace_current_entry value on | 5573 // This is necessary to preserve the should_replace_current_entry value on |
| 5567 // cross-process redirects, in the event it was set by a previous process. | 5574 // cross-process redirects, in the event it was set by a previous process. |
| 5568 WebDataSource* ds = frame_->provisionalDataSource(); | 5575 WebDataSource* ds = frame_->provisionalDataSource(); |
| 5569 DCHECK(ds); | 5576 DCHECK(ds); |
| 5570 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 5577 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
| 5571 } else { | 5578 } else { |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6043 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == | 6050 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == |
| 6044 FetchRedirectMode::MANUAL_MODE); | 6051 FetchRedirectMode::MANUAL_MODE); |
| 6045 DCHECK(frame_->parent() || | 6052 DCHECK(frame_->parent() || |
| 6046 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == | 6053 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
| 6047 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | 6054 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); |
| 6048 DCHECK(!frame_->parent() || | 6055 DCHECK(!frame_->parent() || |
| 6049 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == | 6056 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
| 6050 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 6057 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
| 6051 | 6058 |
| 6052 Send(new FrameHostMsg_BeginNavigation( | 6059 Send(new FrameHostMsg_BeginNavigation( |
| 6053 routing_id_, | 6060 routing_id_, MakeCommonNavigationParams(info), |
| 6054 MakeCommonNavigationParams(info), | |
| 6055 BeginNavigationParams( | 6061 BeginNavigationParams( |
| 6056 GetWebURLRequestHeaders(info.urlRequest), | 6062 GetWebURLRequestHeaders(info.urlRequest), |
| 6057 GetLoadFlagsForWebURLRequest(info.urlRequest), | 6063 GetLoadFlagsForWebURLRequest(info.urlRequest), |
| 6058 info.urlRequest.hasUserGesture(), | 6064 info.urlRequest.hasUserGesture(), |
| 6059 info.urlRequest.skipServiceWorker() != | 6065 info.urlRequest.skipServiceWorker() != |
| 6060 blink::WebURLRequest::SkipServiceWorker::None, | 6066 blink::WebURLRequest::SkipServiceWorker::None, |
| 6061 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); | 6067 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); |
| 6062 } | 6068 } |
| 6063 | 6069 |
| 6064 void RenderFrameImpl::LoadDataURL( | 6070 void RenderFrameImpl::LoadDataURL( |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6548 // event target. Potentially a Pepper plugin will receive the event. | 6554 // event target. Potentially a Pepper plugin will receive the event. |
| 6549 // In order to tell whether a plugin gets the last mouse event and which it | 6555 // In order to tell whether a plugin gets the last mouse event and which it |
| 6550 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6556 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6551 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6557 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6552 // |pepper_last_mouse_event_target_|. | 6558 // |pepper_last_mouse_event_target_|. |
| 6553 pepper_last_mouse_event_target_ = nullptr; | 6559 pepper_last_mouse_event_target_ = nullptr; |
| 6554 #endif | 6560 #endif |
| 6555 } | 6561 } |
| 6556 | 6562 |
| 6557 } // namespace content | 6563 } // namespace content |
| OLD | NEW |