Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2557233002: Revert of Set user_gesture bit at NavigationHandle creation time. (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/test/test_render_frame_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime()); 635 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime());
636 FrameMsg_UILoadMetricsReportType::Value report_type = 636 FrameMsg_UILoadMetricsReportType::Value report_type =
637 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 637 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
638 info.urlRequest.inputPerfMetricReportPolicy()); 638 info.urlRequest.inputPerfMetricReportPolicy());
639 639
640 FrameMsg_Navigate_Type::Value navigation_type = 640 FrameMsg_Navigate_Type::Value navigation_type =
641 info.navigationType == blink::WebNavigationTypeReload 641 info.navigationType == blink::WebNavigationTypeReload
642 ? FrameMsg_Navigate_Type::RELOAD 642 ? FrameMsg_Navigate_Type::RELOAD
643 : FrameMsg_Navigate_Type::NORMAL; 643 : FrameMsg_Navigate_Type::NORMAL;
644 644
645 NavigationGesture gesture = info.urlRequest.hasUserGesture()
646 ? NavigationGestureUser
647 : NavigationGestureAuto;
648 const RequestExtraData* extra_data = 645 const RequestExtraData* extra_data =
649 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); 646 static_cast<RequestExtraData*>(info.urlRequest.getExtraData());
650 DCHECK(extra_data); 647 DCHECK(extra_data);
651 return CommonNavigationParams( 648 return CommonNavigationParams(
652 info.urlRequest.url(), referrer, extra_data->transition_type(), 649 info.urlRequest.url(), referrer, extra_data->transition_type(),
653 navigation_type, gesture, true, info.replacesCurrentHistoryItem, 650 navigation_type, true, info.replacesCurrentHistoryItem, ui_timestamp,
654 ui_timestamp, report_type, GURL(), GURL(), 651 report_type, GURL(), GURL(),
655 static_cast<LoFiState>(info.urlRequest.getLoFiState()), 652 static_cast<LoFiState>(info.urlRequest.getLoFiState()),
656 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), 653 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(),
657 GetRequestBodyForWebURLRequest(info.urlRequest)); 654 GetRequestBodyForWebURLRequest(info.urlRequest));
658 } 655 }
659 656
660 media::Context3D GetSharedMainThreadContext3D( 657 media::Context3D GetSharedMainThreadContext3D(
661 scoped_refptr<ContextProviderCommandBuffer> provider) { 658 scoped_refptr<ContextProviderCommandBuffer> provider) {
662 if (!provider) 659 if (!provider)
663 return media::Context3D(); 660 return media::Context3D();
664 return media::Context3D(provider->ContextGL(), provider->GrContext()); 661 return media::Context3D(provider->ContextGL(), provider->GrContext());
(...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 if (!ds) 3381 if (!ds)
3385 return; 3382 return;
3386 3383
3387 TRACE_EVENT2("navigation,benchmark,rail", 3384 TRACE_EVENT2("navigation,benchmark,rail",
3388 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, 3385 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_,
3389 "url", ds->request().url().string().utf8()); 3386 "url", ds->request().url().string().utf8());
3390 DocumentState* document_state = DocumentState::FromDataSource(ds); 3387 DocumentState* document_state = DocumentState::FromDataSource(ds);
3391 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( 3388 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(
3392 document_state->navigation_state()); 3389 document_state->navigation_state());
3393 bool is_top_most = !frame->parent(); 3390 bool is_top_most = !frame->parent();
3394 NavigationGesture gesture = WebUserGestureIndicator::isProcessingUserGesture()
3395 ? NavigationGestureUser
3396 : NavigationGestureAuto;
3397 if (is_top_most) { 3391 if (is_top_most) {
3398 render_view_->set_navigation_gesture(gesture); 3392 render_view_->set_navigation_gesture(
3393 WebUserGestureIndicator::isProcessingUserGesture() ?
3394 NavigationGestureUser : NavigationGestureAuto);
3399 } else if (ds->replacesCurrentHistoryItem()) { 3395 } else if (ds->replacesCurrentHistoryItem()) {
3400 // Subframe navigations that don't add session history items must be 3396 // Subframe navigations that don't add session history items must be
3401 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 3397 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
3402 // handle loading of error pages. 3398 // handle loading of error pages.
3403 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); 3399 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME);
3404 } 3400 }
3405 3401
3406 base::TimeTicks navigation_start = 3402 base::TimeTicks navigation_start =
3407 navigation_state->common_params().navigation_start; 3403 navigation_state->common_params().navigation_start;
3408 DCHECK(!navigation_start.is_null()); 3404 DCHECK(!navigation_start.is_null());
3409 3405
3410 for (auto& observer : render_view_->observers()) 3406 for (auto& observer : render_view_->observers())
3411 observer.DidStartProvisionalLoad(frame); 3407 observer.DidStartProvisionalLoad(frame);
3412 for (auto& observer : observers_) 3408 for (auto& observer : observers_)
3413 observer.DidStartProvisionalLoad(); 3409 observer.DidStartProvisionalLoad();
3414 3410
3415 Send(new FrameHostMsg_DidStartProvisionalLoad( 3411 Send(new FrameHostMsg_DidStartProvisionalLoad(
3416 routing_id_, ds->request().url(), navigation_start, gesture)); 3412 routing_id_, ds->request().url(), navigation_start));
3417 } 3413 }
3418 3414
3419 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( 3415 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
3420 blink::WebLocalFrame* frame) { 3416 blink::WebLocalFrame* frame) {
3421 DCHECK_EQ(frame_, frame); 3417 DCHECK_EQ(frame_, frame);
3422 3418
3423 // We don't use HistoryController in OOPIF enabled modes. 3419 // We don't use HistoryController in OOPIF enabled modes.
3424 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3420 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
3425 return; 3421 return;
3426 3422
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
4784 if (GURL(frame->document().baseURL()) != params.url) 4780 if (GURL(frame->document().baseURL()) != params.url)
4785 params.base_url = frame->document().baseURL(); 4781 params.base_url = frame->document().baseURL();
4786 4782
4787 GetRedirectChain(ds, &params.redirects); 4783 GetRedirectChain(ds, &params.redirects);
4788 params.should_update_history = 4784 params.should_update_history =
4789 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; 4785 !ds->hasUnreachableURL() && response.httpStatusCode() != 404;
4790 4786
4791 params.searchable_form_url = internal_data->searchable_form_url(); 4787 params.searchable_form_url = internal_data->searchable_form_url();
4792 params.searchable_form_encoding = internal_data->searchable_form_encoding(); 4788 params.searchable_form_encoding = internal_data->searchable_form_encoding();
4793 4789
4794 params.gesture = render_view_->navigation_gesture(); 4790 params.gesture = render_view_->navigation_gesture_;
4795 render_view_->set_navigation_gesture(NavigationGestureUnknown); 4791 render_view_->navigation_gesture_ = NavigationGestureUnknown;
4796 4792
4797 // Make navigation state a part of the DidCommitProvisionalLoad message so 4793 // Make navigation state a part of the DidCommitProvisionalLoad message so
4798 // that committed entry has it at all times. 4794 // that committed entry has it at all times.
4799 int64_t post_id = -1; 4795 int64_t post_id = -1;
4800 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { 4796 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) {
4801 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); 4797 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry();
4802 if (entry) { 4798 if (entry) {
4803 params.page_state = HistoryEntryToPageState(entry); 4799 params.page_state = HistoryEntryToPageState(entry);
4804 post_id = ExtractPostId(entry->root()); 4800 post_id = ExtractPostId(entry->root());
4805 } else { 4801 } else {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
5024 std::unique_ptr<StreamOverrideParameters> stream_override( 5020 std::unique_ptr<StreamOverrideParameters> stream_override(
5025 new StreamOverrideParameters()); 5021 new StreamOverrideParameters());
5026 stream_override->stream_url = stream_url; 5022 stream_override->stream_url = stream_url;
5027 stream_override->response = response; 5023 stream_override->response = response;
5028 stream_override->redirects = request_params.redirects; 5024 stream_override->redirects = request_params.redirects;
5029 stream_override->redirect_responses = request_params.redirect_response; 5025 stream_override->redirect_responses = request_params.redirect_response;
5030 5026
5031 // If the request was initiated in the context of a user gesture then make 5027 // If the request was initiated in the context of a user gesture then make
5032 // sure that the navigation also executes in the context of a user gesture. 5028 // sure that the navigation also executes in the context of a user gesture.
5033 std::unique_ptr<blink::WebScopedUserGesture> gesture( 5029 std::unique_ptr<blink::WebScopedUserGesture> gesture(
5034 (common_params.gesture == NavigationGestureUser) 5030 request_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_)
5035 ? new blink::WebScopedUserGesture(frame_) 5031 : nullptr);
5036 : nullptr);
5037 5032
5038 NavigateInternal(common_params, StartNavigationParams(), request_params, 5033 NavigateInternal(common_params, StartNavigationParams(), request_params,
5039 std::move(stream_override)); 5034 std::move(stream_override));
5040 5035
5041 browser_side_navigation_pending_ = false; 5036 browser_side_navigation_pending_ = false;
5042 } 5037 }
5043 5038
5044 // PlzNavigate 5039 // PlzNavigate
5045 void RenderFrameImpl::OnFailedNavigation( 5040 void RenderFrameImpl::OnFailedNavigation(
5046 const CommonNavigationParams& common_params, 5041 const CommonNavigationParams& common_params,
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
5756 : blink::WebURLRequest::FrameTypeNested); 5751 : blink::WebURLRequest::FrameTypeNested);
5757 5752
5758 if (IsBrowserSideNavigationEnabled() && common_params.post_data) 5753 if (IsBrowserSideNavigationEnabled() && common_params.post_data)
5759 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); 5754 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data));
5760 5755
5761 // Used to determine whether this frame is actually loading a request as part 5756 // Used to determine whether this frame is actually loading a request as part
5762 // of a history navigation. 5757 // of a history navigation.
5763 bool has_history_navigation_in_frame = false; 5758 bool has_history_navigation_in_frame = false;
5764 5759
5765 #if defined(OS_ANDROID) 5760 #if defined(OS_ANDROID)
5766 request.setHasUserGesture(common_params.gesture == NavigationGestureUser); 5761 request.setHasUserGesture(request_params.has_user_gesture);
5767 #endif 5762 #endif
5768 5763
5769 if (browser_side_navigation) { 5764 if (browser_side_navigation) {
5770 // PlzNavigate: Make sure that Blink's loader will not try to use browser 5765 // PlzNavigate: Make sure that Blink's loader will not try to use browser
5771 // side navigation for this request (since it already went to the browser). 5766 // side navigation for this request (since it already went to the browser).
5772 request.setCheckForBrowserSideNavigation(false); 5767 request.setCheckForBrowserSideNavigation(false);
5773 5768
5774 request.setNavigationStartTime( 5769 request.setNavigationStartTime(
5775 ConvertToBlinkTime(common_params.navigation_start)); 5770 ConvertToBlinkTime(common_params.navigation_start));
5776 } 5771 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
6124 DCHECK(frame_->parent() || 6119 DCHECK(frame_->parent() ||
6125 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 6120 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
6126 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 6121 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
6127 DCHECK(!frame_->parent() || 6122 DCHECK(!frame_->parent() ||
6128 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 6123 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
6129 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 6124 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
6130 6125
6131 BeginNavigationParams begin_navigation_params( 6126 BeginNavigationParams begin_navigation_params(
6132 GetWebURLRequestHeaders(info.urlRequest), 6127 GetWebURLRequestHeaders(info.urlRequest),
6133 GetLoadFlagsForWebURLRequest(info.urlRequest), 6128 GetLoadFlagsForWebURLRequest(info.urlRequest),
6129 info.urlRequest.hasUserGesture(),
6134 info.urlRequest.skipServiceWorker() != 6130 info.urlRequest.skipServiceWorker() !=
6135 blink::WebURLRequest::SkipServiceWorker::None, 6131 blink::WebURLRequest::SkipServiceWorker::None,
6136 GetRequestContextTypeForWebURLRequest(info.urlRequest)); 6132 GetRequestContextTypeForWebURLRequest(info.urlRequest));
6137 6133
6138 if (!info.form.isNull()) { 6134 if (!info.form.isNull()) {
6139 WebSearchableFormData web_searchable_form_data(info.form); 6135 WebSearchableFormData web_searchable_form_data(info.form);
6140 begin_navigation_params.searchable_form_url = 6136 begin_navigation_params.searchable_form_url =
6141 web_searchable_form_data.url(); 6137 web_searchable_form_data.url();
6142 begin_navigation_params.searchable_form_encoding = 6138 begin_navigation_params.searchable_form_encoding =
6143 web_searchable_form_data.encoding().utf8(); 6139 web_searchable_form_data.encoding().utf8();
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
6681 // event target. Potentially a Pepper plugin will receive the event. 6677 // event target. Potentially a Pepper plugin will receive the event.
6682 // In order to tell whether a plugin gets the last mouse event and which it 6678 // In order to tell whether a plugin gets the last mouse event and which it
6683 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6679 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6684 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6680 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6685 // |pepper_last_mouse_event_target_|. 6681 // |pepper_last_mouse_event_target_|.
6686 pepper_last_mouse_event_target_ = nullptr; 6682 pepper_last_mouse_event_target_ = nullptr;
6687 #endif 6683 #endif
6688 } 6684 }
6689 6685
6690 } // namespace content 6686 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/test/test_render_frame_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698