| 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 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 } else if (policy == blink::WebNavigationPolicyDownloadTo) { | 1710 } else if (policy == blink::WebNavigationPolicyDownloadTo) { |
| 1711 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 1711 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
| 1712 request.url(), referrer, | 1712 request.url(), referrer, |
| 1713 suggested_name, true)); | 1713 suggested_name, true)); |
| 1714 } else { | 1714 } else { |
| 1715 OpenURL(frame, request.url(), referrer, policy); | 1715 OpenURL(frame, request.url(), referrer, policy); |
| 1716 } | 1716 } |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( | 1719 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( |
| 1720 blink::WebLocalFrame* frame, | 1720 const NavigationPolicyInfo& info) { |
| 1721 blink::WebDataSource::ExtraData* extra_data, | 1721 DCHECK(!frame_ || frame_ == info.frame); |
| 1722 const blink::WebURLRequest& request, | 1722 return DecidePolicyForNavigation(this, info); |
| 1723 blink::WebNavigationType type, | |
| 1724 blink::WebNavigationPolicy default_policy, | |
| 1725 bool is_redirect) { | |
| 1726 DCHECK(!frame_ || frame_ == frame); | |
| 1727 return DecidePolicyForNavigation( | |
| 1728 this, frame, extra_data, request, type, default_policy, is_redirect); | |
| 1729 } | 1723 } |
| 1730 | 1724 |
| 1731 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( | 1725 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( |
| 1732 blink::WebFrame* frame) { | 1726 blink::WebFrame* frame) { |
| 1733 DCHECK(!frame_ || frame_ == frame); | 1727 DCHECK(!frame_ || frame_ == frame); |
| 1734 return render_view_->history_controller()->GetItemForNewChildFrame(this); | 1728 return render_view_->history_controller()->GetItemForNewChildFrame(this); |
| 1735 } | 1729 } |
| 1736 | 1730 |
| 1737 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, | 1731 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, |
| 1738 const blink::WebFormElement& form) { | 1732 const blink::WebFormElement& form) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 render_view_->didCreateDataSource(frame, datasource); | 1773 render_view_->didCreateDataSource(frame, datasource); |
| 1780 | 1774 |
| 1781 // Create the serviceworker's per-document network observing object. | 1775 // Create the serviceworker's per-document network observing object. |
| 1782 scoped_ptr<ServiceWorkerNetworkProvider> | 1776 scoped_ptr<ServiceWorkerNetworkProvider> |
| 1783 network_provider(new ServiceWorkerNetworkProvider()); | 1777 network_provider(new ServiceWorkerNetworkProvider()); |
| 1784 ServiceWorkerNetworkProvider::AttachToDocumentState( | 1778 ServiceWorkerNetworkProvider::AttachToDocumentState( |
| 1785 DocumentState::FromDataSource(datasource), | 1779 DocumentState::FromDataSource(datasource), |
| 1786 network_provider.Pass()); | 1780 network_provider.Pass()); |
| 1787 } | 1781 } |
| 1788 | 1782 |
| 1789 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) { | 1783 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, |
| 1784 bool is_transition_navigation) { |
| 1790 DCHECK(!frame_ || frame_ == frame); | 1785 DCHECK(!frame_ || frame_ == frame); |
| 1791 WebDataSource* ds = frame->provisionalDataSource(); | 1786 WebDataSource* ds = frame->provisionalDataSource(); |
| 1792 | 1787 |
| 1793 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 1788 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
| 1794 // callback is invoked. | 1789 // callback is invoked. |
| 1795 if (!ds) | 1790 if (!ds) |
| 1796 return; | 1791 return; |
| 1797 | 1792 |
| 1798 DocumentState* document_state = DocumentState::FromDataSource(ds); | 1793 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 1799 | 1794 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1823 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we | 1818 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we |
| 1824 // handle loading of error pages. | 1819 // handle loading of error pages. |
| 1825 document_state->navigation_state()->set_transition_type( | 1820 document_state->navigation_state()->set_transition_type( |
| 1826 PAGE_TRANSITION_AUTO_SUBFRAME); | 1821 PAGE_TRANSITION_AUTO_SUBFRAME); |
| 1827 } | 1822 } |
| 1828 | 1823 |
| 1829 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 1824 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 1830 DidStartProvisionalLoad(frame)); | 1825 DidStartProvisionalLoad(frame)); |
| 1831 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); | 1826 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); |
| 1832 | 1827 |
| 1833 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(routing_id_, | 1828 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( |
| 1834 ds->request().url())); | 1829 routing_id_, ds->request().url(), is_transition_navigation)); |
| 1835 } | 1830 } |
| 1836 | 1831 |
| 1837 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 1832 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
| 1838 blink::WebLocalFrame* frame) { | 1833 blink::WebLocalFrame* frame) { |
| 1839 DCHECK(!frame_ || frame_ == frame); | 1834 DCHECK(!frame_ || frame_ == frame); |
| 1840 render_view_->history_controller()->RemoveChildrenForRedirect(this); | 1835 render_view_->history_controller()->RemoveChildrenForRedirect(this); |
| 1841 if (frame->parent()) | 1836 if (frame->parent()) |
| 1842 return; | 1837 return; |
| 1843 // Received a redirect on the main frame. | 1838 // Received a redirect on the main frame. |
| 1844 WebDataSource* data_source = frame->provisionalDataSource(); | 1839 WebDataSource* data_source = frame->provisionalDataSource(); |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3188 renderer_accessibility_->HandleWebAccessibilityEvent(obj, event); | 3183 renderer_accessibility_->HandleWebAccessibilityEvent(obj, event); |
| 3189 } | 3184 } |
| 3190 | 3185 |
| 3191 void RenderFrameImpl::FocusedNodeChanged(const WebNode& node) { | 3186 void RenderFrameImpl::FocusedNodeChanged(const WebNode& node) { |
| 3192 if (renderer_accessibility_) | 3187 if (renderer_accessibility_) |
| 3193 renderer_accessibility_->FocusedNodeChanged(node); | 3188 renderer_accessibility_->FocusedNodeChanged(node); |
| 3194 } | 3189 } |
| 3195 | 3190 |
| 3196 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( | 3191 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( |
| 3197 RenderFrame* render_frame, | 3192 RenderFrame* render_frame, |
| 3198 WebFrame* frame, | 3193 const NavigationPolicyInfo& info) { |
| 3199 WebDataSource::ExtraData* extraData, | |
| 3200 const WebURLRequest& request, | |
| 3201 WebNavigationType type, | |
| 3202 WebNavigationPolicy default_policy, | |
| 3203 bool is_redirect) { | |
| 3204 #ifdef OS_ANDROID | 3194 #ifdef OS_ANDROID |
| 3205 // The handlenavigation API is deprecated and will be removed once | 3195 // The handlenavigation API is deprecated and will be removed once |
| 3206 // crbug.com/325351 is resolved. | 3196 // crbug.com/325351 is resolved. |
| 3207 if (request.url() != GURL(kSwappedOutURL) && | 3197 if (info.urlRequest.url() != GURL(kSwappedOutURL) && |
| 3208 GetContentClient()->renderer()->HandleNavigation( | 3198 GetContentClient()->renderer()->HandleNavigation( |
| 3209 render_frame, | 3199 render_frame, |
| 3210 static_cast<DocumentState*>(extraData), | 3200 static_cast<DocumentState*>(info.extraData), |
| 3211 render_view_->opener_id_, | 3201 render_view_->opener_id_, |
| 3212 frame, | 3202 info.frame, |
| 3213 request, | 3203 info.urlRequest, |
| 3214 type, | 3204 info.navigationType, |
| 3215 default_policy, | 3205 info.defaultPolicy, |
| 3216 is_redirect)) { | 3206 info.isRedirect)) { |
| 3217 return blink::WebNavigationPolicyIgnore; | 3207 return blink::WebNavigationPolicyIgnore; |
| 3218 } | 3208 } |
| 3219 #endif | 3209 #endif |
| 3220 | 3210 |
| 3221 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); | 3211 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(info.frame, |
| 3212 info.urlRequest)); |
| 3222 | 3213 |
| 3223 if (is_swapped_out_ || render_view_->is_swapped_out()) { | 3214 if (is_swapped_out_ || render_view_->is_swapped_out()) { |
| 3224 if (request.url() != GURL(kSwappedOutURL)) { | 3215 if (info.urlRequest.url() != GURL(kSwappedOutURL)) { |
| 3225 // Targeted links may try to navigate a swapped out frame. Allow the | 3216 // Targeted links may try to navigate a swapped out frame. Allow the |
| 3226 // browser process to navigate the tab instead. Note that it is also | 3217 // browser process to navigate the tab instead. Note that it is also |
| 3227 // possible for non-targeted navigations (from this view) to arrive | 3218 // possible for non-targeted navigations (from this view) to arrive |
| 3228 // here just after we are swapped out. It's ok to send them to the | 3219 // here just after we are swapped out. It's ok to send them to the |
| 3229 // browser, as long as they're for the top level frame. | 3220 // browser, as long as they're for the top level frame. |
| 3230 // TODO(creis): Ensure this supports targeted form submissions when | 3221 // TODO(creis): Ensure this supports targeted form submissions when |
| 3231 // fixing http://crbug.com/101395. | 3222 // fixing http://crbug.com/101395. |
| 3232 if (frame->parent() == NULL) { | 3223 if (info.frame->parent() == NULL) { |
| 3233 OpenURL(frame, request.url(), referrer, default_policy); | 3224 OpenURL(info.frame, info.urlRequest.url(), referrer, |
| 3225 info.defaultPolicy); |
| 3234 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3226 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 3235 } | 3227 } |
| 3236 | 3228 |
| 3237 // We should otherwise ignore in-process iframe navigations, if they | 3229 // We should otherwise ignore in-process iframe navigations, if they |
| 3238 // arrive just after we are swapped out. | 3230 // arrive just after we are swapped out. |
| 3239 return blink::WebNavigationPolicyIgnore; | 3231 return blink::WebNavigationPolicyIgnore; |
| 3240 } | 3232 } |
| 3241 | 3233 |
| 3242 // Allow kSwappedOutURL to complete. | 3234 // Allow kSwappedOutURL to complete. |
| 3243 return default_policy; | 3235 return info.defaultPolicy; |
| 3244 } | 3236 } |
| 3245 | 3237 |
| 3246 // Webkit is asking whether to navigate to a new URL. | 3238 // Webkit is asking whether to navigate to a new URL. |
| 3247 // This is fine normally, except if we're showing UI from one security | 3239 // This is fine normally, except if we're showing UI from one security |
| 3248 // context and they're trying to navigate to a different context. | 3240 // context and they're trying to navigate to a different context. |
| 3249 const GURL& url = request.url(); | 3241 const GURL& url = info.urlRequest.url(); |
| 3250 | 3242 |
| 3251 // A content initiated navigation may have originated from a link-click, | 3243 // A content initiated navigation may have originated from a link-click, |
| 3252 // script, drag-n-drop operation, etc. | 3244 // script, drag-n-drop operation, etc. |
| 3253 bool is_content_initiated = static_cast<DocumentState*>(extraData)-> | 3245 bool is_content_initiated = static_cast<DocumentState*>(info.extraData)-> |
| 3254 navigation_state()->is_content_initiated(); | 3246 navigation_state()->is_content_initiated(); |
| 3255 | 3247 |
| 3256 // Experimental: | 3248 // Experimental: |
| 3257 // If --enable-strict-site-isolation or --site-per-process is enabled, send | 3249 // If --enable-strict-site-isolation or --site-per-process is enabled, send |
| 3258 // all top-level navigations to the browser to let it swap processes when | 3250 // all top-level navigations to the browser to let it swap processes when |
| 3259 // crossing site boundaries. This is currently expected to break some script | 3251 // crossing site boundaries. This is currently expected to break some script |
| 3260 // calls and navigations, such as form submissions. | 3252 // calls and navigations, such as form submissions. |
| 3261 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 3253 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 3262 bool force_swap_due_to_flag = | 3254 bool force_swap_due_to_flag = |
| 3263 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || | 3255 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || |
| 3264 command_line.HasSwitch(switches::kSitePerProcess); | 3256 command_line.HasSwitch(switches::kSitePerProcess); |
| 3265 if (force_swap_due_to_flag && | 3257 if (force_swap_due_to_flag && |
| 3266 !frame->parent() && (is_content_initiated || is_redirect)) { | 3258 !info.frame->parent() && (is_content_initiated || info.isRedirect)) { |
| 3267 WebString origin_str = frame->document().securityOrigin().toString(); | 3259 WebString origin_str = info.frame->document().securityOrigin().toString(); |
| 3268 GURL frame_url(origin_str.utf8().data()); | 3260 GURL frame_url(origin_str.utf8().data()); |
| 3269 // TODO(cevans): revisit whether this site check is still necessary once | 3261 // TODO(cevans): revisit whether this site check is still necessary once |
| 3270 // crbug.com/101395 is fixed. | 3262 // crbug.com/101395 is fixed. |
| 3271 bool same_domain_or_host = | 3263 bool same_domain_or_host = |
| 3272 net::registry_controlled_domains::SameDomainOrHost( | 3264 net::registry_controlled_domains::SameDomainOrHost( |
| 3273 frame_url, | 3265 frame_url, |
| 3274 url, | 3266 url, |
| 3275 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 3267 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 3276 if (!same_domain_or_host || frame_url.scheme() != url.scheme()) { | 3268 if (!same_domain_or_host || frame_url.scheme() != url.scheme()) { |
| 3277 OpenURL(frame, url, referrer, default_policy); | 3269 OpenURL(info.frame, url, referrer, info.defaultPolicy); |
| 3278 return blink::WebNavigationPolicyIgnore; | 3270 return blink::WebNavigationPolicyIgnore; |
| 3279 } | 3271 } |
| 3280 } | 3272 } |
| 3281 | 3273 |
| 3282 // If the browser is interested, then give it a chance to look at the request. | 3274 // If the browser is interested, then give it a chance to look at the request. |
| 3283 if (is_content_initiated) { | 3275 if (is_content_initiated) { |
| 3284 bool is_form_post = ((type == blink::WebNavigationTypeFormSubmitted) || | 3276 bool is_form_post = |
| 3285 (type == blink::WebNavigationTypeFormResubmitted)) && | 3277 ((info.navigationType == blink::WebNavigationTypeFormSubmitted) || |
| 3286 EqualsASCII(request.httpMethod(), "POST"); | 3278 (info.navigationType == blink::WebNavigationTypeFormResubmitted)) && |
| 3279 EqualsASCII(info.urlRequest.httpMethod(), "POST"); |
| 3287 bool browser_handles_request = | 3280 bool browser_handles_request = |
| 3288 render_view_->renderer_preferences_ | 3281 render_view_->renderer_preferences_ |
| 3289 .browser_handles_non_local_top_level_requests | 3282 .browser_handles_non_local_top_level_requests |
| 3290 && IsNonLocalTopLevelNavigation(url, frame, type, is_form_post); | 3283 && IsNonLocalTopLevelNavigation(url, info.frame, info.navigationType, |
| 3284 is_form_post); |
| 3291 if (!browser_handles_request) { | 3285 if (!browser_handles_request) { |
| 3292 browser_handles_request = IsTopLevelNavigation(frame) && | 3286 browser_handles_request = IsTopLevelNavigation(info.frame) && |
| 3293 render_view_->renderer_preferences_ | 3287 render_view_->renderer_preferences_ |
| 3294 .browser_handles_all_top_level_requests; | 3288 .browser_handles_all_top_level_requests; |
| 3295 } | 3289 } |
| 3296 | 3290 |
| 3297 if (browser_handles_request) { | 3291 if (browser_handles_request) { |
| 3298 // Reset these counters as the RenderView could be reused for the next | 3292 // Reset these counters as the RenderView could be reused for the next |
| 3299 // navigation. | 3293 // navigation. |
| 3300 render_view_->page_id_ = -1; | 3294 render_view_->page_id_ = -1; |
| 3301 render_view_->last_page_id_sent_to_browser_ = -1; | 3295 render_view_->last_page_id_sent_to_browser_ = -1; |
| 3302 OpenURL(frame, url, referrer, default_policy); | 3296 OpenURL(info.frame, url, referrer, info.defaultPolicy); |
| 3303 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3297 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 3304 } | 3298 } |
| 3305 } | 3299 } |
| 3306 | 3300 |
| 3307 // Use the frame's original request's URL rather than the document's URL for | 3301 // Use the frame's original request's URL rather than the document's URL for |
| 3308 // subsequent checks. For a popup, the document's URL may become the opener | 3302 // subsequent checks. For a popup, the document's URL may become the opener |
| 3309 // window's URL if the opener has called document.write(). | 3303 // window's URL if the opener has called document.write(). |
| 3310 // See http://crbug.com/93517. | 3304 // See http://crbug.com/93517. |
| 3311 GURL old_url(frame->dataSource()->request().url()); | 3305 GURL old_url(info.frame->dataSource()->request().url()); |
| 3312 | 3306 |
| 3313 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 3307 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
| 3314 // an extension or app origin, leaving a WebUI page, etc). We only care about | 3308 // an extension or app origin, leaving a WebUI page, etc). We only care about |
| 3315 // top-level navigations (not iframes). But we sometimes navigate to | 3309 // top-level navigations (not iframes). But we sometimes navigate to |
| 3316 // about:blank to clear a tab, and we want to still allow that. | 3310 // about:blank to clear a tab, and we want to still allow that. |
| 3317 // | 3311 // |
| 3318 // Note: this is known to break POST submissions when crossing process | 3312 // Note: this is known to break POST submissions when crossing process |
| 3319 // boundaries until http://crbug.com/101395 is fixed. This is better for | 3313 // boundaries until http://crbug.com/101395 is fixed. This is better for |
| 3320 // security than loading a WebUI, extension or app page in the wrong process. | 3314 // security than loading a WebUI, extension or app page in the wrong process. |
| 3321 // POST requests don't work because this mechanism does not preserve form | 3315 // POST requests don't work because this mechanism does not preserve form |
| 3322 // POST data. We will need to send the request's httpBody data up to the | 3316 // POST data. We will need to send the request's httpBody data up to the |
| 3323 // browser process, and issue a special POST navigation in WebKit (via | 3317 // browser process, and issue a special POST navigation in WebKit (via |
| 3324 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl | 3318 // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl |
| 3325 // for examples of how to send the httpBody data. | 3319 // for examples of how to send the httpBody data. |
| 3326 if (!frame->parent() && is_content_initiated && | 3320 if (!info.frame->parent() && is_content_initiated && |
| 3327 !url.SchemeIs(url::kAboutScheme)) { | 3321 !url.SchemeIs(url::kAboutScheme)) { |
| 3328 bool send_referrer = false; | 3322 bool send_referrer = false; |
| 3329 | 3323 |
| 3330 // All navigations to or from WebUI URLs or within WebUI-enabled | 3324 // All navigations to or from WebUI URLs or within WebUI-enabled |
| 3331 // RenderProcesses must be handled by the browser process so that the | 3325 // RenderProcesses must be handled by the browser process so that the |
| 3332 // correct bindings and data sources can be registered. | 3326 // correct bindings and data sources can be registered. |
| 3333 // Similarly, navigations to view-source URLs or within ViewSource mode | 3327 // Similarly, navigations to view-source URLs or within ViewSource mode |
| 3334 // must be handled by the browser process (except for reloads - those are | 3328 // must be handled by the browser process (except for reloads - those are |
| 3335 // safe to leave within the renderer). | 3329 // safe to leave within the renderer). |
| 3336 // Lastly, access to file:// URLs from non-file:// URL pages must be | 3330 // Lastly, access to file:// URLs from non-file:// URL pages must be |
| 3337 // handled by the browser so that ordinary renderer processes don't get | 3331 // handled by the browser so that ordinary renderer processes don't get |
| 3338 // blessed with file permissions. | 3332 // blessed with file permissions. |
| 3339 int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); | 3333 int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); |
| 3340 bool is_initial_navigation = render_view_->page_id_ == -1; | 3334 bool is_initial_navigation = render_view_->page_id_ == -1; |
| 3341 bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) || | 3335 bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) || |
| 3342 (cumulative_bindings & BINDINGS_POLICY_WEB_UI) || | 3336 (cumulative_bindings & BINDINGS_POLICY_WEB_UI) || |
| 3343 url.SchemeIs(kViewSourceScheme) || | 3337 url.SchemeIs(kViewSourceScheme) || |
| 3344 (frame->isViewSourceModeEnabled() && | 3338 (info.frame->isViewSourceModeEnabled() && |
| 3345 type != blink::WebNavigationTypeReload); | 3339 info.navigationType != blink::WebNavigationTypeReload); |
| 3346 | 3340 |
| 3347 if (!should_fork && url.SchemeIs(url::kFileScheme)) { | 3341 if (!should_fork && url.SchemeIs(url::kFileScheme)) { |
| 3348 // Fork non-file to file opens. Check the opener URL if this is the | 3342 // Fork non-file to file opens. Check the opener URL if this is the |
| 3349 // initial navigation in a newly opened window. | 3343 // initial navigation in a newly opened window. |
| 3350 GURL source_url(old_url); | 3344 GURL source_url(old_url); |
| 3351 if (is_initial_navigation && source_url.is_empty() && frame->opener()) | 3345 if (is_initial_navigation && source_url.is_empty() && |
| 3352 source_url = frame->opener()->top()->document().url(); | 3346 info.frame->opener()) |
| 3347 source_url = info.frame->opener()->top()->document().url(); |
| 3353 DCHECK(!source_url.is_empty()); | 3348 DCHECK(!source_url.is_empty()); |
| 3354 should_fork = !source_url.SchemeIs(url::kFileScheme); | 3349 should_fork = !source_url.SchemeIs(url::kFileScheme); |
| 3355 } | 3350 } |
| 3356 | 3351 |
| 3357 if (!should_fork) { | 3352 if (!should_fork) { |
| 3358 // Give the embedder a chance. | 3353 // Give the embedder a chance. |
| 3359 should_fork = GetContentClient()->renderer()->ShouldFork( | 3354 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 3360 frame, url, request.httpMethod().utf8(), is_initial_navigation, | 3355 info.frame, url, info.urlRequest.httpMethod().utf8(), |
| 3361 is_redirect, &send_referrer); | 3356 is_initial_navigation, info.isRedirect, &send_referrer); |
| 3362 } | 3357 } |
| 3363 | 3358 |
| 3364 if (should_fork) { | 3359 if (should_fork) { |
| 3365 OpenURL( | 3360 OpenURL(info.frame, url, send_referrer ? referrer : Referrer(), |
| 3366 frame, url, send_referrer ? referrer : Referrer(), default_policy); | 3361 info.defaultPolicy); |
| 3367 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3362 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 3368 } | 3363 } |
| 3369 } | 3364 } |
| 3370 | 3365 |
| 3371 // Detect when a page is "forking" a new tab that can be safely rendered in | 3366 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 3372 // its own process. This is done by sites like Gmail that try to open links | 3367 // its own process. This is done by sites like Gmail that try to open links |
| 3373 // in new windows without script connections back to the original page. We | 3368 // in new windows without script connections back to the original page. We |
| 3374 // treat such cases as browser navigations (in which we will create a new | 3369 // treat such cases as browser navigations (in which we will create a new |
| 3375 // renderer for a cross-site navigation), rather than WebKit navigations. | 3370 // renderer for a cross-site navigation), rather than WebKit navigations. |
| 3376 // | 3371 // |
| 3377 // We use the following heuristic to decide whether to fork a new page in its | 3372 // We use the following heuristic to decide whether to fork a new page in its |
| 3378 // own process: | 3373 // own process: |
| 3379 // The parent page must open a new tab to about:blank, set the new tab's | 3374 // The parent page must open a new tab to about:blank, set the new tab's |
| 3380 // window.opener to null, and then redirect the tab to a cross-site URL using | 3375 // window.opener to null, and then redirect the tab to a cross-site URL using |
| 3381 // JavaScript. | 3376 // JavaScript. |
| 3382 // | 3377 // |
| 3383 // TODO(creis): Deprecate this logic once we can rely on rel=noreferrer | 3378 // TODO(creis): Deprecate this logic once we can rely on rel=noreferrer |
| 3384 // (see below). | 3379 // (see below). |
| 3385 bool is_fork = | 3380 bool is_fork = |
| 3386 // Must start from a tab showing about:blank, which is later redirected. | 3381 // Must start from a tab showing about:blank, which is later redirected. |
| 3387 old_url == GURL(url::kAboutBlankURL) && | 3382 old_url == GURL(url::kAboutBlankURL) && |
| 3388 // Must be the first real navigation of the tab. | 3383 // Must be the first real navigation of the tab. |
| 3389 render_view_->historyBackListCount() < 1 && | 3384 render_view_->historyBackListCount() < 1 && |
| 3390 render_view_->historyForwardListCount() < 1 && | 3385 render_view_->historyForwardListCount() < 1 && |
| 3391 // The parent page must have set the child's window.opener to null before | 3386 // The parent page must have set the child's window.opener to null before |
| 3392 // redirecting to the desired URL. | 3387 // redirecting to the desired URL. |
| 3393 frame->opener() == NULL && | 3388 info.frame->opener() == NULL && |
| 3394 // Must be a top-level frame. | 3389 // Must be a top-level frame. |
| 3395 frame->parent() == NULL && | 3390 info.frame->parent() == NULL && |
| 3396 // Must not have issued the request from this page. | 3391 // Must not have issued the request from this page. |
| 3397 is_content_initiated && | 3392 is_content_initiated && |
| 3398 // Must be targeted at the current tab. | 3393 // Must be targeted at the current tab. |
| 3399 default_policy == blink::WebNavigationPolicyCurrentTab && | 3394 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 3400 // Must be a JavaScript navigation, which appears as "other". | 3395 // Must be a JavaScript navigation, which appears as "other". |
| 3401 type == blink::WebNavigationTypeOther; | 3396 info.navigationType == blink::WebNavigationTypeOther; |
| 3402 | 3397 |
| 3403 if (is_fork) { | 3398 if (is_fork) { |
| 3404 // Open the URL via the browser, not via WebKit. | 3399 // Open the URL via the browser, not via WebKit. |
| 3405 OpenURL(frame, url, Referrer(), default_policy); | 3400 OpenURL(info.frame, url, Referrer(), info.defaultPolicy); |
| 3406 return blink::WebNavigationPolicyIgnore; | 3401 return blink::WebNavigationPolicyIgnore; |
| 3407 } | 3402 } |
| 3408 | 3403 |
| 3409 return default_policy; | 3404 return info.defaultPolicy; |
| 3410 } | 3405 } |
| 3411 | 3406 |
| 3412 void RenderFrameImpl::OpenURL(WebFrame* frame, | 3407 void RenderFrameImpl::OpenURL(WebFrame* frame, |
| 3413 const GURL& url, | 3408 const GURL& url, |
| 3414 const Referrer& referrer, | 3409 const Referrer& referrer, |
| 3415 WebNavigationPolicy policy) { | 3410 WebNavigationPolicy policy) { |
| 3416 DCHECK_EQ(frame_, frame); | 3411 DCHECK_EQ(frame_, frame); |
| 3417 | 3412 |
| 3418 FrameHostMsg_OpenURL_Params params; | 3413 FrameHostMsg_OpenURL_Params params; |
| 3419 params.url = url; | 3414 params.url = url; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3625 | 3620 |
| 3626 #if defined(ENABLE_BROWSER_CDMS) | 3621 #if defined(ENABLE_BROWSER_CDMS) |
| 3627 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3622 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 3628 if (!cdm_manager_) | 3623 if (!cdm_manager_) |
| 3629 cdm_manager_ = new RendererCdmManager(this); | 3624 cdm_manager_ = new RendererCdmManager(this); |
| 3630 return cdm_manager_; | 3625 return cdm_manager_; |
| 3631 } | 3626 } |
| 3632 #endif // defined(ENABLE_BROWSER_CDMS) | 3627 #endif // defined(ENABLE_BROWSER_CDMS) |
| 3633 | 3628 |
| 3634 } // namespace content | 3629 } // namespace content |
| OLD | NEW |