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

Side by Side Diff: chrome/test/base/browser_with_test_window_test.cc

Issue 8224023: Don't show URL for pending new navigations initiated by the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add IsBrowserInitiated helper. Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/test/base/browser_with_test_window_test.h" 5 #include "chrome/test/base/browser_with_test_window_test.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <ole2.h> 8 #include <ole2.h>
9 #endif // defined(OS_WIN) 9 #endif // defined(OS_WIN)
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 params.disposition = NEW_FOREGROUND_TAB; 63 params.disposition = NEW_FOREGROUND_TAB;
64 browser::Navigate(&params); 64 browser::Navigate(&params);
65 CommitPendingLoad(&params.target_contents->controller()); 65 CommitPendingLoad(&params.target_contents->controller());
66 } 66 }
67 67
68 void BrowserWithTestWindowTest::CommitPendingLoad( 68 void BrowserWithTestWindowTest::CommitPendingLoad(
69 NavigationController* controller) { 69 NavigationController* controller) {
70 if (!controller->pending_entry()) 70 if (!controller->pending_entry())
71 return; // Nothing to commit. 71 return; // Nothing to commit.
72 72
73 TestRenderViewHost* test_rvh = 73 TestRenderViewHost* old_rvh =
74 TestRenderViewHostForTab(controller->tab_contents()); 74 TestRenderViewHostForTab(controller->tab_contents());
75 MockRenderProcessHost* mock_rph = static_cast<MockRenderProcessHost*>( 75 MockRenderProcessHost* mock_rph = static_cast<MockRenderProcessHost*>(
76 test_rvh->process()); 76 old_rvh->process());
77
78 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>(
79 controller->tab_contents()->render_manager_for_testing()->
80 pending_render_view_host());
81 if (pending_rvh) {
82 // Simulate the ShouldClose_ACK that is received from the current renderer
83 // for a cross-site navigation.
84 DCHECK(old_rvh != pending_rvh);
Paweł Hajdan Jr. 2011/10/11 22:26:18 nit: DCHECK_NE.
Charlie Reis 2011/10/12 21:55:56 Done.
85 old_rvh->SendShouldCloseACK(true);
86 }
87 // Commit on the pending_rvh, if one exists.
88 TestRenderViewHost* test_rvh = pending_rvh ? pending_rvh : old_rvh;
77 89
78 // For new navigations, we need to send a larger page ID. For renavigations, 90 // For new navigations, we need to send a larger page ID. For renavigations,
79 // we need to send the preexisting page ID. We can tell these apart because 91 // we need to send the preexisting page ID. We can tell these apart because
80 // renavigations will have a pending_entry_index while new ones won't (they'll 92 // renavigations will have a pending_entry_index while new ones won't (they'll
81 // just have a standalong pending_entry that isn't in the list already). 93 // just have a standalong pending_entry that isn't in the list already).
82 if (controller->pending_entry_index() >= 0) { 94 if (controller->pending_entry_index() >= 0) {
83 test_rvh->SendNavigate(controller->pending_entry()->page_id(), 95 test_rvh->SendNavigateWithTransition(
84 controller->pending_entry()->url()); 96 controller->pending_entry()->page_id(),
97 controller->pending_entry()->url(),
98 controller->pending_entry()->transition_type());
85 } else { 99 } else {
86 test_rvh->SendNavigate(mock_rph->max_page_id() + 1, 100 test_rvh->SendNavigateWithTransition(
87 controller->pending_entry()->url()); 101 mock_rph->max_page_id() + 1,
102 controller->pending_entry()->url(),
103 controller->pending_entry()->transition_type());
104 mock_rph->UpdateMaxPageID(mock_rph->max_page_id() + 1);
88 } 105 }
106
107 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation
108 // without making any network requests.
109 if (pending_rvh)
110 old_rvh->OnSwapOutACK();
89 } 111 }
90 112
91 void BrowserWithTestWindowTest::NavigateAndCommit( 113 void BrowserWithTestWindowTest::NavigateAndCommit(
92 NavigationController* controller, 114 NavigationController* controller,
93 const GURL& url) { 115 const GURL& url) {
94 controller->LoadURL(url, GURL(), PageTransition::LINK, std::string()); 116 controller->LoadURL(url, GURL(), PageTransition::LINK, std::string());
95 CommitPendingLoad(controller); 117 CommitPendingLoad(controller);
96 } 118 }
97 119
98 void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) { 120 void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) {
99 NavigateAndCommit(&browser()->GetSelectedTabContents()->controller(), url); 121 NavigateAndCommit(&browser()->GetSelectedTabContents()->controller(), url);
100 } 122 }
101 123
102 void BrowserWithTestWindowTest::DestroyBrowser() { 124 void BrowserWithTestWindowTest::DestroyBrowser() {
103 if (!browser_.get()) 125 if (!browser_.get())
104 return; 126 return;
105 // Make sure we close all tabs, otherwise Browser isn't happy in its 127 // Make sure we close all tabs, otherwise Browser isn't happy in its
106 // destructor. 128 // destructor.
107 browser()->CloseAllTabs(); 129 browser()->CloseAllTabs();
108 browser_.reset(NULL); 130 browser_.reset(NULL);
109 window_.reset(NULL); 131 window_.reset(NULL);
110 } 132 }
111 133
112 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { 134 TestingProfile* BrowserWithTestWindowTest::CreateProfile() {
113 return new TestingProfile(); 135 return new TestingProfile();
114 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698