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

Side by Side Diff: content/test/test_render_frame_host.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/test/test_render_frame_host.h" 5 #include "content/test/test_render_frame_host.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "content/browser/frame_host/frame_tree.h" 8 #include "content/browser/frame_host/frame_tree.h"
9 #include "content/browser/frame_host/navigation_handle_impl.h" 9 #include "content/browser/frame_host/navigation_handle_impl.h"
10 #include "content/browser/frame_host/navigation_request.h" 10 #include "content/browser/frame_host/navigation_request.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 OnDetach(); 103 OnDetach();
104 } 104 }
105 105
106 void TestRenderFrameHost::SimulateNavigationStart(const GURL& url) { 106 void TestRenderFrameHost::SimulateNavigationStart(const GURL& url) {
107 if (IsBrowserSideNavigationEnabled()) { 107 if (IsBrowserSideNavigationEnabled()) {
108 SendRendererInitiatedNavigationRequest(url, false); 108 SendRendererInitiatedNavigationRequest(url, false);
109 return; 109 return;
110 } 110 }
111 111
112 OnDidStartLoading(true); 112 OnDidStartLoading(true);
113 OnDidStartProvisionalLoad(url, base::TimeTicks::Now()); 113 OnDidStartProvisionalLoad(url, base::TimeTicks::Now(),
114 false /* has_user_gesture */);
114 SimulateWillStartRequest(ui::PAGE_TRANSITION_LINK); 115 SimulateWillStartRequest(ui::PAGE_TRANSITION_LINK);
115 } 116 }
116 117
117 void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) { 118 void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) {
118 if (IsBrowserSideNavigationEnabled()) { 119 if (IsBrowserSideNavigationEnabled()) {
119 NavigationRequest* request = frame_tree_node_->navigation_request(); 120 NavigationRequest* request = frame_tree_node_->navigation_request();
120 TestNavigationURLLoader* url_loader = 121 TestNavigationURLLoader* url_loader =
121 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); 122 static_cast<TestNavigationURLLoader*>(request->loader_for_testing());
122 CHECK(url_loader); 123 CHECK(url_loader);
123 url_loader->SimulateServerRedirect(new_url); 124 url_loader->SimulateServerRedirect(new_url);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 193
193 FrameHostMsg_DidFailProvisionalLoadWithError_Params error_params; 194 FrameHostMsg_DidFailProvisionalLoadWithError_Params error_params;
194 error_params.error_code = error_code; 195 error_params.error_code = error_code;
195 error_params.url = url; 196 error_params.url = url;
196 OnDidFailProvisionalLoadWithError(error_params); 197 OnDidFailProvisionalLoadWithError(error_params);
197 } 198 }
198 199
199 void TestRenderFrameHost::SimulateNavigationErrorPageCommit() { 200 void TestRenderFrameHost::SimulateNavigationErrorPageCommit() {
200 CHECK(navigation_handle()); 201 CHECK(navigation_handle());
201 GURL error_url = GURL(kUnreachableWebDataURL); 202 GURL error_url = GURL(kUnreachableWebDataURL);
202 OnDidStartProvisionalLoad(error_url, base::TimeTicks::Now()); 203 OnDidStartProvisionalLoad(error_url, base::TimeTicks::Now(),
204 false /* has_user_gesture */);
203 FrameHostMsg_DidCommitProvisionalLoad_Params params; 205 FrameHostMsg_DidCommitProvisionalLoad_Params params;
204 params.nav_entry_id = 0; 206 params.nav_entry_id = 0;
205 params.did_create_new_entry = true; 207 params.did_create_new_entry = true;
206 params.url = navigation_handle()->GetURL(); 208 params.url = navigation_handle()->GetURL();
207 params.transition = GetParent() ? ui::PAGE_TRANSITION_MANUAL_SUBFRAME 209 params.transition = GetParent() ? ui::PAGE_TRANSITION_MANUAL_SUBFRAME
208 : ui::PAGE_TRANSITION_LINK; 210 : ui::PAGE_TRANSITION_LINK;
209 params.was_within_same_page = false; 211 params.was_within_same_page = false;
210 params.url_is_unreachable = true; 212 params.url_is_unreachable = true;
211 params.page_state = PageState::CreateForTesting(navigation_handle()->GetURL(), 213 params.page_state = PageState::CreateForTesting(navigation_handle()->GetURL(),
212 false, nullptr, nullptr); 214 false, nullptr, nullptr);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 const GURL& url, 302 const GURL& url,
301 ui::PageTransition transition, 303 ui::PageTransition transition,
302 int response_code, 304 int response_code,
303 const ModificationCallback& callback) { 305 const ModificationCallback& callback) {
304 if (!IsBrowserSideNavigationEnabled()) 306 if (!IsBrowserSideNavigationEnabled())
305 OnDidStartLoading(true); 307 OnDidStartLoading(true);
306 308
307 // DidStartProvisionalLoad may delete the pending entry that holds |url|, 309 // DidStartProvisionalLoad may delete the pending entry that holds |url|,
308 // so we keep a copy of it to use below. 310 // so we keep a copy of it to use below.
309 GURL url_copy(url); 311 GURL url_copy(url);
310 OnDidStartProvisionalLoad(url_copy, base::TimeTicks::Now()); 312 OnDidStartProvisionalLoad(url_copy, base::TimeTicks::Now(),
313 false /* has_user_gesture */);
311 SimulateWillStartRequest(transition); 314 SimulateWillStartRequest(transition);
312 315
313 FrameHostMsg_DidCommitProvisionalLoad_Params params; 316 FrameHostMsg_DidCommitProvisionalLoad_Params params;
314 params.nav_entry_id = nav_entry_id; 317 params.nav_entry_id = nav_entry_id;
315 params.url = url_copy; 318 params.url = url_copy;
316 params.transition = transition; 319 params.transition = transition;
317 params.should_update_history = true; 320 params.should_update_history = true;
318 params.did_create_new_entry = did_create_new_entry; 321 params.did_create_new_entry = did_create_new_entry;
319 params.should_replace_current_entry = should_replace_entry; 322 params.should_replace_current_entry = should_replace_entry;
320 params.gesture = NavigationGestureUser; 323 params.gesture = NavigationGestureUser;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 481 }
479 482
480 void TestRenderFrameHost::SimulateWillStartRequest( 483 void TestRenderFrameHost::SimulateWillStartRequest(
481 ui::PageTransition transition) { 484 ui::PageTransition transition) {
482 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at 485 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at
483 // this point. 486 // this point.
484 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) 487 if (!navigation_handle() || IsBrowserSideNavigationEnabled())
485 return; 488 return;
486 navigation_handle()->CallWillStartRequestForTesting( 489 navigation_handle()->CallWillStartRequestForTesting(
487 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), 490 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault),
488 true /* user_gesture */, transition, false /* is_external_protocol */); 491 transition, false /* is_external_protocol */);
489 } 492 }
490 493
491 } // namespace content 494 } // namespace content
OLDNEW
« content/browser/frame_host/render_frame_host_impl.cc ('K') | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698