Chromium Code Reviews| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1685 } else if (policy == blink::WebNavigationPolicyDownloadTo) { | 1685 } else if (policy == blink::WebNavigationPolicyDownloadTo) { |
| 1686 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 1686 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
| 1687 request.url(), referrer, | 1687 request.url(), referrer, |
| 1688 suggested_name, true)); | 1688 suggested_name, true)); |
| 1689 } else { | 1689 } else { |
| 1690 OpenURL(frame, request.url(), referrer, policy); | 1690 OpenURL(frame, request.url(), referrer, policy); |
| 1691 } | 1691 } |
| 1692 } | 1692 } |
| 1693 | 1693 |
| 1694 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( | 1694 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( |
| 1695 blink::WebLocalFrame* frame, | 1695 const NavigationPolicyInfo& info) { |
| 1696 blink::WebDataSource::ExtraData* extra_data, | 1696 DCHECK(!frame_ || frame_ == info.frame); |
| 1697 const blink::WebURLRequest& request, | 1697 return DecidePolicyForNavigation(this, info); |
| 1698 blink::WebNavigationType type, | |
| 1699 blink::WebNavigationPolicy default_policy, | |
| 1700 bool is_redirect) { | |
| 1701 DCHECK(!frame_ || frame_ == frame); | |
| 1702 return DecidePolicyForNavigation( | |
| 1703 this, frame, extra_data, request, type, default_policy, is_redirect); | |
| 1704 } | 1698 } |
| 1705 | 1699 |
| 1706 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( | 1700 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( |
| 1707 blink::WebFrame* frame) { | 1701 blink::WebFrame* frame) { |
| 1708 DCHECK(!frame_ || frame_ == frame); | 1702 DCHECK(!frame_ || frame_ == frame); |
| 1709 return render_view_->history_controller()->GetItemForNewChildFrame(this); | 1703 return render_view_->history_controller()->GetItemForNewChildFrame(this); |
| 1710 } | 1704 } |
| 1711 | 1705 |
| 1712 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, | 1706 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, |
| 1713 const blink::WebFormElement& form) { | 1707 const blink::WebFormElement& form) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1754 render_view_->didCreateDataSource(frame, datasource); | 1748 render_view_->didCreateDataSource(frame, datasource); |
| 1755 | 1749 |
| 1756 // Create the serviceworker's per-document network observing object. | 1750 // Create the serviceworker's per-document network observing object. |
| 1757 scoped_ptr<ServiceWorkerNetworkProvider> | 1751 scoped_ptr<ServiceWorkerNetworkProvider> |
| 1758 network_provider(new ServiceWorkerNetworkProvider()); | 1752 network_provider(new ServiceWorkerNetworkProvider()); |
| 1759 ServiceWorkerNetworkProvider::AttachToDocumentState( | 1753 ServiceWorkerNetworkProvider::AttachToDocumentState( |
| 1760 DocumentState::FromDataSource(datasource), | 1754 DocumentState::FromDataSource(datasource), |
| 1761 network_provider.Pass()); | 1755 network_provider.Pass()); |
| 1762 } | 1756 } |
| 1763 | 1757 |
| 1764 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) { | 1758 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, |
| 1759 bool is_transition_navigation) { | |
| 1765 DCHECK(!frame_ || frame_ == frame); | 1760 DCHECK(!frame_ || frame_ == frame); |
| 1766 WebDataSource* ds = frame->provisionalDataSource(); | 1761 WebDataSource* ds = frame->provisionalDataSource(); |
| 1767 | 1762 |
| 1768 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 1763 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
| 1769 // callback is invoked. | 1764 // callback is invoked. |
| 1770 if (!ds) | 1765 if (!ds) |
| 1771 return; | 1766 return; |
| 1772 | 1767 |
| 1773 DocumentState* document_state = DocumentState::FromDataSource(ds); | 1768 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 1774 | 1769 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1798 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we | 1793 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we |
| 1799 // handle loading of error pages. | 1794 // handle loading of error pages. |
| 1800 document_state->navigation_state()->set_transition_type( | 1795 document_state->navigation_state()->set_transition_type( |
| 1801 PAGE_TRANSITION_AUTO_SUBFRAME); | 1796 PAGE_TRANSITION_AUTO_SUBFRAME); |
| 1802 } | 1797 } |
| 1803 | 1798 |
| 1804 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 1799 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 1805 DidStartProvisionalLoad(frame)); | 1800 DidStartProvisionalLoad(frame)); |
| 1806 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); | 1801 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); |
| 1807 | 1802 |
| 1808 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(routing_id_, | 1803 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( |
| 1809 ds->request().url())); | 1804 routing_id_, ds->request().url(), is_transition_navigation)); |
| 1810 } | 1805 } |
| 1811 | 1806 |
| 1812 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 1807 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
| 1813 blink::WebLocalFrame* frame) { | 1808 blink::WebLocalFrame* frame) { |
| 1814 DCHECK(!frame_ || frame_ == frame); | 1809 DCHECK(!frame_ || frame_ == frame); |
| 1815 render_view_->history_controller()->RemoveChildrenForRedirect(this); | 1810 render_view_->history_controller()->RemoveChildrenForRedirect(this); |
| 1816 if (frame->parent()) | 1811 if (frame->parent()) |
| 1817 return; | 1812 return; |
| 1818 // Received a redirect on the main frame. | 1813 // Received a redirect on the main frame. |
| 1819 WebDataSource* data_source = frame->provisionalDataSource(); | 1814 WebDataSource* data_source = frame->provisionalDataSource(); |
| (...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3159 render_view_->FrameDidStopLoading(frame_); | 3154 render_view_->FrameDidStopLoading(frame_); |
| 3160 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 3155 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 3161 } | 3156 } |
| 3162 | 3157 |
| 3163 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { | 3158 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { |
| 3164 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); | 3159 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); |
| 3165 } | 3160 } |
| 3166 | 3161 |
| 3167 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( | 3162 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( |
| 3168 RenderFrame* render_frame, | 3163 RenderFrame* render_frame, |
| 3169 WebFrame* frame, | 3164 const NavigationPolicyInfo& info ) { |
|
Charlie Reis
2014/07/30 00:00:51
nit: No space after info
oystein (OOO til 10th of July)
2014/07/30 17:30:45
Done.
| |
| 3170 WebDataSource::ExtraData* extraData, | |
| 3171 const WebURLRequest& request, | |
| 3172 WebNavigationType type, | |
| 3173 WebNavigationPolicy default_policy, | |
| 3174 bool is_redirect) { | |
| 3175 #ifdef OS_ANDROID | 3165 #ifdef OS_ANDROID |
| 3176 // The handlenavigation API is deprecated and will be removed once | 3166 // The handlenavigation API is deprecated and will be removed once |
| 3177 // crbug.com/325351 is resolved. | 3167 // crbug.com/325351 is resolved. |
| 3178 if (request.url() != GURL(kSwappedOutURL) && | 3168 if (info.urlRequest.url() != GURL(kSwappedOutURL) && |
| 3179 GetContentClient()->renderer()->HandleNavigation( | 3169 GetContentClient()->renderer()->HandleNavigation( |
| 3180 render_frame, | 3170 render_frame, |
| 3181 static_cast<DocumentState*>(extraData), | 3171 static_cast<DocumentState*>(info.extraData), |
| 3182 render_view_->opener_id_, | 3172 render_view_->opener_id_, |
| 3183 frame, | 3173 info.frame, |
| 3184 request, | 3174 info.urlRequest, |
| 3185 type, | 3175 info.navigationType, |
| 3186 default_policy, | 3176 info.defaultPolicy, |
| 3187 is_redirect)) { | 3177 info.isRedirect)) { |
| 3188 return blink::WebNavigationPolicyIgnore; | 3178 return blink::WebNavigationPolicyIgnore; |
| 3189 } | 3179 } |
| 3190 #endif | 3180 #endif |
| 3191 | 3181 |
| 3192 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); | 3182 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(info.frame, |
| 3183 info.urlRequest)); | |
| 3193 | 3184 |
| 3194 if (is_swapped_out_ || render_view_->is_swapped_out()) { | 3185 if (is_swapped_out_ || render_view_->is_swapped_out()) { |
| 3195 if (request.url() != GURL(kSwappedOutURL)) { | 3186 if (info.urlRequest.url() != GURL(kSwappedOutURL)) { |
| 3196 // Targeted links may try to navigate a swapped out frame. Allow the | 3187 // Targeted links may try to navigate a swapped out frame. Allow the |
| 3197 // browser process to navigate the tab instead. Note that it is also | 3188 // browser process to navigate the tab instead. Note that it is also |
| 3198 // possible for non-targeted navigations (from this view) to arrive | 3189 // possible for non-targeted navigations (from this view) to arrive |
| 3199 // here just after we are swapped out. It's ok to send them to the | 3190 // here just after we are swapped out. It's ok to send them to the |
| 3200 // browser, as long as they're for the top level frame. | 3191 // browser, as long as they're for the top level frame. |
| 3201 // TODO(creis): Ensure this supports targeted form submissions when | 3192 // TODO(creis): Ensure this supports targeted form submissions when |
| 3202 // fixing http://crbug.com/101395. | 3193 // fixing http://crbug.com/101395. |
| 3203 if (frame->parent() == NULL) { | 3194 if (info.frame->parent() == NULL) { |
| 3204 OpenURL(frame, request.url(), referrer, default_policy); | 3195 OpenURL(info.frame, info.urlRequest.url(), referrer, |
| 3196 info.defaultPolicy); | |
| 3205 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3197 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 3206 } | 3198 } |
| 3207 | 3199 |
| 3208 // We should otherwise ignore in-process iframe navigations, if they | 3200 // We should otherwise ignore in-process iframe navigations, if they |
| 3209 // arrive just after we are swapped out. | 3201 // arrive just after we are swapped out. |
| 3210 return blink::WebNavigationPolicyIgnore; | 3202 return blink::WebNavigationPolicyIgnore; |
| 3211 } | 3203 } |
| 3212 | 3204 |
| 3213 // Allow kSwappedOutURL to complete. | 3205 // Allow kSwappedOutURL to complete. |
| 3214 return default_policy; | 3206 return info.defaultPolicy; |
| 3215 } | 3207 } |
| 3216 | 3208 |
| 3217 // Webkit is asking whether to navigate to a new URL. | 3209 // Webkit is asking whether to navigate to a new URL. |
| 3218 // This is fine normally, except if we're showing UI from one security | 3210 // This is fine normally, except if we're showing UI from one security |
| 3219 // context and they're trying to navigate to a different context. | 3211 // context and they're trying to navigate to a different context. |
| 3220 const GURL& url = request.url(); | 3212 const GURL& url = info.urlRequest.url(); |
| 3221 | 3213 |
| 3222 // A content initiated navigation may have originated from a link-click, | 3214 // A content initiated navigation may have originated from a link-click, |
| 3223 // script, drag-n-drop operation, etc. | 3215 // script, drag-n-drop operation, etc. |
| 3224 bool is_content_initiated = static_cast<DocumentState*>(extraData)-> | 3216 bool is_content_initiated = static_cast<DocumentState*>(info.extraData)-> |
| 3225 navigation_state()->is_content_initiated(); | 3217 navigation_state()->is_content_initiated(); |
| 3226 | 3218 |
| 3227 // Experimental: | 3219 // Experimental: |
| 3228 // If --enable-strict-site-isolation or --site-per-process is enabled, send | 3220 // If --enable-strict-site-isolation or --site-per-process is enabled, send |
| 3229 // all top-level navigations to the browser to let it swap processes when | 3221 // all top-level navigations to the browser to let it swap processes when |
| 3230 // crossing site boundaries. This is currently expected to break some script | 3222 // crossing site boundaries. This is currently expected to break some script |
| 3231 // calls and navigations, such as form submissions. | 3223 // calls and navigations, such as form submissions. |
| 3232 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 3224 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 3233 bool force_swap_due_to_flag = | 3225 bool force_swap_due_to_flag = |
| 3234 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || | 3226 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || |
| 3235 command_line.HasSwitch(switches::kSitePerProcess); | 3227 command_line.HasSwitch(switches::kSitePerProcess); |
| 3236 if (force_swap_due_to_flag && | 3228 if (force_swap_due_to_flag && |
| 3237 !frame->parent() && (is_content_initiated || is_redirect)) { | 3229 !info.frame->parent() && (is_content_initiated || info.isRedirect)) { |
| 3238 WebString origin_str = frame->document().securityOrigin().toString(); | 3230 WebString origin_str = info.frame->document().securityOrigin().toString(); |
| 3239 GURL frame_url(origin_str.utf8().data()); | 3231 GURL frame_url(origin_str.utf8().data()); |
| 3240 // TODO(cevans): revisit whether this site check is still necessary once | 3232 // TODO(cevans): revisit whether this site check is still necessary once |
| 3241 // crbug.com/101395 is fixed. | 3233 // crbug.com/101395 is fixed. |
| 3242 bool same_domain_or_host = | 3234 bool same_domain_or_host = |
| 3243 net::registry_controlled_domains::SameDomainOrHost( | 3235 net::registry_controlled_domains::SameDomainOrHost( |
| 3244 frame_url, | 3236 frame_url, |
| 3245 url, | 3237 url, |
| 3246 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 3238 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 3247 if (!same_domain_or_host || frame_url.scheme() != url.scheme()) { | 3239 if (!same_domain_or_host || frame_url.scheme() != url.scheme()) { |
| 3248 OpenURL(frame, url, referrer, default_policy); | 3240 OpenURL(info.frame, url, referrer, info.defaultPolicy); |
| 3249 return blink::WebNavigationPolicyIgnore; | 3241 return blink::WebNavigationPolicyIgnore; |
| 3250 } | 3242 } |
| 3251 } | 3243 } |
| 3252 | 3244 |
| 3253 // If the browser is interested, then give it a chance to look at the request. | 3245 // If the browser is interested, then give it a chance to look at the request. |
| 3254 if (is_content_initiated) { | 3246 if (is_content_initiated) { |
| 3255 bool is_form_post = ((type == blink::WebNavigationTypeFormSubmitted) || | 3247 bool is_form_post = |
| 3256 (type == blink::WebNavigationTypeFormResubmitted)) && | 3248 ((info.navigationType == blink::WebNavigationTypeFormSubmitted) || |
| 3257 EqualsASCII(request.httpMethod(), "POST"); | 3249 (info.navigationType == blink::WebNavigationTypeFormResubmitted)) && |
| 3250 EqualsASCII(info.urlRequest.httpMethod(), "POST"); | |
| 3258 bool browser_handles_request = | 3251 bool browser_handles_request = |
| 3259 render_view_->renderer_preferences_ | 3252 render_view_->renderer_preferences_ |
| 3260 .browser_handles_non_local_top_level_requests | 3253 .browser_handles_non_local_top_level_requests |
| 3261 && IsNonLocalTopLevelNavigation(url, frame, type, is_form_post); | 3254 && IsNonLocalTopLevelNavigation(url, info.frame, info.navigationType, |
| 3255 is_form_post); | |
| 3262 if (!browser_handles_request) { | 3256 if (!browser_handles_request) { |
| 3263 browser_handles_request = IsTopLevelNavigation(frame) && | 3257 browser_handles_request = IsTopLevelNavigation(info.frame) && |
| 3264 render_view_->renderer_preferences_ | 3258 render_view_->renderer_preferences_ |
| 3265 .browser_handles_all_top_level_requests; | 3259 .browser_handles_all_top_level_requests; |
| 3266 } | 3260 } |
| 3267 | 3261 |
| 3268 if (browser_handles_request) { | 3262 if (browser_handles_request) { |
| 3269 // Reset these counters as the RenderView could be reused for the next | 3263 // Reset these counters as the RenderView could be reused for the next |
| 3270 // navigation. | 3264 // navigation. |
| 3271 render_view_->page_id_ = -1; | 3265 render_view_->page_id_ = -1; |
| 3272 render_view_->last_page_id_sent_to_browser_ = -1; | 3266 render_view_->last_page_id_sent_to_browser_ = -1; |
| 3273 OpenURL(frame, url, referrer, default_policy); | 3267 OpenURL(info.frame, url, referrer, info.defaultPolicy); |
| 3274 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3268 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 3275 } | 3269 } |
| 3276 } | 3270 } |
| 3277 | 3271 |
| 3278 // Use the frame's original request's URL rather than the document's URL for | 3272 // Use the frame's original request's URL rather than the document's URL for |
| 3279 // subsequent checks. For a popup, the document's URL may become the opener | 3273 // subsequent checks. For a popup, the document's URL may become the opener |
| 3280 // window's URL if the opener has called document.write(). | 3274 // window's URL if the opener has called document.write(). |
| 3281 // See http://crbug.com/93517. | 3275 // See http://crbug.com/93517. |
| 3282 GURL old_url(frame->dataSource()->request().url()); | 3276 GURL old_url(info.frame->dataSource()->request().url()); |
| 3283 | 3277 |
| 3284 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 3278 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
| 3285 // an extension or app origin, leaving a WebUI page, etc). We only care about | 3279 // an extension or app origin, leaving a WebUI page, etc). We only care about |
| 3286 // top-level navigations (not iframes). But we sometimes navigate to | 3280 // top-level navigations (not iframes). But we sometimes navigate to |
| 3287 // about:blank to clear a tab, and we want to still allow that. | 3281 // about:blank to clear a tab, and we want to still allow that. |
| 3288 // | 3282 // |
| 3289 // Note: this is known to break POST submissions when crossing process | 3283 // Note: this is known to break POST submissions when crossing process |
| 3290 // boundaries until http://crbug.com/101395 is fixed. This is better for | 3284 // boundaries until http://crbug.com/101395 is fixed. This is better for |
| 3291 // security than loading a WebUI, extension or app page in the wrong process. | 3285 // security than loading a WebUI, extension or app page in the wrong process. |
| 3292 // POST requests don't work because this mechanism does not preserve form | 3286 // POST requests don't work because this mechanism does not preserve form |
| 3293 // POST data. We will need to send the request's httpBody data up to the | 3287 // POST data. We will need to send the request's httpBody data up to the |
| 3294 // browser process, and issue a special POST navigation in WebKit (via | 3288 // browser process, and issue a special POST navigation in WebKit (via |
| 3295 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl | 3289 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl |
| 3296 // for examples of how to send the httpBody data. | 3290 // for examples of how to send the httpBody data. |
| 3297 if (!frame->parent() && is_content_initiated && | 3291 if (!info.frame->parent() && is_content_initiated && |
| 3298 !url.SchemeIs(url::kAboutScheme)) { | 3292 !url.SchemeIs(url::kAboutScheme)) { |
| 3299 bool send_referrer = false; | 3293 bool send_referrer = false; |
| 3300 | 3294 |
| 3301 // All navigations to or from WebUI URLs or within WebUI-enabled | 3295 // All navigations to or from WebUI URLs or within WebUI-enabled |
| 3302 // RenderProcesses must be handled by the browser process so that the | 3296 // RenderProcesses must be handled by the browser process so that the |
| 3303 // correct bindings and data sources can be registered. | 3297 // correct bindings and data sources can be registered. |
| 3304 // Similarly, navigations to view-source URLs or within ViewSource mode | 3298 // Similarly, navigations to view-source URLs or within ViewSource mode |
| 3305 // must be handled by the browser process (except for reloads - those are | 3299 // must be handled by the browser process (except for reloads - those are |
| 3306 // safe to leave within the renderer). | 3300 // safe to leave within the renderer). |
| 3307 // Lastly, access to file:// URLs from non-file:// URL pages must be | 3301 // Lastly, access to file:// URLs from non-file:// URL pages must be |
| 3308 // handled by the browser so that ordinary renderer processes don't get | 3302 // handled by the browser so that ordinary renderer processes don't get |
| 3309 // blessed with file permissions. | 3303 // blessed with file permissions. |
| 3310 int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); | 3304 int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); |
| 3311 bool is_initial_navigation = render_view_->page_id_ == -1; | 3305 bool is_initial_navigation = render_view_->page_id_ == -1; |
| 3312 bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) || | 3306 bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) || |
| 3313 (cumulative_bindings & BINDINGS_POLICY_WEB_UI) || | 3307 (cumulative_bindings & BINDINGS_POLICY_WEB_UI) || |
| 3314 url.SchemeIs(kViewSourceScheme) || | 3308 url.SchemeIs(kViewSourceScheme) || |
| 3315 (frame->isViewSourceModeEnabled() && | 3309 (info.frame->isViewSourceModeEnabled() && |
| 3316 type != blink::WebNavigationTypeReload); | 3310 info.navigationType != blink::WebNavigationTypeReload); |
| 3317 | 3311 |
| 3318 if (!should_fork && url.SchemeIs(url::kFileScheme)) { | 3312 if (!should_fork && url.SchemeIs(url::kFileScheme)) { |
| 3319 // Fork non-file to file opens. Check the opener URL if this is the | 3313 // Fork non-file to file opens. Check the opener URL if this is the |
| 3320 // initial navigation in a newly opened window. | 3314 // initial navigation in a newly opened window. |
| 3321 GURL source_url(old_url); | 3315 GURL source_url(old_url); |
| 3322 if (is_initial_navigation && source_url.is_empty() && frame->opener()) | 3316 if (is_initial_navigation && source_url.is_empty() && |
| 3323 source_url = frame->opener()->top()->document().url(); | 3317 info.frame->opener()) |
| 3318 source_url = info.frame->opener()->top()->document().url(); | |
| 3324 DCHECK(!source_url.is_empty()); | 3319 DCHECK(!source_url.is_empty()); |
| 3325 should_fork = !source_url.SchemeIs(url::kFileScheme); | 3320 should_fork = !source_url.SchemeIs(url::kFileScheme); |
| 3326 } | 3321 } |
| 3327 | 3322 |
| 3328 if (!should_fork) { | 3323 if (!should_fork) { |
| 3329 // Give the embedder a chance. | 3324 // Give the embedder a chance. |
| 3330 should_fork = GetContentClient()->renderer()->ShouldFork( | 3325 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 3331 frame, url, request.httpMethod().utf8(), is_initial_navigation, | 3326 info.frame, url, info.urlRequest.httpMethod().utf8(), |
| 3332 is_redirect, &send_referrer); | 3327 is_initial_navigation, info.isRedirect, &send_referrer); |
| 3333 } | 3328 } |
| 3334 | 3329 |
| 3335 if (should_fork) { | 3330 if (should_fork) { |
| 3336 OpenURL( | 3331 OpenURL(info.frame, url, send_referrer ? referrer : Referrer(), |
| 3337 frame, url, send_referrer ? referrer : Referrer(), default_policy); | 3332 info.defaultPolicy); |
| 3338 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3333 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 3339 } | 3334 } |
| 3340 } | 3335 } |
| 3341 | 3336 |
| 3342 // Detect when a page is "forking" a new tab that can be safely rendered in | 3337 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 3343 // its own process. This is done by sites like Gmail that try to open links | 3338 // its own process. This is done by sites like Gmail that try to open links |
| 3344 // in new windows without script connections back to the original page. We | 3339 // in new windows without script connections back to the original page. We |
| 3345 // treat such cases as browser navigations (in which we will create a new | 3340 // treat such cases as browser navigations (in which we will create a new |
| 3346 // renderer for a cross-site navigation), rather than WebKit navigations. | 3341 // renderer for a cross-site navigation), rather than WebKit navigations. |
| 3347 // | 3342 // |
| 3348 // We use the following heuristic to decide whether to fork a new page in its | 3343 // We use the following heuristic to decide whether to fork a new page in its |
| 3349 // own process: | 3344 // own process: |
| 3350 // The parent page must open a new tab to about:blank, set the new tab's | 3345 // The parent page must open a new tab to about:blank, set the new tab's |
| 3351 // window.opener to null, and then redirect the tab to a cross-site URL using | 3346 // window.opener to null, and then redirect the tab to a cross-site URL using |
| 3352 // JavaScript. | 3347 // JavaScript. |
| 3353 // | 3348 // |
| 3354 // TODO(creis): Deprecate this logic once we can rely on rel=noreferrer | 3349 // TODO(creis): Deprecate this logic once we can rely on rel=noreferrer |
| 3355 // (see below). | 3350 // (see below). |
| 3356 bool is_fork = | 3351 bool is_fork = |
| 3357 // Must start from a tab showing about:blank, which is later redirected. | 3352 // Must start from a tab showing about:blank, which is later redirected. |
| 3358 old_url == GURL(url::kAboutBlankURL) && | 3353 old_url == GURL(url::kAboutBlankURL) && |
| 3359 // Must be the first real navigation of the tab. | 3354 // Must be the first real navigation of the tab. |
| 3360 render_view_->historyBackListCount() < 1 && | 3355 render_view_->historyBackListCount() < 1 && |
| 3361 render_view_->historyForwardListCount() < 1 && | 3356 render_view_->historyForwardListCount() < 1 && |
| 3362 // The parent page must have set the child's window.opener to null before | 3357 // The parent page must have set the child's window.opener to null before |
| 3363 // redirecting to the desired URL. | 3358 // redirecting to the desired URL. |
| 3364 frame->opener() == NULL && | 3359 info.frame->opener() == NULL && |
| 3365 // Must be a top-level frame. | 3360 // Must be a top-level frame. |
| 3366 frame->parent() == NULL && | 3361 info.frame->parent() == NULL && |
| 3367 // Must not have issued the request from this page. | 3362 // Must not have issued the request from this page. |
| 3368 is_content_initiated && | 3363 is_content_initiated && |
| 3369 // Must be targeted at the current tab. | 3364 // Must be targeted at the current tab. |
| 3370 default_policy == blink::WebNavigationPolicyCurrentTab && | 3365 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 3371 // Must be a JavaScript navigation, which appears as "other". | 3366 // Must be a JavaScript navigation, which appears as "other". |
| 3372 type == blink::WebNavigationTypeOther; | 3367 info.navigationType == blink::WebNavigationTypeOther; |
| 3373 | 3368 |
| 3374 if (is_fork) { | 3369 if (is_fork) { |
| 3375 // Open the URL via the browser, not via WebKit. | 3370 // Open the URL via the browser, not via WebKit. |
| 3376 OpenURL(frame, url, Referrer(), default_policy); | 3371 OpenURL(info.frame, url, Referrer(), info.defaultPolicy); |
| 3377 return blink::WebNavigationPolicyIgnore; | 3372 return blink::WebNavigationPolicyIgnore; |
| 3378 } | 3373 } |
| 3379 | 3374 |
| 3380 return default_policy; | 3375 return info.defaultPolicy; |
| 3381 } | 3376 } |
| 3382 | 3377 |
| 3383 void RenderFrameImpl::OpenURL(WebFrame* frame, | 3378 void RenderFrameImpl::OpenURL(WebFrame* frame, |
| 3384 const GURL& url, | 3379 const GURL& url, |
| 3385 const Referrer& referrer, | 3380 const Referrer& referrer, |
| 3386 WebNavigationPolicy policy) { | 3381 WebNavigationPolicy policy) { |
| 3387 DCHECK_EQ(frame_, frame); | 3382 DCHECK_EQ(frame_, frame); |
| 3388 | 3383 |
| 3389 FrameHostMsg_OpenURL_Params params; | 3384 FrameHostMsg_OpenURL_Params params; |
| 3390 params.url = url; | 3385 params.url = url; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3596 | 3591 |
| 3597 #if defined(ENABLE_BROWSER_CDMS) | 3592 #if defined(ENABLE_BROWSER_CDMS) |
| 3598 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3593 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 3599 if (!cdm_manager_) | 3594 if (!cdm_manager_) |
| 3600 cdm_manager_ = new RendererCdmManager(this); | 3595 cdm_manager_ = new RendererCdmManager(this); |
| 3601 return cdm_manager_; | 3596 return cdm_manager_; |
| 3602 } | 3597 } |
| 3603 #endif // defined(ENABLE_BROWSER_CDMS) | 3598 #endif // defined(ENABLE_BROWSER_CDMS) |
| 3604 | 3599 |
| 3605 } // namespace content | 3600 } // namespace content |
| OLD | NEW |