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

Side by Side Diff: content/browser/frame_host/navigation_request.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/browser/child_process_security_policy_impl.h" 9 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { 272 if (ShouldMakeNetworkRequestForURL(common_params_.url)) {
273 // It's safe to use base::Unretained because this NavigationRequest owns 273 // It's safe to use base::Unretained because this NavigationRequest owns
274 // the NavigationHandle where the callback will be stored. 274 // the NavigationHandle where the callback will be stored.
275 // TODO(clamy): pass the real value for |is_external_protocol| if needed. 275 // TODO(clamy): pass the real value for |is_external_protocol| if needed.
276 // TODO(clamy): pass the method to the NavigationHandle instead of a 276 // TODO(clamy): pass the method to the NavigationHandle instead of a
277 // boolean. 277 // boolean.
278 navigation_handle_->WillStartRequest( 278 navigation_handle_->WillStartRequest(
279 common_params_.method, common_params_.post_data, 279 common_params_.method, common_params_.post_data,
280 Referrer::SanitizeForRequest(common_params_.url, 280 Referrer::SanitizeForRequest(common_params_.url,
281 common_params_.referrer), 281 common_params_.referrer),
282 begin_params_.has_user_gesture, common_params_.transition, false, 282 common_params_.transition, false, begin_params_.request_context_type,
283 begin_params_.request_context_type,
284 base::Bind(&NavigationRequest::OnStartChecksComplete, 283 base::Bind(&NavigationRequest::OnStartChecksComplete,
285 base::Unretained(this))); 284 base::Unretained(this)));
286 return; 285 return;
287 } 286 }
288 287
289 // There is no need to make a network request for this navigation, so commit 288 // There is no need to make a network request for this navigation, so commit
290 // it immediately. 289 // it immediately.
291 state_ = RESPONSE_STARTED; 290 state_ = RESPONSE_STARTED;
292 291
293 // Select an appropriate RenderFrameHost. 292 // Select an appropriate RenderFrameHost.
294 RenderFrameHostImpl* render_frame_host = 293 RenderFrameHostImpl* render_frame_host =
295 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); 294 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this);
296 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, 295 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host,
297 common_params_.url); 296 common_params_.url);
298 297
299 // Inform the NavigationHandle that the navigation will commit. 298 // Inform the NavigationHandle that the navigation will commit.
300 navigation_handle_->ReadyToCommitNavigation(render_frame_host); 299 navigation_handle_->ReadyToCommitNavigation(render_frame_host);
301 300
302 CommitNavigation(); 301 CommitNavigation();
303 } 302 }
304 303
305 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { 304 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id,
305 bool has_user_gesture) {
306 // TODO(nasko): Update the NavigationHandle creation to ensure that the 306 // TODO(nasko): Update the NavigationHandle creation to ensure that the
307 // proper values are specified for is_same_page and is_srcdoc. 307 // proper values are specified for is_same_page and is_srcdoc.
308 navigation_handle_ = NavigationHandleImpl::Create( 308 navigation_handle_ = NavigationHandleImpl::Create(
309 common_params_.url, frame_tree_node_, !browser_initiated_, 309 common_params_.url, frame_tree_node_, !browser_initiated_,
310 false, // is_same_page 310 false, // is_same_page
311 false, // is_srcdoc 311 false, // is_srcdoc
312 common_params_.navigation_start, pending_nav_entry_id, 312 common_params_.navigation_start, pending_nav_entry_id, has_user_gesture,
313 false); // started_in_context_menu 313 false); // started_in_context_menu
314 314
315 if (!begin_params_.searchable_form_url.is_empty()) { 315 if (!begin_params_.searchable_form_url.is_empty()) {
316 navigation_handle_->set_searchable_form_url( 316 navigation_handle_->set_searchable_form_url(
317 begin_params_.searchable_form_url); 317 begin_params_.searchable_form_url);
318 navigation_handle_->set_searchable_form_encoding( 318 navigation_handle_->set_searchable_form_encoding(
319 begin_params_.searchable_form_encoding); 319 begin_params_.searchable_form_encoding);
320 } 320 }
321 } 321 }
322 322
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 601 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
602 602
603 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 603 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
604 common_params_, request_params_, 604 common_params_, request_params_,
605 is_view_source_); 605 is_view_source_);
606 606
607 frame_tree_node_->ResetNavigationRequest(true); 607 frame_tree_node_->ResetNavigationRequest(true);
608 } 608 }
609 609
610 } // namespace content 610 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698