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

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

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Rebase. Created 3 years, 10 months 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_view_browsertest.cc ('k') | content/test/test_web_contents.h » ('j') | 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 "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/navigation_handle_impl.h" 10 #include "content/browser/frame_host/navigation_handle_impl.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (IsBrowserSideNavigationEnabled()) { 422 if (IsBrowserSideNavigationEnabled()) {
423 // TODO(mkwst): The initiator origin here is incorrect. 423 // TODO(mkwst): The initiator origin here is incorrect.
424 BeginNavigationParams begin_params( 424 BeginNavigationParams begin_params(
425 std::string(), net::LOAD_NORMAL, has_user_gesture, false, 425 std::string(), net::LOAD_NORMAL, has_user_gesture, false,
426 REQUEST_CONTEXT_TYPE_HYPERLINK, 426 REQUEST_CONTEXT_TYPE_HYPERLINK,
427 blink::WebMixedContentContextType::Blockable, url::Origin()); 427 blink::WebMixedContentContextType::Blockable, url::Origin());
428 CommonNavigationParams common_params; 428 CommonNavigationParams common_params;
429 common_params.url = url; 429 common_params.url = url;
430 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); 430 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault);
431 common_params.transition = ui::PAGE_TRANSITION_LINK; 431 common_params.transition = ui::PAGE_TRANSITION_LINK;
432 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT;
432 OnBeginNavigation(common_params, begin_params); 433 OnBeginNavigation(common_params, begin_params);
433 } 434 }
434 } 435 }
435 436
436 void TestRenderFrameHost::DidChangeOpener(int opener_routing_id) { 437 void TestRenderFrameHost::DidChangeOpener(int opener_routing_id) {
437 OnDidChangeOpener(opener_routing_id); 438 OnDidChangeOpener(opener_routing_id);
438 } 439 }
439 440
440 void TestRenderFrameHost::DidEnforceInsecureRequestPolicy( 441 void TestRenderFrameHost::DidEnforceInsecureRequestPolicy(
441 blink::WebInsecureRequestPolicy policy) { 442 blink::WebInsecureRequestPolicy policy) {
442 OnEnforceInsecureRequestPolicy(policy); 443 OnEnforceInsecureRequestPolicy(policy);
443 } 444 }
444 445
445 void TestRenderFrameHost::PrepareForCommit() { 446 void TestRenderFrameHost::PrepareForCommit() {
446 PrepareForCommitWithServerRedirect(GURL()); 447 PrepareForCommitWithServerRedirect(GURL());
447 } 448 }
448 449
449 void TestRenderFrameHost::PrepareForCommitWithServerRedirect( 450 void TestRenderFrameHost::PrepareForCommitWithServerRedirect(
450 const GURL& redirect_url) { 451 const GURL& redirect_url) {
451 if (!IsBrowserSideNavigationEnabled()) { 452 if (!IsBrowserSideNavigationEnabled()) {
452 // Non PlzNavigate 453 // Non PlzNavigate
453 if (is_waiting_for_beforeunload_ack()) 454 if (is_waiting_for_beforeunload_ack())
454 SendBeforeUnloadACK(true); 455 SendBeforeUnloadACK(true);
455 return; 456 return;
456 } 457 }
457 458
458 // PlzNavigate 459 // PlzNavigate
459 NavigationRequest* request = frame_tree_node_->navigation_request(); 460 NavigationRequest* request = frame_tree_node_->navigation_request();
460 CHECK(request); 461 CHECK(request);
461 bool have_to_make_network_request = ShouldMakeNetworkRequestForURL( 462 bool have_to_make_network_request =
462 request->common_params().url); 463 ShouldMakeNetworkRequestForURL(request->common_params().url) &&
464 !FrameMsg_Navigate_Type::IsSameDocument(
465 request->common_params().navigation_type);
463 466
464 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for 467 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for
465 // it. If it runs it will update the request state. 468 // it. If it runs it will update the request state.
466 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) { 469 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) {
467 static_cast<TestRenderFrameHost*>(frame_tree_node()->current_frame_host()) 470 static_cast<TestRenderFrameHost*>(frame_tree_node()->current_frame_host())
468 ->SendBeforeUnloadACK(true); 471 ->SendBeforeUnloadACK(true);
469 } 472 }
470 473
471 if (!have_to_make_network_request) 474 if (!have_to_make_network_request)
472 return; // |request| is destructed by now. 475 return; // |request| is destructed by now.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at 518 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at
516 // this point. 519 // this point.
517 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) 520 if (!navigation_handle() || IsBrowserSideNavigationEnabled())
518 return; 521 return;
519 navigation_handle()->CallWillStartRequestForTesting( 522 navigation_handle()->CallWillStartRequestForTesting(
520 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), 523 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault),
521 true /* user_gesture */, transition, false /* is_external_protocol */); 524 true /* user_gesture */, transition, false /* is_external_protocol */);
522 } 525 }
523 526
524 } // namespace content 527 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_browsertest.cc ('k') | content/test/test_web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698