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

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

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Addressed comments(@brettw) 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
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 if (IsBrowserSideNavigationEnabled()) { 414 if (IsBrowserSideNavigationEnabled()) {
415 // TODO(mkwst): The initiator origin here is incorrect. 415 // TODO(mkwst): The initiator origin here is incorrect.
416 BeginNavigationParams begin_params( 416 BeginNavigationParams begin_params(
417 std::string(), net::LOAD_NORMAL, has_user_gesture, false, 417 std::string(), net::LOAD_NORMAL, has_user_gesture, false,
418 REQUEST_CONTEXT_TYPE_HYPERLINK, 418 REQUEST_CONTEXT_TYPE_HYPERLINK,
419 blink::WebMixedContentContextType::Blockable, url::Origin()); 419 blink::WebMixedContentContextType::Blockable, url::Origin());
420 CommonNavigationParams common_params; 420 CommonNavigationParams common_params;
421 common_params.url = url; 421 common_params.url = url;
422 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); 422 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault);
423 common_params.transition = ui::PAGE_TRANSITION_LINK; 423 common_params.transition = ui::PAGE_TRANSITION_LINK;
424 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT;
424 OnBeginNavigation(common_params, begin_params); 425 OnBeginNavigation(common_params, begin_params);
425 } 426 }
426 } 427 }
427 428
428 void TestRenderFrameHost::DidChangeOpener(int opener_routing_id) { 429 void TestRenderFrameHost::DidChangeOpener(int opener_routing_id) {
429 OnDidChangeOpener(opener_routing_id); 430 OnDidChangeOpener(opener_routing_id);
430 } 431 }
431 432
432 void TestRenderFrameHost::DidEnforceInsecureRequestPolicy( 433 void TestRenderFrameHost::DidEnforceInsecureRequestPolicy(
433 blink::WebInsecureRequestPolicy policy) { 434 blink::WebInsecureRequestPolicy policy) {
434 OnEnforceInsecureRequestPolicy(policy); 435 OnEnforceInsecureRequestPolicy(policy);
435 } 436 }
436 437
437 void TestRenderFrameHost::PrepareForCommit() { 438 void TestRenderFrameHost::PrepareForCommit() {
438 PrepareForCommitWithServerRedirect(GURL()); 439 PrepareForCommitWithServerRedirect(GURL());
439 } 440 }
440 441
441 void TestRenderFrameHost::PrepareForCommitWithServerRedirect( 442 void TestRenderFrameHost::PrepareForCommitWithServerRedirect(
442 const GURL& redirect_url) { 443 const GURL& redirect_url) {
443 if (!IsBrowserSideNavigationEnabled()) { 444 if (!IsBrowserSideNavigationEnabled()) {
444 // Non PlzNavigate 445 // Non PlzNavigate
445 if (is_waiting_for_beforeunload_ack()) 446 if (is_waiting_for_beforeunload_ack())
446 SendBeforeUnloadACK(true); 447 SendBeforeUnloadACK(true);
447 return; 448 return;
448 } 449 }
449 450
450 // PlzNavigate 451 // PlzNavigate
451 NavigationRequest* request = frame_tree_node_->navigation_request(); 452 NavigationRequest* request = frame_tree_node_->navigation_request();
452 CHECK(request); 453 CHECK(request);
453 bool have_to_make_network_request = ShouldMakeNetworkRequestForURL( 454 bool have_to_make_network_request =
454 request->common_params().url); 455 ShouldMakeNetworkRequestForURL(request->common_params().url) &&
456 !FrameMsg_Navigate_Type::IsSameDocument(
457 request->common_params().navigation_type);
455 458
456 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for 459 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for
457 // it. If it runs it will update the request state. 460 // it. If it runs it will update the request state.
458 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) { 461 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) {
459 static_cast<TestRenderFrameHost*>(frame_tree_node()->current_frame_host()) 462 static_cast<TestRenderFrameHost*>(frame_tree_node()->current_frame_host())
460 ->SendBeforeUnloadACK(true); 463 ->SendBeforeUnloadACK(true);
461 } 464 }
462 465
463 if (!have_to_make_network_request) 466 if (!have_to_make_network_request)
464 return; // |request| is destructed by now. 467 return; // |request| is destructed by now.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at 510 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at
508 // this point. 511 // this point.
509 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) 512 if (!navigation_handle() || IsBrowserSideNavigationEnabled())
510 return; 513 return;
511 navigation_handle()->CallWillStartRequestForTesting( 514 navigation_handle()->CallWillStartRequestForTesting(
512 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), 515 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault),
513 true /* user_gesture */, transition, false /* is_external_protocol */); 516 true /* user_gesture */, transition, false /* is_external_protocol */);
514 } 517 }
515 518
516 } // namespace content 519 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698