| 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 3053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3064 blink::WebNavigationPolicy policy, | 3064 blink::WebNavigationPolicy policy, |
| 3065 const blink::WebString& suggested_name, | 3065 const blink::WebString& suggested_name, |
| 3066 bool should_replace_current_entry) { | 3066 bool should_replace_current_entry) { |
| 3067 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); | 3067 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); |
| 3068 if (policy == blink::WebNavigationPolicyDownload) { | 3068 if (policy == blink::WebNavigationPolicyDownload) { |
| 3069 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 3069 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
| 3070 GetRoutingID(), request.url(), referrer, | 3070 GetRoutingID(), request.url(), referrer, |
| 3071 suggested_name)); | 3071 suggested_name)); |
| 3072 } else { | 3072 } else { |
| 3073 OpenURL(request.url(), IsHttpPost(request), | 3073 OpenURL(request.url(), IsHttpPost(request), |
| 3074 GetRequestBodyForWebURLRequest(request), referrer, policy, | 3074 GetRequestBodyForWebURLRequest(request), |
| 3075 GetWebURLRequestHeadersForOpenURLParams(request), referrer, policy, |
| 3075 should_replace_current_entry, false); | 3076 should_replace_current_entry, false); |
| 3076 } | 3077 } |
| 3077 } | 3078 } |
| 3078 | 3079 |
| 3079 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { | 3080 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
| 3080 // OOPIF enabled modes will punt this navigation to the browser in | 3081 // OOPIF enabled modes will punt this navigation to the browser in |
| 3081 // decidePolicyForNavigation. | 3082 // decidePolicyForNavigation. |
| 3082 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3083 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 3083 return WebHistoryItem(); | 3084 return WebHistoryItem(); |
| 3084 | 3085 |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4977 // Webkit is asking whether to navigate to a new URL. | 4978 // Webkit is asking whether to navigate to a new URL. |
| 4978 // This is fine normally, except if we're showing UI from one security | 4979 // This is fine normally, except if we're showing UI from one security |
| 4979 // context and they're trying to navigate to a different context. | 4980 // context and they're trying to navigate to a different context. |
| 4980 const GURL& url = info.urlRequest.url(); | 4981 const GURL& url = info.urlRequest.url(); |
| 4981 | 4982 |
| 4982 // If the browser is interested, then give it a chance to look at the request. | 4983 // If the browser is interested, then give it a chance to look at the request. |
| 4983 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 4984 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
| 4984 render_view_->renderer_preferences_ | 4985 render_view_->renderer_preferences_ |
| 4985 .browser_handles_all_top_level_requests) { | 4986 .browser_handles_all_top_level_requests) { |
| 4986 OpenURL(url, IsHttpPost(info.urlRequest), | 4987 OpenURL(url, IsHttpPost(info.urlRequest), |
| 4987 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 4988 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 4989 GetWebURLRequestHeadersForOpenURLParams(info.urlRequest), referrer, |
| 4988 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 4990 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 4989 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4991 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 4990 } | 4992 } |
| 4991 | 4993 |
| 4992 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 4994 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
| 4993 // should be sent to the browser if there is a matching FrameNavigationEntry. | 4995 // should be sent to the browser if there is a matching FrameNavigationEntry. |
| 4994 // If this frame isn't on the list of unique names that have history items, | 4996 // If this frame isn't on the list of unique names that have history items, |
| 4995 // fall back to loading the default url. (We remove each name as we encounter | 4997 // fall back to loading the default url. (We remove each name as we encounter |
| 4996 // it, because it will only be used once as the frame is created.) | 4998 // it, because it will only be used once as the frame is created.) |
| 4997 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | 4999 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
| 4998 info.isHistoryNavigationInNewChildFrame && is_content_initiated && | 5000 info.isHistoryNavigationInNewChildFrame && is_content_initiated && |
| 4999 frame_->parent() && | 5001 frame_->parent() && |
| 5000 RenderFrameImpl::FromWebFrame(frame_->parent()) | 5002 RenderFrameImpl::FromWebFrame(frame_->parent()) |
| 5001 ->history_subframe_unique_names_.erase( | 5003 ->history_subframe_unique_names_.erase( |
| 5002 frame_->uniqueName().utf8()) > 0) { | 5004 frame_->uniqueName().utf8()) > 0) { |
| 5003 // Don't do this if |info| also says it is a client redirect, in which case | 5005 // Don't do this if |info| also says it is a client redirect, in which case |
| 5004 // JavaScript on the page is trying to interrupt the history navigation. | 5006 // JavaScript on the page is trying to interrupt the history navigation. |
| 5005 if (!info.isClientRedirect) { | 5007 if (!info.isClientRedirect) { |
| 5006 OpenURL(url, IsHttpPost(info.urlRequest), | 5008 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5007 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 5009 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5008 info.defaultPolicy, info.replacesCurrentHistoryItem, true); | 5010 GetWebURLRequestHeadersForOpenURLParams(info.urlRequest), |
| 5011 referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, |
| 5012 true); |
| 5009 // Suppress the load in Blink but mark the frame as loading. | 5013 // Suppress the load in Blink but mark the frame as loading. |
| 5010 return blink::WebNavigationPolicyHandledByClient; | 5014 return blink::WebNavigationPolicyHandledByClient; |
| 5011 } else { | 5015 } else { |
| 5012 // Client redirects during an initial history load should attempt to | 5016 // Client redirects during an initial history load should attempt to |
| 5013 // cancel the history navigation. They will create a provisional document | 5017 // cancel the history navigation. They will create a provisional document |
| 5014 // loader, causing the history load to be ignored in NavigateInternal, and | 5018 // loader, causing the history load to be ignored in NavigateInternal, and |
| 5015 // this IPC will try to cancel any cross-process history load. | 5019 // this IPC will try to cancel any cross-process history load. |
| 5016 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); | 5020 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); |
| 5017 } | 5021 } |
| 5018 } | 5022 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5058 if (!should_fork) { | 5062 if (!should_fork) { |
| 5059 // Give the embedder a chance. | 5063 // Give the embedder a chance. |
| 5060 should_fork = GetContentClient()->renderer()->ShouldFork( | 5064 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 5061 frame_, url, info.urlRequest.httpMethod().utf8(), | 5065 frame_, url, info.urlRequest.httpMethod().utf8(), |
| 5062 is_initial_navigation, is_redirect, &send_referrer); | 5066 is_initial_navigation, is_redirect, &send_referrer); |
| 5063 } | 5067 } |
| 5064 | 5068 |
| 5065 if (should_fork) { | 5069 if (should_fork) { |
| 5066 OpenURL(url, IsHttpPost(info.urlRequest), | 5070 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5067 GetRequestBodyForWebURLRequest(info.urlRequest), | 5071 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5072 GetWebURLRequestHeadersForOpenURLParams(info.urlRequest), |
| 5068 send_referrer ? referrer : Referrer(), info.defaultPolicy, | 5073 send_referrer ? referrer : Referrer(), info.defaultPolicy, |
| 5069 info.replacesCurrentHistoryItem, false); | 5074 info.replacesCurrentHistoryItem, false); |
| 5070 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5075 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5071 } | 5076 } |
| 5072 } | 5077 } |
| 5073 | 5078 |
| 5074 // Detect when a page is "forking" a new tab that can be safely rendered in | 5079 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 5075 // its own process. This is done by sites like Gmail that try to open links | 5080 // its own process. This is done by sites like Gmail that try to open links |
| 5076 // in new windows without script connections back to the original page. We | 5081 // in new windows without script connections back to the original page. We |
| 5077 // treat such cases as browser navigations (in which we will create a new | 5082 // treat such cases as browser navigations (in which we will create a new |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5099 // Must not have issued the request from this page. | 5104 // Must not have issued the request from this page. |
| 5100 is_content_initiated && | 5105 is_content_initiated && |
| 5101 // Must be targeted at the current tab. | 5106 // Must be targeted at the current tab. |
| 5102 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5107 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5103 // Must be a JavaScript navigation, which appears as "other". | 5108 // Must be a JavaScript navigation, which appears as "other". |
| 5104 info.navigationType == blink::WebNavigationTypeOther; | 5109 info.navigationType == blink::WebNavigationTypeOther; |
| 5105 | 5110 |
| 5106 if (is_fork) { | 5111 if (is_fork) { |
| 5107 // Open the URL via the browser, not via WebKit. | 5112 // Open the URL via the browser, not via WebKit. |
| 5108 OpenURL(url, IsHttpPost(info.urlRequest), | 5113 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5109 GetRequestBodyForWebURLRequest(info.urlRequest), Referrer(), | 5114 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5110 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5115 GetWebURLRequestHeadersForOpenURLParams(info.urlRequest), |
| 5116 Referrer(), info.defaultPolicy, info.replacesCurrentHistoryItem, |
| 5117 false); |
| 5111 return blink::WebNavigationPolicyIgnore; | 5118 return blink::WebNavigationPolicyIgnore; |
| 5112 } | 5119 } |
| 5113 | 5120 |
| 5114 bool should_dispatch_before_unload = | 5121 bool should_dispatch_before_unload = |
| 5115 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5122 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5116 // There is no need to execute the BeforeUnload event during a redirect, | 5123 // There is no need to execute the BeforeUnload event during a redirect, |
| 5117 // since it was already executed at the start of the navigation. | 5124 // since it was already executed at the start of the navigation. |
| 5118 !is_redirect && | 5125 !is_redirect && |
| 5119 // PlzNavigate: this should not be executed when commiting the navigation. | 5126 // PlzNavigate: this should not be executed when commiting the navigation. |
| 5120 (!IsBrowserSideNavigationEnabled() || | 5127 (!IsBrowserSideNavigationEnabled() || |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5421 external_popup_menu_->DidSelectItems(canceled, selected_indices); | 5428 external_popup_menu_->DidSelectItems(canceled, selected_indices); |
| 5422 external_popup_menu_.reset(); | 5429 external_popup_menu_.reset(); |
| 5423 } | 5430 } |
| 5424 #endif | 5431 #endif |
| 5425 #endif | 5432 #endif |
| 5426 | 5433 |
| 5427 void RenderFrameImpl::OpenURL( | 5434 void RenderFrameImpl::OpenURL( |
| 5428 const GURL& url, | 5435 const GURL& url, |
| 5429 bool uses_post, | 5436 bool uses_post, |
| 5430 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, | 5437 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, |
| 5438 const std::string& extra_headers, |
| 5431 const Referrer& referrer, | 5439 const Referrer& referrer, |
| 5432 WebNavigationPolicy policy, | 5440 WebNavigationPolicy policy, |
| 5433 bool should_replace_current_entry, | 5441 bool should_replace_current_entry, |
| 5434 bool is_history_navigation_in_new_child) { | 5442 bool is_history_navigation_in_new_child) { |
| 5435 FrameHostMsg_OpenURL_Params params; | 5443 FrameHostMsg_OpenURL_Params params; |
| 5436 params.url = url; | 5444 params.url = url; |
| 5437 params.uses_post = uses_post; | 5445 params.uses_post = uses_post; |
| 5438 params.resource_request_body = resource_request_body; | 5446 params.resource_request_body = resource_request_body; |
| 5447 params.extra_headers = extra_headers; |
| 5439 params.referrer = referrer; | 5448 params.referrer = referrer; |
| 5440 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5449 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
| 5441 | 5450 |
| 5442 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5451 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
| 5443 // This is necessary to preserve the should_replace_current_entry value on | 5452 // This is necessary to preserve the should_replace_current_entry value on |
| 5444 // cross-process redirects, in the event it was set by a previous process. | 5453 // cross-process redirects, in the event it was set by a previous process. |
| 5445 WebDataSource* ds = frame_->provisionalDataSource(); | 5454 WebDataSource* ds = frame_->provisionalDataSource(); |
| 5446 DCHECK(ds); | 5455 DCHECK(ds); |
| 5447 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 5456 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
| 5448 } else { | 5457 } else { |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5925 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == | 5934 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == |
| 5926 FetchRedirectMode::MANUAL_MODE); | 5935 FetchRedirectMode::MANUAL_MODE); |
| 5927 DCHECK(frame_->parent() || | 5936 DCHECK(frame_->parent() || |
| 5928 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == | 5937 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
| 5929 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | 5938 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); |
| 5930 DCHECK(!frame_->parent() || | 5939 DCHECK(!frame_->parent() || |
| 5931 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == | 5940 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
| 5932 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 5941 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
| 5933 | 5942 |
| 5934 Send(new FrameHostMsg_BeginNavigation( | 5943 Send(new FrameHostMsg_BeginNavigation( |
| 5935 routing_id_, | 5944 routing_id_, MakeCommonNavigationParams(info), |
| 5936 MakeCommonNavigationParams(info), | |
| 5937 BeginNavigationParams( | 5945 BeginNavigationParams( |
| 5938 GetWebURLRequestHeaders(info.urlRequest), | 5946 GetWebURLRequestHeadersForResourceRequest(info.urlRequest), |
| 5939 GetLoadFlagsForWebURLRequest(info.urlRequest), | 5947 GetLoadFlagsForWebURLRequest(info.urlRequest), |
| 5940 info.urlRequest.hasUserGesture(), | 5948 info.urlRequest.hasUserGesture(), |
| 5941 info.urlRequest.skipServiceWorker() != | 5949 info.urlRequest.skipServiceWorker() != |
| 5942 blink::WebURLRequest::SkipServiceWorker::None, | 5950 blink::WebURLRequest::SkipServiceWorker::None, |
| 5943 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); | 5951 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); |
| 5944 } | 5952 } |
| 5945 | 5953 |
| 5946 void RenderFrameImpl::LoadDataURL( | 5954 void RenderFrameImpl::LoadDataURL( |
| 5947 const CommonNavigationParams& params, | 5955 const CommonNavigationParams& params, |
| 5948 const RequestNavigationParams& request_params, | 5956 const RequestNavigationParams& request_params, |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6434 // event target. Potentially a Pepper plugin will receive the event. | 6442 // event target. Potentially a Pepper plugin will receive the event. |
| 6435 // In order to tell whether a plugin gets the last mouse event and which it | 6443 // In order to tell whether a plugin gets the last mouse event and which it |
| 6436 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6444 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6437 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6445 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6438 // |pepper_last_mouse_event_target_|. | 6446 // |pepper_last_mouse_event_target_|. |
| 6439 pepper_last_mouse_event_target_ = nullptr; | 6447 pepper_last_mouse_event_target_ = nullptr; |
| 6440 #endif | 6448 #endif |
| 6441 } | 6449 } |
| 6442 | 6450 |
| 6443 } // namespace content | 6451 } // namespace content |
| OLD | NEW |