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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime()); | 633 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime()); |
634 FrameMsg_UILoadMetricsReportType::Value report_type = | 634 FrameMsg_UILoadMetricsReportType::Value report_type = |
635 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 635 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
636 info.urlRequest.inputPerfMetricReportPolicy()); | 636 info.urlRequest.inputPerfMetricReportPolicy()); |
637 | 637 |
638 FrameMsg_Navigate_Type::Value navigation_type = | 638 FrameMsg_Navigate_Type::Value navigation_type = |
639 info.navigationType == blink::WebNavigationTypeReload | 639 info.navigationType == blink::WebNavigationTypeReload |
640 ? FrameMsg_Navigate_Type::RELOAD | 640 ? FrameMsg_Navigate_Type::RELOAD |
641 : FrameMsg_Navigate_Type::NORMAL; | 641 : FrameMsg_Navigate_Type::NORMAL; |
642 | 642 |
| 643 NavigationGesture gesture = info.urlRequest.hasUserGesture() |
| 644 ? NavigationGestureUser |
| 645 : NavigationGestureAuto; |
643 const RequestExtraData* extra_data = | 646 const RequestExtraData* extra_data = |
644 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); | 647 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
645 DCHECK(extra_data); | 648 DCHECK(extra_data); |
646 return CommonNavigationParams( | 649 return CommonNavigationParams( |
647 info.urlRequest.url(), referrer, extra_data->transition_type(), | 650 info.urlRequest.url(), referrer, extra_data->transition_type(), |
648 navigation_type, true, info.replacesCurrentHistoryItem, ui_timestamp, | 651 navigation_type, gesture, true, info.replacesCurrentHistoryItem, |
649 report_type, GURL(), GURL(), | 652 ui_timestamp, report_type, GURL(), GURL(), |
650 static_cast<LoFiState>(info.urlRequest.getLoFiState()), | 653 static_cast<LoFiState>(info.urlRequest.getLoFiState()), |
651 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), | 654 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), |
652 GetRequestBodyForWebURLRequest(info.urlRequest)); | 655 GetRequestBodyForWebURLRequest(info.urlRequest)); |
653 } | 656 } |
654 | 657 |
655 media::Context3D GetSharedMainThreadContext3D( | 658 media::Context3D GetSharedMainThreadContext3D( |
656 scoped_refptr<ContextProviderCommandBuffer> provider) { | 659 scoped_refptr<ContextProviderCommandBuffer> provider) { |
657 if (!provider) | 660 if (!provider) |
658 return media::Context3D(); | 661 return media::Context3D(); |
659 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 662 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
(...skipping 2710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3370 if (!ds) | 3373 if (!ds) |
3371 return; | 3374 return; |
3372 | 3375 |
3373 TRACE_EVENT2("navigation,benchmark,rail", | 3376 TRACE_EVENT2("navigation,benchmark,rail", |
3374 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, | 3377 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, |
3375 "url", ds->request().url().string().utf8()); | 3378 "url", ds->request().url().string().utf8()); |
3376 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3379 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3377 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( | 3380 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( |
3378 document_state->navigation_state()); | 3381 document_state->navigation_state()); |
3379 bool is_top_most = !frame->parent(); | 3382 bool is_top_most = !frame->parent(); |
| 3383 NavigationGesture gesture = WebUserGestureIndicator::isProcessingUserGesture() |
| 3384 ? NavigationGestureUser |
| 3385 : NavigationGestureAuto; |
3380 if (is_top_most) { | 3386 if (is_top_most) { |
3381 render_view_->set_navigation_gesture( | 3387 render_view_->set_navigation_gesture(gesture); |
3382 WebUserGestureIndicator::isProcessingUserGesture() ? | |
3383 NavigationGestureUser : NavigationGestureAuto); | |
3384 } else if (ds->replacesCurrentHistoryItem()) { | 3388 } else if (ds->replacesCurrentHistoryItem()) { |
3385 // Subframe navigations that don't add session history items must be | 3389 // Subframe navigations that don't add session history items must be |
3386 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we | 3390 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we |
3387 // handle loading of error pages. | 3391 // handle loading of error pages. |
3388 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 3392 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
3389 } | 3393 } |
3390 | 3394 |
3391 base::TimeTicks navigation_start = | 3395 base::TimeTicks navigation_start = |
3392 navigation_state->common_params().navigation_start; | 3396 navigation_state->common_params().navigation_start; |
3393 DCHECK(!navigation_start.is_null()); | 3397 DCHECK(!navigation_start.is_null()); |
3394 | 3398 |
3395 for (auto& observer : render_view_->observers()) | 3399 for (auto& observer : render_view_->observers()) |
3396 observer.DidStartProvisionalLoad(frame); | 3400 observer.DidStartProvisionalLoad(frame); |
3397 for (auto& observer : observers_) | 3401 for (auto& observer : observers_) |
3398 observer.DidStartProvisionalLoad(); | 3402 observer.DidStartProvisionalLoad(); |
3399 | 3403 |
3400 Send(new FrameHostMsg_DidStartProvisionalLoad( | 3404 Send(new FrameHostMsg_DidStartProvisionalLoad( |
3401 routing_id_, ds->request().url(), navigation_start)); | 3405 routing_id_, ds->request().url(), navigation_start, gesture)); |
3402 } | 3406 } |
3403 | 3407 |
3404 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 3408 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
3405 blink::WebLocalFrame* frame) { | 3409 blink::WebLocalFrame* frame) { |
3406 DCHECK_EQ(frame_, frame); | 3410 DCHECK_EQ(frame_, frame); |
3407 | 3411 |
3408 // We don't use HistoryController in OOPIF enabled modes. | 3412 // We don't use HistoryController in OOPIF enabled modes. |
3409 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3413 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
3410 return; | 3414 return; |
3411 | 3415 |
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4769 if (GURL(frame->document().baseURL()) != params.url) | 4773 if (GURL(frame->document().baseURL()) != params.url) |
4770 params.base_url = frame->document().baseURL(); | 4774 params.base_url = frame->document().baseURL(); |
4771 | 4775 |
4772 GetRedirectChain(ds, ¶ms.redirects); | 4776 GetRedirectChain(ds, ¶ms.redirects); |
4773 params.should_update_history = | 4777 params.should_update_history = |
4774 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; | 4778 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; |
4775 | 4779 |
4776 params.searchable_form_url = internal_data->searchable_form_url(); | 4780 params.searchable_form_url = internal_data->searchable_form_url(); |
4777 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 4781 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
4778 | 4782 |
4779 params.gesture = render_view_->navigation_gesture_; | 4783 params.gesture = render_view_->navigation_gesture(); |
4780 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 4784 render_view_->set_navigation_gesture(NavigationGestureUnknown); |
4781 | 4785 |
4782 // Make navigation state a part of the DidCommitProvisionalLoad message so | 4786 // Make navigation state a part of the DidCommitProvisionalLoad message so |
4783 // that committed entry has it at all times. | 4787 // that committed entry has it at all times. |
4784 int64_t post_id = -1; | 4788 int64_t post_id = -1; |
4785 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 4789 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
4786 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); | 4790 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); |
4787 if (entry) { | 4791 if (entry) { |
4788 params.page_state = HistoryEntryToPageState(entry); | 4792 params.page_state = HistoryEntryToPageState(entry); |
4789 post_id = ExtractPostId(entry->root()); | 4793 post_id = ExtractPostId(entry->root()); |
4790 } else { | 4794 } else { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5011 std::unique_ptr<StreamOverrideParameters> stream_override( | 5015 std::unique_ptr<StreamOverrideParameters> stream_override( |
5012 new StreamOverrideParameters()); | 5016 new StreamOverrideParameters()); |
5013 stream_override->stream_url = stream_url; | 5017 stream_override->stream_url = stream_url; |
5014 stream_override->response = response; | 5018 stream_override->response = response; |
5015 stream_override->redirects = request_params.redirects; | 5019 stream_override->redirects = request_params.redirects; |
5016 stream_override->redirect_responses = request_params.redirect_response; | 5020 stream_override->redirect_responses = request_params.redirect_response; |
5017 | 5021 |
5018 // If the request was initiated in the context of a user gesture then make | 5022 // If the request was initiated in the context of a user gesture then make |
5019 // sure that the navigation also executes in the context of a user gesture. | 5023 // sure that the navigation also executes in the context of a user gesture. |
5020 std::unique_ptr<blink::WebScopedUserGesture> gesture( | 5024 std::unique_ptr<blink::WebScopedUserGesture> gesture( |
5021 request_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_) | 5025 (common_params.gesture == NavigationGestureUser) |
5022 : nullptr); | 5026 ? new blink::WebScopedUserGesture(frame_) |
| 5027 : nullptr); |
5023 | 5028 |
5024 NavigateInternal(common_params, StartNavigationParams(), request_params, | 5029 NavigateInternal(common_params, StartNavigationParams(), request_params, |
5025 std::move(stream_override)); | 5030 std::move(stream_override)); |
5026 browser_side_navigation_pending_ = false; | 5031 browser_side_navigation_pending_ = false; |
5027 } | 5032 } |
5028 | 5033 |
5029 // PlzNavigate | 5034 // PlzNavigate |
5030 void RenderFrameImpl::OnFailedNavigation( | 5035 void RenderFrameImpl::OnFailedNavigation( |
5031 const CommonNavigationParams& common_params, | 5036 const CommonNavigationParams& common_params, |
5032 const RequestNavigationParams& request_params, | 5037 const RequestNavigationParams& request_params, |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5741 : blink::WebURLRequest::FrameTypeNested); | 5746 : blink::WebURLRequest::FrameTypeNested); |
5742 | 5747 |
5743 if (IsBrowserSideNavigationEnabled() && common_params.post_data) | 5748 if (IsBrowserSideNavigationEnabled() && common_params.post_data) |
5744 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); | 5749 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); |
5745 | 5750 |
5746 // Used to determine whether this frame is actually loading a request as part | 5751 // Used to determine whether this frame is actually loading a request as part |
5747 // of a history navigation. | 5752 // of a history navigation. |
5748 bool has_history_navigation_in_frame = false; | 5753 bool has_history_navigation_in_frame = false; |
5749 | 5754 |
5750 #if defined(OS_ANDROID) | 5755 #if defined(OS_ANDROID) |
5751 request.setHasUserGesture(request_params.has_user_gesture); | 5756 request.setHasUserGesture(common_params.gesture == NavigationGestureUser); |
5752 #endif | 5757 #endif |
5753 | 5758 |
5754 if (browser_side_navigation) { | 5759 if (browser_side_navigation) { |
5755 // PlzNavigate: Make sure that Blink's loader will not try to use browser | 5760 // PlzNavigate: Make sure that Blink's loader will not try to use browser |
5756 // side navigation for this request (since it already went to the browser). | 5761 // side navigation for this request (since it already went to the browser). |
5757 request.setCheckForBrowserSideNavigation(false); | 5762 request.setCheckForBrowserSideNavigation(false); |
5758 | 5763 |
5759 request.setNavigationStartTime( | 5764 request.setNavigationStartTime( |
5760 ConvertToBlinkTime(common_params.navigation_start)); | 5765 ConvertToBlinkTime(common_params.navigation_start)); |
5761 } | 5766 } |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6109 DCHECK(frame_->parent() || | 6114 DCHECK(frame_->parent() || |
6110 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == | 6115 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
6111 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | 6116 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); |
6112 DCHECK(!frame_->parent() || | 6117 DCHECK(!frame_->parent() || |
6113 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == | 6118 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
6114 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 6119 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
6115 | 6120 |
6116 BeginNavigationParams begin_navigation_params( | 6121 BeginNavigationParams begin_navigation_params( |
6117 GetWebURLRequestHeaders(info.urlRequest), | 6122 GetWebURLRequestHeaders(info.urlRequest), |
6118 GetLoadFlagsForWebURLRequest(info.urlRequest), | 6123 GetLoadFlagsForWebURLRequest(info.urlRequest), |
6119 info.urlRequest.hasUserGesture(), | |
6120 info.urlRequest.skipServiceWorker() != | 6124 info.urlRequest.skipServiceWorker() != |
6121 blink::WebURLRequest::SkipServiceWorker::None, | 6125 blink::WebURLRequest::SkipServiceWorker::None, |
6122 GetRequestContextTypeForWebURLRequest(info.urlRequest)); | 6126 GetRequestContextTypeForWebURLRequest(info.urlRequest)); |
6123 | 6127 |
6124 if (!info.form.isNull()) { | 6128 if (!info.form.isNull()) { |
6125 WebSearchableFormData web_searchable_form_data(info.form); | 6129 WebSearchableFormData web_searchable_form_data(info.form); |
6126 begin_navigation_params.searchable_form_url = | 6130 begin_navigation_params.searchable_form_url = |
6127 web_searchable_form_data.url(); | 6131 web_searchable_form_data.url(); |
6128 begin_navigation_params.searchable_form_encoding = | 6132 begin_navigation_params.searchable_form_encoding = |
6129 web_searchable_form_data.encoding().utf8(); | 6133 web_searchable_form_data.encoding().utf8(); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6667 // event target. Potentially a Pepper plugin will receive the event. | 6671 // event target. Potentially a Pepper plugin will receive the event. |
6668 // In order to tell whether a plugin gets the last mouse event and which it | 6672 // In order to tell whether a plugin gets the last mouse event and which it |
6669 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6673 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6670 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6674 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6671 // |pepper_last_mouse_event_target_|. | 6675 // |pepper_last_mouse_event_target_|. |
6672 pepper_last_mouse_event_target_ = nullptr; | 6676 pepper_last_mouse_event_target_ = nullptr; |
6673 #endif | 6677 #endif |
6674 } | 6678 } |
6675 | 6679 |
6676 } // namespace content | 6680 } // namespace content |
OLD | NEW |