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

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

Issue 2499313003: Set user_gesture bit at NavigationHandle creation time. (Closed)
Patch Set: address comments Created 4 years, 1 month 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
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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime()); 631 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime());
632 FrameMsg_UILoadMetricsReportType::Value report_type = 632 FrameMsg_UILoadMetricsReportType::Value report_type =
633 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 633 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
634 info.urlRequest.inputPerfMetricReportPolicy()); 634 info.urlRequest.inputPerfMetricReportPolicy());
635 635
636 FrameMsg_Navigate_Type::Value navigation_type = 636 FrameMsg_Navigate_Type::Value navigation_type =
637 info.navigationType == blink::WebNavigationTypeReload 637 info.navigationType == blink::WebNavigationTypeReload
638 ? FrameMsg_Navigate_Type::RELOAD 638 ? FrameMsg_Navigate_Type::RELOAD
639 : FrameMsg_Navigate_Type::NORMAL; 639 : FrameMsg_Navigate_Type::NORMAL;
640 640
641 NavigationGesture gesture = info.urlRequest.hasUserGesture()
642 ? NavigationGestureUser
643 : NavigationGestureAuto;
641 const RequestExtraData* extra_data = 644 const RequestExtraData* extra_data =
642 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); 645 static_cast<RequestExtraData*>(info.urlRequest.getExtraData());
643 DCHECK(extra_data); 646 DCHECK(extra_data);
644 return CommonNavigationParams( 647 return CommonNavigationParams(
645 info.urlRequest.url(), referrer, extra_data->transition_type(), 648 info.urlRequest.url(), referrer, extra_data->transition_type(),
646 navigation_type, true, info.replacesCurrentHistoryItem, ui_timestamp, 649 navigation_type, gesture, true, info.replacesCurrentHistoryItem,
647 report_type, GURL(), GURL(), 650 ui_timestamp, report_type, GURL(), GURL(),
648 static_cast<LoFiState>(info.urlRequest.getLoFiState()), 651 static_cast<LoFiState>(info.urlRequest.getLoFiState()),
649 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), 652 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(),
650 GetRequestBodyForWebURLRequest(info.urlRequest)); 653 GetRequestBodyForWebURLRequest(info.urlRequest));
651 } 654 }
652 655
653 media::Context3D GetSharedMainThreadContext3D( 656 media::Context3D GetSharedMainThreadContext3D(
654 scoped_refptr<ContextProviderCommandBuffer> provider) { 657 scoped_refptr<ContextProviderCommandBuffer> provider) {
655 if (!provider) 658 if (!provider)
656 return media::Context3D(); 659 return media::Context3D();
657 return media::Context3D(provider->ContextGL(), provider->GrContext()); 660 return media::Context3D(provider->ContextGL(), provider->GrContext());
(...skipping 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after
3345 if (!ds) 3348 if (!ds)
3346 return; 3349 return;
3347 3350
3348 TRACE_EVENT2("navigation,benchmark,rail", 3351 TRACE_EVENT2("navigation,benchmark,rail",
3349 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, 3352 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_,
3350 "url", ds->request().url().string().utf8()); 3353 "url", ds->request().url().string().utf8());
3351 DocumentState* document_state = DocumentState::FromDataSource(ds); 3354 DocumentState* document_state = DocumentState::FromDataSource(ds);
3352 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( 3355 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(
3353 document_state->navigation_state()); 3356 document_state->navigation_state());
3354 bool is_top_most = !frame->parent(); 3357 bool is_top_most = !frame->parent();
3358 NavigationGesture gesture = WebUserGestureIndicator::isProcessingUserGesture()
3359 ? NavigationGestureUser
3360 : NavigationGestureAuto;
3355 if (is_top_most) { 3361 if (is_top_most) {
3356 render_view_->set_navigation_gesture( 3362 render_view_->set_navigation_gesture(gesture);
3357 WebUserGestureIndicator::isProcessingUserGesture() ?
3358 NavigationGestureUser : NavigationGestureAuto);
3359 } else if (ds->replacesCurrentHistoryItem()) { 3363 } else if (ds->replacesCurrentHistoryItem()) {
3360 // Subframe navigations that don't add session history items must be 3364 // Subframe navigations that don't add session history items must be
3361 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 3365 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
3362 // handle loading of error pages. 3366 // handle loading of error pages.
3363 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); 3367 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME);
3364 } 3368 }
3365 3369
3366 base::TimeTicks navigation_start = 3370 base::TimeTicks navigation_start =
3367 navigation_state->common_params().navigation_start; 3371 navigation_state->common_params().navigation_start;
3368 DCHECK(!navigation_start.is_null()); 3372 DCHECK(!navigation_start.is_null());
3369 3373
3370 for (auto& observer : render_view_->observers()) 3374 for (auto& observer : render_view_->observers())
3371 observer.DidStartProvisionalLoad(frame); 3375 observer.DidStartProvisionalLoad(frame);
3372 for (auto& observer : observers_) 3376 for (auto& observer : observers_)
3373 observer.DidStartProvisionalLoad(); 3377 observer.DidStartProvisionalLoad();
3374 3378
3375 Send(new FrameHostMsg_DidStartProvisionalLoad( 3379 Send(new FrameHostMsg_DidStartProvisionalLoad(
3376 routing_id_, ds->request().url(), navigation_start)); 3380 routing_id_, ds->request().url(), navigation_start, gesture));
3377 } 3381 }
3378 3382
3379 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( 3383 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
3380 blink::WebLocalFrame* frame) { 3384 blink::WebLocalFrame* frame) {
3381 DCHECK_EQ(frame_, frame); 3385 DCHECK_EQ(frame_, frame);
3382 3386
3383 // We don't use HistoryController in OOPIF enabled modes. 3387 // We don't use HistoryController in OOPIF enabled modes.
3384 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3388 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
3385 return; 3389 return;
3386 3390
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
4744 if (GURL(frame->document().baseURL()) != params.url) 4748 if (GURL(frame->document().baseURL()) != params.url)
4745 params.base_url = frame->document().baseURL(); 4749 params.base_url = frame->document().baseURL();
4746 4750
4747 GetRedirectChain(ds, &params.redirects); 4751 GetRedirectChain(ds, &params.redirects);
4748 params.should_update_history = 4752 params.should_update_history =
4749 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; 4753 !ds->hasUnreachableURL() && response.httpStatusCode() != 404;
4750 4754
4751 params.searchable_form_url = internal_data->searchable_form_url(); 4755 params.searchable_form_url = internal_data->searchable_form_url();
4752 params.searchable_form_encoding = internal_data->searchable_form_encoding(); 4756 params.searchable_form_encoding = internal_data->searchable_form_encoding();
4753 4757
4754 params.gesture = render_view_->navigation_gesture_; 4758 params.gesture = render_view_->navigation_gesture();
4755 render_view_->navigation_gesture_ = NavigationGestureUnknown; 4759 render_view_->set_navigation_gesture(NavigationGestureUnknown);
4756 4760
4757 // Make navigation state a part of the DidCommitProvisionalLoad message so 4761 // Make navigation state a part of the DidCommitProvisionalLoad message so
4758 // that committed entry has it at all times. 4762 // that committed entry has it at all times.
4759 int64_t post_id = -1; 4763 int64_t post_id = -1;
4760 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { 4764 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) {
4761 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); 4765 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry();
4762 if (entry) { 4766 if (entry) {
4763 params.page_state = HistoryEntryToPageState(entry); 4767 params.page_state = HistoryEntryToPageState(entry);
4764 post_id = ExtractPostId(entry->root()); 4768 post_id = ExtractPostId(entry->root());
4765 } else { 4769 } else {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
4986 std::unique_ptr<StreamOverrideParameters> stream_override( 4990 std::unique_ptr<StreamOverrideParameters> stream_override(
4987 new StreamOverrideParameters()); 4991 new StreamOverrideParameters());
4988 stream_override->stream_url = stream_url; 4992 stream_override->stream_url = stream_url;
4989 stream_override->response = response; 4993 stream_override->response = response;
4990 stream_override->redirects = request_params.redirects; 4994 stream_override->redirects = request_params.redirects;
4991 stream_override->redirect_responses = request_params.redirect_response; 4995 stream_override->redirect_responses = request_params.redirect_response;
4992 4996
4993 // If the request was initiated in the context of a user gesture then make 4997 // If the request was initiated in the context of a user gesture then make
4994 // sure that the navigation also executes in the context of a user gesture. 4998 // sure that the navigation also executes in the context of a user gesture.
4995 std::unique_ptr<blink::WebScopedUserGesture> gesture( 4999 std::unique_ptr<blink::WebScopedUserGesture> gesture(
4996 request_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_) 5000 (common_params.gesture == NavigationGestureUser)
4997 : nullptr); 5001 ? new blink::WebScopedUserGesture(frame_)
5002 : nullptr);
4998 5003
4999 NavigateInternal(common_params, StartNavigationParams(), request_params, 5004 NavigateInternal(common_params, StartNavigationParams(), request_params,
5000 std::move(stream_override)); 5005 std::move(stream_override));
5001 browser_side_navigation_pending_ = false; 5006 browser_side_navigation_pending_ = false;
5002 } 5007 }
5003 5008
5004 // PlzNavigate 5009 // PlzNavigate
5005 void RenderFrameImpl::OnFailedNavigation( 5010 void RenderFrameImpl::OnFailedNavigation(
5006 const CommonNavigationParams& common_params, 5011 const CommonNavigationParams& common_params,
5007 const RequestNavigationParams& request_params, 5012 const RequestNavigationParams& request_params,
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
5712 : blink::WebURLRequest::FrameTypeNested); 5717 : blink::WebURLRequest::FrameTypeNested);
5713 5718
5714 if (IsBrowserSideNavigationEnabled() && common_params.post_data) 5719 if (IsBrowserSideNavigationEnabled() && common_params.post_data)
5715 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); 5720 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data));
5716 5721
5717 // Used to determine whether this frame is actually loading a request as part 5722 // Used to determine whether this frame is actually loading a request as part
5718 // of a history navigation. 5723 // of a history navigation.
5719 bool has_history_navigation_in_frame = false; 5724 bool has_history_navigation_in_frame = false;
5720 5725
5721 #if defined(OS_ANDROID) 5726 #if defined(OS_ANDROID)
5722 request.setHasUserGesture(request_params.has_user_gesture); 5727 request.setHasUserGesture(common_params.gesture == NavigationGestureUser);
5723 #endif 5728 #endif
5724 5729
5725 if (browser_side_navigation) { 5730 if (browser_side_navigation) {
5726 // PlzNavigate: Make sure that Blink's loader will not try to use browser 5731 // PlzNavigate: Make sure that Blink's loader will not try to use browser
5727 // side navigation for this request (since it already went to the browser). 5732 // side navigation for this request (since it already went to the browser).
5728 request.setCheckForBrowserSideNavigation(false); 5733 request.setCheckForBrowserSideNavigation(false);
5729 5734
5730 request.setNavigationStartTime( 5735 request.setNavigationStartTime(
5731 ConvertToBlinkTime(common_params.navigation_start)); 5736 ConvertToBlinkTime(common_params.navigation_start));
5732 } 5737 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
6080 DCHECK(frame_->parent() || 6085 DCHECK(frame_->parent() ||
6081 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 6086 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
6082 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 6087 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
6083 DCHECK(!frame_->parent() || 6088 DCHECK(!frame_->parent() ||
6084 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 6089 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
6085 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 6090 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
6086 6091
6087 BeginNavigationParams begin_navigation_params( 6092 BeginNavigationParams begin_navigation_params(
6088 GetWebURLRequestHeaders(info.urlRequest), 6093 GetWebURLRequestHeaders(info.urlRequest),
6089 GetLoadFlagsForWebURLRequest(info.urlRequest), 6094 GetLoadFlagsForWebURLRequest(info.urlRequest),
6090 info.urlRequest.hasUserGesture(),
6091 info.urlRequest.skipServiceWorker() != 6095 info.urlRequest.skipServiceWorker() !=
6092 blink::WebURLRequest::SkipServiceWorker::None, 6096 blink::WebURLRequest::SkipServiceWorker::None,
6093 GetRequestContextTypeForWebURLRequest(info.urlRequest)); 6097 GetRequestContextTypeForWebURLRequest(info.urlRequest));
6094 6098
6095 if (!info.form.isNull()) { 6099 if (!info.form.isNull()) {
6096 WebSearchableFormData web_searchable_form_data(info.form); 6100 WebSearchableFormData web_searchable_form_data(info.form);
6097 begin_navigation_params.searchable_form_url = 6101 begin_navigation_params.searchable_form_url =
6098 web_searchable_form_data.url(); 6102 web_searchable_form_data.url();
6099 begin_navigation_params.searchable_form_encoding = 6103 begin_navigation_params.searchable_form_encoding =
6100 web_searchable_form_data.encoding().utf8(); 6104 web_searchable_form_data.encoding().utf8();
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
6638 // event target. Potentially a Pepper plugin will receive the event. 6642 // event target. Potentially a Pepper plugin will receive the event.
6639 // In order to tell whether a plugin gets the last mouse event and which it 6643 // In order to tell whether a plugin gets the last mouse event and which it
6640 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6644 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6641 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6645 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6642 // |pepper_last_mouse_event_target_|. 6646 // |pepper_last_mouse_event_target_|.
6643 pepper_last_mouse_event_target_ = nullptr; 6647 pepper_last_mouse_event_target_ = nullptr;
6644 #endif 6648 #endif
6645 } 6649 }
6646 6650
6647 } // namespace content 6651 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698