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

Side by Side Diff: content/test/test_render_frame_host.cc

Issue 2499313003: Set user_gesture bit at NavigationHandle creation time. (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(), NavigationGestureUser);
114 SimulateWillStartRequest(ui::PAGE_TRANSITION_LINK); 114 SimulateWillStartRequest(ui::PAGE_TRANSITION_LINK);
115 } 115 }
116 116
117 void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) { 117 void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) {
118 if (IsBrowserSideNavigationEnabled()) { 118 if (IsBrowserSideNavigationEnabled()) {
119 NavigationRequest* request = frame_tree_node_->navigation_request(); 119 NavigationRequest* request = frame_tree_node_->navigation_request();
120 TestNavigationURLLoader* url_loader = 120 TestNavigationURLLoader* url_loader =
121 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); 121 static_cast<TestNavigationURLLoader*>(request->loader_for_testing());
122 CHECK(url_loader); 122 CHECK(url_loader);
123 url_loader->SimulateServerRedirect(new_url); 123 url_loader->SimulateServerRedirect(new_url);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 FrameHostMsg_DidFailProvisionalLoadWithError_Params error_params; 193 FrameHostMsg_DidFailProvisionalLoadWithError_Params error_params;
194 error_params.error_code = error_code; 194 error_params.error_code = error_code;
195 error_params.url = url; 195 error_params.url = url;
196 OnDidFailProvisionalLoadWithError(error_params); 196 OnDidFailProvisionalLoadWithError(error_params);
197 } 197 }
198 198
199 void TestRenderFrameHost::SimulateNavigationErrorPageCommit() { 199 void TestRenderFrameHost::SimulateNavigationErrorPageCommit() {
200 CHECK(navigation_handle()); 200 CHECK(navigation_handle());
201 GURL error_url = GURL(kUnreachableWebDataURL); 201 GURL error_url = GURL(kUnreachableWebDataURL);
202 OnDidStartProvisionalLoad(error_url, base::TimeTicks::Now()); 202 OnDidStartProvisionalLoad(error_url, base::TimeTicks::Now(),
203 NavigationGestureUser);
203 FrameHostMsg_DidCommitProvisionalLoad_Params params; 204 FrameHostMsg_DidCommitProvisionalLoad_Params params;
204 params.nav_entry_id = 0; 205 params.nav_entry_id = 0;
205 params.did_create_new_entry = true; 206 params.did_create_new_entry = true;
206 params.url = navigation_handle()->GetURL(); 207 params.url = navigation_handle()->GetURL();
207 params.transition = GetParent() ? ui::PAGE_TRANSITION_MANUAL_SUBFRAME 208 params.transition = GetParent() ? ui::PAGE_TRANSITION_MANUAL_SUBFRAME
208 : ui::PAGE_TRANSITION_LINK; 209 : ui::PAGE_TRANSITION_LINK;
209 params.was_within_same_page = false; 210 params.was_within_same_page = false;
210 params.url_is_unreachable = true; 211 params.url_is_unreachable = true;
211 params.page_state = PageState::CreateForTesting(navigation_handle()->GetURL(), 212 params.page_state = PageState::CreateForTesting(navigation_handle()->GetURL(),
212 false, nullptr, nullptr); 213 false, nullptr, nullptr);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 const GURL& url, 301 const GURL& url,
301 ui::PageTransition transition, 302 ui::PageTransition transition,
302 int response_code, 303 int response_code,
303 const ModificationCallback& callback) { 304 const ModificationCallback& callback) {
304 if (!IsBrowserSideNavigationEnabled()) 305 if (!IsBrowserSideNavigationEnabled())
305 OnDidStartLoading(true); 306 OnDidStartLoading(true);
306 307
307 // DidStartProvisionalLoad may delete the pending entry that holds |url|, 308 // DidStartProvisionalLoad may delete the pending entry that holds |url|,
308 // so we keep a copy of it to use below. 309 // so we keep a copy of it to use below.
309 GURL url_copy(url); 310 GURL url_copy(url);
310 OnDidStartProvisionalLoad(url_copy, base::TimeTicks::Now()); 311 OnDidStartProvisionalLoad(url_copy, base::TimeTicks::Now(),
312 NavigationGestureUser);
311 SimulateWillStartRequest(transition); 313 SimulateWillStartRequest(transition);
312 314
313 FrameHostMsg_DidCommitProvisionalLoad_Params params; 315 FrameHostMsg_DidCommitProvisionalLoad_Params params;
314 params.nav_entry_id = nav_entry_id; 316 params.nav_entry_id = nav_entry_id;
315 params.url = url_copy; 317 params.url = url_copy;
316 params.transition = transition; 318 params.transition = transition;
317 params.should_update_history = true; 319 params.should_update_history = true;
318 params.did_create_new_entry = did_create_new_entry; 320 params.did_create_new_entry = did_create_new_entry;
319 params.should_replace_current_entry = should_replace_entry; 321 params.should_replace_current_entry = should_replace_entry;
320 params.gesture = NavigationGestureUser; 322 params.gesture = NavigationGestureUser;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 391 }
390 392
391 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( 393 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest(
392 const GURL& url, 394 const GURL& url,
393 bool has_user_gesture) { 395 bool has_user_gesture) {
394 // Since this is renderer-initiated navigation, the RenderFrame must be 396 // Since this is renderer-initiated navigation, the RenderFrame must be
395 // initialized. Do it if it hasn't happened yet. 397 // initialized. Do it if it hasn't happened yet.
396 InitializeRenderFrameIfNeeded(); 398 InitializeRenderFrameIfNeeded();
397 399
398 if (IsBrowserSideNavigationEnabled()) { 400 if (IsBrowserSideNavigationEnabled()) {
399 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, 401 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false,
400 has_user_gesture, false,
401 REQUEST_CONTEXT_TYPE_HYPERLINK); 402 REQUEST_CONTEXT_TYPE_HYPERLINK);
402 CommonNavigationParams common_params; 403 CommonNavigationParams common_params;
403 common_params.url = url; 404 common_params.url = url;
404 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); 405 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault);
405 common_params.transition = ui::PAGE_TRANSITION_LINK; 406 common_params.transition = ui::PAGE_TRANSITION_LINK;
407 common_params.gesture =
408 has_user_gesture ? NavigationGestureUser : NavigationGestureAuto;
406 OnBeginNavigation(common_params, begin_params); 409 OnBeginNavigation(common_params, begin_params);
407 } 410 }
408 } 411 }
409 412
410 void TestRenderFrameHost::DidChangeOpener(int opener_routing_id) { 413 void TestRenderFrameHost::DidChangeOpener(int opener_routing_id) {
411 OnDidChangeOpener(opener_routing_id); 414 OnDidChangeOpener(opener_routing_id);
412 } 415 }
413 416
414 void TestRenderFrameHost::DidEnforceInsecureRequestPolicy( 417 void TestRenderFrameHost::DidEnforceInsecureRequestPolicy(
415 blink::WebInsecureRequestPolicy policy) { 418 blink::WebInsecureRequestPolicy policy) {
(...skipping 62 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
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698