diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-11 19:35:02 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-11 19:35:02 +0000 |
commit | e04488797a798ff831d7d0b01e8374d714e56794 (patch) | |
tree | 0b341832c14b9676d35015f0ab92a6c426ed678e /chrome/browser | |
parent | 1d44c10678bbdf2dedaf5255f50b2881957a2604 (diff) | |
download | chromium_src-e04488797a798ff831d7d0b01e8374d714e56794.zip chromium_src-e04488797a798ff831d7d0b01e8374d714e56794.tar.gz chromium_src-e04488797a798ff831d7d0b01e8374d714e56794.tar.bz2 |
Remove TabStripModel wrapper use.
BUG=167548
TEST=no functional change
Review URL: https://chromiumcodereview.appspot.com/11833044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176415 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
22 files changed, 400 insertions, 310 deletions
diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index 2554b27..1b7cd3c 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -512,7 +512,9 @@ bool GetTabForId(const AutomationId& id, WebContents** tab) { BrowserList::const_iterator iter = BrowserList::begin(); for (; iter != BrowserList::end(); ++iter) { Browser* browser = *iter; - for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { + for (int tab_index = 0; + tab_index < browser->tab_strip_model()->count(); + ++tab_index) { WebContents* web_contents = browser->tab_strip_model()->GetWebContentsAt(tab_index); SessionTabHelper* session_tab_helper = diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 039655b..be7ebf4 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -982,7 +982,7 @@ void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) { if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); - *tab_count = browser->tab_count(); + *tab_count = browser->tab_strip_model()->count(); } } @@ -1001,8 +1001,9 @@ void TestingAutomationProvider::GetTab(int win_handle, *tab_handle = 0; if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { Browser* browser = browser_tracker_->GetResource(win_handle); - if (tab_index < browser->tab_count()) { - WebContents* web_contents = chrome::GetWebContentsAt(browser, tab_index); + if (tab_index < browser->tab_strip_model()->count()) { + WebContents* web_contents = + browser->tab_strip_model()->GetWebContentsAt(tab_index); *tab_handle = tab_tracker_->Add(&web_contents->GetController()); } } @@ -2192,7 +2193,8 @@ void TestingAutomationProvider::PerformActionOnInfobar( return; } - WebContents* web_contents = chrome::GetWebContentsAt(browser, tab_index); + WebContents* web_contents = + browser->tab_strip_model()->GetWebContentsAt(tab_index); if (!web_contents) { reply.SendError(StringPrintf("No such tab at index %d", tab_index)); return; @@ -2362,8 +2364,8 @@ void TestingAutomationProvider::GetBrowserInfo( // For each window, add info about all tabs in a list of dictionaries, // one dictionary item per tab. ListValue* tabs = new ListValue; - for (int i = 0; i < browser->tab_count(); ++i) { - WebContents* wc = chrome::GetWebContentsAt(browser, i); + for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { + WebContents* wc = browser->tab_strip_model()->GetWebContentsAt(i); DictionaryValue* tab = new DictionaryValue; tab->SetInteger("index", i); tab->SetString("url", wc->GetURL().spec()); @@ -2498,7 +2500,8 @@ void TestingAutomationProvider::GetNavigationInfo( int tab_index; WebContents* web_contents = NULL; if (!args->GetInteger("tab_index", &tab_index) || - !(web_contents = chrome::GetWebContentsAt(browser, tab_index))) { + !(web_contents = + browser->tab_strip_model()->GetWebContentsAt(tab_index))) { reply.SendError("tab_index missing or invalid."); return; } @@ -3104,7 +3107,7 @@ void TestingAutomationProvider::OmniboxAcceptInput( DictionaryValue* args, IPC::Message* reply_message) { NavigationController& controller = - chrome::GetActiveWebContents(browser)->GetController(); + browser->tab_strip_model()->GetActiveWebContents()->GetController(); LocationBar* loc_bar = browser->window()->GetLocationBar(); if (!loc_bar) { AutomationJSONReply(this, reply_message).SendError( @@ -3269,7 +3272,7 @@ void TestingAutomationProvider::SaveTabContents( .SendError("tab_index or filename param missing"); return; } else { - web_contents = chrome::GetWebContentsAt(browser, tab_index); + web_contents = browser->tab_strip_model()->GetWebContentsAt(tab_index); if (!web_contents) { AutomationJSONReply(this, reply_message).SendError("no tab at tab_index"); return; @@ -4977,7 +4980,8 @@ void TestingAutomationProvider::LaunchApp( return; } - WebContents* old_contents = chrome::GetActiveWebContents(browser); + WebContents* old_contents = + browser->tab_strip_model()->GetActiveWebContents(); if (!old_contents) { AutomationJSONReply(this, reply_message).SendError( "Cannot identify selected tab contents."); @@ -5066,7 +5070,7 @@ void TestingAutomationProvider::GetV8HeapStats( return; } - web_contents = chrome::GetWebContentsAt(browser, tab_index); + web_contents = browser->tab_strip_model()->GetWebContentsAt(tab_index); if (!web_contents) { AutomationJSONReply(this, reply_message).SendError( StringPrintf("Could not get WebContents at tab index %d", tab_index)); @@ -5100,7 +5104,7 @@ void TestingAutomationProvider::GetFPS( return; } - web_contents = chrome::GetWebContentsAt(browser, tab_index); + web_contents = browser->tab_strip_model()->GetWebContentsAt(tab_index); if (!web_contents) { AutomationJSONReply(this, reply_message).SendError( StringPrintf("Could not get WebContents at tab index %d", tab_index)); @@ -5140,7 +5144,7 @@ void TestingAutomationProvider::IsMouseLocked(Browser* browser, base::DictionaryValue* args, IPC::Message* reply_message) { DictionaryValue dict; - dict.SetBoolean("result", chrome::GetActiveWebContents(browser)-> + dict.SetBoolean("result", browser->tab_strip_model()->GetActiveWebContents()-> GetRenderViewHost()->GetView()->IsMouseLocked()); AutomationJSONReply(this, reply_message).SendSuccess(&dict); } @@ -5310,8 +5314,11 @@ void TestingAutomationProvider::GetIndicesFromTab( int browser_index = 0; for (; iter != BrowserList::end(); ++iter, ++browser_index) { Browser* browser = *iter; - for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { - WebContents* tab = chrome::GetWebContentsAt(browser, tab_index); + for (int tab_index = 0; + tab_index < browser->tab_strip_model()->count(); + ++tab_index) { + WebContents* tab = + browser->tab_strip_model()->GetWebContentsAt(tab_index); SessionTabHelper* session_tab_helper = SessionTabHelper::FromWebContents(tab); if (session_tab_helper->session_id().id() == id) { @@ -5740,7 +5747,7 @@ void TestingAutomationProvider::GetTabCountJSON( return; } DictionaryValue dict; - dict.SetInteger("tab_count", browser->tab_count()); + dict.SetInteger("tab_count", browser->tab_strip_model()->count()); reply.SendSuccess(&dict); } @@ -5956,9 +5963,9 @@ void TestingAutomationProvider::GetTabIds( BrowserList::const_iterator iter = BrowserList::begin(); for (; iter != BrowserList::end(); ++iter) { Browser* browser = *iter; - for (int i = 0; i < browser->tab_count(); ++i) { + for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { int id = SessionTabHelper::FromWebContents( - chrome::GetWebContentsAt(browser, i))->session_id().id(); + browser->tab_strip_model()->GetWebContentsAt(i))->session_id().id(); id_list->Append(Value::CreateIntegerValue(id)); } } @@ -5975,7 +5982,7 @@ void TestingAutomationProvider::GetViews( BrowserList::const_iterator browser_iter = BrowserList::begin(); for (; browser_iter != BrowserList::end(); ++browser_iter) { Browser* browser = *browser_iter; - for (int i = 0; i < browser->tab_count(); ++i) { + for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { WebContents* tab = browser->tab_strip_model()->GetWebContentsAt(i); DictionaryValue* dict = new DictionaryValue(); AutomationId id = automation_util::GetIdForTab(tab); @@ -6028,8 +6035,8 @@ void TestingAutomationProvider::IsTabIdValid( BrowserList::const_iterator iter = BrowserList::begin(); for (; iter != BrowserList::end(); ++iter) { Browser* browser = *iter; - for (int i = 0; i < browser->tab_count(); ++i) { - WebContents* tab = chrome::GetWebContentsAt(browser, i); + for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { + WebContents* tab = browser->tab_strip_model()->GetWebContentsAt(i); SessionTabHelper* session_tab_helper = SessionTabHelper::FromWebContents(tab); if (session_tab_helper->session_id().id() == id) { diff --git a/chrome/browser/captive_portal/captive_portal_browsertest.cc b/chrome/browser/captive_portal/captive_portal_browsertest.cc index 255851e..6fb3ef2 100644 --- a/chrome/browser/captive_portal/captive_portal_browsertest.cc +++ b/chrome/browser/captive_portal/captive_portal_browsertest.cc @@ -1052,7 +1052,7 @@ void CaptivePortalBrowserTest::NavigateToPageExpectNoTest( // should be no new tabs. EXPECT_EQ(0, portal_observer.num_results_received()); EXPECT_FALSE(CheckPending(browser)); - EXPECT_EQ(1, browser->tab_count()); + EXPECT_EQ(1, browser->tab_strip_model()->count()); EXPECT_EQ(expected_navigations, navigation_observer.num_navigations()); EXPECT_EQ(0, NumLoadingTabs()); EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, @@ -1075,7 +1075,7 @@ void CaptivePortalBrowserTest::SlowLoadNoCaptivePortal( portal_observer.WaitForResults(1); - ASSERT_EQ(1, browser->tab_count()); + ASSERT_EQ(1, browser->tab_strip_model()->count()); EXPECT_EQ(expected_result, portal_observer.captive_portal_result()); EXPECT_EQ(1, portal_observer.num_results_received()); EXPECT_EQ(0, navigation_observer.num_navigations()); @@ -1089,7 +1089,7 @@ void CaptivePortalBrowserTest::SlowLoadNoCaptivePortal( URLRequestTimeoutOnDemandJob::FailJobs(1); navigation_observer.WaitForNavigations(1); - ASSERT_EQ(1, browser->tab_count()); + ASSERT_EQ(1, browser->tab_strip_model()->count()); EXPECT_EQ(1, portal_observer.num_results_received()); EXPECT_FALSE(CheckPending(browser)); EXPECT_EQ(0, NumLoadingTabs()); @@ -1113,8 +1113,8 @@ void CaptivePortalBrowserTest::FastTimeoutNoCaptivePortal( CaptivePortalObserver portal_observer(browser->profile()); // Neither of these should be changed by the navigation. - int active_index = browser->active_index(); - int expected_tab_count = browser->tab_count(); + int active_index = browser->tab_strip_model()->active_index(); + int expected_tab_count = browser->tab_strip_model()->count(); ui_test_utils::NavigateToURL( browser, @@ -1144,7 +1144,7 @@ void CaptivePortalBrowserTest::FastTimeoutNoCaptivePortal( EXPECT_FALSE(CheckPending(browser)); // Make sure no login tab was opened. - EXPECT_EQ(expected_tab_count, browser->tab_count()); + EXPECT_EQ(expected_tab_count, browser->tab_strip_model()->count()); } void CaptivePortalBrowserTest::SlowLoadBehindCaptivePortal( diff --git a/chrome/browser/captive_portal/captive_portal_tab_helper.cc b/chrome/browser/captive_portal/captive_portal_tab_helper.cc index f2e9490..a735f8e 100644 --- a/chrome/browser/captive_portal/captive_portal_tab_helper.cc +++ b/chrome/browser/captive_portal/captive_portal_tab_helper.cc @@ -12,6 +12,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_tabstrip.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" @@ -251,7 +252,8 @@ void CaptivePortalTabHelper::OpenLoginTab() { // TODO(mmenke): Consider focusing that tab, at least if this is the tab // helper for the currently active tab for the profile. for (int i = 0; i < browser->tab_count(); ++i) { - content::WebContents* web_contents = chrome::GetWebContentsAt(browser, i); + content::WebContents* web_contents = + browser->tab_strip_model()->GetWebContentsAt(i); captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper = captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents); if (captive_portal_tab_helper->IsLoginTab()) diff --git a/chrome/browser/chromeos/memory/oom_priority_manager_browsertest.cc b/chrome/browser/chromeos/memory/oom_priority_manager_browsertest.cc index 35aaddb..2bb34b0 100644 --- a/chrome/browser/chromeos/memory/oom_priority_manager_browsertest.cc +++ b/chrome/browser/chromeos/memory/oom_priority_manager_browsertest.cc @@ -52,7 +52,7 @@ IN_PROC_BROWSER_TEST_F(OomPriorityManagerTest, OomPriorityManagerBasics) { browser()->OpenURL(open3); load3.Wait(); - EXPECT_EQ(3, browser()->tab_count()); + EXPECT_EQ(3, browser()->tab_strip_model()->count()); // Navigate the current (third) tab to a different URL, so we can test // back/forward later. @@ -75,19 +75,19 @@ IN_PROC_BROWSER_TEST_F(OomPriorityManagerTest, OomPriorityManagerBasics) { browser()->OpenURL(open5); load5.Wait(); - EXPECT_EQ(3, browser()->tab_count()); + EXPECT_EQ(3, browser()->tab_strip_model()->count()); // Discard a tab. It should kill the first tab, since it was the oldest // and was not selected. EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab()); - EXPECT_EQ(3, browser()->tab_count()); + EXPECT_EQ(3, browser()->tab_strip_model()->count()); EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0)); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(1)); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); // Run discard again, make sure it kills the second tab. EXPECT_TRUE(g_browser_process->oom_priority_manager()->DiscardTab()); - EXPECT_EQ(3, browser()->tab_count()); + EXPECT_EQ(3, browser()->tab_strip_model()->count()); EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(0)); EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(1)); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); @@ -101,7 +101,7 @@ IN_PROC_BROWSER_TEST_F(OomPriorityManagerTest, OomPriorityManagerBasics) { // Kill the third tab after making second tab active. browser()->tab_strip_model()->ActivateTabAt(1, true); - EXPECT_EQ(1, browser()->active_index()); + EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(1)); browser()->tab_strip_model()->DiscardWebContentsAt(2); EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(2)); @@ -118,7 +118,7 @@ IN_PROC_BROWSER_TEST_F(OomPriorityManagerTest, OomPriorityManagerBasics) { // Make sure the FindBarController gets the right WebContents. EXPECT_EQ(browser()->GetFindBarController()->web_contents(), chrome::GetActiveWebContents(browser())); - EXPECT_EQ(0, browser()->active_index()); + EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(0)); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(1)); EXPECT_TRUE(browser()->tab_strip_model()->IsTabDiscarded(2)); @@ -129,7 +129,7 @@ IN_PROC_BROWSER_TEST_F(OomPriorityManagerTest, OomPriorityManagerBasics) { content::NotificationService::AllSources()); chrome::SelectNumberedTab(browser(), 2); reload2.Wait(); - EXPECT_EQ(2, browser()->active_index()); + EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(0)); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(1)); EXPECT_FALSE(browser()->tab_strip_model()->IsTabDiscarded(2)); diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index f435c40..a97aa5f 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc @@ -529,7 +529,7 @@ class DownloadTest : public InProcessBrowserTest { EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); CheckDownloadStatesForBrowser(browser, 1, DownloadItem::COMPLETE); - EXPECT_EQ(2, browser->tab_count()); + EXPECT_EQ(2, browser->tab_strip_model()->count()); // TODO(ahendrickson): check download status text after downloading. @@ -1374,7 +1374,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, NewWindow) { ui_test_utils::GetBrowserNotInSet(original_browsers); ASSERT_TRUE(download_browser != NULL); EXPECT_NE(download_browser, browser()); - EXPECT_EQ(1, download_browser->tab_count()); + EXPECT_EQ(1, download_browser->tab_strip_model()->count()); EXPECT_TRUE(download_browser->window()->IsDownloadShelfVisible()); #if !defined(OS_MACOSX) diff --git a/chrome/browser/extensions/api/management/management_apitest.cc b/chrome/browser/extensions/api/management/management_apitest.cc index 053e542..b1161d5 100644 --- a/chrome/browser/extensions/api/management/management_apitest.cc +++ b/chrome/browser/extensions/api/management/management_apitest.cc @@ -14,6 +14,7 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/manifest.h" @@ -222,7 +223,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { // Code below assumes that the test starts with a single browser window // hosting one tab. ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); - ASSERT_EQ(1, browser()->tab_count()); + ASSERT_EQ(1, browser()->tab_strip_model()->count()); // Load an app with app.launch.container = "tab". std::string app_id; @@ -231,7 +232,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { // Check that the app opened in a new tab of the existing browser. ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); - ASSERT_EQ(2, browser()->tab_count()); + ASSERT_EQ(2, browser()->tab_strip_model()->count()); // Unload the extension. UninstallExtension(app_id); @@ -253,7 +254,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { // App windows are not yet implemented on mac os. We should fall back // to a normal tab. ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); - ASSERT_EQ(2, browser()->tab_count()); + ASSERT_EQ(2, browser()->tab_strip_model()->count()); #else // Find the app's browser. Opening in a new window will create // a new browser. diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc index 3f81fa9..c8c09b7 100644 --- a/chrome/browser/extensions/app_process_apitest.cc +++ b/chrome/browser/extensions/app_process_apitest.cc @@ -13,8 +13,8 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" @@ -84,8 +84,9 @@ class AppApiTest : public ExtensionApiTest { ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); LOG(INFO) << "Nav 1."; EXPECT_TRUE(process_map->Contains( - chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost()->GetID())); - EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 1)->GetWebUI()); + browser()->tab_strip_model()->GetWebContentsAt(1)-> + GetRenderProcessHost()->GetID())); + EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI()); content::WindowedNotificationObserver tab_added_observer( chrome::NOTIFICATION_TAB_ADDED, @@ -97,16 +98,17 @@ class AppApiTest : public ExtensionApiTest { base_url.Resolve("path2/empty.html")); LOG(INFO) << "Nav 2."; EXPECT_TRUE(process_map->Contains( - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()->GetID())); - EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 2)->GetWebUI()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()->GetID())); + EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(2)->GetWebUI()); // We should have opened 2 new extension tabs. Including the original blank // tab, we now have 3 tabs. The two app tabs should not be in the same // process, since they do not have the background permission. (Thus, we // want to separate them to improve responsiveness.) - ASSERT_EQ(3, browser()->tab_count()); - WebContents* tab1 = chrome::GetWebContentsAt(browser(), 1); - WebContents* tab2 = chrome::GetWebContentsAt(browser(), 2); + ASSERT_EQ(3, browser()->tab_strip_model()->count()); + WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(1); + WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(2); EXPECT_NE(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost()); // Opening tabs with window.open should keep the page in the opener's @@ -154,16 +156,18 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) { browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); EXPECT_TRUE(process_map->Contains( - chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost()->GetID())); - EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 1)->GetWebUI()); + browser()->tab_strip_model()->GetWebContentsAt(1)-> + GetRenderProcessHost()->GetID())); + EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI()); LOG(INFO) << "Nav 1."; ui_test_utils::NavigateToURLWithDisposition( browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); EXPECT_TRUE(process_map->Contains( - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()->GetID())); - EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 2)->GetWebUI()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()->GetID())); + EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(2)->GetWebUI()); LOG(INFO) << "Nav 2."; content::WindowedNotificationObserver tab_added_observer( @@ -175,20 +179,23 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) { ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); LOG(INFO) << "Nav 3."; EXPECT_FALSE(process_map->Contains( - chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost()->GetID())); - EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 3)->GetWebUI()); + browser()->tab_strip_model()->GetWebContentsAt(3)-> + GetRenderProcessHost()->GetID())); + EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(3)->GetWebUI()); // We should have opened 3 new extension tabs. Including the original blank // tab, we now have 4 tabs. Because the app_process app has the background // permission, all of its instances are in the same process. Thus two tabs // should be part of the extension app and grouped in the same process. - ASSERT_EQ(4, browser()->tab_count()); - WebContents* tab = chrome::GetWebContentsAt(browser(), 1); + ASSERT_EQ(4, browser()->tab_strip_model()->count()); + WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); EXPECT_EQ(tab->GetRenderProcessHost(), - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()); EXPECT_NE(tab->GetRenderProcessHost(), - chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost()); + browser()->tab_strip_model()->GetWebContentsAt(3)-> + GetRenderProcessHost()); // Now let's do the same using window.open. The same should happen. ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); @@ -208,24 +215,30 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) { // extent. They should switch processes. const GURL& app_url(base_url.Resolve("path1/empty.html")); const GURL& non_app_url(base_url.Resolve("path3/empty.html")); - NavigateInRenderer(chrome::GetWebContentsAt(browser(), 2), non_app_url); + NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(2), + non_app_url); LOG(INFO) << "NavigateTabHelper 1."; - NavigateInRenderer(chrome::GetWebContentsAt(browser(), 3), app_url); + NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(3), + app_url); LOG(INFO) << "NavigateTabHelper 2."; EXPECT_NE(tab->GetRenderProcessHost(), - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()); EXPECT_EQ(tab->GetRenderProcessHost(), - chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost()); + browser()->tab_strip_model()->GetWebContentsAt(3)-> + GetRenderProcessHost()); // If one of the popup tabs navigates back to the app, window.opener should // be valid. - NavigateInRenderer(chrome::GetWebContentsAt(browser(), 6), app_url); + NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(6), + app_url); LOG(INFO) << "NavigateTabHelper 3."; EXPECT_EQ(tab->GetRenderProcessHost(), - chrome::GetWebContentsAt(browser(), 6)->GetRenderProcessHost()); + browser()->tab_strip_model()->GetWebContentsAt(6)-> + GetRenderProcessHost()); bool windowOpenerValid = false; ASSERT_TRUE(content::ExecuteScriptAndExtractBool( - chrome::GetWebContentsAt(browser(), 6), + browser()->tab_strip_model()->GetWebContentsAt(6), "window.domAutomationController.send(window.opener != null)", &windowOpenerValid)); ASSERT_TRUE(windowOpenerValid); @@ -285,8 +298,9 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) { browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); EXPECT_FALSE(process_map->Contains( - chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost()->GetID())); - EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 1)->GetWebUI()); + browser()->tab_strip_model()->GetWebContentsAt(1)-> + GetRenderProcessHost()->GetID())); + EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI()); content::WindowedNotificationObserver tab_added_observer( chrome::NOTIFICATION_TAB_ADDED, @@ -295,16 +309,18 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) { tab_added_observer.Wait(); ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); EXPECT_FALSE(process_map->Contains( - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()->GetID())); - EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 2)->GetWebUI()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()->GetID())); + EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(2)->GetWebUI()); // We should have opened 2 new bookmark app tabs. Including the original blank // tab, we now have 3 tabs. Because normal pages use the // process-per-site-instance model, each should be in its own process. - ASSERT_EQ(3, browser()->tab_count()); - WebContents* tab = chrome::GetWebContentsAt(browser(), 1); + ASSERT_EQ(3, browser()->tab_strip_model()->count()); + WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); EXPECT_NE(tab->GetRenderProcessHost(), - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()); // Now let's do the same using window.open. The same should happen. ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); @@ -316,13 +332,17 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) { const GURL& app_url(base_url.Resolve("path1/empty.html")); const GURL& non_app_url(base_url.Resolve("path3/empty.html")); RenderViewHost* host2 = - chrome::GetWebContentsAt(browser(), 2)->GetRenderViewHost(); - NavigateInRenderer(chrome::GetWebContentsAt(browser(), 2), non_app_url); + browser()->tab_strip_model()->GetWebContentsAt(2)->GetRenderViewHost(); + NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(2), + non_app_url); EXPECT_EQ(host2->GetProcess(), - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()); - NavigateInRenderer(chrome::GetWebContentsAt(browser(), 2), app_url); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()); + NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(2), + app_url); EXPECT_EQ(host2->GetProcess(), - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()); } // Tests that app process switching works properly in the following scenario: @@ -358,12 +378,14 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) { // 3 tabs, including the initial about:blank. The last 2 should be the same // process. - ASSERT_EQ(3, browser()->tab_count()); + ASSERT_EQ(3, browser()->tab_strip_model()->count()); EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", - chrome::GetWebContentsAt(browser(), 2)->GetController(). - GetLastCommittedEntry()->GetURL().path()); - EXPECT_EQ(chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost(), - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetController().GetLastCommittedEntry()->GetURL().path()); + EXPECT_EQ(browser()->tab_strip_model()->GetWebContentsAt(1)-> + GetRenderProcessHost(), + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()); } // Ensure that reloading a URL after installing or uninstalling it as an app @@ -388,7 +410,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadIntoAppProcess) { // Load an app URL before loading the app. ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); - WebContents* contents = chrome::GetWebContentsAt(browser(), 0); + WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); EXPECT_FALSE(process_map->Contains( contents->GetRenderProcessHost()->GetID())); @@ -411,7 +433,8 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadIntoAppProcess) { content::WindowedNotificationObserver reload_observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &chrome::GetActiveWebContents(browser())->GetController())); + &browser()->tab_strip_model()->GetActiveWebContents()-> + GetController())); chrome::Reload(browser(), CURRENT_TAB); reload_observer.Wait(); EXPECT_TRUE(process_map->Contains( @@ -422,7 +445,8 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadIntoAppProcess) { content::WindowedNotificationObserver reload_observer2( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &chrome::GetActiveWebContents(browser())->GetController())); + &browser()->tab_strip_model()->GetActiveWebContents()-> + GetController())); chrome::Reload(browser(), CURRENT_TAB); reload_observer2.Wait(); EXPECT_FALSE(process_map->Contains( @@ -433,7 +457,8 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadIntoAppProcess) { content::WindowedNotificationObserver js_reload_observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &chrome::GetActiveWebContents(browser())->GetController())); + &browser()->tab_strip_model()->GetActiveWebContents()-> + GetController())); ASSERT_TRUE(content::ExecuteScript(contents, "location.reload();")); js_reload_observer.Wait(); EXPECT_TRUE(process_map->Contains( @@ -444,7 +469,8 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadIntoAppProcess) { content::WindowedNotificationObserver js_reload_observer2( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &chrome::GetActiveWebContents(browser())->GetController())); + &browser()->tab_strip_model()->GetActiveWebContents()-> + GetController())); ASSERT_TRUE(content::ExecuteScript(contents, "location = location;")); js_reload_observer2.Wait(); EXPECT_FALSE(process_map->Contains( @@ -476,7 +502,8 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/container.html")); EXPECT_FALSE(process_map->Contains( - chrome::GetWebContentsAt(browser(), 0)->GetRenderProcessHost()->GetID())); + browser()->tab_strip_model()->GetWebContentsAt(0)-> + GetRenderProcessHost()->GetID())); popup_observer.Wait(); // Popup window should be in the app's process. @@ -510,7 +537,7 @@ IN_PROC_BROWSER_TEST_F(BlockedAppApiTest, MAYBE_OpenAppFromIframe) { blocker_observer.Wait(); - WebContents* tab = chrome::GetActiveWebContents(browser()); + WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); BlockedContentTabHelper* blocked_content_tab_helper = BlockedContentTabHelper::FromWebContents(tab); std::vector<WebContents*> blocked_contents; @@ -554,7 +581,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromExtension) { // App has loaded, and chrome.app.isInstalled should be true. bool is_installed = false; ASSERT_TRUE(content::ExecuteScriptAndExtractBool( - chrome::GetActiveWebContents(browser()), + browser()->tab_strip_model()->GetActiveWebContents(), "window.domAutomationController.send(chrome.app.isInstalled)", &is_installed)); ASSERT_TRUE(is_installed); @@ -587,7 +614,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/container.html")); content::RenderProcessHost* process = - chrome::GetWebContentsAt(browser(), 0)->GetRenderProcessHost(); + browser()->tab_strip_model()->GetWebContentsAt(0)->GetRenderProcessHost(); EXPECT_TRUE(process_map->Contains(process->GetID())); // Wait for popup window to appear. @@ -618,7 +645,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadAppAfterCrash) { // Load the app, chrome.app.isInstalled should be true. ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); - WebContents* contents = chrome::GetWebContentsAt(browser(), 0); + WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); EXPECT_TRUE(process_map->Contains( contents->GetRenderProcessHost()->GetID())); bool is_installed = false; @@ -629,11 +656,12 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadAppAfterCrash) { ASSERT_TRUE(is_installed); // Crash the tab and reload it, chrome.app.isInstalled should still be true. - content::CrashTab(chrome::GetActiveWebContents(browser())); + content::CrashTab(browser()->tab_strip_model()->GetActiveWebContents()); content::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &chrome::GetActiveWebContents(browser())->GetController())); + &browser()->tab_strip_model()->GetActiveWebContents()-> + GetController())); chrome::Reload(browser(), CURRENT_TAB); observer.Wait(); ASSERT_TRUE(content::ExecuteScriptAndExtractBool( diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index bb916bf..af79818 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -14,7 +14,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" -#include "chrome/browser/ui/browser_tabstrip.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" #include "content/public/browser/web_contents.h" @@ -26,7 +26,8 @@ class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { // Checks that a theme info bar is currently visible and issues an undo to // revert to the previous theme. void VerifyThemeInfoBarAndUndoInstall() { - WebContents* web_contents = chrome::GetActiveWebContents(browser()); + WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents); InfoBarService* infobar_service = InfoBarService::FromWebContents(web_contents); @@ -122,14 +123,15 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, AppInstallConfirmation) { - int num_tabs = browser()->tab_count(); + int num_tabs = browser()->tab_strip_model()->count(); FilePath app_dir = test_data_dir_.AppendASCII("app"); ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, browser())); if (NewTabUI::ShouldShowApps()) { - EXPECT_EQ(num_tabs + 1, browser()->tab_count()); - WebContents* web_contents = chrome::GetActiveWebContents(browser()); + EXPECT_EQ(num_tabs + 1, browser()->tab_strip_model()->count()); + WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents); EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), "chrome://newtab/", false)); @@ -142,17 +144,19 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, AppInstallConfirmation_Incognito) { Browser* incognito_browser = CreateIncognitoBrowser(); - int num_incognito_tabs = incognito_browser->tab_count(); - int num_normal_tabs = browser()->tab_count(); + int num_incognito_tabs = incognito_browser->tab_strip_model()->count(); + int num_normal_tabs = browser()->tab_strip_model()->count(); FilePath app_dir = test_data_dir_.AppendASCII("app"); ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, incognito_browser)); - EXPECT_EQ(num_incognito_tabs, incognito_browser->tab_count()); + EXPECT_EQ(num_incognito_tabs, + incognito_browser->tab_strip_model()->count()); if (NewTabUI::ShouldShowApps()) { - EXPECT_EQ(num_normal_tabs + 1, browser()->tab_count()); - WebContents* web_contents = chrome::GetActiveWebContents(browser()); + EXPECT_EQ(num_normal_tabs + 1, browser()->tab_strip_model()->count()); + WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents); EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), "chrome://newtab/", false)); diff --git a/chrome/browser/extensions/isolated_app_browsertest.cc b/chrome/browser/extensions/isolated_app_browsertest.cc index c882a85..ef70a88 100644 --- a/chrome/browser/extensions/isolated_app_browsertest.cc +++ b/chrome/browser/extensions/isolated_app_browsertest.cc @@ -11,7 +11,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/browser_tabstrip.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/ui_test_utils.h" @@ -114,14 +114,15 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossProcessClientRedirect) { browser(), base_url.Resolve("non_app/main.html"), NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - WebContents* tab0 = chrome::GetWebContentsAt(browser(), 1); + WebContents* tab0 = browser()->tab_strip_model()->GetWebContentsAt(1); // Using JavaScript to navigate to app2 page, // after the non_app page has finished loading. content::WindowedNotificationObserver observer1( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &chrome::GetActiveWebContents(browser())->GetController())); + &browser()->tab_strip_model()->GetActiveWebContents()-> + GetController())); std::string script = base::StringPrintf( "document.location.href=\"%s\";", base_url.Resolve("app2/main.html").spec().c_str()); @@ -165,12 +166,12 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) { browser(), base_url.Resolve("non_app/main.html"), NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - ASSERT_EQ(3, browser()->tab_count()); + ASSERT_EQ(3, browser()->tab_strip_model()->count()); // Ensure first two tabs have installed apps. - WebContents* tab0 = chrome::GetWebContentsAt(browser(), 0); - WebContents* tab1 = chrome::GetWebContentsAt(browser(), 1); - WebContents* tab2 = chrome::GetWebContentsAt(browser(), 2); + WebContents* tab0 = browser()->tab_strip_model()->GetWebContentsAt(0); + WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(1); + WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(2); ASSERT_TRUE(GetInstalledApp(tab0)); ASSERT_TRUE(GetInstalledApp(tab1)); ASSERT_TRUE(!GetInstalledApp(tab2)); @@ -227,7 +228,8 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) { content::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &chrome::GetActiveWebContents(browser())->GetController())); + &browser()->tab_strip_model()->GetActiveWebContents()-> + GetController())); chrome::Reload(browser(), CURRENT_TAB); observer.Wait(); EXPECT_TRUE(HasCookie(tab0, "app1=3")); @@ -260,24 +262,33 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_NoCookieIsolationWithoutApp) { browser(), base_url.Resolve("non_app/main.html"), NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - ASSERT_EQ(3, browser()->tab_count()); + ASSERT_EQ(3, browser()->tab_strip_model()->count()); // Check that tabs see each other's cookies. - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 0), "app2=4")); - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 0), "normalPage=5")); - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 0), "nonAppFrame=6")); - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 1), "app1=3")); - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 1), "normalPage=5")); - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 1), "nonAppFrame=6")); - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 2), "app1=3")); - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 2), "app2=4")); - EXPECT_TRUE(HasCookie(chrome::GetWebContentsAt(browser(), 2), "nonAppFrame=6")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(0), + "app2=4")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(0), + "normalPage=5")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(0), + "nonAppFrame=6")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(1), + "app1=3")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(1), + "normalPage=5")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(1), + "nonAppFrame=6")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(2), + "app1=3")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(2), + "app2=4")); + EXPECT_TRUE(HasCookie(browser()->tab_strip_model()->GetWebContentsAt(2), + "nonAppFrame=6")); // Check that all tabs share the same localStorage if they have the same // origin. - WebContents* app1_wc = chrome::GetWebContentsAt(browser(), 0); - WebContents* app2_wc = chrome::GetWebContentsAt(browser(), 1); - WebContents* non_app_wc = chrome::GetWebContentsAt(browser(), 2); + WebContents* app1_wc = browser()->tab_strip_model()->GetWebContentsAt(0); + WebContents* app2_wc = browser()->tab_strip_model()->GetWebContentsAt(1); + WebContents* non_app_wc = browser()->tab_strip_model()->GetWebContentsAt(2); ASSERT_TRUE(ExecuteScript( app1_wc, "window.localStorage.setItem('testdata', 'ls_app1');")); ASSERT_TRUE(ExecuteScript( @@ -321,12 +332,12 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, SubresourceCookieIsolation) { ui_test_utils::NavigateToURLWithDisposition( browser(), root_url.Resolve("set-cookie?nonApp=1"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - WebContents* tab0 = chrome::GetWebContentsAt(browser(), 0); + WebContents* tab0 = browser()->tab_strip_model()->GetWebContentsAt(0); ASSERT_FALSE(GetInstalledApp(tab0)); ui_test_utils::NavigateToURLWithDisposition( browser(), base_url.Resolve("app1/main.html"), NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - WebContents* tab1 = chrome::GetWebContentsAt(browser(), 1); + WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(1); ASSERT_TRUE(GetInstalledApp(tab1)); // Check that each tab sees its own cookie. @@ -343,7 +354,8 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, SubresourceCookieIsolation) { // We must wait for the onload event, to allow the subresources to finish. content::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, - content::Source<WebContents>(chrome::GetActiveWebContents(browser()))); + content::Source<WebContents>( + browser()->tab_strip_model()->GetActiveWebContents())); ui_test_utils::NavigateToURLWithDisposition( browser(), base_url.Resolve("app1/app_subresources.html"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); @@ -357,7 +369,7 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, SubresourceCookieIsolation) { ui_test_utils::NavigateToURLWithDisposition( browser(), root_url, NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - WebContents* tab2 = chrome::GetWebContentsAt(browser(), 2); + WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(2); EXPECT_FALSE(HasCookie(tab2, "nonAppMedia=1")); EXPECT_FALSE(HasCookie(tab2, "app1Media=1")); EXPECT_FALSE(HasCookie(tab2, "nonAppImage=1")); @@ -389,33 +401,37 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, IsolatedAppProcessModel) { browser(), base_url.Resolve("app1/main.html"), NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); // For the third tab, use window.open to keep it in process with an opener. - OpenWindow(chrome::GetWebContentsAt(browser(), 0), + OpenWindow(browser()->tab_strip_model()->GetWebContentsAt(0), base_url.Resolve("app1/main.html"), true, NULL); // In a fourth tab, use window.open to a non-app URL. It should open in a // separate process, even though this would trigger the OAuth workaround // for hosted apps (from http://crbug.com/59285). - OpenWindow(chrome::GetWebContentsAt(browser(), 0), + OpenWindow(browser()->tab_strip_model()->GetWebContentsAt(0), base_url.Resolve("non_app/main.html"), false, NULL); // We should now have four tabs, the first and third sharing a process. // The second one is an independent instance in a separate process. - ASSERT_EQ(4, browser()->tab_count()); - int process_id_0 = - chrome::GetWebContentsAt(browser(), 0)->GetRenderProcessHost()->GetID(); - int process_id_1 = - chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost()->GetID(); + ASSERT_EQ(4, browser()->tab_strip_model()->count()); + int process_id_0 = browser()->tab_strip_model()->GetWebContentsAt(0)-> + GetRenderProcessHost()->GetID(); + int process_id_1 = browser()->tab_strip_model()->GetWebContentsAt(1)-> + GetRenderProcessHost()->GetID(); EXPECT_NE(process_id_0, process_id_1); EXPECT_EQ(process_id_0, - chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()->GetID()); + browser()->tab_strip_model()->GetWebContentsAt(2)-> + GetRenderProcessHost()->GetID()); EXPECT_NE(process_id_0, - chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost()->GetID()); + browser()->tab_strip_model()->GetWebContentsAt(3)-> + GetRenderProcessHost()->GetID()); // Navigating the second tab out of the app should cause a process swap. const GURL& non_app_url(base_url.Resolve("non_app/main.html")); - NavigateInRenderer(chrome::GetWebContentsAt(browser(), 1), non_app_url); + NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(1), + non_app_url); EXPECT_NE(process_id_1, - chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost()->GetID()); + browser()->tab_strip_model()->GetWebContentsAt(1)-> + GetRenderProcessHost()->GetID()); } // This test no longer passes, since we don't properly isolate sessionStorage @@ -444,21 +460,21 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_SessionStorage) { browser(), base_url.Resolve("app1/main.html"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_TRUE(ExecuteScript( - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), "window.sessionStorage.setItem('testdata', 'ss_app1');")); ui_test_utils::NavigateToURLWithDisposition( browser(), base_url.Resolve("app2/main.html"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_TRUE(ExecuteScript( - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), "window.sessionStorage.setItem('testdata', 'ss_app2');")); ui_test_utils::NavigateToURLWithDisposition( browser(), base_url.Resolve("non_app/main.html"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_TRUE(ExecuteScript( - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), "window.sessionStorage.setItem('testdata', 'ss_normal');")); // Now, ensure that the sessionStorage is correctly partitioned, and persists @@ -471,7 +487,7 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_SessionStorage) { browser(), base_url.Resolve("app1/main.html"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_TRUE(ExecuteScriptAndExtractString( - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), kRetrieveSessionStorage.c_str(), &result)); EXPECT_EQ("ss_app1", result); @@ -479,7 +495,7 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_SessionStorage) { browser(), base_url.Resolve("app2/main.html"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_TRUE(ExecuteScriptAndExtractString( - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), kRetrieveSessionStorage.c_str(), &result)); EXPECT_EQ("ss_app2", result); @@ -487,7 +503,7 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_SessionStorage) { browser(), base_url.Resolve("non_app/main.html"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_TRUE(ExecuteScriptAndExtractString( - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), kRetrieveSessionStorage.c_str(), &result)); EXPECT_EQ("ss_normal", result); } diff --git a/chrome/browser/extensions/lazy_background_page_apitest.cc b/chrome/browser/extensions/lazy_background_page_apitest.cc index a64f763..a74c184 100644 --- a/chrome/browser/extensions/lazy_background_page_apitest.cc +++ b/chrome/browser/extensions/lazy_background_page_apitest.cc @@ -17,7 +17,6 @@ #include "chrome/browser/extensions/lazy_background_page_test_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/omnibox/location_bar.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -104,7 +103,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BrowserActionCreateTab) { ExtensionProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); - int num_tabs_before = browser()->tab_count(); + int num_tabs_before = browser()->tab_strip_model()->count(); // Observe background page being created and closed after // the browser action is clicked. @@ -114,7 +113,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BrowserActionCreateTab) { // Background page created a new tab before it closed. EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); - EXPECT_EQ(num_tabs_before + 1, browser()->tab_count()); + EXPECT_EQ(num_tabs_before + 1, browser()->tab_strip_model()->count()); EXPECT_EQ(std::string(chrome::kChromeUIExtensionsURL), browser()->tab_strip_model()->GetActiveWebContents()-> GetURL().spec()); @@ -128,7 +127,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, ExtensionProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); - int num_tabs_before = browser()->tab_count(); + int num_tabs_before = browser()->tab_strip_model()->count(); // Observe background page being created and closed after // the browser action is clicked. @@ -138,7 +137,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, // Background page is closed after creating a new tab. EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); - EXPECT_EQ(num_tabs_before + 1, browser()->tab_count()); + EXPECT_EQ(num_tabs_before + 1, browser()->tab_strip_model()->count()); } IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BroadcastEvent) { @@ -371,7 +370,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Messaging) { ExtensionProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); // Navigate to a page that opens a message channel to the background page. ResultCatcher catcher; diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc index 718d2bd..36d5a91 100644 --- a/chrome/browser/extensions/platform_app_browsertest.cc +++ b/chrome/browser/extensions/platform_app_browsertest.cc @@ -23,10 +23,10 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/tab_contents/render_view_context_menu.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/browser/ui/extensions/native_app_window.h" #include "chrome/browser/ui/extensions/shell_window.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/url_constants.h" @@ -177,7 +177,8 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchReply) { // Navigate to a boring page: we don't care what it is, but we require some // source WebContents to launch the Web Intent "from". ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); - WebContents* web_contents = chrome::GetActiveWebContents(browser()); + WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents); extensions::LaunchPlatformAppWithWebIntent( @@ -421,7 +422,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Isolation) { std::string cookie_value; automation_util::GetCookies( set_cookie_url, - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), &cookie_size, &cookie_value); ASSERT_EQ("testCookie=1", cookie_value); @@ -577,7 +578,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { content::Source<content::WebContentsDelegate>(browser())); LoadAndLaunchPlatformApp("open_link"); observer.Wait(); - ASSERT_EQ(2, browser()->tab_count()); + ASSERT_EQ(2, browser()->tab_strip_model()->count()); } IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc index 1c8a406..83eb7c1 100644 --- a/chrome/browser/extensions/window_open_apitest.cc +++ b/chrome/browser/extensions/window_open_apitest.cc @@ -15,6 +15,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/panels/panel_manager.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/test/base/ui_test_utils.h" @@ -55,7 +56,7 @@ void WaitForTabsAndPopups(Browser* browser, base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime; while (base::TimeTicks::Now() < end_time) { if (chrome::GetBrowserCount(browser->profile()) == num_browsers && - browser->tab_count() == num_tabs && + browser->tab_strip_model()->count() == num_tabs && PanelManager::GetInstance()->num_panels() == num_panels) break; @@ -63,7 +64,7 @@ void WaitForTabsAndPopups(Browser* browser, } EXPECT_EQ(num_browsers, chrome::GetBrowserCount(browser->profile())); - EXPECT_EQ(num_tabs, browser->tab_count()); + EXPECT_EQ(num_tabs, browser->tab_strip_model()->count()); EXPECT_EQ(num_panels, PanelManager::GetInstance()->num_panels()); int num_popups_seen = 0; @@ -387,8 +388,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { last_loaded_extension_id_ + "/test.html"); ui_test_utils::NavigateToURL(browser(), start_url); WebContents* newtab = NULL; - ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), - start_url.Resolve("newtab.html"), true, &newtab)); + ASSERT_NO_FATAL_FAILURE( + OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), + start_url.Resolve("newtab.html"), true, &newtab)); bool result = false; ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", @@ -405,7 +407,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) { GURL start_url(std::string("chrome-extension://") + last_loaded_extension_id_ + "/test.html"); ui_test_utils::NavigateToURL(browser(), start_url); - ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), + ASSERT_NO_FATAL_FAILURE( + OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), GURL("chrome-extension://thisissurelynotavalidextensionid/newtab.html"), false, NULL)); @@ -422,7 +425,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) { ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); WebContents* newtab = NULL; - ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), + ASSERT_NO_FATAL_FAILURE( + OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + "/newtab.html"), false, &newtab)); diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc index dd17b0f..9499adf 100644 --- a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc +++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc @@ -20,6 +20,7 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -80,7 +81,7 @@ void GoBackToSafety(content::WebContents* web_contents) { if (BrowserList::size() == 1) { Browser* browser = *(BrowserList::begin()); DCHECK(browser == chrome::FindBrowserWithWebContents(web_contents)); - if (browser->tab_count() == 1) + if (browser->tab_strip_model()->count() == 1) chrome::NewEmptyWindow(browser->profile()); } diff --git a/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc b/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc index 251da63..8e57fba 100644 --- a/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc +++ b/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc @@ -54,7 +54,7 @@ class TabDestroyedObserver : public content::WebContentsObserver { IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, NavigateFromInitiatorTab) { // Lets start with one tab. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); // Create a reference to initiator tab contents. WebContents* initiator_tab = @@ -73,7 +73,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, tab_controller->GetOrCreatePreviewTab(initiator_tab); // New print preview tab is created. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); ASSERT_TRUE(preview_tab); ASSERT_NE(initiator_tab, preview_tab); TabDestroyedObserver observer(preview_tab); @@ -90,7 +90,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, tab_controller->GetOrCreatePreviewTab(initiator_tab); // New preview tab is created. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); EXPECT_TRUE(new_preview_tab); } @@ -99,7 +99,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, ReloadInitiatorTab) { // Lets start with one tab. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); // Create a reference to initiator tab contents. WebContents* initiator_tab = @@ -118,7 +118,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, tab_controller->GetOrCreatePreviewTab(initiator_tab); // New print preview tab is created. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); ASSERT_TRUE(preview_tab); ASSERT_NE(initiator_tab, preview_tab); TabDestroyedObserver tab_destroyed_observer(preview_tab); @@ -137,6 +137,6 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, WebContents* new_preview_tab = tab_controller->GetOrCreatePreviewTab(initiator_tab); - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); EXPECT_TRUE(new_preview_tab); } diff --git a/chrome/browser/printing/print_preview_dialog_controller_unittest.cc b/chrome/browser/printing/print_preview_dialog_controller_unittest.cc index 2f047706..f92c6d0 100644 --- a/chrome/browser/printing/print_preview_dialog_controller_unittest.cc +++ b/chrome/browser/printing/print_preview_dialog_controller_unittest.cc @@ -7,7 +7,6 @@ #include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" #include "content/public/browser/navigation_details.h" @@ -35,9 +34,9 @@ typedef PrintPreviewTest PrintPreviewDialogControllerUnitTest; TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_GetOrCreatePreviewTab) { // Lets start with one window with one tab. EXPECT_EQ(1u, BrowserList::size()); - EXPECT_EQ(0, browser()->tab_count()); + EXPECT_EQ(0, browser()->tab_strip_model()->count()); chrome::NewTab(browser()); - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); // Create a reference to initiator tab contents. WebContents* initiator_tab = @@ -53,7 +52,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_GetOrCreatePreviewTab) { tab_controller->GetOrCreatePreviewTab(initiator_tab); // New print preview tab is created. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); EXPECT_NE(initiator_tab, preview_tab); // Get the print preview tab for initiator tab. @@ -61,7 +60,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_GetOrCreatePreviewTab) { tab_controller->GetOrCreatePreviewTab(initiator_tab); // Preview tab already exists. Tab count remains the same. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); // 1:1 relationship between initiator and preview tab. EXPECT_EQ(new_preview_tab, preview_tab); @@ -73,18 +72,19 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_GetOrCreatePreviewTab) { TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewTabs) { // Lets start with one window and two tabs. EXPECT_EQ(1u, BrowserList::size()); - EXPECT_EQ(0, browser()->tab_count()); + TabStripModel* model = browser()->tab_strip_model(); + ASSERT_TRUE(model); + + EXPECT_EQ(0, model->count()); chrome::NewTab(browser()); - WebContents* web_contents_1 = - browser()->tab_strip_model()->GetActiveWebContents(); + WebContents* web_contents_1 = model->GetActiveWebContents(); ASSERT_TRUE(web_contents_1); chrome::NewTab(browser()); - WebContents* web_contents_2 = - browser()->tab_strip_model()->GetActiveWebContents(); + WebContents* web_contents_2 = model->GetActiveWebContents(); ASSERT_TRUE(web_contents_2); - EXPECT_EQ(2, browser()->tab_count()); + EXPECT_EQ(2, model->count()); printing::PrintPreviewDialogController* tab_controller = printing::PrintPreviewDialogController::GetInstance(); @@ -97,7 +97,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewTabs) { tab_controller->GetOrCreatePreviewTab(web_contents_1); EXPECT_NE(web_contents_1, preview_tab_1); - EXPECT_EQ(2, browser()->tab_count()); + EXPECT_EQ(2, model->count()); // Create preview tab for |tab_contents_2| printing::PrintViewManager::FromWebContents(web_contents_2)-> @@ -108,10 +108,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewTabs) { EXPECT_NE(web_contents_2, preview_tab_2); // 2 initiator tab and 2 preview tabs exist in the same browser. // The preview tabs are constrained in their respective initiator tabs. - EXPECT_EQ(2, browser()->tab_count()); - - TabStripModel* model = browser()->tab_strip_model(); - ASSERT_TRUE(model); + EXPECT_EQ(2, model->count()); int tab_1_index = model->GetIndexOfWebContents(web_contents_1); int tab_2_index = model->GetIndexOfWebContents(web_contents_2); @@ -120,21 +117,21 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewTabs) { EXPECT_EQ(-1, preview_tab_1_index); EXPECT_EQ(-1, preview_tab_2_index); - EXPECT_EQ(tab_2_index, browser()->active_index()); + EXPECT_EQ(tab_2_index, model->active_index()); // When we get the preview tab for |tab_contents_1|, // |preview_tab_1| is activated and focused. tab_controller->GetOrCreatePreviewTab(web_contents_1); - EXPECT_EQ(tab_1_index, browser()->active_index()); + EXPECT_EQ(tab_1_index, model->active_index()); } // Clear the initiator tab details associated with preview tab. TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_ClearInitiatorTabDetails) { // Lets start with one window with one tab. EXPECT_EQ(1u, BrowserList::size()); - EXPECT_EQ(0, browser()->tab_count()); + EXPECT_EQ(0, browser()->tab_strip_model()->count()); chrome::NewTab(browser()); - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); // Create a reference to initiator tab contents. WebContents* initiator_tab = @@ -150,7 +147,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_ClearInitiatorTabDetails) { tab_controller->GetOrCreatePreviewTab(initiator_tab); // New print preview tab is created. Current focus is on preview tab. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); EXPECT_NE(initiator_tab, preview_tab); // Clear the initiator tab details associated with the preview tab. @@ -161,6 +158,6 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_ClearInitiatorTabDetails) { tab_controller->GetOrCreatePreviewTab(initiator_tab); // New preview tab is created. - EXPECT_EQ(1, browser()->tab_count()); + EXPECT_EQ(1, browser()->tab_strip_model()->count()); EXPECT_NE(new_preview_tab, preview_tab); } diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc index 7ed2efd..deb8ff8 100644 --- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc +++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc @@ -6,8 +6,8 @@ #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/singleton_tabs.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" @@ -71,7 +71,7 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest { // handle. base::ProcessHandle ShowSingletonTab(const GURL& page) { chrome::ShowSingletonTab(browser(), page); - WebContents* wc = chrome::GetActiveWebContents(browser()); + WebContents* wc = browser()->tab_strip_model()->GetActiveWebContents(); CHECK(wc->GetURL() == page); // Ensure that the backgrounding / foregrounding gets a chance to run. @@ -99,8 +99,8 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest { // Change the first tab to be the new tab page (TYPE_WEBUI). GURL newtab(chrome::kChromeUINewTabURL); ui_test_utils::NavigateToURL(browser(), newtab); - EXPECT_EQ(tab_count, browser()->tab_count()); - tab1 = chrome::GetWebContentsAt(browser(), tab_count - 1); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); + tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); rph1 = tab1->GetRenderProcessHost(); EXPECT_EQ(tab1->GetURL(), newtab); EXPECT_EQ(host_count, RenderProcessHostCount()); @@ -108,12 +108,12 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest { // Create a new TYPE_TABBED tab. It should be in its own process. GURL page1("data:text/html,hello world1"); chrome::ShowSingletonTab(browser(), page1); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - tab1 = chrome::GetWebContentsAt(browser(), tab_count - 1); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); + tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); rph2 = tab1->GetRenderProcessHost(); EXPECT_EQ(tab1->GetURL(), page1); EXPECT_EQ(host_count, RenderProcessHostCount()); @@ -122,11 +122,11 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest { // Create another TYPE_TABBED tab. It should share the previous process. GURL page2("data:text/html,hello world2"); chrome::ShowSingletonTab(browser(), page2); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - tab2 = chrome::GetWebContentsAt(browser(), tab_count - 1); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); + tab2 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); EXPECT_EQ(tab2->GetURL(), page2); EXPECT_EQ(host_count, RenderProcessHostCount()); EXPECT_EQ(tab2->GetRenderProcessHost(), rph2); @@ -137,11 +137,11 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest { // normal renderers. GURL history(chrome::kChromeUIHistoryURL); chrome::ShowSingletonTab(browser(), history); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - tab2 = chrome::GetWebContentsAt(browser(), tab_count - 1); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); + tab2 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); EXPECT_EQ(tab2->GetURL(), GURL(history)); EXPECT_EQ(host_count, RenderProcessHostCount()); EXPECT_EQ(tab2->GetRenderProcessHost(), rph1); @@ -150,12 +150,12 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest { // (the bookmark manager is implemented as an extension) GURL bookmarks(chrome::kChromeUIBookmarksURL); chrome::ShowSingletonTab(browser(), bookmarks); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - tab1 = chrome::GetWebContentsAt(browser(), tab_count - 1); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); + tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); rph3 = tab1->GetRenderProcessHost(); EXPECT_EQ(tab1->GetURL(), bookmarks); EXPECT_EQ(host_count, RenderProcessHostCount()); @@ -186,42 +186,42 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) { // Change the first tab to be the new tab page (TYPE_WEBUI). GURL newtab(chrome::kChromeUINewTabURL); ui_test_utils::NavigateToURL(browser(), newtab); - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); // Create a new TYPE_TABBED tab. It should be in its own process. GURL page1("data:text/html,hello world1"); chrome::ShowSingletonTab(browser(), page1); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); // Create another TYPE_TABBED tab. It should share the previous process. GURL page2("data:text/html,hello world2"); chrome::ShowSingletonTab(browser(), page2); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); // Create another new tab. It should share the process with the other WebUI. chrome::NewTab(browser()); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); // Create another new tab. It should share the process with the other WebUI. chrome::NewTab(browser()); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); } @@ -286,17 +286,17 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, GURL page1("data:text/html,hello world1"); chrome::ShowSingletonTab(browser(), page1); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); // DevTools start in docked mode (no new tab), in a separate process. chrome::ToggleDevToolsWindow(browser(), DEVTOOLS_TOGGLE_ACTION_INSPECT); host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); RenderViewHost* devtools = FindFirstDevToolsHost(); @@ -306,7 +306,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, DevToolsWindow::ToggleDevToolsWindow( devtools, true, DEVTOOLS_TOGGLE_ACTION_INSPECT); host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); } @@ -319,17 +319,17 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, GURL page1("data:text/html,hello world1"); chrome::ShowSingletonTab(browser(), page1); - if (browser()->tab_count() == tab_count) + if (browser()->tab_strip_model()->count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); // DevTools start in docked mode (no new tab), in a separate process. chrome::ToggleDevToolsWindow(browser(), DEVTOOLS_TOGGLE_ACTION_INSPECT); host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); RenderViewHost* devtools = FindFirstDevToolsHost(); @@ -339,6 +339,6 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, DevToolsWindow::ToggleDevToolsWindow( devtools, true, DEVTOOLS_TOGGLE_ACTION_INSPECT); host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); } diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 70be198..bfa5619 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -280,7 +280,8 @@ void TabLoader::LoadNextTab() { content::WebContents* contents = tab->GetWebContents(); if (contents) { Browser* browser = chrome::FindBrowserWithWebContents(contents); - if (browser && chrome::GetActiveWebContents(browser) != contents) { + if (browser && + browser->tab_strip_model()->GetActiveWebContents() != contents) { // By default tabs are marked as visible. As only the active tab is // visible we need to explicitly tell non-active tabs they are hidden. // Without this call non-active tabs are not marked as backgrounded. @@ -570,7 +571,7 @@ class SessionRestoreImpl : public content::NotificationObserver { RestoreTabsToBrowser(*(*i), browser, selected_tab_index); ShowBrowser(browser, selected_tab_index); tab_loader_->TabIsLoading( - &chrome::GetActiveWebContents(browser)->GetController()); + &browser->tab_strip_model()->GetActiveWebContents()->GetController()); NotifySessionServiceOfRestoredTabs(browser, initial_tab_count); } @@ -607,7 +608,8 @@ class SessionRestoreImpl : public content::NotificationObserver { NULL, tab.user_agent_override); } else { - int tab_index = use_new_window ? 0 : browser->active_index() + 1; + int tab_index = + use_new_window ? 0 : browser->tab_strip_model()->active_index() + 1; WebContents* web_contents = chrome::AddRestoredTab( browser, tab.navigations, @@ -627,7 +629,8 @@ class SessionRestoreImpl : public content::NotificationObserver { browser->tab_strip_model()->ActivateTabAt(0, true); browser->window()->Show(); } - NotifySessionServiceOfRestoredTabs(browser, browser->tab_count()); + NotifySessionServiceOfRestoredTabs(browser, + browser->tab_strip_model()->count()); // Since FinishedTabCreation() is not called here, |this| will leak if we // are not in sychronous mode. @@ -837,8 +840,9 @@ class SessionRestoreImpl : public content::NotificationObserver { } if ((*i)->type == Browser::TYPE_TABBED) last_browser = browser; - WebContents* active_tab = chrome::GetActiveWebContents(browser); - int initial_tab_count = browser->tab_count(); + WebContents* active_tab = + browser->tab_strip_model()->GetActiveWebContents(); + int initial_tab_count = browser->tab_strip_model()->count(); int selected_tab_index = std::max( 0, std::min((*i)->selected_tab_index, @@ -852,12 +856,13 @@ class SessionRestoreImpl : public content::NotificationObserver { } if (clobber_existing_tab_ && i == windows->begin() && (*i)->type == Browser::TYPE_TABBED && active_tab && - browser == browser_ && browser->tab_count() > initial_tab_count) { + browser == browser_ && + browser->tab_strip_model()->count() > initial_tab_count) { chrome::CloseWebContents(browser, active_tab, true); selected_tab_to_activate = -1; } tab_loader_->TabIsLoading( - &chrome::GetActiveWebContents(browser)->GetController()); + &browser->tab_strip_model()->GetActiveWebContents()->GetController()); NotifySessionServiceOfRestoredTabs(browser, initial_tab_count); } @@ -924,7 +929,7 @@ class SessionRestoreImpl : public content::NotificationObserver { WebContents* selected_web_contents = NULL; // If browser already has tabs, we want to restore the new ones after the // existing ones. E.g., this happens in Win8 Metro where we merge windows. - int tab_index_offset = browser->tab_count(); + int tab_index_offset = browser->tab_strip_model()->count(); for (int i = 0; i < static_cast<int>(window.tabs.size()); ++i) { const SessionTab& tab = *(window.tabs[i]); // Don't schedule a load for the selected tab, as ShowBrowser() will do @@ -1020,7 +1025,7 @@ class SessionRestoreImpl : public content::NotificationObserver { void ShowBrowser(Browser* browser, int selected_tab_index) { DCHECK(browser); - DCHECK(browser->tab_count()); + DCHECK(browser->tab_strip_model()->count()); browser->tab_strip_model()->ActivateTabAt(selected_tab_index, true); if (browser_ == browser) @@ -1040,7 +1045,8 @@ class SessionRestoreImpl : public content::NotificationObserver { // TODO(jcampan): http://crbug.com/8123 we should not need to set the // initial focus explicitly. - chrome::GetActiveWebContents(browser)->GetView()->SetInitialFocus(); + browser->tab_strip_model()->GetActiveWebContents()-> + GetView()->SetInitialFocus(); if (!browser_shown_) { browser_shown_ = true; @@ -1077,9 +1083,10 @@ class SessionRestoreImpl : public content::NotificationObserver { SessionServiceFactory::GetForProfile(profile_); if (!session_service) return; - for (int i = initial_count; i < browser->tab_count(); ++i) - session_service->TabRestored(chrome::GetWebContentsAt(browser, i), - browser->tab_strip_model()->IsTabPinned(i)); + TabStripModel* tab_strip = browser->tab_strip_model(); + for (int i = initial_count; i < tab_strip->count(); ++i) + session_service->TabRestored(tab_strip->GetWebContentsAt(i), + tab_strip->IsTabPinned(i)); } // The profile to create the sessions for. diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc index 9c5b50a..b1b722d 100644 --- a/chrome/browser/sessions/session_restore_browsertest.cc +++ b/chrome/browser/sessions/session_restore_browsertest.cc @@ -142,7 +142,7 @@ class SessionRestoreTest : public InProcessBrowserTest { void AssertOneWindowWithOneTab(Browser* browser) { ASSERT_EQ(1u, BrowserList::size()); - ASSERT_EQ(1, browser->tab_count()); + ASSERT_EQ(1, browser->tab_strip_model()->count()); } int RenderProcessHostCount() { @@ -193,9 +193,9 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, NoSessionRestoreNewWindowChromeOS) { Browser* new_browser = browser_added_observer.WaitForSingleNewBrowser(); ASSERT_TRUE(new_browser); - EXPECT_EQ(1, new_browser->tab_count()); + EXPECT_EQ(1, new_browser->tab_strip_model()->count()); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), - chrome::GetWebContentsAt(new_browser, 0)->GetURL()); + new_browser->tab_strip_model()->GetWebContentsAt(0)->GetURL()); } #endif // OS_CHROMEOS @@ -246,10 +246,10 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ASSERT_TRUE(new_browser != NULL); // The browser should only have one tab. - ASSERT_EQ(1, new_browser->tab_count()); + ASSERT_EQ(1, new_browser->tab_strip_model()->count()); // And the first url should be url. - EXPECT_EQ(url, chrome::GetWebContentsAt(new_browser, 0)->GetURL()); + EXPECT_EQ(url, new_browser->tab_strip_model()->GetWebContentsAt(0)->GetURL()); } #endif // !OS_CHROMEOS @@ -320,7 +320,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) { // Make sure that the restored tab was restored with the correct // timestamp. const content::WebContents* contents = - chrome::GetActiveWebContents(browser()); + browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(contents); const content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); @@ -387,7 +387,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, IncognitotoNonIncognito) { // The first tab should have 'url' as its url. ASSERT_TRUE(new_browser); - EXPECT_EQ(url, chrome::GetWebContentsAt(new_browser, 0)->GetURL()); + EXPECT_EQ(url, new_browser->tab_strip_model()->GetWebContentsAt(0)->GetURL()); } #endif // !OS_CHROMEOS @@ -433,7 +433,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { SessionTypesTestHelper::GetTimestamp(tab.navigations[i]).is_null()); } - ASSERT_EQ(1, browser()->tab_count()); + ASSERT_EQ(1, browser()->tab_strip_model()->count()); // Restore in the current tab. { @@ -441,11 +441,12 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); SessionRestore::RestoreForeignSessionTab( - chrome::GetActiveWebContents(browser()), tab, CURRENT_TAB); + browser()->tab_strip_model()->GetActiveWebContents(), tab, CURRENT_TAB); observer.Wait(); } - ASSERT_EQ(1, browser()->tab_count()); - content::WebContents* web_contents = chrome::GetWebContentsAt(browser(), 0); + ASSERT_EQ(1, browser()->tab_strip_model()->count()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetWebContentsAt(0); VerifyNavigationEntries(web_contents->GetController(), url1, url2); ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); @@ -455,12 +456,13 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); SessionRestore::RestoreForeignSessionTab( - chrome::GetActiveWebContents(browser()), tab, NEW_BACKGROUND_TAB); + browser()->tab_strip_model()->GetActiveWebContents(), + tab, NEW_BACKGROUND_TAB); observer.Wait(); } - ASSERT_EQ(2, browser()->tab_count()); - ASSERT_EQ(0, browser()->active_index()); - web_contents = chrome::GetWebContentsAt(browser(), 1); + ASSERT_EQ(2, browser()->tab_strip_model()->count()); + ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); + web_contents = browser()->tab_strip_model()->GetWebContentsAt(1); VerifyNavigationEntries(web_contents->GetController(), url1, url2); ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); @@ -472,13 +474,13 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); SessionRestore::RestoreForeignSessionTab( - chrome::GetActiveWebContents(browser()), tab, NEW_WINDOW); + browser()->tab_strip_model()->GetActiveWebContents(), tab, NEW_WINDOW); new_browser = browser_observer.WaitForSingleNewBrowser(); observer.Wait(); } - ASSERT_EQ(1, new_browser->tab_count()); - web_contents = chrome::GetWebContentsAt(new_browser, 0); + ASSERT_EQ(1, new_browser->tab_strip_model()->count()); + web_contents = new_browser->tab_strip_model()->GetWebContentsAt(0); VerifyNavigationEntries(web_contents->GetController(), url1, url2); ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); } @@ -526,12 +528,12 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignSession) { Browser* new_browser = window_observer.WaitForSingleNewBrowser(); ASSERT_TRUE(new_browser); ASSERT_EQ(2u, BrowserList::size()); - ASSERT_EQ(2, new_browser->tab_count()); + ASSERT_EQ(2, new_browser->tab_strip_model()->count()); content::WebContents* web_contents_1 = - chrome::GetWebContentsAt(new_browser, 0); + new_browser->tab_strip_model()->GetWebContentsAt(0); content::WebContents* web_contents_2 = - chrome::GetWebContentsAt(new_browser, 1); + new_browser->tab_strip_model()->GetWebContentsAt(1); ASSERT_EQ(url1, web_contents_1->GetURL()); ASSERT_EQ(url2, web_contents_2->GetURL()); @@ -559,9 +561,11 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, Basic) { Browser* new_browser = QuitBrowserAndRestore(browser(), 1); ASSERT_EQ(1u, BrowserList::size()); - ASSERT_EQ(url2_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url2_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); GoBack(new_browser); - ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url1_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); } IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { @@ -572,16 +576,20 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { GoBack(browser()); Browser* new_browser = QuitBrowserAndRestore(browser(), 1); ASSERT_EQ(1u, BrowserList::size()); - ASSERT_EQ(url2_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url2_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); GoForward(new_browser); - ASSERT_EQ(url3_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url3_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); GoBack(new_browser); - ASSERT_EQ(url2_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url2_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); // Test renderer-initiated back/forward as well. GURL go_back_url("javascript:history.back();"); ui_test_utils::NavigateToURL(new_browser, go_back_url); - ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url1_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); } // Tests that the SiteInstances used for entries in a restored tab's history @@ -601,23 +609,25 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, GoBack(browser()); Browser* new_browser = QuitBrowserAndRestore(browser(), 1); ASSERT_EQ(1u, BrowserList::size()); - ASSERT_EQ(1, new_browser->tab_count()); + ASSERT_EQ(1, new_browser->tab_strip_model()->count()); // Check that back and forward work as expected. ASSERT_EQ(cross_site_url, - chrome::GetActiveWebContents(new_browser)->GetURL()); + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); GoBack(new_browser); - ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url1_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); GoForward(new_browser); ASSERT_EQ(cross_site_url, - chrome::GetActiveWebContents(new_browser)->GetURL()); + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); // Test renderer-initiated back/forward as well. GURL go_forward_url("javascript:history.forward();"); ui_test_utils::NavigateToURL(new_browser, go_forward_url); - ASSERT_EQ(url2_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url2_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); } IN_PROC_BROWSER_TEST_F(SessionRestoreTest, TwoTabsSecondSelected) { @@ -630,11 +640,13 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, TwoTabsSecondSelected) { Browser* new_browser = QuitBrowserAndRestore(browser(), 2); ASSERT_EQ(1u, BrowserList::size()); - ASSERT_EQ(2, new_browser->tab_count()); - ASSERT_EQ(1, new_browser->active_index()); - ASSERT_EQ(url2_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(2, new_browser->tab_strip_model()->count()); + ASSERT_EQ(1, new_browser->tab_strip_model()->active_index()); + ASSERT_EQ(url2_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); - ASSERT_EQ(url1_, chrome::GetWebContentsAt(new_browser, 0)->GetURL()); + ASSERT_EQ(url1_, + new_browser->tab_strip_model()->GetWebContentsAt(0)->GetURL()); } // Creates two tabs, closes one, quits and makes sure only one tab is restored. @@ -649,7 +661,8 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ClosedTabStaysClosed) { Browser* new_browser = QuitBrowserAndRestore(browser(), 1); AssertOneWindowWithOneTab(new_browser); - ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url1_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); } // Creates a tabbed browser and popup and makes sure we restore both. @@ -727,7 +740,8 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, AssertOneWindowWithOneTab(new_browser); - ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url1_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); } #endif // !defined(OS_CHROMEOS) && !defined(OS_MACOSX) @@ -753,7 +767,8 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, TwoWindowsCloseOneRestoreOnlyOne) { AssertOneWindowWithOneTab(new_browser); - ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url1_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); } // Make sure after a restore the number of processes matches that of the number @@ -781,7 +796,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ShareProcessesOnRestore) { // Restart. Browser* new_browser = QuitBrowserAndRestore(browser(), 3); - ASSERT_EQ(3, new_browser->tab_count()); + ASSERT_EQ(3, new_browser->tab_strip_model()->count()); ASSERT_EQ(expected_process_count, RenderProcessHostCount()); } @@ -790,26 +805,29 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ShareProcessesOnRestore) { IN_PROC_BROWSER_TEST_F(SessionRestoreTest, PersistAndRestoreUserAgentOverride) { // Create a tab with an overridden user agent. ui_test_utils::NavigateToURL(browser(), url1_); - ASSERT_EQ(0, browser()->active_index()); - chrome::GetWebContentsAt(browser(), 0)->SetUserAgentOverride("override"); + ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); + browser()->tab_strip_model()->GetWebContentsAt(0)-> + SetUserAgentOverride("override"); // Create a tab without an overridden user agent. ui_test_utils::NavigateToURLWithDisposition( browser(), url2_, NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - ASSERT_EQ(1, browser()->active_index()); + ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); // Kill the original browser then open a new one to trigger a restore. Browser* new_browser = QuitBrowserAndRestore(browser(), 1); ASSERT_EQ(1u, BrowserList::size()); - ASSERT_EQ(2, new_browser->tab_count()); - ASSERT_EQ(1, new_browser->active_index()); + ASSERT_EQ(2, new_browser->tab_strip_model()->count()); + ASSERT_EQ(1, new_browser->tab_strip_model()->active_index()); // Confirm that the user agent overrides are properly set. EXPECT_EQ("override", - chrome::GetWebContentsAt(new_browser, 0)->GetUserAgentOverride()); + new_browser->tab_strip_model()->GetWebContentsAt(0)-> + GetUserAgentOverride()); EXPECT_EQ("", - chrome::GetWebContentsAt(new_browser, 1)->GetUserAgentOverride()); + new_browser->tab_strip_model()->GetWebContentsAt(1)-> + GetUserAgentOverride()); } // Regression test for crbug.com/125958. When restoring a pinned selected tab in @@ -820,26 +838,26 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestorePinnedSelectedTab) { // Create a pinned tab. ui_test_utils::NavigateToURL(browser(), url1_); browser()->tab_strip_model()->SetTabPinned(0, true); - ASSERT_EQ(0, browser()->active_index()); + ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); // Create a nonpinned tab. ui_test_utils::NavigateToURLWithDisposition( browser(), url2_, NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - ASSERT_EQ(1, browser()->active_index()); + ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); // Select the pinned tab. browser()->tab_strip_model()->ActivateTabAt(0, true); - ASSERT_EQ(0, browser()->active_index()); + ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); Profile* profile = browser()->profile(); // This will also initiate a session restore, but we're not interested in it. Browser* new_browser = QuitBrowserAndRestore(browser(), 1); ASSERT_EQ(1u, BrowserList::size()); - ASSERT_EQ(2, new_browser->tab_count()); - ASSERT_EQ(0, new_browser->active_index()); + ASSERT_EQ(2, new_browser->tab_strip_model()->count()); + ASSERT_EQ(0, new_browser->tab_strip_model()->active_index()); // Close the pinned tab. chrome::CloseTab(new_browser); - ASSERT_EQ(1, new_browser->tab_count()); - ASSERT_EQ(0, new_browser->active_index()); + ASSERT_EQ(1, new_browser->tab_strip_model()->count()); + ASSERT_EQ(0, new_browser->tab_strip_model()->active_index()); // Use the existing tab to navigate away, so that we can verify it was really // clobbered. ui_test_utils::NavigateToURL(new_browser, url3_); @@ -851,24 +869,27 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestorePinnedSelectedTab) { std::vector<GURL>()); // The pinned tab is the selected tab. - ASSERT_EQ(2, new_browser->tab_count()); - EXPECT_EQ(0, new_browser->active_index()); - EXPECT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); - EXPECT_EQ(url2_, chrome::GetWebContentsAt(new_browser, 1)->GetURL()); + ASSERT_EQ(2, new_browser->tab_strip_model()->count()); + EXPECT_EQ(0, new_browser->tab_strip_model()->active_index()); + EXPECT_EQ(url1_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); + EXPECT_EQ(url2_, + new_browser->tab_strip_model()->GetWebContentsAt(1)->GetURL()); } IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorage) { ui_test_utils::NavigateToURL(browser(), url1_); content::NavigationController* controller = - &chrome::GetActiveWebContents(browser())->GetController(); + &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); ASSERT_TRUE(controller->GetDefaultSessionStorageNamespace()); std::string session_storage_persistent_id = controller->GetDefaultSessionStorageNamespace()->persistent_id(); Browser* new_browser = QuitBrowserAndRestore(browser(), 1); ASSERT_EQ(1u, BrowserList::size()); - ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); + ASSERT_EQ(url1_, + new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); content::NavigationController* new_controller = - &chrome::GetActiveWebContents(new_browser)->GetController(); + &new_browser->tab_strip_model()->GetActiveWebContents()->GetController(); ASSERT_TRUE(new_controller->GetDefaultSessionStorageNamespace()); std::string restored_session_storage_persistent_id = new_controller->GetDefaultSessionStorageNamespace()->persistent_id(); @@ -881,7 +902,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorageAfterTabReplace) { // SessionStorageNamespace as an existing tab, then replace the tab with it. { content::NavigationController* controller = - &chrome::GetActiveWebContents(browser())->GetController(); + &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); ASSERT_TRUE(controller->GetDefaultSessionStorageNamespace()); content::SessionStorageNamespaceMap session_storage_namespace_map; @@ -903,7 +924,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorageAfterTabReplace) { // Check that the sessionStorage data is going to be persisted. content::NavigationController* controller = - &chrome::GetActiveWebContents(browser())->GetController(); + &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); EXPECT_TRUE( controller->GetDefaultSessionStorageNamespace()->should_persist()); diff --git a/chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc b/chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc index cd84bf5..36e6952 100644 --- a/chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc +++ b/chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc @@ -61,7 +61,7 @@ void SessionsSyncPerfTest::UpdateTabs(int profile) { Browser* browser = GetBrowser(profile); GURL url; std::vector<GURL> urls; - for (int i = 0; i < browser->tab_count(); ++i) { + for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { chrome::SelectNumberedTab(browser, i); url = NextURL(); browser->OpenURL( diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index b519b0e..fedf4f1 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -655,7 +655,7 @@ void Browser::OnWindowClosing() { tab_restore_service->BrowserClosing(tab_restore_service_delegate()); #endif - if (tab_restore_service && is_type_tabbed() && tab_count()) + if (tab_restore_service && is_type_tabbed() && tab_strip_model_->count()) tab_restore_service->BrowserClosing(tab_restore_service_delegate()); // TODO(sky): convert session/tab restore to use notification. @@ -1445,9 +1445,9 @@ void Browser::OnStartDownload(WebContents* source, shelf->AddDownload(download); // If the download occurs in a new tab, and it's not a save page - // download (started before initial navigation completed) close it. - if (source->GetController().IsInitialNavigation() && tab_count() > 1 && - !download->IsSavePackageDownload()) + // download (started before initial navigation completed), close it. + if (source->GetController().IsInitialNavigation() && + tab_strip_model_->count() > 1 && !download->IsSavePackageDownload()) CloseContents(source); } @@ -2019,7 +2019,7 @@ void Browser::ProcessPendingUIUpdates() { for (UpdateMap::const_iterator i = scheduled_updates_.begin(); i != scheduled_updates_.end(); ++i) { bool found = false; - for (int tab = 0; tab < tab_count(); tab++) { + for (int tab = 0; tab < tab_strip_model_->count(); tab++) { if (tab_strip_model_->GetWebContentsAt(tab) == i->first) { found = true; break; @@ -2098,7 +2098,7 @@ void Browser::SyncHistoryWithTabs(int index) { SessionService* session_service = SessionServiceFactory::GetForProfileIfExisting(profile()); if (session_service) { - for (int i = index; i < tab_count(); ++i) { + for (int i = index; i < tab_strip_model_->count(); ++i) { WebContents* web_contents = tab_strip_model_->GetWebContentsAt(i); if (web_contents) { SessionTabHelper* session_tab_helper = diff --git a/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc b/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc index e46b77a..69c8f7a 100644 --- a/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc +++ b/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc @@ -89,7 +89,7 @@ IN_PROC_BROWSER_TEST_F(BookmarksTest, TwoCommandsOneTab) { chrome::ShowBookmarkManager(browser()); navigation_observer.Wait(); - ASSERT_EQ(1, browser()->tab_count()); + ASSERT_EQ(1, browser()->tab_strip_model()->count()); } IN_PROC_BROWSER_TEST_F(BookmarksTest, BookmarksLoaded) { |