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

Side by Side Diff: content/browser/frame_host/navigator_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/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return delegate_; 136 return delegate_;
137 } 137 }
138 138
139 NavigationController* NavigatorImpl::GetController() { 139 NavigationController* NavigatorImpl::GetController() {
140 return controller_; 140 return controller_;
141 } 141 }
142 142
143 void NavigatorImpl::DidStartProvisionalLoad( 143 void NavigatorImpl::DidStartProvisionalLoad(
144 RenderFrameHostImpl* render_frame_host, 144 RenderFrameHostImpl* render_frame_host,
145 const GURL& url, 145 const GURL& url,
146 const base::TimeTicks& navigation_start) { 146 const base::TimeTicks& navigation_start,
147 bool has_user_gesture) {
147 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); 148 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame();
148 bool is_error_page = (url.spec() == kUnreachableWebDataURL); 149 bool is_error_page = (url.spec() == kUnreachableWebDataURL);
149 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); 150 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL);
150 GURL validated_url(url); 151 GURL validated_url(url);
151 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); 152 RenderProcessHost* render_process_host = render_frame_host->GetProcess();
152 render_process_host->FilterURL(false, &validated_url); 153 render_process_host->FilterURL(false, &validated_url);
153 154
154 // Do not allow browser plugin guests to navigate to non-web URLs, since they 155 // Do not allow browser plugin guests to navigate to non-web URLs, since they
155 // cannot swap processes or grant bindings. 156 // cannot swap processes or grant bindings.
156 ChildProcessSecurityPolicyImpl* policy = 157 ChildProcessSecurityPolicyImpl* policy =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 is_renderer_initiated = pending_entry->is_renderer_initiated(); 203 is_renderer_initiated = pending_entry->is_renderer_initiated();
203 pending_nav_entry_id = pending_entry->GetUniqueID(); 204 pending_nav_entry_id = pending_entry->GetUniqueID();
204 started_from_context_menu = pending_entry->has_started_from_context_menu(); 205 started_from_context_menu = pending_entry->has_started_from_context_menu();
205 } 206 }
206 207
207 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( 208 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create(
208 validated_url, render_frame_host->frame_tree_node(), 209 validated_url, render_frame_host->frame_tree_node(),
209 is_renderer_initiated, 210 is_renderer_initiated,
210 false, // is_same_page 211 false, // is_same_page
211 is_iframe_srcdoc, // is_srcdoc 212 is_iframe_srcdoc, // is_srcdoc
212 navigation_start, pending_nav_entry_id, started_from_context_menu)); 213 navigation_start, pending_nav_entry_id, has_user_gesture,
214 started_from_context_menu));
213 } 215 }
214 216
215 void NavigatorImpl::DidFailProvisionalLoadWithError( 217 void NavigatorImpl::DidFailProvisionalLoadWithError(
216 RenderFrameHostImpl* render_frame_host, 218 RenderFrameHostImpl* render_frame_host,
217 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { 219 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {
218 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() 220 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec()
219 << ", error_code: " << params.error_code 221 << ", error_code: " << params.error_code
220 << ", error_description: " << params.error_description 222 << ", error_description: " << params.error_description
221 << ", showing_repost_interstitial: " << 223 << ", showing_repost_interstitial: " <<
222 params.showing_repost_interstitial 224 params.showing_repost_interstitial
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 common_params.url, 996 common_params.url,
995 frame_tree_node->current_frame_host()->GetSiteInstance(), nullptr); 997 frame_tree_node->current_frame_host()->GetSiteInstance(), nullptr);
996 navigation_data_.reset(); 998 navigation_data_.reset();
997 } 999 }
998 1000
999 // For main frames, NavigationHandle will be created after the call to 1001 // For main frames, NavigationHandle will be created after the call to
1000 // |DidStartMainFrameNavigation|, so it receives the most up to date pending 1002 // |DidStartMainFrameNavigation|, so it receives the most up to date pending
1001 // entry from the NavigationController. 1003 // entry from the NavigationController.
1002 NavigationEntry* pending_entry = controller_->GetPendingEntry(); 1004 NavigationEntry* pending_entry = controller_->GetPendingEntry();
1003 navigation_request->CreateNavigationHandle( 1005 navigation_request->CreateNavigationHandle(
1004 pending_entry ? pending_entry->GetUniqueID() : 0); 1006 pending_entry ? pending_entry->GetUniqueID() : 0,
1007 begin_params.has_user_gesture);
1005 navigation_request->BeginNavigation(); 1008 navigation_request->BeginNavigation();
1006 } 1009 }
1007 1010
1008 // PlzNavigate 1011 // PlzNavigate
1009 void NavigatorImpl::FailedNavigation(FrameTreeNode* frame_tree_node, 1012 void NavigatorImpl::FailedNavigation(FrameTreeNode* frame_tree_node,
1010 bool has_stale_copy_in_cache, 1013 bool has_stale_copy_in_cache,
1011 int error_code) { 1014 int error_code) {
1012 CHECK(IsBrowserSideNavigationEnabled()); 1015 CHECK(IsBrowserSideNavigationEnabled());
1013 1016
1014 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); 1017 NavigationRequest* navigation_request = frame_tree_node->navigation_request();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 *navigation_request); 1154 *navigation_request);
1152 render_frame_host->CommitNavigation(nullptr, // response 1155 render_frame_host->CommitNavigation(nullptr, // response
1153 nullptr, // body 1156 nullptr, // body
1154 navigation_request->common_params(), 1157 navigation_request->common_params(),
1155 navigation_request->request_params(), 1158 navigation_request->request_params(),
1156 navigation_request->is_view_source()); 1159 navigation_request->is_view_source());
1157 return; 1160 return;
1158 } 1161 }
1159 1162
1160 frame_tree_node->CreatedNavigationRequest(std::move(scoped_request)); 1163 frame_tree_node->CreatedNavigationRequest(std::move(scoped_request));
1161 navigation_request->CreateNavigationHandle(entry.GetUniqueID()); 1164
1165 // Browser-initiated navigations are not currently considered to have a user
1166 // gesture, though this is intended to change as part of PlzNavigate (see the
1167 // TODO(clamy) for HasUserGesture in navigation_handle.h).
1168 bool has_user_gesture = false;
1169 navigation_request->CreateNavigationHandle(entry.GetUniqueID(),
1170 has_user_gesture);
clamy 2016/11/17 14:30:04 We have the info about user gesture in the BeginNa
Bryan McQuade 2016/11/19 20:21:38 Ah, I missed that. Fixed, thanks!
1162 1171
1163 // Have the current renderer execute its beforeunload event if needed. If it 1172 // Have the current renderer execute its beforeunload event if needed. If it
1164 // is not needed then NavigationRequest::BeginNavigation should be directly 1173 // is not needed then NavigationRequest::BeginNavigation should be directly
1165 // called instead. 1174 // called instead.
1166 if (should_dispatch_beforeunload && !IsRendererDebugURL(dest_url)) { 1175 if (should_dispatch_beforeunload && !IsRendererDebugURL(dest_url)) {
1167 navigation_request->SetWaitingForRendererResponse(); 1176 navigation_request->SetWaitingForRendererResponse();
1168 frame_tree_node->current_frame_host()->DispatchBeforeUnload( 1177 frame_tree_node->current_frame_host()->DispatchBeforeUnload(
1169 true, reload_type != ReloadType::NONE); 1178 true, reload_type != ReloadType::NONE);
1170 } else { 1179 } else {
1171 navigation_request->BeginNavigation(); 1180 navigation_request->BeginNavigation();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 if (navigation_handle) 1273 if (navigation_handle)
1265 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1274 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1266 1275
1267 controller_->SetPendingEntry(std::move(entry)); 1276 controller_->SetPendingEntry(std::move(entry));
1268 if (delegate_) 1277 if (delegate_)
1269 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1278 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1270 } 1279 }
1271 } 1280 }
1272 1281
1273 } // namespace content 1282 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698