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 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); | 1637 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); |
1638 if (policy == blink::WebNavigationPolicyDownload) { | 1638 if (policy == blink::WebNavigationPolicyDownload) { |
1639 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 1639 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
1640 request.url(), referrer, | 1640 request.url(), referrer, |
1641 suggested_name, false)); | 1641 suggested_name, false)); |
1642 } else if (policy == blink::WebNavigationPolicyDownloadTo) { | 1642 } else if (policy == blink::WebNavigationPolicyDownloadTo) { |
1643 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 1643 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
1644 request.url(), referrer, | 1644 request.url(), referrer, |
1645 suggested_name, true)); | 1645 suggested_name, true)); |
1646 } else { | 1646 } else { |
1647 OpenURL(frame, request.url(), referrer, policy); | 1647 OpenURL(frame, request.url(), referrer, policy, false); |
1648 } | 1648 } |
1649 } | 1649 } |
1650 | 1650 |
1651 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( | 1651 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( |
1652 blink::WebLocalFrame* frame, | 1652 const NavigationPolicyInfo& info) { |
1653 blink::WebDataSource::ExtraData* extra_data, | 1653 DCHECK(!frame_ || frame_ == info.frame); |
1654 const blink::WebURLRequest& request, | |
1655 blink::WebNavigationType type, | |
1656 blink::WebNavigationPolicy default_policy, | |
1657 bool is_redirect) { | |
1658 DCHECK(!frame_ || frame_ == frame); | |
1659 return DecidePolicyForNavigation( | 1654 return DecidePolicyForNavigation( |
1660 this, frame, extra_data, request, type, default_policy, is_redirect); | 1655 this, info.frame, info.extraData, info.urlRequest, info.navigationType, |
| 1656 info.defaultPolicy, info.isRedirect, info.isTransitionNavigation); |
1661 } | 1657 } |
1662 | 1658 |
1663 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( | 1659 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( |
1664 blink::WebFrame* frame) { | 1660 blink::WebFrame* frame) { |
1665 DCHECK(!frame_ || frame_ == frame); | 1661 DCHECK(!frame_ || frame_ == frame); |
1666 return render_view_->history_controller()->GetItemForNewChildFrame(this); | 1662 return render_view_->history_controller()->GetItemForNewChildFrame(this); |
1667 } | 1663 } |
1668 | 1664 |
1669 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, | 1665 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, |
1670 const blink::WebFormElement& form) { | 1666 const blink::WebFormElement& form) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 render_view_->didCreateDataSource(frame, datasource); | 1707 render_view_->didCreateDataSource(frame, datasource); |
1712 | 1708 |
1713 // Create the serviceworker's per-document network observing object. | 1709 // Create the serviceworker's per-document network observing object. |
1714 scoped_ptr<ServiceWorkerNetworkProvider> | 1710 scoped_ptr<ServiceWorkerNetworkProvider> |
1715 network_provider(new ServiceWorkerNetworkProvider()); | 1711 network_provider(new ServiceWorkerNetworkProvider()); |
1716 ServiceWorkerNetworkProvider::AttachToDocumentState( | 1712 ServiceWorkerNetworkProvider::AttachToDocumentState( |
1717 DocumentState::FromDataSource(datasource), | 1713 DocumentState::FromDataSource(datasource), |
1718 network_provider.Pass()); | 1714 network_provider.Pass()); |
1719 } | 1715 } |
1720 | 1716 |
1721 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) { | 1717 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, |
| 1718 bool is_transition_navigation) { |
1722 DCHECK(!frame_ || frame_ == frame); | 1719 DCHECK(!frame_ || frame_ == frame); |
1723 WebDataSource* ds = frame->provisionalDataSource(); | 1720 WebDataSource* ds = frame->provisionalDataSource(); |
1724 | 1721 |
1725 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 1722 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
1726 // callback is invoked. | 1723 // callback is invoked. |
1727 if (!ds) | 1724 if (!ds) |
1728 return; | 1725 return; |
1729 | 1726 |
1730 DocumentState* document_state = DocumentState::FromDataSource(ds); | 1727 DocumentState* document_state = DocumentState::FromDataSource(ds); |
1731 | 1728 |
(...skipping 26 matching lines...) Expand all Loading... |
1758 PAGE_TRANSITION_AUTO_SUBFRAME); | 1755 PAGE_TRANSITION_AUTO_SUBFRAME); |
1759 } | 1756 } |
1760 | 1757 |
1761 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 1758 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
1762 DidStartProvisionalLoad(frame)); | 1759 DidStartProvisionalLoad(frame)); |
1763 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); | 1760 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); |
1764 | 1761 |
1765 int parent_routing_id = frame->parent() ? | 1762 int parent_routing_id = frame->parent() ? |
1766 FromWebFrame(frame->parent())->GetRoutingID() : -1; | 1763 FromWebFrame(frame->parent())->GetRoutingID() : -1; |
1767 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( | 1764 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( |
1768 routing_id_, parent_routing_id, ds->request().url())); | 1765 routing_id_, parent_routing_id, ds->request().url(), |
| 1766 is_transition_navigation)); |
1769 } | 1767 } |
1770 | 1768 |
1771 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 1769 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
1772 blink::WebLocalFrame* frame) { | 1770 blink::WebLocalFrame* frame) { |
1773 DCHECK(!frame_ || frame_ == frame); | 1771 DCHECK(!frame_ || frame_ == frame); |
1774 render_view_->history_controller()->RemoveChildrenForRedirect(this); | 1772 render_view_->history_controller()->RemoveChildrenForRedirect(this); |
1775 if (frame->parent()) | 1773 if (frame->parent()) |
1776 return; | 1774 return; |
1777 // Received a redirect on the main frame. | 1775 // Received a redirect on the main frame. |
1778 WebDataSource* data_source = frame->provisionalDataSource(); | 1776 WebDataSource* data_source = frame->provisionalDataSource(); |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3116 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); | 3114 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); |
3117 } | 3115 } |
3118 | 3116 |
3119 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( | 3117 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( |
3120 RenderFrame* render_frame, | 3118 RenderFrame* render_frame, |
3121 WebFrame* frame, | 3119 WebFrame* frame, |
3122 WebDataSource::ExtraData* extraData, | 3120 WebDataSource::ExtraData* extraData, |
3123 const WebURLRequest& request, | 3121 const WebURLRequest& request, |
3124 WebNavigationType type, | 3122 WebNavigationType type, |
3125 WebNavigationPolicy default_policy, | 3123 WebNavigationPolicy default_policy, |
3126 bool is_redirect) { | 3124 bool is_redirect, |
| 3125 bool is_transition_navigation) { |
3127 #ifdef OS_ANDROID | 3126 #ifdef OS_ANDROID |
3128 // The handlenavigation API is deprecated and will be removed once | 3127 // The handlenavigation API is deprecated and will be removed once |
3129 // crbug.com/325351 is resolved. | 3128 // crbug.com/325351 is resolved. |
3130 if (request.url() != GURL(kSwappedOutURL) && | 3129 if (request.url() != GURL(kSwappedOutURL) && |
3131 GetContentClient()->renderer()->HandleNavigation( | 3130 GetContentClient()->renderer()->HandleNavigation( |
3132 render_frame, | 3131 render_frame, |
3133 static_cast<DocumentState*>(extraData), | 3132 static_cast<DocumentState*>(extraData), |
3134 render_view_->opener_id_, | 3133 render_view_->opener_id_, |
3135 frame, | 3134 frame, |
3136 request, | 3135 request, |
3137 type, | 3136 type, |
3138 default_policy, | 3137 default_policy, |
3139 is_redirect)) { | 3138 is_redirect)) { |
3140 return blink::WebNavigationPolicyIgnore; | 3139 return blink::WebNavigationPolicyIgnore; |
3141 } | 3140 } |
3142 #endif | 3141 #endif |
3143 | 3142 |
3144 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); | 3143 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); |
3145 | 3144 |
3146 if (is_swapped_out_ || render_view_->is_swapped_out()) { | 3145 if (is_swapped_out_ || render_view_->is_swapped_out()) { |
3147 if (request.url() != GURL(kSwappedOutURL)) { | 3146 if (request.url() != GURL(kSwappedOutURL)) { |
3148 // Targeted links may try to navigate a swapped out frame. Allow the | 3147 // Targeted links may try to navigate a swapped out frame. Allow the |
3149 // browser process to navigate the tab instead. Note that it is also | 3148 // browser process to navigate the tab instead. Note that it is also |
3150 // possible for non-targeted navigations (from this view) to arrive | 3149 // possible for non-targeted navigations (from this view) to arrive |
3151 // here just after we are swapped out. It's ok to send them to the | 3150 // here just after we are swapped out. It's ok to send them to the |
3152 // browser, as long as they're for the top level frame. | 3151 // browser, as long as they're for the top level frame. |
3153 // TODO(creis): Ensure this supports targeted form submissions when | 3152 // TODO(creis): Ensure this supports targeted form submissions when |
3154 // fixing http://crbug.com/101395. | 3153 // fixing http://crbug.com/101395. |
3155 if (frame->parent() == NULL) { | 3154 if (frame->parent() == NULL) { |
3156 OpenURL(frame, request.url(), referrer, default_policy); | 3155 OpenURL(frame, request.url(), referrer, default_policy, |
| 3156 is_transition_navigation); |
3157 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3157 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
3158 } | 3158 } |
3159 | 3159 |
3160 // We should otherwise ignore in-process iframe navigations, if they | 3160 // We should otherwise ignore in-process iframe navigations, if they |
3161 // arrive just after we are swapped out. | 3161 // arrive just after we are swapped out. |
3162 return blink::WebNavigationPolicyIgnore; | 3162 return blink::WebNavigationPolicyIgnore; |
3163 } | 3163 } |
3164 | 3164 |
3165 // Allow kSwappedOutURL to complete. | 3165 // Allow kSwappedOutURL to complete. |
3166 return default_policy; | 3166 return default_policy; |
(...skipping 23 matching lines...) Expand all Loading... |
3190 WebString origin_str = frame->document().securityOrigin().toString(); | 3190 WebString origin_str = frame->document().securityOrigin().toString(); |
3191 GURL frame_url(origin_str.utf8().data()); | 3191 GURL frame_url(origin_str.utf8().data()); |
3192 // TODO(cevans): revisit whether this site check is still necessary once | 3192 // TODO(cevans): revisit whether this site check is still necessary once |
3193 // crbug.com/101395 is fixed. | 3193 // crbug.com/101395 is fixed. |
3194 bool same_domain_or_host = | 3194 bool same_domain_or_host = |
3195 net::registry_controlled_domains::SameDomainOrHost( | 3195 net::registry_controlled_domains::SameDomainOrHost( |
3196 frame_url, | 3196 frame_url, |
3197 url, | 3197 url, |
3198 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 3198 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
3199 if (!same_domain_or_host || frame_url.scheme() != url.scheme()) { | 3199 if (!same_domain_or_host || frame_url.scheme() != url.scheme()) { |
3200 OpenURL(frame, url, referrer, default_policy); | 3200 OpenURL(frame, url, referrer, default_policy, is_transition_navigation); |
3201 return blink::WebNavigationPolicyIgnore; | 3201 return blink::WebNavigationPolicyIgnore; |
3202 } | 3202 } |
3203 } | 3203 } |
3204 | 3204 |
3205 // If the browser is interested, then give it a chance to look at the request. | 3205 // If the browser is interested, then give it a chance to look at the request. |
3206 if (is_content_initiated) { | 3206 if (is_content_initiated) { |
3207 bool is_form_post = ((type == blink::WebNavigationTypeFormSubmitted) || | 3207 bool is_form_post = ((type == blink::WebNavigationTypeFormSubmitted) || |
3208 (type == blink::WebNavigationTypeFormResubmitted)) && | 3208 (type == blink::WebNavigationTypeFormResubmitted)) && |
3209 EqualsASCII(request.httpMethod(), "POST"); | 3209 EqualsASCII(request.httpMethod(), "POST"); |
3210 bool browser_handles_request = | 3210 bool browser_handles_request = |
3211 render_view_->renderer_preferences_ | 3211 render_view_->renderer_preferences_ |
3212 .browser_handles_non_local_top_level_requests | 3212 .browser_handles_non_local_top_level_requests |
3213 && IsNonLocalTopLevelNavigation(url, frame, type, is_form_post); | 3213 && IsNonLocalTopLevelNavigation(url, frame, type, is_form_post); |
3214 if (!browser_handles_request) { | 3214 if (!browser_handles_request) { |
3215 browser_handles_request = IsTopLevelNavigation(frame) && | 3215 browser_handles_request = IsTopLevelNavigation(frame) && |
3216 render_view_->renderer_preferences_ | 3216 render_view_->renderer_preferences_ |
3217 .browser_handles_all_top_level_requests; | 3217 .browser_handles_all_top_level_requests; |
3218 } | 3218 } |
3219 | 3219 |
3220 if (browser_handles_request) { | 3220 if (browser_handles_request) { |
3221 // Reset these counters as the RenderView could be reused for the next | 3221 // Reset these counters as the RenderView could be reused for the next |
3222 // navigation. | 3222 // navigation. |
3223 render_view_->page_id_ = -1; | 3223 render_view_->page_id_ = -1; |
3224 render_view_->last_page_id_sent_to_browser_ = -1; | 3224 render_view_->last_page_id_sent_to_browser_ = -1; |
3225 OpenURL(frame, url, referrer, default_policy); | 3225 OpenURL(frame, url, referrer, default_policy, is_transition_navigation); |
3226 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3226 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
3227 } | 3227 } |
3228 } | 3228 } |
3229 | 3229 |
3230 // Use the frame's original request's URL rather than the document's URL for | 3230 // Use the frame's original request's URL rather than the document's URL for |
3231 // subsequent checks. For a popup, the document's URL may become the opener | 3231 // subsequent checks. For a popup, the document's URL may become the opener |
3232 // window's URL if the opener has called document.write(). | 3232 // window's URL if the opener has called document.write(). |
3233 // See http://crbug.com/93517. | 3233 // See http://crbug.com/93517. |
3234 GURL old_url(frame->dataSource()->request().url()); | 3234 GURL old_url(frame->dataSource()->request().url()); |
3235 | 3235 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3279 | 3279 |
3280 if (!should_fork) { | 3280 if (!should_fork) { |
3281 // Give the embedder a chance. | 3281 // Give the embedder a chance. |
3282 should_fork = GetContentClient()->renderer()->ShouldFork( | 3282 should_fork = GetContentClient()->renderer()->ShouldFork( |
3283 frame, url, request.httpMethod().utf8(), is_initial_navigation, | 3283 frame, url, request.httpMethod().utf8(), is_initial_navigation, |
3284 is_redirect, &send_referrer); | 3284 is_redirect, &send_referrer); |
3285 } | 3285 } |
3286 | 3286 |
3287 if (should_fork) { | 3287 if (should_fork) { |
3288 OpenURL( | 3288 OpenURL( |
3289 frame, url, send_referrer ? referrer : Referrer(), default_policy); | 3289 frame, url, send_referrer ? referrer : Referrer(), default_policy, |
| 3290 is_transition_navigation); |
3290 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3291 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
3291 } | 3292 } |
3292 } | 3293 } |
3293 | 3294 |
3294 // Detect when a page is "forking" a new tab that can be safely rendered in | 3295 // Detect when a page is "forking" a new tab that can be safely rendered in |
3295 // its own process. This is done by sites like Gmail that try to open links | 3296 // its own process. This is done by sites like Gmail that try to open links |
3296 // in new windows without script connections back to the original page. We | 3297 // in new windows without script connections back to the original page. We |
3297 // treat such cases as browser navigations (in which we will create a new | 3298 // treat such cases as browser navigations (in which we will create a new |
3298 // renderer for a cross-site navigation), rather than WebKit navigations. | 3299 // renderer for a cross-site navigation), rather than WebKit navigations. |
3299 // | 3300 // |
(...skipping 18 matching lines...) Expand all Loading... |
3318 frame->parent() == NULL && | 3319 frame->parent() == NULL && |
3319 // Must not have issued the request from this page. | 3320 // Must not have issued the request from this page. |
3320 is_content_initiated && | 3321 is_content_initiated && |
3321 // Must be targeted at the current tab. | 3322 // Must be targeted at the current tab. |
3322 default_policy == blink::WebNavigationPolicyCurrentTab && | 3323 default_policy == blink::WebNavigationPolicyCurrentTab && |
3323 // Must be a JavaScript navigation, which appears as "other". | 3324 // Must be a JavaScript navigation, which appears as "other". |
3324 type == blink::WebNavigationTypeOther; | 3325 type == blink::WebNavigationTypeOther; |
3325 | 3326 |
3326 if (is_fork) { | 3327 if (is_fork) { |
3327 // Open the URL via the browser, not via WebKit. | 3328 // Open the URL via the browser, not via WebKit. |
3328 OpenURL(frame, url, Referrer(), default_policy); | 3329 OpenURL(frame, url, Referrer(), default_policy, is_transition_navigation); |
3329 return blink::WebNavigationPolicyIgnore; | 3330 return blink::WebNavigationPolicyIgnore; |
3330 } | 3331 } |
3331 | 3332 |
3332 return default_policy; | 3333 return default_policy; |
3333 } | 3334 } |
3334 | 3335 |
3335 void RenderFrameImpl::OpenURL(WebFrame* frame, | 3336 void RenderFrameImpl::OpenURL(WebFrame* frame, |
3336 const GURL& url, | 3337 const GURL& url, |
3337 const Referrer& referrer, | 3338 const Referrer& referrer, |
3338 WebNavigationPolicy policy) { | 3339 WebNavigationPolicy policy, |
| 3340 bool is_transition_navigation) { |
3339 DCHECK_EQ(frame_, frame); | 3341 DCHECK_EQ(frame_, frame); |
3340 | 3342 |
3341 FrameHostMsg_OpenURL_Params params; | 3343 FrameHostMsg_OpenURL_Params params; |
3342 params.url = url; | 3344 params.url = url; |
3343 params.referrer = referrer; | 3345 params.referrer = referrer; |
3344 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 3346 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
| 3347 params.is_transition_navigation = is_transition_navigation; |
3345 WebDataSource* ds = frame->provisionalDataSource(); | 3348 WebDataSource* ds = frame->provisionalDataSource(); |
3346 if (ds) { | 3349 if (ds) { |
3347 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3350 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3348 NavigationState* navigation_state = document_state->navigation_state(); | 3351 NavigationState* navigation_state = document_state->navigation_state(); |
3349 if (navigation_state->is_content_initiated()) { | 3352 if (navigation_state->is_content_initiated()) { |
3350 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 3353 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
3351 } else { | 3354 } else { |
3352 // This is necessary to preserve the should_replace_current_entry value on | 3355 // This is necessary to preserve the should_replace_current_entry value on |
3353 // cross-process redirects, in the event it was set by a previous process. | 3356 // cross-process redirects, in the event it was set by a previous process. |
3354 // | 3357 // |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3564 | 3567 |
3565 #if defined(ENABLE_BROWSER_CDMS) | 3568 #if defined(ENABLE_BROWSER_CDMS) |
3566 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3569 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
3567 if (!cdm_manager_) | 3570 if (!cdm_manager_) |
3568 cdm_manager_ = new RendererCdmManager(this); | 3571 cdm_manager_ = new RendererCdmManager(this); |
3569 return cdm_manager_; | 3572 return cdm_manager_; |
3570 } | 3573 } |
3571 #endif // defined(ENABLE_BROWSER_CDMS) | 3574 #endif // defined(ENABLE_BROWSER_CDMS) |
3572 | 3575 |
3573 } // namespace content | 3576 } // namespace content |
OLD | NEW |