| 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 3073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3084 blink::WebNavigationPolicy policy, | 3084 blink::WebNavigationPolicy policy, |
| 3085 const blink::WebString& suggested_name, | 3085 const blink::WebString& suggested_name, |
| 3086 bool should_replace_current_entry) { | 3086 bool should_replace_current_entry) { |
| 3087 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); | 3087 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); |
| 3088 if (policy == blink::WebNavigationPolicyDownload) { | 3088 if (policy == blink::WebNavigationPolicyDownload) { |
| 3089 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 3089 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
| 3090 GetRoutingID(), request.url(), referrer, | 3090 GetRoutingID(), request.url(), referrer, |
| 3091 suggested_name)); | 3091 suggested_name)); |
| 3092 } else { | 3092 } else { |
| 3093 OpenURL(request.url(), IsHttpPost(request), | 3093 OpenURL(request.url(), IsHttpPost(request), |
| 3094 GetRequestBodyForWebURLRequest(request), referrer, policy, | 3094 GetRequestBodyForWebURLRequest(request), |
| 3095 GetWebURLRequestHeaders(request), referrer, policy, |
| 3095 should_replace_current_entry, false); | 3096 should_replace_current_entry, false); |
| 3096 } | 3097 } |
| 3097 } | 3098 } |
| 3098 | 3099 |
| 3099 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { | 3100 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
| 3100 // OOPIF enabled modes will punt this navigation to the browser in | 3101 // OOPIF enabled modes will punt this navigation to the browser in |
| 3101 // decidePolicyForNavigation. | 3102 // decidePolicyForNavigation. |
| 3102 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3103 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 3103 return WebHistoryItem(); | 3104 return WebHistoryItem(); |
| 3104 | 3105 |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5032 // Webkit is asking whether to navigate to a new URL. | 5033 // Webkit is asking whether to navigate to a new URL. |
| 5033 // This is fine normally, except if we're showing UI from one security | 5034 // This is fine normally, except if we're showing UI from one security |
| 5034 // context and they're trying to navigate to a different context. | 5035 // context and they're trying to navigate to a different context. |
| 5035 const GURL& url = info.urlRequest.url(); | 5036 const GURL& url = info.urlRequest.url(); |
| 5036 | 5037 |
| 5037 // If the browser is interested, then give it a chance to look at the request. | 5038 // If the browser is interested, then give it a chance to look at the request. |
| 5038 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 5039 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
| 5039 render_view_->renderer_preferences_ | 5040 render_view_->renderer_preferences_ |
| 5040 .browser_handles_all_top_level_requests) { | 5041 .browser_handles_all_top_level_requests) { |
| 5041 OpenURL(url, IsHttpPost(info.urlRequest), | 5042 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5042 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 5043 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5044 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| 5043 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5045 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 5044 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5046 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5045 } | 5047 } |
| 5046 | 5048 |
| 5047 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 5049 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
| 5048 // should be sent to the browser if there is a matching FrameNavigationEntry. | 5050 // should be sent to the browser if there is a matching FrameNavigationEntry. |
| 5049 // If this frame isn't on the list of unique names that have history items, | 5051 // If this frame isn't on the list of unique names that have history items, |
| 5050 // fall back to loading the default url. (We remove each name as we encounter | 5052 // fall back to loading the default url. (We remove each name as we encounter |
| 5051 // it, because it will only be used once as the frame is created.) | 5053 // it, because it will only be used once as the frame is created.) |
| 5052 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | 5054 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
| 5053 info.isHistoryNavigationInNewChildFrame && is_content_initiated && | 5055 info.isHistoryNavigationInNewChildFrame && is_content_initiated && |
| 5054 frame_->parent() && | 5056 frame_->parent() && |
| 5055 RenderFrameImpl::FromWebFrame(frame_->parent()) | 5057 RenderFrameImpl::FromWebFrame(frame_->parent()) |
| 5056 ->history_subframe_unique_names_.erase( | 5058 ->history_subframe_unique_names_.erase( |
| 5057 frame_->uniqueName().utf8()) > 0) { | 5059 frame_->uniqueName().utf8()) > 0) { |
| 5058 // Don't do this if |info| also says it is a client redirect, in which case | 5060 // Don't do this if |info| also says it is a client redirect, in which case |
| 5059 // JavaScript on the page is trying to interrupt the history navigation. | 5061 // JavaScript on the page is trying to interrupt the history navigation. |
| 5060 if (!info.isClientRedirect) { | 5062 if (!info.isClientRedirect) { |
| 5061 OpenURL(url, IsHttpPost(info.urlRequest), | 5063 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5062 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 5064 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5065 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| 5063 info.defaultPolicy, info.replacesCurrentHistoryItem, true); | 5066 info.defaultPolicy, info.replacesCurrentHistoryItem, true); |
| 5064 // Suppress the load in Blink but mark the frame as loading. | 5067 // Suppress the load in Blink but mark the frame as loading. |
| 5065 return blink::WebNavigationPolicyHandledByClient; | 5068 return blink::WebNavigationPolicyHandledByClient; |
| 5066 } else { | 5069 } else { |
| 5067 // Client redirects during an initial history load should attempt to | 5070 // Client redirects during an initial history load should attempt to |
| 5068 // cancel the history navigation. They will create a provisional document | 5071 // cancel the history navigation. They will create a provisional document |
| 5069 // loader, causing the history load to be ignored in NavigateInternal, and | 5072 // loader, causing the history load to be ignored in NavigateInternal, and |
| 5070 // this IPC will try to cancel any cross-process history load. | 5073 // this IPC will try to cancel any cross-process history load. |
| 5071 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); | 5074 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); |
| 5072 } | 5075 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5113 if (!should_fork) { | 5116 if (!should_fork) { |
| 5114 // Give the embedder a chance. | 5117 // Give the embedder a chance. |
| 5115 should_fork = GetContentClient()->renderer()->ShouldFork( | 5118 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 5116 frame_, url, info.urlRequest.httpMethod().utf8(), | 5119 frame_, url, info.urlRequest.httpMethod().utf8(), |
| 5117 is_initial_navigation, is_redirect, &send_referrer); | 5120 is_initial_navigation, is_redirect, &send_referrer); |
| 5118 } | 5121 } |
| 5119 | 5122 |
| 5120 if (should_fork) { | 5123 if (should_fork) { |
| 5121 OpenURL(url, IsHttpPost(info.urlRequest), | 5124 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5122 GetRequestBodyForWebURLRequest(info.urlRequest), | 5125 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5126 GetWebURLRequestHeaders(info.urlRequest), |
| 5123 send_referrer ? referrer : Referrer(), info.defaultPolicy, | 5127 send_referrer ? referrer : Referrer(), info.defaultPolicy, |
| 5124 info.replacesCurrentHistoryItem, false); | 5128 info.replacesCurrentHistoryItem, false); |
| 5125 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5129 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5126 } | 5130 } |
| 5127 } | 5131 } |
| 5128 | 5132 |
| 5129 // Detect when a page is "forking" a new tab that can be safely rendered in | 5133 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 5130 // its own process. This is done by sites like Gmail that try to open links | 5134 // its own process. This is done by sites like Gmail that try to open links |
| 5131 // in new windows without script connections back to the original page. We | 5135 // in new windows without script connections back to the original page. We |
| 5132 // treat such cases as browser navigations (in which we will create a new | 5136 // treat such cases as browser navigations (in which we will create a new |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5154 // Must not have issued the request from this page. | 5158 // Must not have issued the request from this page. |
| 5155 is_content_initiated && | 5159 is_content_initiated && |
| 5156 // Must be targeted at the current tab. | 5160 // Must be targeted at the current tab. |
| 5157 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5161 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5158 // Must be a JavaScript navigation, which appears as "other". | 5162 // Must be a JavaScript navigation, which appears as "other". |
| 5159 info.navigationType == blink::WebNavigationTypeOther; | 5163 info.navigationType == blink::WebNavigationTypeOther; |
| 5160 | 5164 |
| 5161 if (is_fork) { | 5165 if (is_fork) { |
| 5162 // Open the URL via the browser, not via WebKit. | 5166 // Open the URL via the browser, not via WebKit. |
| 5163 OpenURL(url, IsHttpPost(info.urlRequest), | 5167 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5164 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), | 5168 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5169 GetWebURLRequestHeaders(info.urlRequest), Referrer(), |
| 5165 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5170 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 5166 return blink::WebNavigationPolicyIgnore; | 5171 return blink::WebNavigationPolicyIgnore; |
| 5167 } | 5172 } |
| 5168 | 5173 |
| 5169 bool should_dispatch_before_unload = | 5174 bool should_dispatch_before_unload = |
| 5170 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5175 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5171 // There is no need to execute the BeforeUnload event during a redirect, | 5176 // There is no need to execute the BeforeUnload event during a redirect, |
| 5172 // since it was already executed at the start of the navigation. | 5177 // since it was already executed at the start of the navigation. |
| 5173 !is_redirect && | 5178 !is_redirect && |
| 5174 // PlzNavigate: this should not be executed when commiting the navigation. | 5179 // PlzNavigate: this should not be executed when commiting the navigation. |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5491 external_popup_menu_->DidSelectItems(canceled, selected_indices); | 5496 external_popup_menu_->DidSelectItems(canceled, selected_indices); |
| 5492 external_popup_menu_.reset(); | 5497 external_popup_menu_.reset(); |
| 5493 } | 5498 } |
| 5494 #endif | 5499 #endif |
| 5495 #endif | 5500 #endif |
| 5496 | 5501 |
| 5497 void RenderFrameImpl::OpenURL( | 5502 void RenderFrameImpl::OpenURL( |
| 5498 const GURL& url, | 5503 const GURL& url, |
| 5499 bool uses_post, | 5504 bool uses_post, |
| 5500 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, | 5505 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, |
| 5506 const std::string& extra_headers, |
| 5501 const Referrer& referrer, | 5507 const Referrer& referrer, |
| 5502 WebNavigationPolicy policy, | 5508 WebNavigationPolicy policy, |
| 5503 bool should_replace_current_entry, | 5509 bool should_replace_current_entry, |
| 5504 bool is_history_navigation_in_new_child) { | 5510 bool is_history_navigation_in_new_child) { |
| 5505 FrameHostMsg_OpenURL_Params params; | 5511 FrameHostMsg_OpenURL_Params params; |
| 5506 params.url = url; | 5512 params.url = url; |
| 5507 params.uses_post = uses_post; | 5513 params.uses_post = uses_post; |
| 5508 params.resource_request_body = resource_request_body; | 5514 params.resource_request_body = resource_request_body; |
| 5515 params.extra_headers = extra_headers; |
| 5509 params.referrer = referrer; | 5516 params.referrer = referrer; |
| 5510 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5517 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
| 5511 | 5518 |
| 5512 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5519 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
| 5513 // This is necessary to preserve the should_replace_current_entry value on | 5520 // This is necessary to preserve the should_replace_current_entry value on |
| 5514 // cross-process redirects, in the event it was set by a previous process. | 5521 // cross-process redirects, in the event it was set by a previous process. |
| 5515 WebDataSource* ds = frame_->provisionalDataSource(); | 5522 WebDataSource* ds = frame_->provisionalDataSource(); |
| 5516 DCHECK(ds); | 5523 DCHECK(ds); |
| 5517 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 5524 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
| 5518 } else { | 5525 } else { |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5992 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == | 5999 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == |
| 5993 FetchRedirectMode::MANUAL_MODE); | 6000 FetchRedirectMode::MANUAL_MODE); |
| 5994 DCHECK(frame_->parent() || | 6001 DCHECK(frame_->parent() || |
| 5995 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == | 6002 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
| 5996 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | 6003 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); |
| 5997 DCHECK(!frame_->parent() || | 6004 DCHECK(!frame_->parent() || |
| 5998 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == | 6005 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
| 5999 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 6006 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
| 6000 | 6007 |
| 6001 Send(new FrameHostMsg_BeginNavigation( | 6008 Send(new FrameHostMsg_BeginNavigation( |
| 6002 routing_id_, | 6009 routing_id_, MakeCommonNavigationParams(info), |
| 6003 MakeCommonNavigationParams(info), | |
| 6004 BeginNavigationParams( | 6010 BeginNavigationParams( |
| 6005 GetWebURLRequestHeaders(info.urlRequest), | 6011 GetWebURLRequestHeaders(info.urlRequest), |
| 6006 GetLoadFlagsForWebURLRequest(info.urlRequest), | 6012 GetLoadFlagsForWebURLRequest(info.urlRequest), |
| 6007 info.urlRequest.hasUserGesture(), | 6013 info.urlRequest.hasUserGesture(), |
| 6008 info.urlRequest.skipServiceWorker() != | 6014 info.urlRequest.skipServiceWorker() != |
| 6009 blink::WebURLRequest::SkipServiceWorker::None, | 6015 blink::WebURLRequest::SkipServiceWorker::None, |
| 6010 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); | 6016 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); |
| 6011 } | 6017 } |
| 6012 | 6018 |
| 6013 void RenderFrameImpl::LoadDataURL( | 6019 void RenderFrameImpl::LoadDataURL( |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6491 // event target. Potentially a Pepper plugin will receive the event. | 6497 // event target. Potentially a Pepper plugin will receive the event. |
| 6492 // In order to tell whether a plugin gets the last mouse event and which it | 6498 // In order to tell whether a plugin gets the last mouse event and which it |
| 6493 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6499 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6494 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6500 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6495 // |pepper_last_mouse_event_target_|. | 6501 // |pepper_last_mouse_event_target_|. |
| 6496 pepper_last_mouse_event_target_ = nullptr; | 6502 pepper_last_mouse_event_target_ = nullptr; |
| 6497 #endif | 6503 #endif |
| 6498 } | 6504 } |
| 6499 | 6505 |
| 6500 } // namespace content | 6506 } // namespace content |
| OLD | NEW |