diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-14 18:38:10 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-14 18:38:10 +0000 |
commit | 3695357bc1e9a041a781411555ba39b7cd6319b8 (patch) | |
tree | 652a29cb30d99b472555a589d6aec7d0e899af97 /chrome/browser | |
parent | 85f2fcc7b577362dd1def5895d60ea70d6e6b8d0 (diff) | |
download | chromium_src-3695357bc1e9a041a781411555ba39b7cd6319b8.zip chromium_src-3695357bc1e9a041a781411555ba39b7cd6319b8.tar.gz chromium_src-3695357bc1e9a041a781411555ba39b7cd6319b8.tar.bz2 |
Remove GetWebContentsAt from browser_tabstrip.
BUG=167548
TEST=no functional change
Review URL: https://chromiumcodereview.appspot.com/11874002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
15 files changed, 92 insertions, 80 deletions
diff --git a/chrome/browser/automation/automation_tab_helper_browsertest.cc b/chrome/browser/automation/automation_tab_helper_browsertest.cc index 6566518..e236cad 100644 --- a/chrome/browser/automation/automation_tab_helper_browsertest.cc +++ b/chrome/browser/automation/automation_tab_helper_browsertest.cc @@ -12,7 +12,7 @@ #include "chrome/browser/automation/automation_tab_helper.h" #include "chrome/browser/automation/mock_tab_event_observer.h" #include "chrome/browser/ui/browser.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 "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" @@ -89,8 +89,8 @@ class AutomationTabHelperBrowserTest : public InProcessBrowserTest { void RunTestCaseInJavaScript(int test_case_number, bool wait_for_response) { std::string script = base::StringPrintf("runTestCase(%d);", test_case_number); - content::RenderViewHost* host = - chrome::GetActiveWebContents(browser())->GetRenderViewHost(); + content::RenderViewHost* host = browser()->tab_strip_model()-> + GetActiveWebContents()->GetRenderViewHost(); if (wait_for_response) { ASSERT_TRUE(content::ExecuteScript(host, script)); } else { @@ -103,7 +103,7 @@ class AutomationTabHelperBrowserTest : public InProcessBrowserTest { // Returns the |AutomationTabHelper| for the first browser's first tab. AutomationTabHelper* tab_helper() { return AutomationTabHelper::FromWebContents( - chrome::GetWebContentsAt(browser(), 0)); + browser()->tab_strip_model()->GetWebContentsAt(0)); } protected: diff --git a/chrome/browser/captive_portal/captive_portal_browsertest.cc b/chrome/browser/captive_portal/captive_portal_browsertest.cc index 6fb3ef2..a6632d4 100644 --- a/chrome/browser/captive_portal/captive_portal_browsertest.cc +++ b/chrome/browser/captive_portal/captive_portal_browsertest.cc @@ -24,7 +24,6 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_navigator.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_notification_types.h" @@ -1135,7 +1134,7 @@ void CaptivePortalBrowserTest::FastTimeoutNoCaptivePortal( // Check that the right tab was navigated, and there were no extra // navigations. EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( - chrome::GetWebContentsAt(browser, active_index))); + browser->tab_strip_model()->GetWebContentsAt(active_index))); EXPECT_EQ(0, NumLoadingTabs()); // Check the tab's state, and verify no captive portal check is pending. @@ -1990,7 +1989,7 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, GoBackToTimeout) { GetStateOfTabReloaderAt(browser(), 0)); EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, GetStateOfTabReloaderAt(browser(), 1)); - ASSERT_TRUE(IsLoginTab(chrome::GetWebContentsAt(browser(), 1))); + ASSERT_TRUE(IsLoginTab(browser()->tab_strip_model()->GetWebContentsAt(1))); ASSERT_EQ(2, tab_strip_model->count()); EXPECT_EQ(1, tab_strip_model->active_index()); diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc index cd24045..af8e86b 100644 --- a/chrome/browser/custom_home_pages_table_model.cc +++ b/chrome/browser/custom_home_pages_table_model.cc @@ -13,7 +13,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.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/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -189,7 +188,8 @@ void CustomHomePagesTableModel::SetToCurrentlyOpenPages() { for (int tab_index = 0; tab_index < browser->tab_strip_model()->count(); ++tab_index) { - const GURL url = chrome::GetWebContentsAt(browser, tab_index)->GetURL(); + const GURL url = + browser->tab_strip_model()->GetWebContentsAt(tab_index)->GetURL(); if (ShouldAddPage(url)) Add(add_index++, url); } diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc index b6521ba..3f3598b 100644 --- a/chrome/browser/devtools/devtools_sanity_browsertest.cc +++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc @@ -18,7 +18,6 @@ #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_notification_types.h" #include "chrome/common/chrome_paths.h" @@ -143,7 +142,7 @@ class DevToolsSanityTest : public InProcessBrowserTest { } WebContents* GetInspectedTab() { - return chrome::GetWebContentsAt(browser(), 0); + return browser()->tab_strip_model()->GetWebContentsAt(0); } void CloseDevToolsWindow() { @@ -515,7 +514,8 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestReattachAfterCrash) { 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(); diff --git a/chrome/browser/extensions/browser_event_router.cc b/chrome/browser/extensions/browser_event_router.cc index e647b8f..d6d26ca 100644 --- a/chrome/browser/extensions/browser_event_router.cc +++ b/chrome/browser/extensions/browser_event_router.cc @@ -19,7 +19,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.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/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" @@ -90,7 +89,7 @@ BrowserEventRouter::BrowserEventRouter(Profile* profile) Browser* browser = *iter; if (browser->tab_strip_model()) { for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { - WebContents* contents = chrome::GetWebContentsAt(browser, i); + WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(i); int tab_id = ExtensionTabUtil::GetTabId(contents); tab_entries_[tab_id] = TabEntry(); } @@ -110,10 +109,11 @@ void BrowserEventRouter::RegisterForBrowserNotifications(Browser* browser) { if (!profile_->IsSameProfile(browser->profile())) return; // Start listening to TabStripModel events for this browser. - browser->tab_strip_model()->AddObserver(this); + TabStripModel* tab_strip = browser->tab_strip_model(); + tab_strip->AddObserver(this); - for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { - RegisterForTabNotifications(chrome::GetWebContentsAt(browser, i)); + for (int i = 0; i < tab_strip->count(); ++i) { + RegisterForTabNotifications(tab_strip->GetWebContentsAt(i)); } } diff --git a/chrome/browser/extensions/web_view_browsertest.cc b/chrome/browser/extensions/web_view_browsertest.cc index 138d4ed..16ce050 100644 --- a/chrome/browser/extensions/web_view_browsertest.cc +++ b/chrome/browser/extensions/web_view_browsertest.cc @@ -5,7 +5,8 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/automation/automation_util.h" #include "chrome/browser/extensions/platform_app_browsertest_util.h" -#include "chrome/browser/ui/browser_tabstrip.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/test_launcher_utils.h" #include "content/public/browser/notification_service.h" @@ -129,10 +130,10 @@ class WebViewTest : public extensions::PlatformAppBrowserTest { // The two sets of tags should also be isolated from the main browser. EXPECT_NE(source1->GetWebContents()->GetRenderProcessHost()->GetID(), - chrome::GetWebContentsAt(browser(), 0)-> + browser()->tab_strip_model()->GetWebContentsAt(0)-> GetRenderProcessHost()->GetID()); EXPECT_NE(source3->GetWebContents()->GetRenderProcessHost()->GetID(), - chrome::GetWebContentsAt(browser(), 0)-> + browser()->tab_strip_model()->GetWebContentsAt(0)-> GetRenderProcessHost()->GetID()); // Check that the storage partitions of the first two tags match and are @@ -255,7 +256,7 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, CookieIsolation) { // Test the regular browser context to ensure we have only one cookie. automation_util::GetCookies(GURL("http://localhost"), - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), &cookie_size, &cookie_value); EXPECT_EQ("testCookie=1", cookie_value); @@ -495,12 +496,12 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, DOMStorageIsolation) { // Also, let's check that the main browser and another tag that doesn't share // the same partition don't have those values stored. EXPECT_TRUE(ExecuteScriptAndExtractString( - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), get_local_storage.c_str(), &output)); EXPECT_STREQ("badval", output.c_str()); EXPECT_TRUE(ExecuteScriptAndExtractString( - chrome::GetWebContentsAt(browser(), 0), + browser()->tab_strip_model()->GetWebContentsAt(0), get_session_storage.c_str(), &output)); EXPECT_STREQ("badval", output.c_str()); @@ -590,7 +591,7 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, IndexedDBIsolation) { " else " " document.title = 'error';" "}"; - ExecuteScriptWaitForTitle(chrome::GetWebContentsAt(browser(), 0), + ExecuteScriptWaitForTitle(browser()->tab_strip_model()->GetWebContentsAt(0), script, "db not found"); ExecuteScriptWaitForTitle(default_tag_contents1, script, "db not found"); } diff --git a/chrome/browser/infobars/infobars_browsertest.cc b/chrome/browser/infobars/infobars_browsertest.cc index f43f8f1..f23f60a 100644 --- a/chrome/browser/infobars/infobars_browsertest.cc +++ b/chrome/browser/infobars/infobars_browsertest.cc @@ -10,7 +10,7 @@ #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.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 "chrome/common/chrome_switches.h" #include "chrome/test/base/in_process_browser_test.h" @@ -38,8 +38,8 @@ class InfoBarsTest : public InProcessBrowserTest { chrome::NOTIFICATION_EXTENSION_LOADED, content::NotificationService::AllSources()); - ExtensionInstallPrompt* client = - new ExtensionInstallPrompt(chrome::GetActiveWebContents(browser())); + ExtensionInstallPrompt* client = new ExtensionInstallPrompt( + browser()->tab_strip_model()->GetActiveWebContents()); scoped_refptr<extensions::CrxInstaller> installer( extensions::CrxInstaller::Create(service, client)); installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION); @@ -74,8 +74,8 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { infobar_added_2.Wait(); infobar_removed_1.Wait(); EXPECT_EQ(0u, - InfoBarService::FromWebContents( - chrome::GetWebContentsAt(browser(), 0))->GetInfoBarCount()); + InfoBarService::FromWebContents(browser()->tab_strip_model()-> + GetWebContentsAt(0))->GetInfoBarCount()); content::WindowedNotificationObserver infobar_removed_2( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, @@ -83,6 +83,6 @@ IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme(); infobar_removed_2.Wait(); EXPECT_EQ(0u, - InfoBarService::FromWebContents( - chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); + InfoBarService::FromWebContents(browser()->tab_strip_model()-> + GetActiveWebContents())->GetInfoBarCount()); } diff --git a/chrome/browser/sessions/better_session_restore_browsertest.cc b/chrome/browser/sessions/better_session_restore_browsertest.cc index a23d63d..afb36ef 100644 --- a/chrome/browser/sessions/better_session_restore_browsertest.cc +++ b/chrome/browser/sessions/better_session_restore_browsertest.cc @@ -23,9 +23,9 @@ #include "chrome/browser/ui/browser.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/browser_window.h" #include "chrome/browser/ui/startup/startup_browser_creator.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/content_settings.h" #include "chrome/common/pref_names.h" @@ -146,7 +146,7 @@ class BetterSessionRestoreTest : public InProcessBrowserTest { void StoreDataWithPage(Browser* browser, const std::string& filename) { content::WebContents* web_contents = - chrome::GetActiveWebContents(browser); + browser->tab_strip_model()->GetActiveWebContents(); content::TitleWatcher title_watcher(web_contents, title_storing_); title_watcher.AlsoWaitForTitle(title_pass_); title_watcher.AlsoWaitForTitle(title_error_write_failed_); @@ -166,7 +166,7 @@ class BetterSessionRestoreTest : public InProcessBrowserTest { // Navigate to a page which has previously stored data; check that the // stored data can be accessed. content::WebContents* web_contents = - chrome::GetActiveWebContents(browser); + browser->tab_strip_model()->GetActiveWebContents(); content::TitleWatcher title_watcher(web_contents, title_pass_); title_watcher.AlsoWaitForTitle(title_storing_); title_watcher.AlsoWaitForTitle(title_error_write_failed_); @@ -190,7 +190,8 @@ class BetterSessionRestoreTest : public InProcessBrowserTest { } void CheckTitle(Browser* browser, const string16& expected_title) { - content::WebContents* web_contents = chrome::GetWebContentsAt(browser, 0); + content::WebContents* web_contents = + browser->tab_strip_model()->GetWebContentsAt(0); content::TitleWatcher title_watcher(web_contents, expected_title); title_watcher.AlsoWaitForTitle(title_pass_); title_watcher.AlsoWaitForTitle(title_storing_); @@ -212,7 +213,7 @@ class BetterSessionRestoreTest : public InProcessBrowserTest { void PostFormWithPage(const std::string& filename, bool password_present) { content::WebContents* web_contents = - chrome::GetActiveWebContents(browser()); + browser()->tab_strip_model()->GetActiveWebContents(); content::TitleWatcher title_watcher(web_contents, title_pass_); ui_test_utils::NavigateToURL( browser(), GURL(fake_server_address_ + test_path_ + filename)); @@ -463,7 +464,8 @@ IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_SessionCookies) { } IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, SessionCookies) { - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(std::string(chrome::kAboutBlankURL), web_contents->GetURL().spec()); // When we navigate to the page again, it doens't see the data previously // stored. @@ -475,7 +477,8 @@ IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_SessionStorage) { } IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, SessionStorage) { - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(std::string(chrome::kAboutBlankURL), web_contents->GetURL().spec()); StoreDataWithPage("session_storage.html"); } @@ -487,7 +490,8 @@ IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_LocalStorageClearedOnExit) { // Normally localStorage is persisted. - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(std::string(chrome::kAboutBlankURL), web_contents->GetURL().spec()); NavigateAndCheckStoredData("local_storage.html"); // ... but not if it's set to clear on exit. @@ -496,7 +500,8 @@ IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_LocalStorageClearedOnExit) { } IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, LocalStorageClearedOnExit) { - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(std::string(chrome::kAboutBlankURL), web_contents->GetURL().spec()); StoreDataWithPage("local_storage.html"); } @@ -507,7 +512,8 @@ IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_PRE_CookiesClearedOnExit) { IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_CookiesClearedOnExit) { // Normally cookies are restored. - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(std::string(chrome::kAboutBlankURL), web_contents->GetURL().spec()); NavigateAndCheckStoredData("cookies.html"); // ... but not if the content setting is set to clear on exit. @@ -516,7 +522,8 @@ IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, PRE_CookiesClearedOnExit) { } IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, CookiesClearedOnExit) { - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(std::string(chrome::kAboutBlankURL), web_contents->GetURL().spec()); StoreDataWithPage("local_storage.html"); } @@ -566,7 +573,7 @@ class BetterSessionRestoreCrashTest : public BetterSessionRestoreTest { FindOneOtherBrowserForProfile(profile, browser_before_restore); ASSERT_TRUE(browser_after_restore); content::WebContents* web_contents = - chrome::GetActiveWebContents(browser_after_restore); + browser_after_restore->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); InfoBarService* infobar_service = @@ -580,7 +587,8 @@ class BetterSessionRestoreCrashTest : public BetterSessionRestoreTest { loop.RunUntilIdle(); // Check the restored page. - web_contents = chrome::GetWebContentsAt(browser_after_restore, 0); + web_contents = + browser_after_restore->tab_strip_model()->GetWebContentsAt(0); ASSERT_TRUE(web_contents); EXPECT_EQ(GURL(fake_server_address() + test_path() + filename), web_contents->GetURL()); diff --git a/chrome/browser/tab_contents/view_source_browsertest.cc b/chrome/browser/tab_contents/view_source_browsertest.cc index 3d08b05..7eb3f51 100644 --- a/chrome/browser/tab_contents/view_source_browsertest.cc +++ b/chrome/browser/tab_contents/view_source_browsertest.cc @@ -6,7 +6,7 @@ #include "chrome/app/chrome_command_ids.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/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -41,7 +41,7 @@ IN_PROC_BROWSER_TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) { // Check that the title didn't get set. It should not be there (because we // are in view-source mode). EXPECT_NE(ASCIIToUTF16("foo"), - chrome::GetActiveWebContents(browser())->GetTitle()); + browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); } // This test renders a page normally and then renders the same page in @@ -62,7 +62,8 @@ IN_PROC_BROWSER_TEST_F(ViewSourceTest, DoesBrowserConsumeViewSourcePrefix) { // The URL should still be prefixed with "view-source:". EXPECT_EQ(url_viewsource.spec(), - chrome::GetActiveWebContents(browser())->GetURL().spec()); + browser()->tab_strip_model()->GetActiveWebContents()-> + GetURL().spec()); } // Make sure that when looking at the actual page, we can select "View Source" @@ -84,7 +85,7 @@ IN_PROC_BROWSER_TEST_F(ViewSourceTest, ViewSourceInMenuDisabledOnAMediaPage) { GURL url(test_server()->GetURL(kTestMedia)); ui_test_utils::NavigateToURL(browser(), url); - const char* mime_type = chrome::GetActiveWebContents(browser())-> + const char* mime_type = browser()->tab_strip_model()->GetActiveWebContents()-> GetContentsMimeType().c_str(); EXPECT_STREQ("audio/wav", mime_type); @@ -119,13 +120,14 @@ IN_PROC_BROWSER_TEST_F(ViewSourceTest, DISABLED_TestViewSourceReload) { ui_test_utils::NavigateToURL(browser(), url_viewsource); observer.Wait(); - ASSERT_TRUE(content::ExecuteScript(chrome::GetWebContentsAt(browser(), 0), - "window.location.reload();")); + ASSERT_TRUE( + content::ExecuteScript(browser()->tab_strip_model()->GetWebContentsAt(0), + "window.location.reload();")); content::WindowedNotificationObserver observer2( content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); observer2.Wait(); - ASSERT_TRUE(chrome::GetWebContentsAt(browser(), 0)->GetController(). - GetActiveEntry()->IsViewSourceMode()); + ASSERT_TRUE(browser()->tab_strip_model()->GetWebContentsAt(0)-> + GetController().GetActiveEntry()->IsViewSourceMode()); } diff --git a/chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc b/chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc index 7d9444f..8d066a0 100644 --- a/chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc +++ b/chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc @@ -10,7 +10,7 @@ #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_tabstrip.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -79,7 +79,8 @@ class LauncherFaviconLoaderBrowsertest : public InProcessBrowserTest { ui_test_utils::NavigateToURL(panel_browser_, GURL()); EXPECT_FALSE(contents_observer_.get()); contents_observer_.reset( - new ContentsObserver(chrome::GetWebContentsAt(panel_browser_, 0))); + new ContentsObserver( + panel_browser_->tab_strip_model()->GetWebContentsAt(0))); } return panel_browser_; } diff --git a/chrome/browser/ui/browser_tabstrip.cc b/chrome/browser/ui/browser_tabstrip.cc index f88ba871..708a746 100644 --- a/chrome/browser/ui/browser_tabstrip.cc +++ b/chrome/browser/ui/browser_tabstrip.cc @@ -22,10 +22,6 @@ content::WebContents* GetActiveWebContents(const Browser* browser) { return browser->tab_strip_model()->GetActiveWebContents(); } -content::WebContents* GetWebContentsAt(const Browser* browser, int index) { - return browser->tab_strip_model()->GetWebContentsAt(index); -} - void AddBlankTabAt(Browser* browser, int index, bool foreground) { // TODO(scottmg): http://crbug.com/128578 // This is necessary because WebContentsViewAura doesn't have enough context diff --git a/chrome/browser/ui/browser_tabstrip.h b/chrome/browser/ui/browser_tabstrip.h index cbc2c99..7434914 100644 --- a/chrome/browser/ui/browser_tabstrip.h +++ b/chrome/browser/ui/browser_tabstrip.h @@ -26,8 +26,6 @@ namespace chrome { content::WebContents* GetActiveWebContents(const Browser* browser); -content::WebContents* GetWebContentsAt(const Browser* browser, int index); - // Adds a blank tab to the tab strip of the specified browser; an |index| of -1 // means to append it to the end of the tab strip. void AddBlankTabAt(Browser* browser, int index, bool foreground); diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm index 6f2bc00..290f18b 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller.mm @@ -30,7 +30,6 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_instant_controller.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window_state.h" #import "chrome/browser/ui/cocoa/background_gradient_view.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" @@ -593,7 +592,8 @@ enum { - (void)windowDidBecomeKey:(NSNotification*)notification { // We need to activate the controls (in the "WebView"). To do this, get the // selected WebContents's RenderWidgetHostView and tell it to activate. - if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { + if (WebContents* contents = + browser_->tab_strip_model()->GetActiveWebContents()) { if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) rwhv->SetActive(true); } @@ -610,7 +610,8 @@ enum { // We need to deactivate the controls (in the "WebView"). To do this, get the // selected WebContents's RenderWidgetHostView and tell it to deactivate. - if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { + if (WebContents* contents = + browser_->tab_strip_model()->GetActiveWebContents()) { if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) rwhv->SetActive(false); } @@ -621,7 +622,8 @@ enum { [self saveWindowPositionIfNeeded]; // Let the selected RenderWidgetHostView know, so that it can tell plugins. - if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { + if (WebContents* contents = + browser_->tab_strip_model()->GetActiveWebContents()) { if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) rwhv->SetWindowVisibility(false); } @@ -630,7 +632,8 @@ enum { // Called when we have been unminimized. - (void)windowDidDeminiaturize:(NSNotification *)notification { // Let the selected RenderWidgetHostView know, so that it can tell plugins. - if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { + if (WebContents* contents = + browser_->tab_strip_model()->GetActiveWebContents()) { if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) rwhv->SetWindowVisibility(true); } @@ -641,7 +644,8 @@ enum { // Let the selected RenderWidgetHostView know, so that it can tell plugins // (unless we are minimized, in which case nothing has really changed). if (![[self window] isMiniaturized]) { - if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { + if (WebContents* contents = + browser_->tab_strip_model()->GetActiveWebContents()) { if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) rwhv->SetWindowVisibility(false); } @@ -653,7 +657,8 @@ enum { // Let the selected RenderWidgetHostView know, so that it can tell plugins // (unless we are minimized, in which case nothing has really changed). if (![[self window] isMiniaturized]) { - if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { + if (WebContents* contents = + browser_->tab_strip_model()->GetActiveWebContents()) { if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) rwhv->SetWindowVisibility(true); } @@ -698,7 +703,7 @@ enum { std::max(kProportion * NSWidth(frame), std::min(kProportion * NSHeight(frame), NSWidth(frame))); - WebContents* contents = chrome::GetActiveWebContents(browser_.get()); + WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); if (contents) { // If the intrinsic width is bigger, then make it the zoomed width. const int kScrollbarWidth = 16; // TODO(viettrungluu): ugh. @@ -941,7 +946,7 @@ enum { if (resizeRectDirty) { // Send new resize rect to foreground tab. if (content::WebContents* contents = - chrome::GetActiveWebContents(browser_.get())) { + browser_->tab_strip_model()->GetActiveWebContents()) { if (content::RenderViewHost* rvh = contents->GetRenderViewHost()) { rvh->ResizeRectChanged(windowShim_->GetRootWindowResizerRect()); } @@ -981,10 +986,11 @@ enum { DCHECK(browser_.get()); Profile* profile = browser_->profile(); DCHECK(profile); - WebContents* current_tab = chrome::GetActiveWebContents(browser_.get()); - if (!current_tab) { + WebContents* current_tab = + browser_->tab_strip_model()->GetActiveWebContents(); + if (!current_tab) return; - } + const std::string encoding = current_tab->GetEncoding(); bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag); @@ -1492,7 +1498,7 @@ enum { } - (NSString*)activeTabTitle { - WebContents* contents = chrome::GetActiveWebContents(browser_.get()); + WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); return base::SysUTF16ToNSString(contents->GetTitle()); } @@ -1511,7 +1517,7 @@ enum { // tabsheets between windows. Until then, we have to prevent having to move a // tabsheet between windows, e.g. no tearing off of tabs. int index = [tabStripController_ modelIndexForTabView:tabView]; - WebContents* contents = chrome::GetWebContentsAt(browser_.get(), index); + WebContents* contents = browser_->tab_strip_model()->GetWebContentsAt(index); if (!contents) return NO; return !WebContentsModalDialogManager::FromWebContents(contents)-> @@ -1751,7 +1757,8 @@ enum { } // Let the selected RenderWidgetHostView know, so that it can tell plugins. - if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { + if (WebContents* contents = + browser_->tab_strip_model()->GetActiveWebContents()) { if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) rwhv->WindowFrameChanged(); } @@ -1810,7 +1817,8 @@ enum { [self resetWindowGrowthState]; // Let the selected RenderWidgetHostView know, so that it can tell plugins. - if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { + if (WebContents* contents = + browser_->tab_strip_model()->GetActiveWebContents()) { if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) rwhv->WindowFrameChanged(); } diff --git a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc index 40387b7..926cb8c 100644 --- a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc +++ b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc @@ -10,8 +10,8 @@ #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/search/search.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/toolbar/toolbar_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/browser_with_test_window_test.h" @@ -153,7 +153,7 @@ class ToolbarModelTest : public BrowserWithTestWindowTest { const string16 expected_text, bool would_replace, bool should_display) { - WebContents* contents = chrome::GetWebContentsAt(browser(), 0); + WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); browser()->OpenURL(OpenURLParams( url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc index 335a9ed..06d74e9 100644 --- a/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc @@ -14,7 +14,6 @@ #include "chrome/browser/prerender/prerender_manager_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/webui/web_ui_browsertest.h" #include "chrome/common/chrome_switches.h" @@ -267,7 +266,7 @@ void NetInternalsTest::MessageHandler::PrerenderPage( void NetInternalsTest::MessageHandler::NavigateToPrerender( const ListValue* list_value) { content::RenderViewHost* host = - chrome::GetWebContentsAt(browser(), 1)->GetRenderViewHost(); + browser()->tab_strip_model()->GetWebContentsAt(1)->GetRenderViewHost(); host->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16("Click()")); } |