Remove tabstrip wrappers in browser_tabstrip.

BUG=none
TEST=no functional change


Review URL: https://chromiumcodereview.appspot.com/11364239

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168076 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index af1a9d8..ed0e35f 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -294,7 +294,8 @@
 int AutomationProvider::GetIndexForNavigationController(
     const NavigationController* controller, const Browser* parent) const {
   DCHECK(parent);
-  return chrome::GetIndexOfTab(parent, controller->GetWebContents());
+  return parent->tab_strip_model()->GetIndexOfWebContents(
+      controller->GetWebContents());
 }
 
 // TODO(phajdan.jr): move to TestingAutomationProvider.
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 32ea487..805e3ba 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -1037,7 +1037,8 @@
     NavigationController* tab = tab_tracker_->GetResource(handle);
     Browser* browser = browser::FindBrowserWithWebContents(
         tab->GetWebContents());
-    *tabstrip_index = chrome::GetIndexOfTab(browser, tab->GetWebContents());
+    *tabstrip_index = browser->tab_strip_model()->GetIndexOfWebContents(
+        tab->GetWebContents());
   }
 }
 
@@ -4777,8 +4778,9 @@
   }
   // The key events will be sent to the browser window, we need the current tab
   // containing the element we send the text in to be shown.
-  chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, web_contents),
-                        true);
+  TabStripModel* tab_strip = browser->tab_strip_model();
+  tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents),
+                           true);
 
   BrowserWindow* browser_window = browser->window();
   if (!browser_window) {
@@ -6214,8 +6216,9 @@
     reply.SendError(error);
     return;
   }
-  chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, web_contents),
-                        true);
+  TabStripModel* tab_strip = browser->tab_strip_model();
+  tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents),
+                           true);
   reply.SendSuccess(NULL);
 }
 
@@ -6351,6 +6354,7 @@
 
 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
                                                   WebContents* tab) {
-  if (chrome::GetActiveWebContents(browser) != tab)
-    chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
+  TabStripModel* tab_strip = browser->tab_strip_model();
+  if (tab_strip->GetActiveWebContents() != tab)
+    tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true);
 }
diff --git a/chrome/browser/debugger/devtools_sanity_browsertest.cc b/chrome/browser/debugger/devtools_sanity_browsertest.cc
index 2f40821..7d4f12b 100644
--- a/chrome/browser/debugger/devtools_sanity_browsertest.cc
+++ b/chrome/browser/debugger/devtools_sanity_browsertest.cc
@@ -20,6 +20,7 @@
 #include "chrome/browser/ui/browser_commands.h"
 #include "chrome/browser/ui/browser_tabstrip.h"
 #include "chrome/browser/ui/tab_contents/tab_contents.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/chrome_switches.h"
@@ -406,7 +407,7 @@
 
   void CloseDevToolsWindow() {
     Browser* browser = window_->browser();
-    chrome::CloseAllTabs(browser);
+    browser->tab_strip_model()->CloseAllTabs();
     BrowserClosedObserver close_observer(browser);
   }
 
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc
index 1ea71b1..783c753 100644
--- a/chrome/browser/debugger/devtools_window.cc
+++ b/chrome/browser/debugger/devtools_window.cc
@@ -159,7 +159,7 @@
     Browser* browser,
     DevToolsToggleAction action) {
   if (action == DEVTOOLS_TOGGLE_ACTION_TOGGLE && browser->is_devtools()) {
-    chrome::CloseAllTabs(browser);
+    browser->tab_strip_model()->CloseAllTabs();
     return NULL;
   }
   RenderViewHost* inspected_rvh =
@@ -276,7 +276,7 @@
     // for us.
     Browser* browser = browser_;
     delete this;
-    chrome::CloseAllTabs(browser);
+    browser->tab_strip_model()->CloseAllTabs();
   }
 }
 
@@ -421,7 +421,8 @@
 
   for (BrowserList::const_iterator it = BrowserList::begin();
        it != BrowserList::end(); ++it) {
-    int tab_index = chrome::GetIndexOfTab(*it, inspected_tab_->web_contents());
+    int tab_index = (*it)->tab_strip_model()->GetIndexOfWebContents(
+        inspected_tab_->web_contents());
     if (tab_index != TabStripModel::kNoTab) {
       *browser = *it;
       *tab = tab_index;
diff --git a/chrome/browser/extensions/api/tabs/tabs.cc b/chrome/browser/extensions/api/tabs/tabs.cc
index 97a4ea6..d9644ee 100644
--- a/chrome/browser/extensions/api/tabs/tabs.cc
+++ b/chrome/browser/extensions/api/tabs/tabs.cc
@@ -1433,7 +1433,7 @@
       return false;
 
     // Don't let the extension move the tab if the user is dragging tabs.
-    if (!chrome::IsTabStripEditable(source_browser)) {
+    if (!source_browser->window()->IsTabStripEditable()) {
       error_ = keys::kTabStripNotEditableError;
       return false;
     }
@@ -1450,7 +1450,7 @@
       if (!GetBrowserFromWindowID(this, window_id, &target_browser))
         return false;
 
-      if (!chrome::IsTabStripEditable(target_browser)) {
+      if (!target_browser->window()->IsTabStripEditable()) {
         error_ = keys::kTabStripNotEditableError;
         return false;
       }
@@ -1599,7 +1599,7 @@
       return false;
 
     // Don't let the extension remove a tab if the user is dragging tabs around.
-    if (!chrome::IsTabStripEditable(browser)) {
+    if (!browser->window()->IsTabStripEditable()) {
       error_ = keys::kTabStripNotEditableError;
       return false;
     }
diff --git a/chrome/browser/extensions/browser_extension_window_controller.cc b/chrome/browser/extensions/browser_extension_window_controller.cc
index 65552a14..665c5ad7 100644
--- a/chrome/browser/extensions/browser_extension_window_controller.cc
+++ b/chrome/browser/extensions/browser_extension_window_controller.cc
@@ -61,7 +61,7 @@
 bool BrowserExtensionWindowController::CanClose(Reason* reason) const {
   // Don't let an extension remove the window if the user is dragging tabs
   // in that window.
-  if (!chrome::IsTabStripEditable(browser_)) {
+  if (!browser_->window()->IsTabStripEditable()) {
     *reason = extensions::WindowController::REASON_NOT_EDITABLE;
     return false;
   }
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index afb6251..a14c22d 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -936,8 +936,11 @@
         RestoreTab(tab, tab_index_offset + i, browser, true);
       }
     }
-    return selected_web_contents ?
-        chrome::GetIndexOfTab(browser, selected_web_contents) : 0;
+    if (selected_web_contents) {
+      return browser->tab_strip_model()->
+          GetIndexOfWebContents(selected_web_contents);
+    }
+    return 0;
   }
 
   WebContents* RestoreTab(const SessionTab& tab,
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 ac959e0..cd84bf5 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
@@ -3,13 +3,13 @@
 // found in the LICENSE file.
 
 #include "base/stringprintf.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/browser_tabstrip.h"
 #include "chrome/browser/sync/profile_sync_service_harness.h"
 #include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h"
 #include "chrome/browser/sync/test/integration/sessions_helper.h"
 #include "chrome/browser/sync/test/integration/sync_test.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
 
 using content::OpenURLParams;
 using sessions_helper::GetLocalSession;
@@ -76,7 +76,7 @@
 }
 
 void SessionsSyncPerfTest::RemoveTabs(int profile) {
-  chrome::CloseAllTabs(GetBrowser(profile));
+  GetBrowser(profile)->tab_strip_model()->CloseAllTabs();
 }
 
 int SessionsSyncPerfTest::GetTabCount(int profile) {
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index b3558fa6..5ba7a6e 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -536,7 +536,8 @@
     FindBar* find_bar = window_->CreateFindBar();
     find_bar_controller_.reset(new FindBarController(find_bar));
     find_bar->SetFindBarController(find_bar_controller_.get());
-    find_bar_controller_->ChangeWebContents(chrome::GetActiveWebContents(this));
+    find_bar_controller_->ChangeWebContents(
+        tab_strip_model_->GetActiveWebContents());
     find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true);
   }
   return find_bar_controller_.get();
@@ -558,7 +559,7 @@
 // Browser, State Storage and Retrieval for UI:
 
 gfx::Image Browser::GetCurrentPageIcon() const {
-  WebContents* web_contents = chrome::GetActiveWebContents(this);
+  WebContents* web_contents = tab_strip_model_->GetActiveWebContents();
   // |web_contents| can be NULL since GetCurrentPageIcon() is called by the
   // window during the window's creation (before tabs have been added).
   FaviconTabHelper* favicon_tab_helper =
@@ -567,7 +568,7 @@
 }
 
 string16 Browser::GetWindowTitleForCurrentTab() const {
-  WebContents* contents = chrome::GetActiveWebContents(this);
+  WebContents* contents = tab_strip_model_->GetActiveWebContents();
   string16 title;
 
   // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the
@@ -658,13 +659,13 @@
       content::Source<Browser>(this),
       content::NotificationService::NoDetails());
 
-  chrome::CloseAllTabs(this);
+  tab_strip_model_->CloseAllTabs();
 }
 
 void Browser::OnWindowActivated() {
   // On some platforms we want to automatically reload tabs that are
   // killed when the user selects them.
-  WebContents* contents = chrome::GetActiveWebContents(this);
+  WebContents* contents = tab_strip_model_->GetActiveWebContents();
   if (contents && ShouldReloadCrashedTab(contents))
     chrome::Reload(this, CURRENT_TAB);
 }
@@ -794,7 +795,7 @@
   // OTOH, if "auto detect" is turned off, we don't change the currently
   // active encoding.
   if (encoding_auto_detect_.GetValue()) {
-    WebContents* contents = chrome::GetActiveWebContents(this);
+    WebContents* contents = tab_strip_model_->GetActiveWebContents();
     if (contents)
       contents->ResetOverrideEncoding();
   }
@@ -804,7 +805,7 @@
   content::RecordAction(UserMetricsAction("OverrideEncoding"));
   const std::string selected_encoding =
       CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id);
-  WebContents* contents = chrome::GetActiveWebContents(this);
+  WebContents* contents = tab_strip_model_->GetActiveWebContents();
   if (!selected_encoding.empty() && contents)
      contents->SetOverrideEncoding(selected_encoding);
   // Update the list of recently selected encodings.
@@ -822,7 +823,7 @@
   content::RecordAction(UserMetricsAction("OpenFile"));
   select_file_dialog_ = ui::SelectFileDialog::Create(
       this, new ChromeSelectFilePolicy(
-          chrome::GetActiveWebContents(this)));
+          tab_strip_model_->GetActiveWebContents()));
 
   const FilePath directory = profile_->last_selected_directory();
 
@@ -990,7 +991,8 @@
                                          bool user_initiated) {
   tab_strip_model_->TabNavigating(contents, transition);
 
-  bool contents_is_selected = contents == chrome::GetActiveTabContents(this);
+  bool contents_is_selected =
+      contents == tab_strip_model_->GetActiveTabContents();
   if (user_initiated && contents_is_selected && window()->GetLocationBar()) {
     // Forcibly reset the location bar if the url is going to change in the
     // current tab, since otherwise it won't discard any ongoing user edits,
@@ -1130,9 +1132,8 @@
     status_bubble->Hide();
 
     // Show the loading state (if any).
-    status_bubble->SetStatus(
-        CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))->
-            GetStatusText());
+    status_bubble->SetStatus(CoreTabHelper::FromWebContents(
+        tab_strip_model_->GetActiveWebContents())->GetStatusText());
   }
 
   if (HasFindBarController()) {
@@ -1284,7 +1285,7 @@
 WebContents* Browser::OpenURLFromTab(WebContents* source,
                                      const OpenURLParams& params) {
   chrome::NavigateParams nav_params(this, params.url, params.transition);
-  nav_params.source_contents = chrome::GetTabContentsAt(this,
+  nav_params.source_contents = tab_strip_model_->GetTabContentsAt(
       tab_strip_model_->GetIndexOfWebContents(source));
   nav_params.referrer = params.referrer;
   nav_params.extra_headers = params.extra_headers;
@@ -1329,8 +1330,8 @@
 }
 
 void Browser::ActivateContents(WebContents* contents) {
-  chrome::ActivateTabAt(this, tab_strip_model_->GetIndexOfWebContents(contents),
-                        false);
+  tab_strip_model_->ActivateTabAt(
+      tab_strip_model_->GetIndexOfWebContents(contents), false);
   window_->Activate();
 }
 
@@ -1342,14 +1343,13 @@
   window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading());
   window_->UpdateTitleBar();
 
-  WebContents* selected_contents = chrome::GetActiveWebContents(this);
+  WebContents* selected_contents = tab_strip_model_->GetActiveWebContents();
   if (source == selected_contents) {
     bool is_loading = source->IsLoading();
     command_controller_->LoadingStateChanged(is_loading, false);
     if (GetStatusBubble()) {
-      GetStatusBubble()->SetStatus(
-          CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))->
-              GetStatusText());
+      GetStatusBubble()->SetStatus(CoreTabHelper::FromWebContents(
+          tab_strip_model_->GetActiveWebContents())->GetStatusText());
     }
   }
 }
@@ -1377,7 +1377,7 @@
   if (!GetStatusBubble())
     return;
 
-  if (source == chrome::GetActiveWebContents(this)) {
+  if (source == tab_strip_model_->GetActiveWebContents()) {
     PrefService* prefs = profile_->GetPrefs();
     GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages));
   }
@@ -1388,7 +1388,7 @@
   if (!GetStatusBubble())
     return;
 
-  if (source == chrome::GetActiveWebContents(this)) {
+  if (source == tab_strip_model_->GetActiveWebContents()) {
     GetStatusBubble()->MouseMoved(location, !motion);
     if (!motion)
       GetStatusBubble()->SetURL(GURL(), std::string());
@@ -1483,7 +1483,7 @@
 
 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) {
   DCHECK(source);
-  TabContents* tab_contents = chrome::GetTabContentsAt(this,
+  TabContents* tab_contents = tab_strip_model_->GetTabContentsAt(
       tab_strip_model_->GetIndexOfWebContents(source));
   chrome::ViewSource(this, tab_contents);
 }
@@ -1492,7 +1492,7 @@
                                  const GURL& frame_url,
                                  const std::string& frame_content_state) {
   DCHECK(source);
-  TabContents* tab_contents = chrome::GetTabContentsAt(this,
+  TabContents* tab_contents = tab_strip_model_->GetTabContentsAt(
       tab_strip_model_->GetIndexOfWebContents(source));
   chrome::ViewSource(this, tab_contents, frame_url, frame_content_state);
 }
@@ -1577,12 +1577,12 @@
 }
 
 void Browser::DidNavigateMainFramePostCommit(WebContents* web_contents) {
-  if (web_contents == chrome::GetActiveWebContents(this))
+  if (web_contents == tab_strip_model_->GetActiveWebContents())
     UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
 }
 
 void Browser::DidNavigateToPendingEntry(WebContents* web_contents) {
-  if (web_contents == chrome::GetActiveWebContents(this))
+  if (web_contents == tab_strip_model_->GetActiveWebContents())
     UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
 }
 
@@ -1702,7 +1702,7 @@
   if (!web_contents) {
     // Intent is system-caused and the picker will show over the currently
     // active web contents.
-    web_contents = chrome::GetActiveWebContents(this);
+    web_contents = tab_strip_model_->GetActiveWebContents();
   }
   WebIntentPickerController* web_intent_picker_controller =
       WebIntentPickerController::FromWebContents(web_contents);
@@ -1791,7 +1791,7 @@
   tab_strip_model_->SetTabBlocked(index, blocked);
   command_controller_->PrintingStateChanged();
   command_controller_->FullscreenStateChanged();
-  if (!blocked && chrome::GetActiveWebContents(this) == web_contents)
+  if (!blocked && tab_strip_model_->GetActiveWebContents() == web_contents)
     web_contents->Focus();
 }
 
@@ -1818,7 +1818,7 @@
 
 void Browser::URLStarredChanged(content::WebContents* web_contents,
                                 bool starred) {
-  if (web_contents == chrome::GetActiveWebContents(this))
+  if (web_contents == tab_strip_model_->GetActiveWebContents())
     window_->SetStarredState(starred);
 }
 
@@ -1827,7 +1827,7 @@
 
 void Browser::OnZoomChanged(content::WebContents* source,
                             bool can_show_bubble) {
-  if (source == chrome::GetActiveWebContents(this)) {
+  if (source == tab_strip_model_->GetActiveWebContents()) {
     // Only show the zoom bubble for zoom changes in the active window.
     window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive());
   }
@@ -1875,8 +1875,8 @@
       // (NavigationControllers) for convenience, so the notification could
       // actually be for a different window while we're doing asynchronous
       // closing of this one.
-      if (chrome::GetActiveWebContents(this) &&
-          &chrome::GetActiveWebContents(this)->GetController() ==
+      if (tab_strip_model_->GetActiveWebContents() &&
+          &tab_strip_model_->GetActiveWebContents()->GetController() ==
           content::Source<NavigationController>(source).ptr())
         UpdateToolbar(false);
       break;
@@ -1893,10 +1893,10 @@
             content::Details<extensions::UnloadedExtensionInfo>(
                 details)->extension;
         for (int i = tab_strip_model_->count() - 1; i >= 0; --i) {
-          WebContents* tc = chrome::GetTabContentsAt(this, i)->web_contents();
-          if (tc->GetURL().SchemeIs(extensions::kExtensionScheme) &&
-              tc->GetURL().host() == extension->id())
-            chrome::CloseWebContents(this, tc);
+          WebContents* web_contents = tab_strip_model_->GetWebContentsAt(i);
+          if (web_contents->GetURL().SchemeIs(extensions::kExtensionScheme) &&
+              web_contents->GetURL().host() == extension->id())
+            chrome::CloseWebContents(this, web_contents);
         }
       }
       break;
@@ -1927,7 +1927,7 @@
 
     case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: {
       WebContents* web_contents = content::Source<WebContents>(source).ptr();
-      if (web_contents == chrome::GetActiveWebContents(this)) {
+      if (web_contents == tab_strip_model_->GetActiveWebContents()) {
         LocationBar* location_bar = window()->GetLocationBar();
         if (location_bar)
           location_bar->UpdateContentSettingsIcons();
@@ -1969,7 +1969,7 @@
 // Browser, UI update coalescing and handling (private):
 
 void Browser::UpdateToolbar(bool should_restore_state) {
-  window_->UpdateToolbar(chrome::GetActiveTabContents(this),
+  window_->UpdateToolbar(tab_strip_model_->GetActiveTabContents(),
                          should_restore_state);
 }
 
@@ -1985,7 +1985,7 @@
 
   // Do some synchronous updates.
   if (changed_flags & content::INVALIDATE_TYPE_URL &&
-      source == chrome::GetActiveWebContents(this)) {
+      source == tab_strip_model_->GetActiveWebContents()) {
     // Only update the URL for the current tab. Note that we do not update
     // the navigation commands since those would have already been updated
     // synchronously by NavigationStateChanged.
@@ -1997,7 +1997,7 @@
     // immediately start/stop, which gives a more snappy feel. We want to do
     // this for any tab so they start & stop quickly.
     tab_strip_model_->UpdateTabContentsStateAt(
-        chrome::GetIndexOfTab(this, source),
+        tab_strip_model_->GetIndexOfWebContents(source),
         TabStripModelObserver::LOADING_ONLY);
     // The status bubble needs to be updated during INVALIDATE_TYPE_LOAD too,
     // but we do that asynchronously by not stripping INVALIDATE_TYPE_LOAD from
@@ -2010,7 +2010,7 @@
     // the TabStripModel, so we notify the TabStripModel now and notify others
     // asynchronously.
     tab_strip_model_->UpdateTabContentsStateAt(
-        chrome::GetIndexOfTab(this, source),
+        tab_strip_model_->GetIndexOfWebContents(source),
         TabStripModelObserver::TITLE_NOT_LOADING);
   }
 
@@ -2040,7 +2040,7 @@
        i != scheduled_updates_.end(); ++i) {
     bool found = false;
     for (int tab = 0; tab < tab_count(); tab++) {
-      if (chrome::GetWebContentsAt(this, tab) == i->first) {
+      if (tab_strip_model_->GetWebContentsAt(tab) == i->first) {
         found = true;
         break;
       }
@@ -2057,7 +2057,7 @@
     const WebContents* contents = i->first;
     unsigned flags = i->second;
 
-    if (contents == chrome::GetActiveWebContents(this)) {
+    if (contents == tab_strip_model_->GetActiveWebContents()) {
       // Updates that only matter when the tab is selected go here.
 
       if (flags & content::INVALIDATE_TYPE_PAGE_ACTIONS) {
@@ -2067,9 +2067,8 @@
       }
       // Updating the URL happens synchronously in ScheduleUIUpdate.
       if (flags & content::INVALIDATE_TYPE_LOAD && GetStatusBubble()) {
-        GetStatusBubble()->SetStatus(
-            CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))->
-                GetStatusText());
+        GetStatusBubble()->SetStatus(CoreTabHelper::FromWebContents(
+            tab_strip_model_->GetActiveWebContents())->GetStatusText());
       }
 
       if (flags & (content::INVALIDATE_TYPE_TAB |
@@ -2120,7 +2119,7 @@
       SessionServiceFactory::GetForProfileIfExisting(profile());
   if (session_service) {
     for (int i = index; i < tab_count(); ++i) {
-      WebContents* web_contents = chrome::GetWebContentsAt(this, i);
+      WebContents* web_contents = tab_strip_model_->GetWebContentsAt(i);
       if (web_contents) {
         SessionTabHelper* session_tab_helper =
             SessionTabHelper::FromWebContents(web_contents);
@@ -2174,7 +2173,7 @@
     // is the selected tab.  Because saving state can conditionally revert the
     // location bar, saving the current tab's location bar state to a
     // non-selected tab can corrupt both tabs.
-    if (contents == chrome::GetActiveWebContents(this)) {
+    if (contents == tab_strip_model_->GetActiveWebContents()) {
       LocationBar* location_bar = window()->GetLocationBar();
       if (location_bar)
         location_bar->SaveStateToContents(contents);
@@ -2241,7 +2240,7 @@
     state = search_model_->mode().is_ntp() ?
         BookmarkBar::DETACHED : BookmarkBar::SHOW;
   } else {
-    WebContents* web_contents = chrome::GetActiveWebContents(this);
+    WebContents* web_contents = tab_strip_model_->GetActiveWebContents();
     BookmarkTabHelper* bookmark_tab_helper =
         web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL;
     if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar())
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 5aea1b0..74401f7 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -1530,9 +1530,9 @@
   EXPECT_EQ(4, browser()->tab_count());
 
   // Close the additional browsers.
-  chrome::CloseAllTabs(popup_browser);
-  chrome::CloseAllTabs(app_browser);
-  chrome::CloseAllTabs(app_popup_browser);
+  popup_browser->tab_strip_model()->CloseAllTabs();
+  app_browser->tab_strip_model()->CloseAllTabs();
+  app_popup_browser->tab_strip_model()->CloseAllTabs();
 }
 #endif
 
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index bde7ec3..43aa1bb 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -610,7 +610,9 @@
     browser->window()->Show();
 
     // The page transition below is only for the purpose of inserting the tab.
-    AddTab(browser, contents_dupe, content::PAGE_TRANSITION_LINK);
+    browser->tab_strip_model()->AddTabContents(contents_dupe, -1,
+                                               content::PAGE_TRANSITION_LINK,
+                                               TabStripModel::ADD_ACTIVE);
   }
 
   SessionService* session_service =
@@ -1042,7 +1044,9 @@
     b->window()->Show();
 
     // The page transition below is only for the purpose of inserting the tab.
-    AddTab(b, view_source_contents, content::PAGE_TRANSITION_LINK);
+    b->tab_strip_model()->AddTabContents(view_source_contents, -1,
+                                         content::PAGE_TRANSITION_LINK,
+                                         TabStripModel::ADD_ACTIVE);
   }
 
   SessionService* session_service =
diff --git a/chrome/browser/ui/browser_tabstrip.cc b/chrome/browser/ui/browser_tabstrip.cc
index e312dd8c..91604bc9 100644
--- a/chrome/browser/ui/browser_tabstrip.cc
+++ b/chrome/browser/ui/browser_tabstrip.cc
@@ -9,7 +9,6 @@
 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_navigator.h"
-#include "chrome/browser/ui/browser_window.h"
 #include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/common/chrome_switches.h"
@@ -28,11 +27,6 @@
 
 namespace chrome {
 
-int GetIndexOfTab(const Browser* browser,
-                  const content::WebContents* contents) {
-  return browser->tab_strip_model()->GetIndexOfWebContents(contents);
-}
-
 TabContents* GetActiveTabContents(const Browser* browser) {
   return browser->tab_strip_model()->GetActiveTabContents();
 }
@@ -74,10 +68,6 @@
       new_tab_start_time);
 }
 
-bool IsTabStripEditable(Browser* browser) {
-  return browser->window()->IsTabStripEditable();
-}
-
 content::WebContents* AddSelectedTabWithURL(
     Browser* browser,
     const GURL& url,
@@ -88,13 +78,6 @@
   return params.target_contents ? params.target_contents->web_contents() : NULL;
 }
 
-void AddTab(Browser* browser,
-            TabContents* tab_contents,
-            content::PageTransition type) {
-  browser->tab_strip_model()->AddTabContents(tab_contents, -1, type,
-                                             TabStripModel::ADD_ACTIVE);
-}
-
 void AddWebContents(Browser* browser,
                     content::WebContents* source_contents,
                     content::WebContents* new_contents,
@@ -148,8 +131,13 @@
   }
 
   NavigateParams params(browser, new_tab_contents);
-  params.source_contents = source_contents ?
-      GetTabContentsAt(browser, GetIndexOfTab(browser, source_contents)) : NULL;
+  if (source_contents) {
+    TabStripModel* tab_strip_model = browser->tab_strip_model();
+    params.source_contents = tab_strip_model->GetTabContentsAt(
+        tab_strip_model->GetIndexOfWebContents(source_contents));
+  } else {
+    params.source_contents = NULL;
+  }
   params.disposition = disposition;
   params.window_bounds = initial_pos;
   params.window_action = NavigateParams::SHOW_WINDOW;
@@ -168,10 +156,6 @@
       TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
 }
 
-void CloseAllTabs(Browser* browser) {
-  browser->tab_strip_model()->CloseAllTabs();
-}
-
 TabContents* TabContentsFactory(
     Profile* profile,
     content::SiteInstance* site_instance,
diff --git a/chrome/browser/ui/browser_tabstrip.h b/chrome/browser/ui/browser_tabstrip.h
index b0877f9..d3b963d 100644
--- a/chrome/browser/ui/browser_tabstrip.h
+++ b/chrome/browser/ui/browser_tabstrip.h
@@ -25,8 +25,6 @@
 
 namespace chrome {
 
-int GetIndexOfTab(const Browser* browser, const content::WebContents* contents);
-
 TabContents* GetActiveTabContents(const Browser* browser);
 content::WebContents* GetActiveWebContents(const Browser* browser);
 
@@ -39,20 +37,12 @@
 // means to append it to the end of the tab strip.
 void AddBlankTabAt(Browser* browser, int index, bool foreground);
 
-// Used by extensions.
-bool IsTabStripEditable(Browser* browser);
-
 // Adds a selected tab with the specified URL and transition, returns the
 // created TabContents.
 content::WebContents* AddSelectedTabWithURL(Browser* browser,
                                             const GURL& url,
                                             content::PageTransition transition);
 
-// Adds |tab_contents| to |browser|'s tabstrip.
-void AddTab(Browser* browser,
-            TabContents* tab_contents,
-            content::PageTransition type);
-
 // Creates a new tab with the already-created WebContents 'new_contents'.
 // The window for the added contents will be reparented correctly when this
 // method returns.  If |disposition| is NEW_POPUP, |pos| should hold the
@@ -67,8 +57,6 @@
                     bool* was__blocked);
 void CloseWebContents(Browser* browser, content::WebContents* contents);
 
-void CloseAllTabs(Browser* browser);
-
 // Centralized methods for creating a TabContents, configuring and
 // installing all its supporting objects and observers.
 TabContents* TabContentsFactory(
diff --git a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
index 35dd6d30..0408c5a 100644
--- a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
+++ b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
@@ -10,6 +10,7 @@
 #import "chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.h"
 #import "chrome/browser/ui/cocoa/applescript/constants_applescript.h"
 #import "chrome/browser/ui/cocoa/applescript/window_applescript.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/gtest_mac.h"
@@ -35,8 +36,8 @@
   }
 
   // Close the additional browsers.
-  chrome::CloseAllTabs(b1);
-  chrome::CloseAllTabs(b2);
+  b1->tab_strip_model()->CloseAllTabs();
+  b2->tab_strip_model()->CloseAllTabs();
 }
 
 // Insert a new window.
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 90bb372..9dd944a 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -438,7 +438,7 @@
 }
 
 - (void)dealloc {
-  chrome::CloseAllTabs(browser_.get());
+  browser_->tab_strip_model()->CloseAllTabs();
   [downloadShelfController_ exiting];
 
   // Explicitly release |presentationModeController_| here, as it may call back
diff --git a/chrome/browser/ui/cocoa/cocoa_profile_test.mm b/chrome/browser/ui/cocoa/cocoa_profile_test.mm
index 94a14fb..f236bcc 100644
--- a/chrome/browser/ui/cocoa/cocoa_profile_test.mm
+++ b/chrome/browser/ui/cocoa/cocoa_profile_test.mm
@@ -9,6 +9,7 @@
 #include "chrome/browser/search_engines/template_url_service_factory.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/test/base/testing_browser_process.h"
 #include "content/public/test/test_browser_thread.h"
 
@@ -85,7 +86,7 @@
 void CocoaProfileTest::CloseBrowserWindow() {
   // Check to make sure a window was actually created.
   DCHECK(browser_->window());
-  chrome::CloseAllTabs(browser_.get());
+  browser_->tab_strip_model()->CloseAllTabs();
   chrome::CloseWindow(browser_.get());
   // |browser_| will be deleted by its BrowserWindowController.
   ignore_result(browser_.release());
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index b8f5a2ff..4ff41ba 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -1249,7 +1249,8 @@
   NSInteger activeIndex = [self indexFromModelIndex:modelIndex];
 
   if (oldContents) {
-    int oldModelIndex = chrome::GetIndexOfTab(browser_, oldContents);
+    int oldModelIndex =
+        browser_->tab_strip_model()->GetIndexOfWebContents(oldContents);
     if (oldModelIndex != -1) {  // When closing a tab, the old tab may be gone.
       NSInteger oldIndex = [self indexFromModelIndex:oldModelIndex];
       TabContentsController* oldController =
diff --git a/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc b/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc
index 9c4966c..77d6df0 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc
@@ -13,6 +13,7 @@
 #include "chrome/browser/ui/browser_commands.h"
 #include "chrome/browser/ui/browser_tabstrip.h"
 #include "chrome/browser/ui/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/test/base/browser_with_test_window_test.h"
@@ -68,7 +69,7 @@
   EXPECT_EQ(4U, CountAllTabs());
 
   // Close some tabs.
-  chrome::CloseAllTabs(browser2.get());
+  browser2->tab_strip_model()->CloseAllTabs();
 
   EXPECT_EQ(1U, CountAllTabs());
 
@@ -78,7 +79,7 @@
 
   EXPECT_EQ(42U, CountAllTabs());
   // Close all remaining tabs to keep all the destructors happy.
-  chrome::CloseAllTabs(browser3.get());
+  browser3->tab_strip_model()->CloseAllTabs();
 }
 
 TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) {
@@ -115,7 +116,7 @@
   }
 
   // Close some tabs.
-  chrome::CloseAllTabs(browser2.get());
+  browser2->tab_strip_model()->CloseAllTabs();
 
   count = 0;
   for (TabContentsIterator iterator; !iterator.done(); ++iterator, ++count) {
@@ -142,8 +143,8 @@
   }
 
   // Close all remaining tabs to keep all the destructors happy.
-  chrome::CloseAllTabs(browser2.get());
-  chrome::CloseAllTabs(browser3.get());
+  browser2->tab_strip_model()->CloseAllTabs();
+  browser3->tab_strip_model()->CloseAllTabs();
 }
 
 #if defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/tabs/pinned_tab_service_unittest.cc b/chrome/browser/ui/tabs/pinned_tab_service_unittest.cc
index dd5935d..714268b 100644
--- a/chrome/browser/ui/tabs/pinned_tab_service_unittest.cc
+++ b/chrome/browser/ui/tabs/pinned_tab_service_unittest.cc
@@ -65,7 +65,7 @@
   EXPECT_EQ("http://www.google.com/::pinned:", result);
 
   // Close the popup. This shouldn't reset the saved state.
-  chrome::CloseAllTabs(popup.get());
+  popup->tab_strip_model()->CloseAllTabs();
   popup.reset(NULL);
 
   // Check the state to make sure it hasn't changed.
diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
index dc60b5b..624fd6bd 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
@@ -15,6 +15,7 @@
 #include "chrome/browser/profiles/profile_manager.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/url_constants.h"
 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
 #include "chrome/test/base/test_browser_window.h"
@@ -566,7 +567,7 @@
                       new_icon_bitmap.getSize()));
 
   // Make sure the browser deconstructor doesn't have problems.
-  chrome::CloseAllTabs(browser.get());
+  browser->tab_strip_model()->CloseAllTabs();
   // This is required to prevent the message loop from hanging.
   profile()->DestroyHistoryService();
 }
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index dd8b5fc0..0d051e4 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -16,6 +16,7 @@
 #include "chrome/browser/ui/browser.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/browser/ui/views/bookmarks/bookmark_bar_view.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/pref_names.h"
@@ -157,7 +158,7 @@
   virtual void TearDown() {
     // Destroy everything, then run the message loop to ensure we delete all
     // Tasks and fully shut down.
-    chrome::CloseAllTabs(browser_.get());
+    browser_->tab_strip_model()->CloseAllTabs();
     bb_view_.reset();
     browser_.reset();
     profile_.reset();
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 3bc661d5..8ce10cb 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
@@ -16,6 +16,7 @@
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_tabstrip.h"
 #include "chrome/browser/ui/tab_contents/tab_contents.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"
 #include "chrome/test/base/ui_test_utils.h"
@@ -284,7 +285,7 @@
 void NetInternalsTest::MessageHandler::CloseIncognitoBrowser(
     const ListValue* list_value) {
   ASSERT_TRUE(incognito_browser_);
-  chrome::CloseAllTabs(incognito_browser_);
+  incognito_browser_->tab_strip_model()->CloseAllTabs();
   // Closing all a Browser's tabs will ultimately result in its destruction,
   // thought it may not have been destroyed yet.
   incognito_browser_ = NULL;
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index cc1eb29..3276f6f 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -151,7 +151,7 @@
   if (browser_.get()) {
     // Make sure we close all tabs, otherwise Browser isn't happy in its
     // destructor.
-    chrome::CloseAllTabs(browser());
+    browser()->tab_strip_model()->CloseAllTabs();
     browser_.reset(NULL);
   }
   window_.reset(NULL);