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

Side by Side Diff: chrome/browser/tab_contents/test_tab_contents.cc

Issue 3537005: Merge 58701 - Relanding this:... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/517/src/
Patch Set: Created 10 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/browser/tab_contents/test_tab_contents.h" 5 #include "chrome/browser/tab_contents/test_tab_contents.h"
6 6
7 #include "chrome/browser/browser_url_handler.h" 7 #include "chrome/browser/browser_url_handler.h"
8 #include "chrome/browser/renderer_host/mock_render_process_host.h" 8 #include "chrome/browser/renderer_host/mock_render_process_host.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/browser/renderer_host/site_instance.h" 10 #include "chrome/browser/renderer_host/site_instance.h"
(...skipping 27 matching lines...) Expand all
38 case NotificationType::TAB_CONTENTS_INFOBAR_REPLACED: 38 case NotificationType::TAB_CONTENTS_INFOBAR_REPLACED:
39 Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details).ptr()-> 39 Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details).ptr()->
40 first->InfoBarClosed(); 40 first->InfoBarClosed();
41 break; 41 break;
42 default: 42 default:
43 TabContents::Observe(type, source, details); 43 TabContents::Observe(type, source, details);
44 break; 44 break;
45 } 45 }
46 } 46 }
47 47
48 TestRenderViewHost* TestTabContents::pending_rvh() { 48 TestRenderViewHost* TestTabContents::pending_rvh() const {
49 return static_cast<TestRenderViewHost*>( 49 return static_cast<TestRenderViewHost*>(
50 render_manager_.pending_render_view_host_); 50 render_manager_.pending_render_view_host_);
51 } 51 }
52 52
53 bool TestTabContents::CreateRenderViewForRenderManager( 53 bool TestTabContents::CreateRenderViewForRenderManager(
54 RenderViewHost* render_view_host) { 54 RenderViewHost* render_view_host) {
55 // This will go to a TestRenderViewHost. 55 // This will go to a TestRenderViewHost.
56 render_view_host->CreateRenderView(string16()); 56 render_view_host->CreateRenderView(string16());
57 return true; 57 return true;
58 } 58 }
59 59
60 TabContents* TestTabContents::Clone() { 60 TabContents* TestTabContents::Clone() {
61 TabContents* tc = new TestTabContents( 61 TabContents* tc = new TestTabContents(
62 profile(), SiteInstance::CreateSiteInstance(profile())); 62 profile(), SiteInstance::CreateSiteInstance(profile()));
63 tc->controller().CopyStateFrom(controller_); 63 tc->controller().CopyStateFrom(controller_);
64 return tc; 64 return tc;
65 } 65 }
66 66
67 void TestTabContents::NavigateAndCommit(const GURL& url) { 67 void TestTabContents::NavigateAndCommit(const GURL& url) {
68 controller().LoadURL(url, GURL(), 0); 68 controller().LoadURL(url, GURL(), 0);
69 GURL loaded_url(url); 69 GURL loaded_url(url);
70 bool reverse_on_redirect = false; 70 bool reverse_on_redirect = false;
71 BrowserURLHandler::RewriteURLIfNecessary( 71 BrowserURLHandler::RewriteURLIfNecessary(
72 &loaded_url, profile(), &reverse_on_redirect); 72 &loaded_url, profile(), &reverse_on_redirect);
73 static_cast<TestRenderViewHost*>(render_view_host())->SendNavigate( 73
74 static_cast<MockRenderProcessHost*>(render_view_host()->process())-> 74 // LoadURL created a navigation entry, now simulate the RenderView sending
75 max_page_id() + 1, loaded_url); 75 // a notification that it actually navigated.
76 CommitPendingNavigation();
76 } 77 }
78
79 void TestTabContents::CommitPendingNavigation() {
80 // If we are doing a cross-site navigation, this simulates the current RVH
81 // notifying that it has unloaded so the pending RVH is resumed and can
82 // navigate.
83 ProceedWithCrossSiteNavigation();
84 TestRenderViewHost* rvh = pending_rvh();
85 if (!rvh)
86 rvh = static_cast<TestRenderViewHost*>(render_manager_.current_host());
87
88 const NavigationEntry* entry = controller().pending_entry();
89 DCHECK(entry);
90 int page_id = entry->page_id();
91 if (page_id == -1) {
92 // It's a new navigation, assign a never-seen page id to it.
93 page_id =
94 static_cast<MockRenderProcessHost*>(rvh->process())->max_page_id() + 1;
95 }
96 rvh->SendNavigate(page_id, entry->url());
97 }
98
99 void TestTabContents::ProceedWithCrossSiteNavigation() {
100 if (!pending_rvh())
101 return;
102 render_manager_.ShouldClosePage(true, true);
103 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/test_tab_contents.h ('k') | chrome/browser/translate/translate_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698