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

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

Issue 2499313003: Set user_gesture bit at NavigationHandle creation time. (Closed)
Patch Set: remove gesture dcheck 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 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 if (!ds) 3381 if (!ds)
3382 return; 3382 return;
3383 3383
3384 TRACE_EVENT2("navigation,benchmark,rail", 3384 TRACE_EVENT2("navigation,benchmark,rail",
3385 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, 3385 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_,
3386 "url", ds->request().url().string().utf8()); 3386 "url", ds->request().url().string().utf8());
3387 DocumentState* document_state = DocumentState::FromDataSource(ds); 3387 DocumentState* document_state = DocumentState::FromDataSource(ds);
3388 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( 3388 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(
3389 document_state->navigation_state()); 3389 document_state->navigation_state());
3390 bool is_top_most = !frame->parent(); 3390 bool is_top_most = !frame->parent();
3391 NavigationGesture gesture = WebUserGestureIndicator::isProcessingUserGesture()
3392 ? NavigationGestureUser
3393 : NavigationGestureAuto;
3391 if (is_top_most) { 3394 if (is_top_most) {
3392 render_view_->set_navigation_gesture( 3395 render_view_->set_navigation_gesture(gesture);
3393 WebUserGestureIndicator::isProcessingUserGesture() ?
3394 NavigationGestureUser : NavigationGestureAuto);
3395 } else if (ds->replacesCurrentHistoryItem()) { 3396 } else if (ds->replacesCurrentHistoryItem()) {
3396 // Subframe navigations that don't add session history items must be 3397 // Subframe navigations that don't add session history items must be
3397 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 3398 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
3398 // handle loading of error pages. 3399 // handle loading of error pages.
3399 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); 3400 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME);
3400 } 3401 }
3401 3402
3402 base::TimeTicks navigation_start = 3403 base::TimeTicks navigation_start =
3403 navigation_state->common_params().navigation_start; 3404 navigation_state->common_params().navigation_start;
3404 DCHECK(!navigation_start.is_null()); 3405 DCHECK(!navigation_start.is_null());
3405 3406
3406 for (auto& observer : render_view_->observers()) 3407 for (auto& observer : render_view_->observers())
3407 observer.DidStartProvisionalLoad(frame); 3408 observer.DidStartProvisionalLoad(frame);
3408 for (auto& observer : observers_) 3409 for (auto& observer : observers_)
3409 observer.DidStartProvisionalLoad(); 3410 observer.DidStartProvisionalLoad();
3410 3411
3411 Send(new FrameHostMsg_DidStartProvisionalLoad( 3412 Send(new FrameHostMsg_DidStartProvisionalLoad(
3412 routing_id_, ds->request().url(), navigation_start)); 3413 routing_id_, ds->request().url(), navigation_start, gesture));
3413 } 3414 }
3414 3415
3415 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( 3416 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
3416 blink::WebLocalFrame* frame) { 3417 blink::WebLocalFrame* frame) {
3417 DCHECK_EQ(frame_, frame); 3418 DCHECK_EQ(frame_, frame);
3418 3419
3419 // We don't use HistoryController in OOPIF enabled modes. 3420 // We don't use HistoryController in OOPIF enabled modes.
3420 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3421 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
3421 return; 3422 return;
3422 3423
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
4780 if (GURL(frame->document().baseURL()) != params.url) 4781 if (GURL(frame->document().baseURL()) != params.url)
4781 params.base_url = frame->document().baseURL(); 4782 params.base_url = frame->document().baseURL();
4782 4783
4783 GetRedirectChain(ds, &params.redirects); 4784 GetRedirectChain(ds, &params.redirects);
4784 params.should_update_history = 4785 params.should_update_history =
4785 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; 4786 !ds->hasUnreachableURL() && response.httpStatusCode() != 404;
4786 4787
4787 params.searchable_form_url = internal_data->searchable_form_url(); 4788 params.searchable_form_url = internal_data->searchable_form_url();
4788 params.searchable_form_encoding = internal_data->searchable_form_encoding(); 4789 params.searchable_form_encoding = internal_data->searchable_form_encoding();
4789 4790
4790 params.gesture = render_view_->navigation_gesture_; 4791 params.gesture = render_view_->navigation_gesture();
4791 render_view_->navigation_gesture_ = NavigationGestureUnknown; 4792 render_view_->set_navigation_gesture(NavigationGestureUnknown);
4792 4793
4793 // Make navigation state a part of the DidCommitProvisionalLoad message so 4794 // Make navigation state a part of the DidCommitProvisionalLoad message so
4794 // that committed entry has it at all times. 4795 // that committed entry has it at all times.
4795 int64_t post_id = -1; 4796 int64_t post_id = -1;
4796 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { 4797 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) {
4797 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); 4798 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry();
4798 if (entry) { 4799 if (entry) {
4799 params.page_state = HistoryEntryToPageState(entry); 4800 params.page_state = HistoryEntryToPageState(entry);
4800 post_id = ExtractPostId(entry->root()); 4801 post_id = ExtractPostId(entry->root());
4801 } else { 4802 } else {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
5022 std::unique_ptr<StreamOverrideParameters> stream_override( 5023 std::unique_ptr<StreamOverrideParameters> stream_override(
5023 new StreamOverrideParameters()); 5024 new StreamOverrideParameters());
5024 stream_override->stream_url = stream_url; 5025 stream_override->stream_url = stream_url;
5025 stream_override->response = response; 5026 stream_override->response = response;
5026 stream_override->redirects = request_params.redirects; 5027 stream_override->redirects = request_params.redirects;
5027 stream_override->redirect_responses = request_params.redirect_response; 5028 stream_override->redirect_responses = request_params.redirect_response;
5028 5029
5029 // If the request was initiated in the context of a user gesture then make 5030 // If the request was initiated in the context of a user gesture then make
5030 // sure that the navigation also executes in the context of a user gesture. 5031 // sure that the navigation also executes in the context of a user gesture.
5031 std::unique_ptr<blink::WebScopedUserGesture> gesture( 5032 std::unique_ptr<blink::WebScopedUserGesture> gesture(
5032 request_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_) 5033 (request_params.gesture == NavigationGestureUser)
5033 : nullptr); 5034 ? new blink::WebScopedUserGesture(frame_)
5035 : nullptr);
5034 5036
5035 NavigateInternal(common_params, StartNavigationParams(), request_params, 5037 NavigateInternal(common_params, StartNavigationParams(), request_params,
5036 std::move(stream_override)); 5038 std::move(stream_override));
5037 browser_side_navigation_pending_ = false; 5039 browser_side_navigation_pending_ = false;
5038 } 5040 }
5039 5041
5040 // PlzNavigate 5042 // PlzNavigate
5041 void RenderFrameImpl::OnFailedNavigation( 5043 void RenderFrameImpl::OnFailedNavigation(
5042 const CommonNavigationParams& common_params, 5044 const CommonNavigationParams& common_params,
5043 const RequestNavigationParams& request_params, 5045 const RequestNavigationParams& request_params,
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
5748 : blink::WebURLRequest::FrameTypeNested); 5750 : blink::WebURLRequest::FrameTypeNested);
5749 5751
5750 if (IsBrowserSideNavigationEnabled() && common_params.post_data) 5752 if (IsBrowserSideNavigationEnabled() && common_params.post_data)
5751 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); 5753 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data));
5752 5754
5753 // Used to determine whether this frame is actually loading a request as part 5755 // Used to determine whether this frame is actually loading a request as part
5754 // of a history navigation. 5756 // of a history navigation.
5755 bool has_history_navigation_in_frame = false; 5757 bool has_history_navigation_in_frame = false;
5756 5758
5757 #if defined(OS_ANDROID) 5759 #if defined(OS_ANDROID)
5758 request.setHasUserGesture(request_params.has_user_gesture); 5760 request.setHasUserGesture(request_params.gesture == NavigationGestureUser);
5759 #endif 5761 #endif
5760 5762
5761 if (browser_side_navigation) { 5763 if (browser_side_navigation) {
5762 // PlzNavigate: Make sure that Blink's loader will not try to use browser 5764 // PlzNavigate: Make sure that Blink's loader will not try to use browser
5763 // side navigation for this request (since it already went to the browser). 5765 // side navigation for this request (since it already went to the browser).
5764 request.setCheckForBrowserSideNavigation(false); 5766 request.setCheckForBrowserSideNavigation(false);
5765 5767
5766 request.setNavigationStartTime( 5768 request.setNavigationStartTime(
5767 ConvertToBlinkTime(common_params.navigation_start)); 5769 ConvertToBlinkTime(common_params.navigation_start));
5768 } 5770 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
6116 DCHECK(frame_->parent() || 6118 DCHECK(frame_->parent() ||
6117 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 6119 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
6118 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 6120 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
6119 DCHECK(!frame_->parent() || 6121 DCHECK(!frame_->parent() ||
6120 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == 6122 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) ==
6121 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 6123 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
6122 6124
6123 BeginNavigationParams begin_navigation_params( 6125 BeginNavigationParams begin_navigation_params(
6124 GetWebURLRequestHeaders(info.urlRequest), 6126 GetWebURLRequestHeaders(info.urlRequest),
6125 GetLoadFlagsForWebURLRequest(info.urlRequest), 6127 GetLoadFlagsForWebURLRequest(info.urlRequest),
6126 info.urlRequest.hasUserGesture(), 6128 info.urlRequest.hasUserGesture() ? NavigationGestureUser
6129 : NavigationGestureAuto,
6127 info.urlRequest.skipServiceWorker() != 6130 info.urlRequest.skipServiceWorker() !=
6128 blink::WebURLRequest::SkipServiceWorker::None, 6131 blink::WebURLRequest::SkipServiceWorker::None,
6129 GetRequestContextTypeForWebURLRequest(info.urlRequest)); 6132 GetRequestContextTypeForWebURLRequest(info.urlRequest));
6130 6133
6131 if (!info.form.isNull()) { 6134 if (!info.form.isNull()) {
6132 WebSearchableFormData web_searchable_form_data(info.form); 6135 WebSearchableFormData web_searchable_form_data(info.form);
6133 begin_navigation_params.searchable_form_url = 6136 begin_navigation_params.searchable_form_url =
6134 web_searchable_form_data.url(); 6137 web_searchable_form_data.url();
6135 begin_navigation_params.searchable_form_encoding = 6138 begin_navigation_params.searchable_form_encoding =
6136 web_searchable_form_data.encoding().utf8(); 6139 web_searchable_form_data.encoding().utf8();
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
6637 // event target. Potentially a Pepper plugin will receive the event. 6640 // event target. Potentially a Pepper plugin will receive the event.
6638 // In order to tell whether a plugin gets the last mouse event and which it 6641 // In order to tell whether a plugin gets the last mouse event and which it
6639 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6642 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6640 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6643 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6641 // |pepper_last_mouse_event_target_|. 6644 // |pepper_last_mouse_event_target_|.
6642 pepper_last_mouse_event_target_ = nullptr; 6645 pepper_last_mouse_event_target_ = nullptr;
6643 #endif 6646 #endif
6644 } 6647 }
6645 6648
6646 } // namespace content 6649 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698