| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 using blink::WebFrameLoadType; | 295 using blink::WebFrameLoadType; |
| 296 using blink::WebFrameSerializer; | 296 using blink::WebFrameSerializer; |
| 297 using blink::WebFrameSerializerClient; | 297 using blink::WebFrameSerializerClient; |
| 298 using blink::WebHistoryItem; | 298 using blink::WebHistoryItem; |
| 299 using blink::WebHTTPBody; | 299 using blink::WebHTTPBody; |
| 300 using blink::WebLocalFrame; | 300 using blink::WebLocalFrame; |
| 301 using blink::WebMediaPlayer; | 301 using blink::WebMediaPlayer; |
| 302 using blink::WebMediaPlayerClient; | 302 using blink::WebMediaPlayerClient; |
| 303 using blink::WebMediaPlayerEncryptedMediaClient; | 303 using blink::WebMediaPlayerEncryptedMediaClient; |
| 304 using blink::WebNavigationPolicy; | 304 using blink::WebNavigationPolicy; |
| 305 using blink::WebNavigationType; | |
| 306 using blink::WebNode; | 305 using blink::WebNode; |
| 307 using blink::WebPluginDocument; | 306 using blink::WebPluginDocument; |
| 308 using blink::WebPluginParams; | 307 using blink::WebPluginParams; |
| 309 using blink::WebPoint; | 308 using blink::WebPoint; |
| 310 using blink::WebPopupMenuInfo; | 309 using blink::WebPopupMenuInfo; |
| 311 using blink::WebRange; | 310 using blink::WebRange; |
| 312 using blink::WebRect; | 311 using blink::WebRect; |
| 313 using blink::WebReferrerPolicy; | 312 using blink::WebReferrerPolicy; |
| 314 using blink::WebScriptSource; | 313 using blink::WebScriptSource; |
| 315 using blink::WebSearchableFormData; | 314 using blink::WebSearchableFormData; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 // version supported by blink. It will be passed back to the renderer in the | 625 // version supported by blink. It will be passed back to the renderer in the |
| 627 // CommitNavigation IPC, and then back to the browser again in the | 626 // CommitNavigation IPC, and then back to the browser again in the |
| 628 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. | 627 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. |
| 629 base::TimeTicks ui_timestamp = | 628 base::TimeTicks ui_timestamp = |
| 630 base::TimeTicks() + | 629 base::TimeTicks() + |
| 631 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime()); | 630 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime()); |
| 632 FrameMsg_UILoadMetricsReportType::Value report_type = | 631 FrameMsg_UILoadMetricsReportType::Value report_type = |
| 633 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 632 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
| 634 info.urlRequest.inputPerfMetricReportPolicy()); | 633 info.urlRequest.inputPerfMetricReportPolicy()); |
| 635 | 634 |
| 635 bool is_reload = info.loadType == WebFrameLoadType::Reload || |
| 636 info.loadType == WebFrameLoadType::ReloadMainResource || |
| 637 info.loadType == WebFrameLoadType::ReloadBypassingCache; |
| 636 FrameMsg_Navigate_Type::Value navigation_type = | 638 FrameMsg_Navigate_Type::Value navigation_type = |
| 637 info.navigationType == blink::WebNavigationTypeReload | 639 is_reload ? FrameMsg_Navigate_Type::RELOAD |
| 638 ? FrameMsg_Navigate_Type::RELOAD | 640 : FrameMsg_Navigate_Type::NORMAL; |
| 639 : FrameMsg_Navigate_Type::NORMAL; | |
| 640 | 641 |
| 641 const RequestExtraData* extra_data = | 642 const RequestExtraData* extra_data = |
| 642 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); | 643 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
| 643 DCHECK(extra_data); | 644 DCHECK(extra_data); |
| 644 return CommonNavigationParams( | 645 return CommonNavigationParams( |
| 645 info.urlRequest.url(), referrer, extra_data->transition_type(), | 646 info.urlRequest.url(), referrer, extra_data->transition_type(), |
| 646 navigation_type, true, info.replacesCurrentHistoryItem, ui_timestamp, | 647 navigation_type, true, |
| 648 info.loadType == WebFrameLoadType::ReplaceCurrentItem, ui_timestamp, |
| 647 report_type, GURL(), GURL(), | 649 report_type, GURL(), GURL(), |
| 648 static_cast<PreviewsState>(info.urlRequest.getPreviewsState()), | 650 static_cast<PreviewsState>(info.urlRequest.getPreviewsState()), |
| 649 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), | 651 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), |
| 650 GetRequestBodyForWebURLRequest(info.urlRequest)); | 652 GetRequestBodyForWebURLRequest(info.urlRequest)); |
| 651 } | 653 } |
| 652 | 654 |
| 653 media::Context3D GetSharedMainThreadContext3D( | 655 media::Context3D GetSharedMainThreadContext3D( |
| 654 scoped_refptr<ui::ContextProviderCommandBuffer> provider) { | 656 scoped_refptr<ui::ContextProviderCommandBuffer> provider) { |
| 655 if (!provider) | 657 if (!provider) |
| 656 return media::Context3D(); | 658 return media::Context3D(); |
| (...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2495 } | 2497 } |
| 2496 #if defined(OS_CHROMEOS) | 2498 #if defined(OS_CHROMEOS) |
| 2497 LOG(WARNING) << "Pepper module/plugin creation failed."; | 2499 LOG(WARNING) << "Pepper module/plugin creation failed."; |
| 2498 #endif | 2500 #endif |
| 2499 #endif | 2501 #endif |
| 2500 return NULL; | 2502 return NULL; |
| 2501 } | 2503 } |
| 2502 | 2504 |
| 2503 void RenderFrameImpl::LoadURLExternally(const blink::WebURLRequest& request, | 2505 void RenderFrameImpl::LoadURLExternally(const blink::WebURLRequest& request, |
| 2504 blink::WebNavigationPolicy policy) { | 2506 blink::WebNavigationPolicy policy) { |
| 2505 loadURLExternally(request, policy, WebString(), false); | 2507 loadURLExternally(request, policy, WebString(), WebFrameLoadType::Standard); |
| 2506 } | 2508 } |
| 2507 | 2509 |
| 2508 void RenderFrameImpl::loadErrorPage(int reason) { | 2510 void RenderFrameImpl::loadErrorPage(int reason) { |
| 2509 blink::WebURLError error; | 2511 blink::WebURLError error; |
| 2510 error.unreachableURL = frame_->document().url(); | 2512 error.unreachableURL = frame_->document().url(); |
| 2511 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2513 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2512 error.reason = reason; | 2514 error.reason = reason; |
| 2513 | 2515 |
| 2514 std::string error_html; | 2516 std::string error_html; |
| 2515 GetContentClient()->renderer()->GetNavigationErrorStrings( | 2517 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3264 } | 3266 } |
| 3265 | 3267 |
| 3266 Send(new FrameHostMsg_DidAddMessageToConsole( | 3268 Send(new FrameHostMsg_DidAddMessageToConsole( |
| 3267 routing_id_, static_cast<int32_t>(log_severity), message.text.utf16(), | 3269 routing_id_, static_cast<int32_t>(log_severity), message.text.utf16(), |
| 3268 static_cast<int32_t>(source_line), source_name.utf16())); | 3270 static_cast<int32_t>(source_line), source_name.utf16())); |
| 3269 } | 3271 } |
| 3270 | 3272 |
| 3271 void RenderFrameImpl::loadURLExternally(const blink::WebURLRequest& request, | 3273 void RenderFrameImpl::loadURLExternally(const blink::WebURLRequest& request, |
| 3272 blink::WebNavigationPolicy policy, | 3274 blink::WebNavigationPolicy policy, |
| 3273 const blink::WebString& suggested_name, | 3275 const blink::WebString& suggested_name, |
| 3274 bool should_replace_current_entry) { | 3276 WebFrameLoadType load_type) { |
| 3275 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); | 3277 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); |
| 3276 if (policy == blink::WebNavigationPolicyDownload) { | 3278 if (policy == blink::WebNavigationPolicyDownload) { |
| 3277 FrameHostMsg_DownloadUrl_Params params; | 3279 FrameHostMsg_DownloadUrl_Params params; |
| 3278 params.render_view_id = render_view_->GetRoutingID(); | 3280 params.render_view_id = render_view_->GetRoutingID(); |
| 3279 params.render_frame_id = GetRoutingID(); | 3281 params.render_frame_id = GetRoutingID(); |
| 3280 params.url = request.url(); | 3282 params.url = request.url(); |
| 3281 params.referrer = referrer; | 3283 params.referrer = referrer; |
| 3282 params.initiator_origin = request.requestorOrigin(); | 3284 params.initiator_origin = request.requestorOrigin(); |
| 3283 params.suggested_name = suggested_name.utf16(); | 3285 params.suggested_name = suggested_name.utf16(); |
| 3284 | 3286 |
| 3285 Send(new FrameHostMsg_DownloadUrl(params)); | 3287 Send(new FrameHostMsg_DownloadUrl(params)); |
| 3286 } else { | 3288 } else { |
| 3287 OpenURL(request.url(), IsHttpPost(request), | 3289 OpenURL(request.url(), IsHttpPost(request), |
| 3288 GetRequestBodyForWebURLRequest(request), | 3290 GetRequestBodyForWebURLRequest(request), |
| 3289 GetWebURLRequestHeaders(request), referrer, policy, | 3291 GetWebURLRequestHeaders(request), referrer, policy, load_type); |
| 3290 should_replace_current_entry, false); | |
| 3291 } | 3292 } |
| 3292 } | 3293 } |
| 3293 | 3294 |
| 3294 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { | 3295 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
| 3295 // We will punt this navigation to the browser in decidePolicyForNavigation. | 3296 // We will punt this navigation to the browser in decidePolicyForNavigation. |
| 3296 // TODO(creis): Look into cleaning this up. | 3297 // TODO(creis): Look into cleaning this up. |
| 3297 return WebHistoryItem(); | 3298 return WebHistoryItem(); |
| 3298 } | 3299 } |
| 3299 | 3300 |
| 3300 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { | 3301 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3413 DocumentState::FromDataSource(datasource))) | 3414 DocumentState::FromDataSource(datasource))) |
| 3414 return; | 3415 return; |
| 3415 | 3416 |
| 3416 ServiceWorkerNetworkProvider::AttachToDocumentState( | 3417 ServiceWorkerNetworkProvider::AttachToDocumentState( |
| 3417 DocumentState::FromDataSource(datasource), | 3418 DocumentState::FromDataSource(datasource), |
| 3418 ServiceWorkerNetworkProvider::CreateForNavigation( | 3419 ServiceWorkerNetworkProvider::CreateForNavigation( |
| 3419 routing_id_, navigation_state->request_params(), frame, | 3420 routing_id_, navigation_state->request_params(), frame, |
| 3420 content_initiated)); | 3421 content_initiated)); |
| 3421 } | 3422 } |
| 3422 | 3423 |
| 3423 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) { | 3424 void RenderFrameImpl::didStartProvisionalLoad(WebDataSource* ds, |
| 3424 DCHECK_EQ(frame_, frame); | 3425 WebFrameLoadType type) { |
| 3425 WebDataSource* ds = frame->provisionalDataSource(); | |
| 3426 | |
| 3427 // In fast/loader/stop-provisional-loads.html, we abort the load before this | |
| 3428 // callback is invoked. | |
| 3429 if (!ds) | |
| 3430 return; | |
| 3431 | |
| 3432 TRACE_EVENT2("navigation,benchmark,rail", | 3426 TRACE_EVENT2("navigation,benchmark,rail", |
| 3433 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, | 3427 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, |
| 3434 "url", ds->getRequest().url().string().utf8()); | 3428 "url", ds->getRequest().url().string().utf8()); |
| 3435 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3429 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3436 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( | 3430 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( |
| 3437 document_state->navigation_state()); | 3431 document_state->navigation_state()); |
| 3438 bool is_top_most = !frame->parent(); | 3432 bool is_top_most = !frame_->parent(); |
| 3439 if (is_top_most) { | 3433 if (is_top_most) { |
| 3440 render_view_->set_navigation_gesture( | 3434 render_view_->set_navigation_gesture( |
| 3441 WebUserGestureIndicator::isProcessingUserGesture() ? | 3435 WebUserGestureIndicator::isProcessingUserGesture() ? |
| 3442 NavigationGestureUser : NavigationGestureAuto); | 3436 NavigationGestureUser : NavigationGestureAuto); |
| 3443 } else if (ds->replacesCurrentHistoryItem()) { | 3437 } else if (type == WebFrameLoadType::ReplaceCurrentItem) { |
| 3444 // Subframe navigations that don't add session history items must be | 3438 // Subframe navigations that don't add session history items must be |
| 3445 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we | 3439 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we |
| 3446 // handle loading of error pages. | 3440 // handle loading of error pages. |
| 3447 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 3441 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
| 3448 } | 3442 } |
| 3449 | 3443 |
| 3450 base::TimeTicks navigation_start = | 3444 base::TimeTicks navigation_start = |
| 3451 navigation_state->common_params().navigation_start; | 3445 navigation_state->common_params().navigation_start; |
| 3452 DCHECK(!navigation_start.is_null()); | 3446 DCHECK(!navigation_start.is_null()); |
| 3453 | 3447 |
| 3454 for (auto& observer : render_view_->observers()) | 3448 for (auto& observer : render_view_->observers()) |
| 3455 observer.DidStartProvisionalLoad(frame); | 3449 observer.DidStartProvisionalLoad(frame_); |
| 3456 for (auto& observer : observers_) | 3450 for (auto& observer : observers_) |
| 3457 observer.DidStartProvisionalLoad(); | 3451 observer.DidStartProvisionalLoad(); |
| 3458 | 3452 |
| 3459 Send(new FrameHostMsg_DidStartProvisionalLoad( | 3453 Send(new FrameHostMsg_DidStartProvisionalLoad( |
| 3460 routing_id_, ds->getRequest().url(), navigation_start)); | 3454 routing_id_, ds->getRequest().url(), navigation_start)); |
| 3461 } | 3455 } |
| 3462 | 3456 |
| 3463 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 3457 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
| 3464 blink::WebLocalFrame* frame) { | 3458 blink::WebLocalFrame* frame) { |
| 3465 DCHECK_EQ(frame_, frame); | 3459 DCHECK_EQ(frame_, frame); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3515 pending_navigation_params_.reset(new NavigationParams( | 3509 pending_navigation_params_.reset(new NavigationParams( |
| 3516 navigation_state->common_params(), navigation_state->start_params(), | 3510 navigation_state->common_params(), navigation_state->start_params(), |
| 3517 navigation_state->request_params())); | 3511 navigation_state->request_params())); |
| 3518 } | 3512 } |
| 3519 | 3513 |
| 3520 // Load an error page. | 3514 // Load an error page. |
| 3521 LoadNavigationErrorPage(failed_request, error, replace, nullptr); | 3515 LoadNavigationErrorPage(failed_request, error, replace, nullptr); |
| 3522 } | 3516 } |
| 3523 | 3517 |
| 3524 void RenderFrameImpl::didCommitProvisionalLoad( | 3518 void RenderFrameImpl::didCommitProvisionalLoad( |
| 3525 blink::WebLocalFrame* frame, | 3519 blink::WebDataSource* data_source, |
| 3520 blink::WebFrameLoadType load_type, |
| 3526 const blink::WebHistoryItem& item, | 3521 const blink::WebHistoryItem& item, |
| 3527 blink::WebHistoryCommitType commit_type) { | 3522 blink::WebHistoryCommitType commit_type) { |
| 3528 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::didCommitProvisionalLoad", | 3523 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::didCommitProvisionalLoad", |
| 3529 "id", routing_id_, | 3524 "id", routing_id_, |
| 3530 "url", GetLoadingUrl().possibly_invalid_spec()); | 3525 "url", GetLoadingUrl().possibly_invalid_spec()); |
| 3531 DCHECK_EQ(frame_, frame); | |
| 3532 | 3526 |
| 3533 // TODO(dcheng): Remove this UMA once we have enough measurements. | 3527 // TODO(dcheng): Remove this UMA once we have enough measurements. |
| 3534 // Record the number of subframes where window.name changes between the | 3528 // Record the number of subframes where window.name changes between the |
| 3535 // creation of the frame and the first commit that records a history entry | 3529 // creation of the frame and the first commit that records a history entry |
| 3536 // with a persisted unique name. We'd like to make unique name immutable to | 3530 // with a persisted unique name. We'd like to make unique name immutable to |
| 3537 // simplify code, but it's unclear if there are site that depend on the | 3531 // simplify code, but it's unclear if there are site that depend on the |
| 3538 // following pattern: | 3532 // following pattern: |
| 3539 // 1. Create a new subframe. | 3533 // 1. Create a new subframe. |
| 3540 // 2. Assign it a window.name. | 3534 // 2. Assign it a window.name. |
| 3541 // 3. Navigate it. | 3535 // 3. Navigate it. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3559 // Record if window.name has changed. | 3553 // Record if window.name has changed. |
| 3560 if (!committed_first_load_ && !current_history_item_.isNull()) { | 3554 if (!committed_first_load_ && !current_history_item_.isNull()) { |
| 3561 if (!IsMainFrame()) { | 3555 if (!IsMainFrame()) { |
| 3562 UMA_HISTOGRAM_BOOLEAN( | 3556 UMA_HISTOGRAM_BOOLEAN( |
| 3563 "SessionRestore.SubFrameUniqueNameChangedBeforeFirstCommit", | 3557 "SessionRestore.SubFrameUniqueNameChangedBeforeFirstCommit", |
| 3564 name_changed_before_first_commit_); | 3558 name_changed_before_first_commit_); |
| 3565 } | 3559 } |
| 3566 committed_first_load_ = true; | 3560 committed_first_load_ = true; |
| 3567 } | 3561 } |
| 3568 | 3562 |
| 3569 DocumentState* document_state = | 3563 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 3570 DocumentState::FromDataSource(frame->dataSource()); | |
| 3571 NavigationStateImpl* navigation_state = | 3564 NavigationStateImpl* navigation_state = |
| 3572 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3565 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 3573 WebURLResponseExtraDataImpl* extra_data = | 3566 WebURLResponseExtraDataImpl* extra_data = |
| 3574 GetExtraDataFromResponse(frame->dataSource()->response()); | 3567 GetExtraDataFromResponse(data_source->response()); |
| 3575 // Only update the PreviewsState and effective connection type states for new | 3568 // Only update the PreviewsState and effective connection type states for new |
| 3576 // main frame documents. Subframes inherit from the main frame and should not | 3569 // main frame documents. Subframes inherit from the main frame and should not |
| 3577 // change at commit time. | 3570 // change at commit time. |
| 3578 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3571 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
| 3579 previews_state_ = | 3572 previews_state_ = |
| 3580 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; | 3573 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; |
| 3581 if (extra_data) { | 3574 if (extra_data) { |
| 3582 effective_connection_type_ = | 3575 effective_connection_type_ = |
| 3583 EffectiveConnectionTypeToWebEffectiveConnectionType( | 3576 EffectiveConnectionTypeToWebEffectiveConnectionType( |
| 3584 extra_data->effective_connection_type()); | 3577 extra_data->effective_connection_type()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3636 } else { | 3629 } else { |
| 3637 if (request_params.nav_entry_id != 0 && | 3630 if (request_params.nav_entry_id != 0 && |
| 3638 !request_params.intended_as_new_entry) { | 3631 !request_params.intended_as_new_entry) { |
| 3639 // This is a successful session history navigation! | 3632 // This is a successful session history navigation! |
| 3640 render_view_->history_list_offset_ = | 3633 render_view_->history_list_offset_ = |
| 3641 request_params.pending_history_list_offset; | 3634 request_params.pending_history_list_offset; |
| 3642 } | 3635 } |
| 3643 } | 3636 } |
| 3644 | 3637 |
| 3645 for (auto& observer : render_view_->observers_) | 3638 for (auto& observer : render_view_->observers_) |
| 3646 observer.DidCommitProvisionalLoad(frame, is_new_navigation); | 3639 observer.DidCommitProvisionalLoad(frame_, is_new_navigation); |
| 3647 for (auto& observer : observers_) { | 3640 for (auto& observer : observers_) { |
| 3648 observer.DidCommitProvisionalLoad(is_new_navigation, | 3641 observer.DidCommitProvisionalLoad(is_new_navigation, |
| 3649 navigation_state->WasWithinSamePage()); | 3642 navigation_state->WasWithinSamePage()); |
| 3650 } | 3643 } |
| 3651 | 3644 |
| 3652 if (!frame->parent()) { // Only for top frames. | 3645 if (!frame_->parent()) { // Only for top frames. |
| 3653 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 3646 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
| 3654 if (render_thread_impl) { // Can be NULL in tests. | 3647 if (render_thread_impl) { // Can be NULL in tests. |
| 3655 render_thread_impl->histogram_customizer()-> | 3648 render_thread_impl->histogram_customizer()-> |
| 3656 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(), | 3649 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(), |
| 3657 RenderView::GetRenderViewCount()); | 3650 RenderView::GetRenderViewCount()); |
| 3658 // The scheduler isn't interested in history inert commits unless they | 3651 // The scheduler isn't interested in history inert commits unless they |
| 3659 // are reloads. | 3652 // are reloads. |
| 3660 if (commit_type != blink::WebHistoryInertCommit || | 3653 if (commit_type != blink::WebHistoryInertCommit || |
| 3661 PageTransitionCoreTypeIs( | 3654 PageTransitionCoreTypeIs( |
| 3662 navigation_state->GetTransitionType(), | 3655 navigation_state->GetTransitionType(), |
| 3663 ui::PAGE_TRANSITION_RELOAD)) { | 3656 ui::PAGE_TRANSITION_RELOAD)) { |
| 3664 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); | 3657 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); |
| 3665 } | 3658 } |
| 3666 } | 3659 } |
| 3667 } | 3660 } |
| 3668 | 3661 |
| 3669 // Remember that we've already processed this request, so we don't update | 3662 // Remember that we've already processed this request, so we don't update |
| 3670 // the session history again. We do this regardless of whether this is | 3663 // the session history again. We do this regardless of whether this is |
| 3671 // a session history navigation, because if we attempted a session history | 3664 // a session history navigation, because if we attempted a session history |
| 3672 // navigation without valid HistoryItem state, WebCore will think it is a | 3665 // navigation without valid HistoryItem state, WebCore will think it is a |
| 3673 // new navigation. | 3666 // new navigation. |
| 3674 navigation_state->set_request_committed(true); | 3667 navigation_state->set_request_committed(true); |
| 3675 | 3668 |
| 3676 SendDidCommitProvisionalLoad(frame, commit_type, item); | 3669 SendDidCommitProvisionalLoad(data_source, load_type, item); |
| 3677 | 3670 |
| 3678 // Check whether we have new encoding name. | 3671 // Check whether we have new encoding name. |
| 3679 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3672 UpdateEncoding(frame_, frame_->view()->pageEncoding().utf8()); |
| 3680 } | 3673 } |
| 3681 | 3674 |
| 3682 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { | 3675 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { |
| 3683 DCHECK(!frame_ || frame_ == frame); | 3676 DCHECK(!frame_ || frame_ == frame); |
| 3684 | 3677 |
| 3685 for (auto& observer : observers_) | 3678 for (auto& observer : observers_) |
| 3686 observer.DidCreateNewDocument(); | 3679 observer.DidCreateNewDocument(); |
| 3687 for (auto& observer : render_view_->observers()) | 3680 for (auto& observer : render_view_->observers()) |
| 3688 observer.DidCreateNewDocument(frame); | 3681 observer.DidCreateNewDocument(frame); |
| 3689 } | 3682 } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3967 memory_metrics.non_discardable_total_allocated_mb); | 3960 memory_metrics.non_discardable_total_allocated_mb); |
| 3968 UMA_HISTOGRAM_MEMORY_MB( | 3961 UMA_HISTOGRAM_MEMORY_MB( |
| 3969 "Memory.Experimental.Renderer.TotalAllocatedPerRenderView." | 3962 "Memory.Experimental.Renderer.TotalAllocatedPerRenderView." |
| 3970 "MainFrameDidFinishLoad", | 3963 "MainFrameDidFinishLoad", |
| 3971 memory_metrics.total_allocated_per_render_view_mb); | 3964 memory_metrics.total_allocated_per_render_view_mb); |
| 3972 } | 3965 } |
| 3973 } | 3966 } |
| 3974 } | 3967 } |
| 3975 | 3968 |
| 3976 void RenderFrameImpl::didNavigateWithinPage( | 3969 void RenderFrameImpl::didNavigateWithinPage( |
| 3977 blink::WebLocalFrame* frame, | 3970 blink::WebDataSource* data_source, |
| 3971 blink::WebFrameLoadType load_type, |
| 3978 const blink::WebHistoryItem& item, | 3972 const blink::WebHistoryItem& item, |
| 3979 blink::WebHistoryCommitType commit_type, | 3973 blink::WebHistoryCommitType commit_type, |
| 3980 bool content_initiated) { | 3974 bool content_initiated) { |
| 3981 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didNavigateWithinPage", | 3975 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didNavigateWithinPage", |
| 3982 "id", routing_id_); | 3976 "id", routing_id_); |
| 3983 DCHECK_EQ(frame_, frame); | 3977 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 3984 DocumentState* document_state = | |
| 3985 DocumentState::FromDataSource(frame->dataSource()); | |
| 3986 UpdateNavigationState(document_state, true /* was_within_same_page */, | 3978 UpdateNavigationState(document_state, true /* was_within_same_page */, |
| 3987 content_initiated); | 3979 content_initiated); |
| 3988 static_cast<NavigationStateImpl*>(document_state->navigation_state()) | 3980 static_cast<NavigationStateImpl*>(document_state->navigation_state()) |
| 3989 ->set_was_within_same_page(true); | 3981 ->set_was_within_same_page(true); |
| 3990 | 3982 |
| 3991 didCommitProvisionalLoad(frame, item, commit_type); | 3983 didCommitProvisionalLoad(data_source, load_type, item, commit_type); |
| 3992 } | 3984 } |
| 3993 | 3985 |
| 3994 void RenderFrameImpl::didUpdateCurrentHistoryItem() { | 3986 void RenderFrameImpl::didUpdateCurrentHistoryItem() { |
| 3995 render_view_->StartNavStateSyncTimerIfNecessary(this); | 3987 render_view_->StartNavStateSyncTimerIfNecessary(this); |
| 3996 } | 3988 } |
| 3997 | 3989 |
| 3998 void RenderFrameImpl::didChangeThemeColor() { | 3990 void RenderFrameImpl::didChangeThemeColor() { |
| 3999 if (frame_->parent()) | 3991 if (frame_->parent()) |
| 4000 return; | 3992 return; |
| 4001 | 3993 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4159 void RenderFrameImpl::saveImageFromDataURL(const blink::WebString& data_url) { | 4151 void RenderFrameImpl::saveImageFromDataURL(const blink::WebString& data_url) { |
| 4160 // Note: We should basically send GURL but we use size-limited string instead | 4152 // Note: We should basically send GURL but we use size-limited string instead |
| 4161 // in order to send a larger data url to save a image for <canvas> or <img>. | 4153 // in order to send a larger data url to save a image for <canvas> or <img>. |
| 4162 if (data_url.length() < kMaxLengthOfDataURLString) { | 4154 if (data_url.length() < kMaxLengthOfDataURLString) { |
| 4163 Send(new FrameHostMsg_SaveImageFromDataURL( | 4155 Send(new FrameHostMsg_SaveImageFromDataURL( |
| 4164 render_view_->GetRoutingID(), routing_id_, data_url.utf8())); | 4156 render_view_->GetRoutingID(), routing_id_, data_url.utf8())); |
| 4165 } | 4157 } |
| 4166 } | 4158 } |
| 4167 | 4159 |
| 4168 void RenderFrameImpl::willSendRequest(blink::WebLocalFrame* frame, | 4160 void RenderFrameImpl::willSendRequest(blink::WebLocalFrame* frame, |
| 4169 blink::WebURLRequest& request) { | 4161 blink::WebURLRequest& request, |
| 4162 blink::WebFrameLoadType load_type) { |
| 4170 DCHECK_EQ(frame_, frame); | 4163 DCHECK_EQ(frame_, frame); |
| 4171 | 4164 |
| 4172 // Set the first party for cookies url if it has not been set yet (new | 4165 // Set the first party for cookies url if it has not been set yet (new |
| 4173 // requests). This value will be updated during redirects, consistent with | 4166 // requests). This value will be updated during redirects, consistent with |
| 4174 // https://tools.ietf.org/html/draft-west-first-party-cookies-04#section-2.1.1 | 4167 // https://tools.ietf.org/html/draft-west-first-party-cookies-04#section-2.1.1 |
| 4175 if (request.firstPartyForCookies().isEmpty()) { | 4168 if (request.firstPartyForCookies().isEmpty()) { |
| 4176 if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel) | 4169 if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel) |
| 4177 request.setFirstPartyForCookies(request.url()); | 4170 request.setFirstPartyForCookies(request.url()); |
| 4178 else | 4171 else |
| 4179 request.setFirstPartyForCookies(frame->document().firstPartyForCookies()); | 4172 request.setFirstPartyForCookies(frame->document().firstPartyForCookies()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4246 else | 4239 else |
| 4247 request.setHTTPHeaderField("X-Requested-With", requested_with); | 4240 request.setHTTPHeaderField("X-Requested-With", requested_with); |
| 4248 } | 4241 } |
| 4249 stream_override = old_extra_data->TakeStreamOverrideOwnership(); | 4242 stream_override = old_extra_data->TakeStreamOverrideOwnership(); |
| 4250 } | 4243 } |
| 4251 | 4244 |
| 4252 // Add an empty HTTP origin header for non GET methods if none is currently | 4245 // Add an empty HTTP origin header for non GET methods if none is currently |
| 4253 // present. | 4246 // present. |
| 4254 request.addHTTPOriginIfNeeded(WebSecurityOrigin::createUnique()); | 4247 request.addHTTPOriginIfNeeded(WebSecurityOrigin::createUnique()); |
| 4255 | 4248 |
| 4256 // Attach |should_replace_current_entry| state to requests so that, should | |
| 4257 // this navigation later require a request transfer, all state is preserved | |
| 4258 // when it is re-created in the new process. | |
| 4259 bool should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | |
| 4260 | |
| 4261 int provider_id = kInvalidServiceWorkerProviderId; | 4249 int provider_id = kInvalidServiceWorkerProviderId; |
| 4262 if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel || | 4250 if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel || |
| 4263 request.getFrameType() == blink::WebURLRequest::FrameTypeNested) { | 4251 request.getFrameType() == blink::WebURLRequest::FrameTypeNested) { |
| 4264 // |provisionalDataSource| may be null in some content::ResourceFetcher | 4252 // |provisionalDataSource| may be null in some content::ResourceFetcher |
| 4265 // use cases, we don't hook those requests. | 4253 // use cases, we don't hook those requests. |
| 4266 if (frame->provisionalDataSource()) { | 4254 if (frame->provisionalDataSource()) { |
| 4267 ServiceWorkerNetworkProvider* provider = | 4255 ServiceWorkerNetworkProvider* provider = |
| 4268 ServiceWorkerNetworkProvider::FromDocumentState( | 4256 ServiceWorkerNetworkProvider::FromDocumentState( |
| 4269 DocumentState::FromDataSource(frame->provisionalDataSource())); | 4257 DocumentState::FromDataSource(frame->provisionalDataSource())); |
| 4270 DCHECK(provider); | 4258 DCHECK(provider); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4299 extra_data->set_requested_with(requested_with); | 4287 extra_data->set_requested_with(requested_with); |
| 4300 extra_data->set_render_frame_id(routing_id_); | 4288 extra_data->set_render_frame_id(routing_id_); |
| 4301 extra_data->set_is_main_frame(!parent); | 4289 extra_data->set_is_main_frame(!parent); |
| 4302 extra_data->set_frame_origin( | 4290 extra_data->set_frame_origin( |
| 4303 url::Origin(frame->document().getSecurityOrigin())); | 4291 url::Origin(frame->document().getSecurityOrigin())); |
| 4304 extra_data->set_parent_is_main_frame(parent && !parent->parent()); | 4292 extra_data->set_parent_is_main_frame(parent && !parent->parent()); |
| 4305 extra_data->set_parent_render_frame_id(parent_routing_id); | 4293 extra_data->set_parent_render_frame_id(parent_routing_id); |
| 4306 extra_data->set_allow_download( | 4294 extra_data->set_allow_download( |
| 4307 navigation_state->common_params().allow_download); | 4295 navigation_state->common_params().allow_download); |
| 4308 extra_data->set_transition_type(transition_type); | 4296 extra_data->set_transition_type(transition_type); |
| 4309 extra_data->set_should_replace_current_entry(should_replace_current_entry); | 4297 extra_data->set_should_replace_current_entry( |
| 4298 load_type == WebFrameLoadType::ReplaceCurrentItem); |
| 4310 extra_data->set_service_worker_provider_id(provider_id); | 4299 extra_data->set_service_worker_provider_id(provider_id); |
| 4311 extra_data->set_stream_override(std::move(stream_override)); | 4300 extra_data->set_stream_override(std::move(stream_override)); |
| 4312 bool is_prefetch = | 4301 bool is_prefetch = |
| 4313 GetContentClient()->renderer()->IsPrefetchOnly(this, request); | 4302 GetContentClient()->renderer()->IsPrefetchOnly(this, request); |
| 4314 extra_data->set_is_prefetch(is_prefetch); | 4303 extra_data->set_is_prefetch(is_prefetch); |
| 4315 extra_data->set_download_to_network_cache_only( | 4304 extra_data->set_download_to_network_cache_only( |
| 4316 is_prefetch && | 4305 is_prefetch && |
| 4317 WebURLRequestToResourceType(request) != RESOURCE_TYPE_MAIN_FRAME); | 4306 WebURLRequestToResourceType(request) != RESOURCE_TYPE_MAIN_FRAME); |
| 4318 extra_data->set_initiated_in_secure_context( | 4307 extra_data->set_initiated_in_secure_context( |
| 4319 frame->document().isSecureContext()); | 4308 frame->document().isSecureContext()); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4781 return is_local_root; | 4770 return is_local_root; |
| 4782 } | 4771 } |
| 4783 | 4772 |
| 4784 const RenderFrameImpl* RenderFrameImpl::GetLocalRoot() const { | 4773 const RenderFrameImpl* RenderFrameImpl::GetLocalRoot() const { |
| 4785 return IsLocalRoot() ? this | 4774 return IsLocalRoot() ? this |
| 4786 : RenderFrameImpl::FromWebFrame(frame_->localRoot()); | 4775 : RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
| 4787 } | 4776 } |
| 4788 | 4777 |
| 4789 // Tell the embedding application that the URL of the active page has changed. | 4778 // Tell the embedding application that the URL of the active page has changed. |
| 4790 void RenderFrameImpl::SendDidCommitProvisionalLoad( | 4779 void RenderFrameImpl::SendDidCommitProvisionalLoad( |
| 4791 blink::WebFrame* frame, | 4780 blink::WebDataSource* ds, |
| 4792 blink::WebHistoryCommitType commit_type, | 4781 blink::WebFrameLoadType load_type, |
| 4793 const blink::WebHistoryItem& item) { | 4782 const blink::WebHistoryItem& item) { |
| 4794 DCHECK_EQ(frame_, frame); | |
| 4795 WebDataSource* ds = frame->dataSource(); | |
| 4796 DCHECK(ds); | 4783 DCHECK(ds); |
| 4797 | 4784 |
| 4798 const WebURLRequest& request = ds->getRequest(); | 4785 const WebURLRequest& request = ds->getRequest(); |
| 4799 const WebURLResponse& response = ds->response(); | 4786 const WebURLResponse& response = ds->response(); |
| 4800 | 4787 |
| 4801 DocumentState* document_state = DocumentState::FromDataSource(ds); | 4788 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 4802 NavigationStateImpl* navigation_state = | 4789 NavigationStateImpl* navigation_state = |
| 4803 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 4790 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 4804 InternalDocumentStateData* internal_data = | 4791 InternalDocumentStateData* internal_data = |
| 4805 InternalDocumentStateData::FromDocumentState(document_state); | 4792 InternalDocumentStateData::FromDocumentState(document_state); |
| 4806 | 4793 |
| 4807 // Set the correct engagement level on the frame, and wipe the cached origin | 4794 // Set the correct engagement level on the frame, and wipe the cached origin |
| 4808 // so this will not be reused accidentally. | 4795 // so this will not be reused accidentally. |
| 4809 if (url::Origin(frame_->getSecurityOrigin()) == engagement_level_.first) { | 4796 if (url::Origin(frame_->getSecurityOrigin()) == engagement_level_.first) { |
| 4810 frame_->setEngagementLevel(engagement_level_.second); | 4797 frame_->setEngagementLevel(engagement_level_.second); |
| 4811 engagement_level_.first = url::Origin(); | 4798 engagement_level_.first = url::Origin(); |
| 4812 } | 4799 } |
| 4813 | 4800 |
| 4814 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4801 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 4815 params.http_status_code = response.httpStatusCode(); | 4802 params.http_status_code = response.httpStatusCode(); |
| 4816 params.url_is_unreachable = ds->hasUnreachableURL(); | 4803 params.url_is_unreachable = ds->hasUnreachableURL(); |
| 4817 params.method = "GET"; | 4804 params.method = "GET"; |
| 4818 params.intended_as_new_entry = | 4805 params.intended_as_new_entry = |
| 4819 navigation_state->request_params().intended_as_new_entry; | 4806 navigation_state->request_params().intended_as_new_entry; |
| 4820 params.did_create_new_entry = commit_type == blink::WebStandardCommit; | 4807 params.did_create_new_entry = load_type == WebFrameLoadType::Standard; |
| 4821 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 4808 params.should_replace_current_entry = |
| 4809 load_type == WebFrameLoadType::ReplaceCurrentItem; |
| 4822 params.post_id = -1; | 4810 params.post_id = -1; |
| 4823 params.nav_entry_id = navigation_state->request_params().nav_entry_id; | 4811 params.nav_entry_id = navigation_state->request_params().nav_entry_id; |
| 4824 // We need to track the RenderViewHost routing_id because of downstream | 4812 // We need to track the RenderViewHost routing_id because of downstream |
| 4825 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 4813 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
| 4826 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 4814 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
| 4827 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 4815 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
| 4828 // based on the ID stored in the resource requests. Once those dependencies | 4816 // based on the ID stored in the resource requests. Once those dependencies |
| 4829 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the | 4817 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the |
| 4830 // client to be based on the routing_id of the RenderFrameHost. | 4818 // client to be based on the routing_id of the RenderFrameHost. |
| 4831 params.render_view_routing_id = render_view_->routing_id(); | 4819 params.render_view_routing_id = render_view_->routing_id(); |
| 4832 params.socket_address.set_host(response.remoteIPAddress().utf8()); | 4820 params.socket_address.set_host(response.remoteIPAddress().utf8()); |
| 4833 params.socket_address.set_port(response.remotePort()); | 4821 params.socket_address.set_port(response.remotePort()); |
| 4834 params.was_within_same_page = navigation_state->WasWithinSamePage(); | 4822 params.was_within_same_page = navigation_state->WasWithinSamePage(); |
| 4835 | 4823 |
| 4836 // Set the origin of the frame. This will be replicated to the corresponding | 4824 // Set the origin of the frame. This will be replicated to the corresponding |
| 4837 // RenderFrameProxies in other processes. | 4825 // RenderFrameProxies in other processes. |
| 4838 params.origin = frame->document().getSecurityOrigin(); | 4826 params.origin = frame_->document().getSecurityOrigin(); |
| 4839 | 4827 |
| 4840 params.insecure_request_policy = frame->getInsecureRequestPolicy(); | 4828 params.insecure_request_policy = frame_->getInsecureRequestPolicy(); |
| 4841 | 4829 |
| 4842 params.has_potentially_trustworthy_unique_origin = | 4830 params.has_potentially_trustworthy_unique_origin = |
| 4843 frame->document().getSecurityOrigin().isUnique() && | 4831 frame_->document().getSecurityOrigin().isUnique() && |
| 4844 frame->document().getSecurityOrigin().isPotentiallyTrustworthy(); | 4832 frame_->document().getSecurityOrigin().isPotentiallyTrustworthy(); |
| 4845 | 4833 |
| 4846 // Set the URL to be displayed in the browser UI to the user. | 4834 // Set the URL to be displayed in the browser UI to the user. |
| 4847 params.url = GetLoadingUrl(); | 4835 params.url = GetLoadingUrl(); |
| 4848 if (GURL(frame->document().baseURL()) != params.url) | 4836 if (GURL(frame_->document().baseURL()) != params.url) |
| 4849 params.base_url = frame->document().baseURL(); | 4837 params.base_url = frame_->document().baseURL(); |
| 4850 | 4838 |
| 4851 GetRedirectChain(ds, ¶ms.redirects); | 4839 GetRedirectChain(ds, ¶ms.redirects); |
| 4852 params.should_update_history = | 4840 params.should_update_history = |
| 4853 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; | 4841 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; |
| 4854 | 4842 |
| 4855 params.searchable_form_url = internal_data->searchable_form_url(); | 4843 params.searchable_form_url = internal_data->searchable_form_url(); |
| 4856 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 4844 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
| 4857 | 4845 |
| 4858 params.gesture = render_view_->navigation_gesture_; | 4846 params.gesture = render_view_->navigation_gesture_; |
| 4859 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 4847 render_view_->navigation_gesture_ = NavigationGestureUnknown; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4872 params.item_sequence_number = item.itemSequenceNumber(); | 4860 params.item_sequence_number = item.itemSequenceNumber(); |
| 4873 params.document_sequence_number = item.documentSequenceNumber(); | 4861 params.document_sequence_number = item.documentSequenceNumber(); |
| 4874 | 4862 |
| 4875 // If the page contained a client redirect (meta refresh, document.loc...), | 4863 // If the page contained a client redirect (meta refresh, document.loc...), |
| 4876 // set the referrer appropriately. | 4864 // set the referrer appropriately. |
| 4877 if (ds->isClientRedirect()) { | 4865 if (ds->isClientRedirect()) { |
| 4878 params.referrer = | 4866 params.referrer = |
| 4879 Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy()); | 4867 Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy()); |
| 4880 } else { | 4868 } else { |
| 4881 params.referrer = | 4869 params.referrer = |
| 4882 RenderViewImpl::GetReferrerFromRequest(frame, ds->getRequest()); | 4870 RenderViewImpl::GetReferrerFromRequest(frame_, ds->getRequest()); |
| 4883 } | 4871 } |
| 4884 | 4872 |
| 4885 if (!frame->parent()) { | 4873 if (!frame_->parent()) { |
| 4886 // Top-level navigation. | 4874 // Top-level navigation. |
| 4887 | 4875 |
| 4888 // Reset the zoom limits in case a plugin had changed them previously. This | 4876 // Reset the zoom limits in case a plugin had changed them previously. This |
| 4889 // will also call us back which will cause us to send a message to | 4877 // will also call us back which will cause us to send a message to |
| 4890 // update WebContentsImpl. | 4878 // update WebContentsImpl. |
| 4891 render_view_->webview()->zoomLimitsChanged( | 4879 render_view_->webview()->zoomLimitsChanged( |
| 4892 ZoomFactorToZoomLevel(kMinimumZoomFactor), | 4880 ZoomFactorToZoomLevel(kMinimumZoomFactor), |
| 4893 ZoomFactorToZoomLevel(kMaximumZoomFactor)); | 4881 ZoomFactorToZoomLevel(kMaximumZoomFactor)); |
| 4894 | 4882 |
| 4895 // Set zoom level, but don't do it for full-page plugin since they don't use | 4883 // Set zoom level, but don't do it for full-page plugin since they don't use |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4945 | 4933 |
| 4946 // Track the URL of the original request. We use the first entry of the | 4934 // Track the URL of the original request. We use the first entry of the |
| 4947 // redirect chain if it exists because the chain may have started in another | 4935 // redirect chain if it exists because the chain may have started in another |
| 4948 // process. | 4936 // process. |
| 4949 params.original_request_url = GetOriginalRequestURL(ds); | 4937 params.original_request_url = GetOriginalRequestURL(ds); |
| 4950 | 4938 |
| 4951 params.history_list_was_cleared = | 4939 params.history_list_was_cleared = |
| 4952 navigation_state->request_params().should_clear_history_list; | 4940 navigation_state->request_params().should_clear_history_list; |
| 4953 | 4941 |
| 4954 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 4942 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
| 4955 frame->dataSource()->getRequest().inputPerfMetricReportPolicy()); | 4943 ds->getRequest().inputPerfMetricReportPolicy()); |
| 4956 params.ui_timestamp = base::TimeTicks() + | 4944 params.ui_timestamp = |
| 4957 base::TimeDelta::FromSecondsD( | 4945 base::TimeTicks() + |
| 4958 frame->dataSource()->getRequest().uiStartTime()); | 4946 base::TimeDelta::FromSecondsD(ds->getRequest().uiStartTime()); |
| 4959 } else { | 4947 } else { |
| 4960 // Subframe navigation: the type depends on whether this navigation | 4948 // Subframe navigation: the type depends on whether this navigation |
| 4961 // generated a new session history entry. When they do generate a session | 4949 // generated a new session history entry. When they do generate a session |
| 4962 // history entry, it means the user initiated the navigation and we should | 4950 // history entry, it means the user initiated the navigation and we should |
| 4963 // mark it as such. | 4951 // mark it as such. |
| 4964 if (commit_type == blink::WebStandardCommit) | 4952 if (load_type == WebFrameLoadType::Standard) |
| 4965 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 4953 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
| 4966 else | 4954 else |
| 4967 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 4955 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| 4968 | 4956 |
| 4969 DCHECK(!navigation_state->request_params().should_clear_history_list); | 4957 DCHECK(!navigation_state->request_params().should_clear_history_list); |
| 4970 params.history_list_was_cleared = false; | 4958 params.history_list_was_cleared = false; |
| 4971 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; | 4959 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; |
| 4972 // Subframes should match the zoom level of the main frame. | 4960 // Subframes should match the zoom level of the main frame. |
| 4973 render_view_->SetZoomLevel(render_view_->page_zoom_level()); | 4961 render_view_->SetZoomLevel(render_view_->page_zoom_level()); |
| 4974 } | 4962 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5211 bool is_content_initiated = | 5199 bool is_content_initiated = |
| 5212 info.extraData | 5200 info.extraData |
| 5213 ? static_cast<DocumentState*>(info.extraData) | 5201 ? static_cast<DocumentState*>(info.extraData) |
| 5214 ->navigation_state() | 5202 ->navigation_state() |
| 5215 ->IsContentInitiated() | 5203 ->IsContentInitiated() |
| 5216 : !IsBrowserInitiated(pending_navigation_params_.get()); | 5204 : !IsBrowserInitiated(pending_navigation_params_.get()); |
| 5217 bool is_redirect = | 5205 bool is_redirect = |
| 5218 info.extraData || | 5206 info.extraData || |
| 5219 (pending_navigation_params_ && | 5207 (pending_navigation_params_ && |
| 5220 !pending_navigation_params_->request_params.redirects.empty()); | 5208 !pending_navigation_params_->request_params.redirects.empty()); |
| 5209 bool is_reload = info.loadType == WebFrameLoadType::Reload || |
| 5210 info.loadType == WebFrameLoadType::ReloadMainResource || |
| 5211 info.loadType == WebFrameLoadType::ReloadBypassingCache; |
| 5221 | 5212 |
| 5222 #ifdef OS_ANDROID | 5213 #ifdef OS_ANDROID |
| 5223 bool render_view_was_created_by_renderer = | 5214 bool render_view_was_created_by_renderer = |
| 5224 render_view_->was_created_by_renderer_; | 5215 render_view_->was_created_by_renderer_; |
| 5225 // The handlenavigation API is deprecated and will be removed once | 5216 // The handlenavigation API is deprecated and will be removed once |
| 5226 // crbug.com/325351 is resolved. | 5217 // crbug.com/325351 is resolved. |
| 5227 if (GetContentClient()->renderer()->HandleNavigation( | 5218 if (GetContentClient()->renderer()->HandleNavigation( |
| 5228 this, is_content_initiated, render_view_was_created_by_renderer, | 5219 this, is_content_initiated, render_view_was_created_by_renderer, |
| 5229 frame_, info.urlRequest, info.navigationType, info.defaultPolicy, | 5220 frame_, info.urlRequest, |
| 5221 info.loadType == WebFrameLoadType::BackForward, info.defaultPolicy, |
| 5230 is_redirect)) { | 5222 is_redirect)) { |
| 5231 return blink::WebNavigationPolicyIgnore; | 5223 return blink::WebNavigationPolicyIgnore; |
| 5232 } | 5224 } |
| 5233 #endif | 5225 #endif |
| 5234 | 5226 |
| 5235 Referrer referrer( | 5227 Referrer referrer( |
| 5236 RenderViewImpl::GetReferrerFromRequest(frame_, info.urlRequest)); | 5228 RenderViewImpl::GetReferrerFromRequest(frame_, info.urlRequest)); |
| 5237 | 5229 |
| 5238 // Webkit is asking whether to navigate to a new URL. | 5230 // Webkit is asking whether to navigate to a new URL. |
| 5239 // This is fine normally, except if we're showing UI from one security | 5231 // This is fine normally, except if we're showing UI from one security |
| 5240 // context and they're trying to navigate to a different context. | 5232 // context and they're trying to navigate to a different context. |
| 5241 const GURL& url = info.urlRequest.url(); | 5233 const GURL& url = info.urlRequest.url(); |
| 5242 | 5234 |
| 5243 // If the browser is interested, then give it a chance to look at the request. | 5235 // If the browser is interested, then give it a chance to look at the request. |
| 5244 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 5236 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
| 5245 render_view_->renderer_preferences_ | 5237 render_view_->renderer_preferences_ |
| 5246 .browser_handles_all_top_level_requests) { | 5238 .browser_handles_all_top_level_requests) { |
| 5247 OpenURL(url, IsHttpPost(info.urlRequest), | 5239 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5248 GetRequestBodyForWebURLRequest(info.urlRequest), | 5240 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5249 GetWebURLRequestHeaders(info.urlRequest), referrer, | 5241 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| 5250 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5242 info.defaultPolicy, info.loadType); |
| 5251 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5243 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5252 } | 5244 } |
| 5253 | 5245 |
| 5254 // Back/forward navigations in newly created subframes should be sent to the | 5246 // Back/forward navigations in newly created subframes should be sent to the |
| 5255 // browser if there is a matching FrameNavigationEntry, and if it isn't just | 5247 // browser if there is a matching FrameNavigationEntry, and if it isn't just |
| 5256 // staying at about:blank. If this frame isn't in the map of unique names | 5248 // staying at about:blank. If this frame isn't in the map of unique names |
| 5257 // that have history items, or if it's staying at the initial about:blank URL, | 5249 // that have history items, or if it's staying at the initial about:blank URL, |
| 5258 // fall back to loading the default url. (We remove each name as we encounter | 5250 // fall back to loading the default url. (We remove each name as we encounter |
| 5259 // it, because it will only be used once as the frame is created.) | 5251 // it, because it will only be used once as the frame is created.) |
| 5260 if (info.isHistoryNavigationInNewChildFrame && is_content_initiated && | 5252 if (info.loadType == WebFrameLoadType::InitialHistoryLoad && |
| 5261 frame_->parent()) { | 5253 is_content_initiated && frame_->parent()) { |
| 5262 // Check whether the browser has a history item for this frame that isn't | 5254 // Check whether the browser has a history item for this frame that isn't |
| 5263 // just staying at the initial about:blank document. | 5255 // just staying at the initial about:blank document. |
| 5264 bool should_ask_browser = false; | 5256 bool should_ask_browser = false; |
| 5265 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); | 5257 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); |
| 5266 const auto& iter = parent->history_subframe_unique_names_.find( | 5258 const auto& iter = parent->history_subframe_unique_names_.find( |
| 5267 frame_->uniqueName().utf8()); | 5259 frame_->uniqueName().utf8()); |
| 5268 if (iter != parent->history_subframe_unique_names_.end()) { | 5260 if (iter != parent->history_subframe_unique_names_.end()) { |
| 5269 bool history_item_is_about_blank = iter->second; | 5261 bool history_item_is_about_blank = iter->second; |
| 5270 should_ask_browser = | 5262 should_ask_browser = |
| 5271 !history_item_is_about_blank || url != url::kAboutBlankURL; | 5263 !history_item_is_about_blank || url != url::kAboutBlankURL; |
| 5272 parent->history_subframe_unique_names_.erase(frame_->uniqueName().utf8()); | 5264 parent->history_subframe_unique_names_.erase(frame_->uniqueName().utf8()); |
| 5273 } | 5265 } |
| 5274 | 5266 |
| 5275 if (should_ask_browser) { | 5267 if (should_ask_browser) { |
| 5276 // Don't do this if |info| also says it is a client redirect, in which | 5268 // Don't do this if |info| also says it is a client redirect, in which |
| 5277 // case JavaScript on the page is trying to interrupt the history | 5269 // case JavaScript on the page is trying to interrupt the history |
| 5278 // navigation. | 5270 // navigation. |
| 5279 if (!info.isClientRedirect) { | 5271 if (!info.isClientRedirect) { |
| 5280 OpenURL(url, IsHttpPost(info.urlRequest), | 5272 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5281 GetRequestBodyForWebURLRequest(info.urlRequest), | 5273 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5282 GetWebURLRequestHeaders(info.urlRequest), referrer, | 5274 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| 5283 info.defaultPolicy, info.replacesCurrentHistoryItem, true); | 5275 info.defaultPolicy, info.loadType); |
| 5284 // Suppress the load in Blink but mark the frame as loading. | 5276 // Suppress the load in Blink but mark the frame as loading. |
| 5285 return blink::WebNavigationPolicyHandledByClient; | 5277 return blink::WebNavigationPolicyHandledByClient; |
| 5286 } else { | 5278 } else { |
| 5287 // Client redirects during an initial history load should attempt to | 5279 // Client redirects during an initial history load should attempt to |
| 5288 // cancel the history navigation. They will create a provisional | 5280 // cancel the history navigation. They will create a provisional |
| 5289 // document loader, causing the history load to be ignored in | 5281 // document loader, causing the history load to be ignored in |
| 5290 // NavigateInternal, and this IPC will try to cancel any cross-process | 5282 // NavigateInternal, and this IPC will try to cancel any cross-process |
| 5291 // history load. | 5283 // history load. |
| 5292 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); | 5284 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); |
| 5293 } | 5285 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5315 // must be handled by the browser process (except for reloads - those are | 5307 // must be handled by the browser process (except for reloads - those are |
| 5316 // safe to leave within the renderer). | 5308 // safe to leave within the renderer). |
| 5317 // Lastly, access to file:// URLs from non-file:// URL pages must be | 5309 // Lastly, access to file:// URLs from non-file:// URL pages must be |
| 5318 // handled by the browser so that ordinary renderer processes don't get | 5310 // handled by the browser so that ordinary renderer processes don't get |
| 5319 // blessed with file permissions. | 5311 // blessed with file permissions. |
| 5320 int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); | 5312 int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); |
| 5321 bool is_initial_navigation = render_view_->history_list_length_ == 0; | 5313 bool is_initial_navigation = render_view_->history_list_length_ == 0; |
| 5322 bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) || | 5314 bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) || |
| 5323 (cumulative_bindings & BINDINGS_POLICY_WEB_UI) || | 5315 (cumulative_bindings & BINDINGS_POLICY_WEB_UI) || |
| 5324 url.SchemeIs(kViewSourceScheme) || | 5316 url.SchemeIs(kViewSourceScheme) || |
| 5325 (frame_->isViewSourceModeEnabled() && | 5317 (frame_->isViewSourceModeEnabled() && is_reload); |
| 5326 info.navigationType != blink::WebNavigationTypeReload); | |
| 5327 | 5318 |
| 5328 if (!should_fork && url.SchemeIs(url::kFileScheme)) { | 5319 if (!should_fork && url.SchemeIs(url::kFileScheme)) { |
| 5329 // Fork non-file to file opens. Note that this may fork unnecessarily if | 5320 // Fork non-file to file opens. Note that this may fork unnecessarily if |
| 5330 // another tab (hosting a file or not) targeted this one before its | 5321 // another tab (hosting a file or not) targeted this one before its |
| 5331 // initial navigation, but that shouldn't cause a problem. | 5322 // initial navigation, but that shouldn't cause a problem. |
| 5332 should_fork = !old_url.SchemeIs(url::kFileScheme); | 5323 should_fork = !old_url.SchemeIs(url::kFileScheme); |
| 5333 } | 5324 } |
| 5334 | 5325 |
| 5335 if (!should_fork) { | 5326 if (!should_fork) { |
| 5336 // Give the embedder a chance. | 5327 // Give the embedder a chance. |
| 5337 should_fork = GetContentClient()->renderer()->ShouldFork( | 5328 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 5338 frame_, url, info.urlRequest.httpMethod().utf8(), | 5329 frame_, url, info.urlRequest.httpMethod().utf8(), |
| 5339 is_initial_navigation, is_redirect, &send_referrer); | 5330 is_initial_navigation, is_redirect, &send_referrer); |
| 5340 } | 5331 } |
| 5341 | 5332 |
| 5342 if (should_fork) { | 5333 if (should_fork) { |
| 5343 OpenURL(url, IsHttpPost(info.urlRequest), | 5334 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5344 GetRequestBodyForWebURLRequest(info.urlRequest), | 5335 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5345 GetWebURLRequestHeaders(info.urlRequest), | 5336 GetWebURLRequestHeaders(info.urlRequest), |
| 5346 send_referrer ? referrer : Referrer(), info.defaultPolicy, | 5337 send_referrer ? referrer : Referrer(), info.defaultPolicy, |
| 5347 info.replacesCurrentHistoryItem, false); | 5338 info.loadType); |
| 5348 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5339 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5349 } | 5340 } |
| 5350 } | 5341 } |
| 5351 | 5342 |
| 5352 // Detect when a page is "forking" a new tab that can be safely rendered in | 5343 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 5353 // its own process. This is done by sites like Gmail that try to open links | 5344 // its own process. This is done by sites like Gmail that try to open links |
| 5354 // in new windows without script connections back to the original page. We | 5345 // in new windows without script connections back to the original page. We |
| 5355 // treat such cases as browser navigations (in which we will create a new | 5346 // treat such cases as browser navigations (in which we will create a new |
| 5356 // renderer for a cross-site navigation), rather than WebKit navigations. | 5347 // renderer for a cross-site navigation), rather than WebKit navigations. |
| 5357 // | 5348 // |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5371 render_view_->historyForwardListCount() < 1 && | 5362 render_view_->historyForwardListCount() < 1 && |
| 5372 // The parent page must have set the child's window.opener to null before | 5363 // The parent page must have set the child's window.opener to null before |
| 5373 // redirecting to the desired URL. | 5364 // redirecting to the desired URL. |
| 5374 frame_->opener() == NULL && | 5365 frame_->opener() == NULL && |
| 5375 // Must be a top-level frame. | 5366 // Must be a top-level frame. |
| 5376 frame_->parent() == NULL && | 5367 frame_->parent() == NULL && |
| 5377 // Must not have issued the request from this page. | 5368 // Must not have issued the request from this page. |
| 5378 is_content_initiated && | 5369 is_content_initiated && |
| 5379 // Must be targeted at the current tab. | 5370 // Must be targeted at the current tab. |
| 5380 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5371 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5381 // Must be a JavaScript navigation, which appears as "other". | 5372 // Must be a JavaScript navigation. |
| 5382 info.navigationType == blink::WebNavigationTypeOther; | 5373 info.isClientRedirect; |
| 5383 | 5374 |
| 5384 if (is_fork) { | 5375 if (is_fork) { |
| 5385 // Open the URL via the browser, not via WebKit. | 5376 // Open the URL via the browser, not via WebKit. |
| 5386 OpenURL(url, IsHttpPost(info.urlRequest), | 5377 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5387 GetRequestBodyForWebURLRequest(info.urlRequest), | 5378 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5388 GetWebURLRequestHeaders(info.urlRequest), Referrer(), | 5379 GetWebURLRequestHeaders(info.urlRequest), Referrer(), |
| 5389 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5380 info.defaultPolicy, info.loadType); |
| 5390 return blink::WebNavigationPolicyIgnore; | 5381 return blink::WebNavigationPolicyIgnore; |
| 5391 } | 5382 } |
| 5392 | 5383 |
| 5393 bool should_dispatch_before_unload = | 5384 bool should_dispatch_before_unload = |
| 5394 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 5385 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
| 5395 // There is no need to execute the BeforeUnload event during a redirect, | 5386 // There is no need to execute the BeforeUnload event during a redirect, |
| 5396 // since it was already executed at the start of the navigation. | 5387 // since it was already executed at the start of the navigation. |
| 5397 !is_redirect && | 5388 !is_redirect && |
| 5398 // PlzNavigate: this should not be executed when commiting the navigation. | 5389 // PlzNavigate: this should not be executed when commiting the navigation. |
| 5399 (!IsBrowserSideNavigationEnabled() || | 5390 (!IsBrowserSideNavigationEnabled() || |
| 5400 info.urlRequest.checkForBrowserSideNavigation()) && | 5391 info.urlRequest.checkForBrowserSideNavigation()) && |
| 5401 // No need to dispatch beforeunload if the frame has not committed a | 5392 // No need to dispatch beforeunload if the frame has not committed a |
| 5402 // navigation and contains an empty initial document. | 5393 // navigation and contains an empty initial document. |
| 5403 (has_accessed_initial_document_ || !current_history_item_.isNull()); | 5394 (has_accessed_initial_document_ || !current_history_item_.isNull()); |
| 5404 | 5395 |
| 5405 if (should_dispatch_before_unload) { | 5396 if (should_dispatch_before_unload) { |
| 5406 // Execute the BeforeUnload event. If asked not to proceed or the frame is | 5397 // Execute the BeforeUnload event. If asked not to proceed or the frame is |
| 5407 // destroyed, ignore the navigation. | 5398 // destroyed, ignore the navigation. |
| 5408 // Keep a WeakPtr to this RenderFrameHost to detect if executing the | 5399 // Keep a WeakPtr to this RenderFrameHost to detect if executing the |
| 5409 // BeforeUnload event destriyed this frame. | 5400 // BeforeUnload event destriyed this frame. |
| 5410 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); | 5401 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); |
| 5411 | 5402 |
| 5412 if (!frame_->dispatchBeforeUnloadEvent(info.navigationType == | 5403 if (!frame_->dispatchBeforeUnloadEvent(is_reload) || !weak_self) |
| 5413 blink::WebNavigationTypeReload) || | |
| 5414 !weak_self) { | |
| 5415 return blink::WebNavigationPolicyIgnore; | 5404 return blink::WebNavigationPolicyIgnore; |
| 5416 } | |
| 5417 | 5405 |
| 5418 // |navigation_start| must be recorded immediately after dispatching the | 5406 // |navigation_start| must be recorded immediately after dispatching the |
| 5419 // beforeunload event. | 5407 // beforeunload event. |
| 5420 if (pending_navigation_params_) { | 5408 if (pending_navigation_params_) { |
| 5421 pending_navigation_params_->common_params.navigation_start = | 5409 pending_navigation_params_->common_params.navigation_start = |
| 5422 base::TimeTicks::Now(); | 5410 base::TimeTicks::Now(); |
| 5423 } | 5411 } |
| 5424 } | 5412 } |
| 5425 | 5413 |
| 5426 // PlzNavigate: if the navigation is not synchronous, send it to the browser. | 5414 // PlzNavigate: if the navigation is not synchronous, send it to the browser. |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5740 #endif | 5728 #endif |
| 5741 #endif | 5729 #endif |
| 5742 | 5730 |
| 5743 void RenderFrameImpl::OpenURL( | 5731 void RenderFrameImpl::OpenURL( |
| 5744 const GURL& url, | 5732 const GURL& url, |
| 5745 bool uses_post, | 5733 bool uses_post, |
| 5746 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, | 5734 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body, |
| 5747 const std::string& extra_headers, | 5735 const std::string& extra_headers, |
| 5748 const Referrer& referrer, | 5736 const Referrer& referrer, |
| 5749 WebNavigationPolicy policy, | 5737 WebNavigationPolicy policy, |
| 5750 bool should_replace_current_entry, | 5738 WebFrameLoadType load_type) { |
| 5751 bool is_history_navigation_in_new_child) { | |
| 5752 FrameHostMsg_OpenURL_Params params; | 5739 FrameHostMsg_OpenURL_Params params; |
| 5753 params.url = url; | 5740 params.url = url; |
| 5754 params.uses_post = uses_post; | 5741 params.uses_post = uses_post; |
| 5755 params.resource_request_body = resource_request_body; | 5742 params.resource_request_body = resource_request_body; |
| 5756 params.extra_headers = extra_headers; | 5743 params.extra_headers = extra_headers; |
| 5757 params.referrer = referrer; | 5744 params.referrer = referrer; |
| 5758 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5745 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
| 5759 | 5746 |
| 5760 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5747 params.should_replace_current_entry = |
| 5761 // This is necessary to preserve the should_replace_current_entry value on | 5748 load_type == WebFrameLoadType::ReplaceCurrentItem && |
| 5762 // cross-process redirects, in the event it was set by a previous process. | 5749 (IsBrowserInitiated(pending_navigation_params_.get()) || |
| 5763 WebDataSource* ds = frame_->provisionalDataSource(); | 5750 render_view_->history_list_length_); |
| 5764 DCHECK(ds); | |
| 5765 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | |
| 5766 } else { | |
| 5767 params.should_replace_current_entry = | |
| 5768 should_replace_current_entry && render_view_->history_list_length_; | |
| 5769 } | |
| 5770 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 5751 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
| 5771 if (GetContentClient()->renderer()->AllowPopup()) | 5752 if (GetContentClient()->renderer()->AllowPopup()) |
| 5772 params.user_gesture = true; | 5753 params.user_gesture = true; |
| 5773 | 5754 |
| 5774 if (policy == blink::WebNavigationPolicyNewBackgroundTab || | 5755 if (policy == blink::WebNavigationPolicyNewBackgroundTab || |
| 5775 policy == blink::WebNavigationPolicyNewForegroundTab || | 5756 policy == blink::WebNavigationPolicyNewForegroundTab || |
| 5776 policy == blink::WebNavigationPolicyNewWindow || | 5757 policy == blink::WebNavigationPolicyNewWindow || |
| 5777 policy == blink::WebNavigationPolicyNewPopup) { | 5758 policy == blink::WebNavigationPolicyNewPopup) { |
| 5778 WebUserGestureIndicator::consumeUserGesture(); | 5759 WebUserGestureIndicator::consumeUserGesture(); |
| 5779 } | 5760 } |
| 5780 | 5761 |
| 5781 if (is_history_navigation_in_new_child) | 5762 if (load_type == WebFrameLoadType::InitialHistoryLoad) |
| 5782 params.is_history_navigation_in_new_child = true; | 5763 params.is_history_navigation_in_new_child = true; |
| 5783 | 5764 |
| 5784 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 5765 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 5785 } | 5766 } |
| 5786 | 5767 |
| 5787 void RenderFrameImpl::NavigateInternal( | 5768 void RenderFrameImpl::NavigateInternal( |
| 5788 const CommonNavigationParams& common_params, | 5769 const CommonNavigationParams& common_params, |
| 5789 const StartNavigationParams& start_params, | 5770 const StartNavigationParams& start_params, |
| 5790 const RequestNavigationParams& request_params, | 5771 const RequestNavigationParams& request_params, |
| 5791 std::unique_ptr<StreamOverrideParameters> stream_params) { | 5772 std::unique_ptr<StreamOverrideParameters> stream_params) { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6167 // Note: At this stage, the goal is to apply all the modifications the | 6148 // Note: At this stage, the goal is to apply all the modifications the |
| 6168 // renderer wants to make to the request, and then send it to the browser, so | 6149 // renderer wants to make to the request, and then send it to the browser, so |
| 6169 // that the actual network request can be started. Ideally, all such | 6150 // that the actual network request can be started. Ideally, all such |
| 6170 // modifications should take place in willSendRequest, and in the | 6151 // modifications should take place in willSendRequest, and in the |
| 6171 // implementation of willSendRequest for the various InspectorAgents | 6152 // implementation of willSendRequest for the various InspectorAgents |
| 6172 // (devtools). | 6153 // (devtools). |
| 6173 // | 6154 // |
| 6174 // TODO(clamy): Apply devtools override. | 6155 // TODO(clamy): Apply devtools override. |
| 6175 // TODO(clamy): Make sure that navigation requests are not modified somewhere | 6156 // TODO(clamy): Make sure that navigation requests are not modified somewhere |
| 6176 // else in blink. | 6157 // else in blink. |
| 6177 willSendRequest(frame_, info.urlRequest); | 6158 willSendRequest(frame_, info.urlRequest, info.loadType); |
| 6178 | 6159 |
| 6179 // Update the transition type of the request for client side redirects. | 6160 // Update the transition type of the request for client side redirects. |
| 6180 if (!info.urlRequest.getExtraData()) | 6161 if (!info.urlRequest.getExtraData()) |
| 6181 info.urlRequest.setExtraData(new RequestExtraData()); | 6162 info.urlRequest.setExtraData(new RequestExtraData()); |
| 6182 if (info.isClientRedirect) { | 6163 if (info.isClientRedirect) { |
| 6183 RequestExtraData* extra_data = | 6164 RequestExtraData* extra_data = |
| 6184 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); | 6165 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
| 6185 extra_data->set_transition_type(ui::PageTransitionFromInt( | 6166 extra_data->set_transition_type(ui::PageTransitionFromInt( |
| 6186 extra_data->transition_type() | ui::PAGE_TRANSITION_CLIENT_REDIRECT)); | 6167 extra_data->transition_type() | ui::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 6187 } | 6168 } |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6796 // event target. Potentially a Pepper plugin will receive the event. | 6777 // event target. Potentially a Pepper plugin will receive the event. |
| 6797 // In order to tell whether a plugin gets the last mouse event and which it | 6778 // In order to tell whether a plugin gets the last mouse event and which it |
| 6798 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6779 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6799 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6780 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6800 // |pepper_last_mouse_event_target_|. | 6781 // |pepper_last_mouse_event_target_|. |
| 6801 pepper_last_mouse_event_target_ = nullptr; | 6782 pepper_last_mouse_event_target_ = nullptr; |
| 6802 #endif | 6783 #endif |
| 6803 } | 6784 } |
| 6804 | 6785 |
| 6805 } // namespace content | 6786 } // namespace content |
| OLD | NEW |