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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2499313003: Set user_gesture bit at NavigationHandle creation time. (Closed)
Patch Set: 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/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 base::TimeDelta::FromMilliseconds(10), 1061 base::TimeDelta::FromMilliseconds(10),
1062 base::TimeDelta::FromMinutes(10), 100); 1062 base::TimeDelta::FromMinutes(10), 100);
1063 } 1063 }
1064 // This message is only sent for top-level frames. TODO(avi): when frame tree 1064 // This message is only sent for top-level frames. TODO(avi): when frame tree
1065 // mirroring works correctly, add a check here to enforce it. 1065 // mirroring works correctly, add a check here to enforce it.
1066 delegate_->DocumentOnLoadCompleted(this); 1066 delegate_->DocumentOnLoadCompleted(this);
1067 } 1067 }
1068 1068
1069 void RenderFrameHostImpl::OnDidStartProvisionalLoad( 1069 void RenderFrameHostImpl::OnDidStartProvisionalLoad(
1070 const GURL& url, 1070 const GURL& url,
1071 const base::TimeTicks& navigation_start) { 1071 const base::TimeTicks& navigation_start,
1072 bool has_user_gesture) {
1072 // TODO(clamy): Check if other navigation methods (OpenURL, 1073 // TODO(clamy): Check if other navigation methods (OpenURL,
1073 // DidFailProvisionalLoad, ...) should also be ignored if the RFH is no longer 1074 // DidFailProvisionalLoad, ...) should also be ignored if the RFH is no longer
1074 // active. 1075 // active.
1075 if (!is_active()) 1076 if (!is_active())
1076 return; 1077 return;
1077 frame_tree_node_->navigator()->DidStartProvisionalLoad(this, url, 1078 frame_tree_node_->navigator()->DidStartProvisionalLoad(
1078 navigation_start); 1079 this, url, navigation_start, has_user_gesture);
1079 } 1080 }
1080 1081
1081 void RenderFrameHostImpl::OnDidFailProvisionalLoadWithError( 1082 void RenderFrameHostImpl::OnDidFailProvisionalLoadWithError(
1082 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { 1083 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {
1083 // TODO(clamy): Kill the renderer with RFH_FAIL_PROVISIONAL_LOAD_NO_HANDLE and 1084 // TODO(clamy): Kill the renderer with RFH_FAIL_PROVISIONAL_LOAD_NO_HANDLE and
1084 // return early if navigation_handle_ is null, once we prevent that case from 1085 // return early if navigation_handle_ is null, once we prevent that case from
1085 // happening in practice. 1086 // happening in practice.
1086 1087
1087 // Update the error code in the NavigationHandle of the navigation. 1088 // Update the error code in the NavigationHandle of the navigation.
1088 if (navigation_handle_) { 1089 if (navigation_handle_) {
(...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 NavigationEntryImpl::FromNavigationEntry( 3217 NavigationEntryImpl::FromNavigationEntry(
3217 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); 3218 frame_tree_node()->navigator()->GetController()->GetPendingEntry());
3218 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { 3219 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) {
3219 pending_nav_entry_id = params.nav_entry_id; 3220 pending_nav_entry_id = params.nav_entry_id;
3220 is_renderer_initiated = pending_entry->is_renderer_initiated(); 3221 is_renderer_initiated = pending_entry->is_renderer_initiated();
3221 } 3222 }
3222 3223
3223 return NavigationHandleImpl::Create( 3224 return NavigationHandleImpl::Create(
3224 params.url, frame_tree_node_, is_renderer_initiated, 3225 params.url, frame_tree_node_, is_renderer_initiated,
3225 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), 3226 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(),
3226 pending_nav_entry_id, false); // started_from_context_menu 3227 pending_nav_entry_id, params.gesture == NavigationGestureUser,
clamy 2016/11/17 14:30:04 While we're at it, why not replace the has_user_ge
Bryan McQuade 2016/11/19 20:21:38 Sure, makes sense, thanks! I went ahead and did th
3228 false); // started_from_context_menu
3227 } 3229 }
3228 3230
3229 // Determine if the current NavigationHandle can be used. 3231 // Determine if the current NavigationHandle can be used.
3230 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { 3232 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) {
3231 return std::move(navigation_handle_); 3233 return std::move(navigation_handle_);
3232 } 3234 }
3233 3235
3234 // If the URL does not match what the NavigationHandle expects, treat the 3236 // If the URL does not match what the NavigationHandle expects, treat the
3235 // commit as a new navigation. This can happen when loading a Data 3237 // commit as a new navigation. This can happen when loading a Data
3236 // navigation with LoadDataWithBaseURL. 3238 // navigation with LoadDataWithBaseURL.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3268 // Reset any existing NavigationHandle. 3270 // Reset any existing NavigationHandle.
3269 navigation_handle_.reset(); 3271 navigation_handle_.reset();
3270 } 3272 }
3271 3273
3272 // There is no pending NavigationEntry in these cases, so pass 0 as the 3274 // There is no pending NavigationEntry in these cases, so pass 0 as the
3273 // pending_nav_entry_id. If the previous handle was a prematurely aborted 3275 // pending_nav_entry_id. If the previous handle was a prematurely aborted
3274 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. 3276 // navigation loaded via LoadDataWithBaseURL, propagate the entry id.
3275 return NavigationHandleImpl::Create( 3277 return NavigationHandleImpl::Create(
3276 params.url, frame_tree_node_, is_renderer_initiated, 3278 params.url, frame_tree_node_, is_renderer_initiated,
3277 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), 3279 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(),
3278 entry_id_for_data_nav, false); // started_from_context_menu 3280 entry_id_for_data_nav, params.gesture == NavigationGestureUser,
3281 false); // started_from_context_menu
3279 } 3282 }
3280 3283
3281 } // namespace content 3284 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698