Index: content/browser/frame_host/navigation_handle_impl.cc |
diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc |
index 2ea53c8b9df7a3cd9a99ba8ccd067c318002f04b..93d6b99d2dfa2acf4898ce6216306ed2dd67302c 100644 |
--- a/content/browser/frame_host/navigation_handle_impl.cc |
+++ b/content/browser/frame_host/navigation_handle_impl.cc |
@@ -56,10 +56,12 @@ std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
bool is_srcdoc, |
const base::TimeTicks& navigation_start, |
int pending_nav_entry_id, |
+ NavigationGesture gesture, |
bool started_from_context_menu) { |
return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
url, frame_tree_node, is_renderer_initiated, is_same_page, is_srcdoc, |
- navigation_start, pending_nav_entry_id, started_from_context_menu)); |
+ navigation_start, pending_nav_entry_id, gesture, |
+ started_from_context_menu)); |
} |
NavigationHandleImpl::NavigationHandleImpl( |
@@ -70,9 +72,10 @@ NavigationHandleImpl::NavigationHandleImpl( |
bool is_srcdoc, |
const base::TimeTicks& navigation_start, |
int pending_nav_entry_id, |
+ NavigationGesture gesture, |
bool started_from_context_menu) |
: url_(url), |
- has_user_gesture_(false), |
+ gesture_(gesture), |
transition_(ui::PAGE_TRANSITION_LINK), |
is_external_protocol_(false), |
net_error_code_(net::OK), |
@@ -204,9 +207,7 @@ const Referrer& NavigationHandleImpl::GetReferrer() { |
} |
bool NavigationHandleImpl::HasUserGesture() { |
- CHECK_NE(INITIAL, state_) |
- << "This accessor should not be called before the request is started."; |
- return has_user_gesture_; |
+ return gesture_ == NavigationGestureUser; |
} |
ui::PageTransition NavigationHandleImpl::GetPageTransition() { |
@@ -302,7 +303,6 @@ NavigationThrottle::ThrottleCheckResult |
NavigationHandleImpl::CallWillStartRequestForTesting( |
bool is_post, |
const Referrer& sanitized_referrer, |
- bool has_user_gesture, |
ui::PageTransition transition, |
bool is_external_protocol) { |
NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
@@ -318,7 +318,7 @@ NavigationHandleImpl::CallWillStartRequestForTesting( |
} |
WillStartRequest(method, resource_request_body, sanitized_referrer, |
- has_user_gesture, transition, is_external_protocol, |
+ transition, is_external_protocol, |
REQUEST_CONTEXT_TYPE_LOCATION, |
base::Bind(&UpdateThrottleCheckResult, &result)); |
@@ -417,7 +417,6 @@ void NavigationHandleImpl::WillStartRequest( |
const std::string& method, |
scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, |
const Referrer& sanitized_referrer, |
- bool has_user_gesture, |
ui::PageTransition transition, |
bool is_external_protocol, |
RequestContextType request_context_type, |
@@ -430,7 +429,6 @@ void NavigationHandleImpl::WillStartRequest( |
if (method_ == "POST") |
resource_request_body_ = resource_request_body; |
sanitized_referrer_ = sanitized_referrer; |
- has_user_gesture_ = has_user_gesture; |
transition_ = transition; |
is_external_protocol_ = is_external_protocol; |
request_context_type_ = request_context_type; |
@@ -540,8 +538,14 @@ void NavigationHandleImpl::DidCommitNavigation( |
DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); |
CHECK_EQ(url_, params.url); |
+ // TODO(clamy): Once crbug.com/667572 is addressed, apply this DCHECK on all |
+ // navigations, not just same-page navigations, and make gesture_ a const |
+ // member, set only in the constructor. |
+ if (same_page) |
+ DCHECK_EQ(gesture_, params.gesture); |
+ gesture_ = params.gesture; |
+ |
method_ = params.method; |
- has_user_gesture_ = (params.gesture == NavigationGestureUser); |
transition_ = params.transition; |
render_frame_host_ = render_frame_host; |