Remove active_index from Browser.

BUG=167548
TEST=no functional change


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176621 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc
index e0a357f..a65cbaf 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc
@@ -1233,9 +1233,10 @@
   for (BrowserList::const_reverse_iterator it =
            BrowserList::begin_last_active();
        it != BrowserList::end_last_active(); ++it, ++index) {
-    Browser *browser = *it;
-    WebContents* web_contents = browser->tab_strip_model()->GetWebContentsAt(
-        browser->active_index());
+    Browser* browser = *it;
+    TabStripModel* tab_strip = browser->tab_strip_model();
+    WebContents* web_contents =
+        tab_strip->GetWebContentsAt(tab_strip->active_index());
     FaviconTabHelper* favicon_tab_helper =
         FaviconTabHelper::FromWebContents(web_contents);
     gfx::Image app_icon = favicon_tab_helper->GetFavicon();
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 073af7b..5c4daaf 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -752,13 +752,6 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// Browser, TabStripModel pass-thrus:
-
-int Browser::active_index() const {
-  return tab_strip_model_->active_index();
-}
-
-////////////////////////////////////////////////////////////////////////////////
 // Browser, Tab adding/showing functions:
 
 void Browser::WindowFullscreenStateChanged() {
@@ -1096,7 +1089,8 @@
   SessionService* session_service =
       SessionServiceFactory::GetForProfileIfExisting(profile_);
   if (session_service && !tab_strip_model_->closing_all()) {
-    session_service->SetSelectedTabInWindow(session_id(), active_index());
+    session_service->SetSelectedTabInWindow(session_id(),
+                                            tab_strip_model_->active_index());
   }
 
   UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH);
@@ -1123,7 +1117,9 @@
       SessionServiceFactory::GetForProfile(profile_);
   if (session_service)
     session_service->TabClosing(old_contents);
-  TabInsertedAt(new_contents, index, (index == active_index()));
+  TabInsertedAt(new_contents,
+                index,
+                (index == tab_strip_model_->active_index()));
 
   int entry_count = new_contents->GetController().GetEntryCount();
   if (entry_count > 0) {
@@ -2177,7 +2173,7 @@
   SetAsDelegate(contents, NULL);
   RemoveScheduledUpdatesFor(contents);
 
-  if (find_bar_controller_.get() && index == active_index()) {
+  if (find_bar_controller_.get() && index == tab_strip_model_->active_index()) {
     find_bar_controller_->ChangeWebContents(NULL);
   }
 
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index e946691..42dd223a 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -248,6 +248,7 @@
   BrowserWindow* window() const { return window_; }
   ToolbarModel* toolbar_model() { return toolbar_model_.get(); }
   const ToolbarModel* toolbar_model() const { return toolbar_model_.get(); }
+  TabStripModel* tab_strip_model() const { return tab_strip_model_.get(); }
   chrome::BrowserCommandController* command_controller() {
     return command_controller_.get();
   }
@@ -326,11 +327,7 @@
   DownloadClosePreventionType OkToCloseWithInProgressDownloads(
       int* num_downloads_blocking) const;
 
-  // TabStripModel pass-thrus /////////////////////////////////////////////////
-
-  TabStripModel* tab_strip_model() const { return tab_strip_model_.get(); }
-
-  int active_index() const;
+  // Tab adding/showing functions /////////////////////////////////////////////
 
   // Invoked when the fullscreen state of the window changes.
   // BrowserWindow::EnterFullscreen invokes this after the window has become
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index a895ecf..65302f5 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -551,7 +551,7 @@
 
 void DuplicateTab(Browser* browser) {
   content::RecordAction(UserMetricsAction("Duplicate"));
-  DuplicateTabAt(browser, browser->active_index());
+  DuplicateTabAt(browser, browser->tab_strip_model()->active_index());
 }
 
 bool CanDuplicateTab(const Browser* browser) {
@@ -622,8 +622,9 @@
 
 void ConvertPopupToTabbedBrowser(Browser* browser) {
   content::RecordAction(UserMetricsAction("ShowAsTab"));
+  TabStripModel* tab_strip = browser->tab_strip_model();
   WebContents* contents =
-      browser->tab_strip_model()->DetachWebContentsAt(browser->active_index());
+      tab_strip->DetachWebContentsAt(tab_strip->active_index());
   Browser* b = new Browser(Browser::CreateParams(browser->profile(),
                                                  browser->host_desktop_type()));
   b->tab_strip_model()->AppendWebContents(contents, true);
diff --git a/chrome/browser/ui/browser_focus_uitest.cc b/chrome/browser/ui/browser_focus_uitest.cc
index 3f9f689..bf518ba 100644
--- a/chrome/browser/ui/browser_focus_uitest.cc
+++ b/chrome/browser/ui/browser_focus_uitest.cc
@@ -949,14 +949,14 @@
                                    content::PAGE_TRANSITION_TYPED, GURL());
 
   // Make sure the second tab is selected.
-  EXPECT_EQ(1, browser()->active_index());
+  EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
 
   // The tab contents should have the focus in the second tab.
   EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
 
   // Go back to the first tab. The focus should not be in the omnibox.
   chrome::SelectPreviousTab(browser());
-  EXPECT_EQ(0, browser()->active_index());
+  EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
   EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
                                             VIEW_ID_LOCATION_BAR));
 }
diff --git a/chrome/browser/ui/browser_tabrestore.cc b/chrome/browser/ui/browser_tabrestore.cc
index 85cb7f5..0e96e0d0 100644
--- a/chrome/browser/ui/browser_tabrestore.cc
+++ b/chrome/browser/ui/browser_tabrestore.cc
@@ -147,13 +147,13 @@
 
   // ReplaceWebContentsAt won't animate in the restoration, so manually do the
   // equivalent of ReplaceWebContentsAt.
-  int insertion_index = browser->active_index();
-  browser->tab_strip_model()->InsertWebContentsAt(
-      insertion_index + 1,
-      web_contents,
-      TabStripModel::ADD_ACTIVE | TabStripModel::ADD_INHERIT_GROUP);
-  browser->tab_strip_model()->CloseWebContentsAt(
-      insertion_index, TabStripModel::CLOSE_NONE);
+  TabStripModel* tab_strip = browser->tab_strip_model();
+  int insertion_index = tab_strip->active_index();
+  tab_strip->InsertWebContentsAt(insertion_index + 1,
+                                 web_contents,
+                                 TabStripModel::ADD_ACTIVE |
+                                 TabStripModel::ADD_INHERIT_GROUP);
+  tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE);
 }
 
 }  // namespace chrome
diff --git a/chrome/browser/ui/cocoa/applescript/window_applescript.mm b/chrome/browser/ui/cocoa/applescript/window_applescript.mm
index 1d42f15..abb38d4 100644
--- a/chrome/browser/ui/cocoa/applescript/window_applescript.mm
+++ b/chrome/browser/ui/cocoa/applescript/window_applescript.mm
@@ -106,7 +106,7 @@
 
 - (NSNumber*)activeTabIndex {
   // Note: applescript is 1-based, that is lists begin with index 1.
-  int activeTabIndex = browser_->active_index() + 1;
+  int activeTabIndex = browser_->tab_strip_model()->active_index() + 1;
   if (!activeTabIndex) {
     return nil;
   }
diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc
index 4dbcfe1..618b7a5 100644
--- a/chrome/browser/ui/gtk/browser_titlebar.cc
+++ b/chrome/browser/ui/gtk/browser_titlebar.cc
@@ -874,7 +874,7 @@
 
 gboolean BrowserTitlebar::OnScroll(GtkWidget* widget, GdkEventScroll* event) {
   Browser* browser = browser_window_->browser();
-  int index = browser->active_index();
+  int index = browser->tab_strip_model()->active_index();
   if (event->direction == GDK_SCROLL_LEFT ||
       event->direction == GDK_SCROLL_UP) {
     if (index != 0)
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 65be17ec..6fc5e13 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -1195,7 +1195,7 @@
   // the model has already removed |contents| from its list, so
   // chrome::GetActiveWebContents(browser_.get()) will return NULL or something
   // else.
-  if (index == browser_->active_index()) {
+  if (index == browser_->tab_strip_model()->active_index()) {
     infobar_container_->ChangeInfoBarService(NULL);
     UpdateDevToolsForContents(NULL);
   }
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index f7c5e46..f3bf790 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -403,13 +403,13 @@
 
     // Select the first Tab.
     ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_1, kCtrlOrCmdMask));
-    ASSERT_EQ(0, browser()->active_index());
+    ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
 
     chrome::FocusLocationBar(browser());
 
     // Select the second Tab.
     ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_2, kCtrlOrCmdMask));
-    ASSERT_EQ(1, browser()->active_index());
+    ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
 
     chrome::FocusLocationBar(browser());
 
diff --git a/chrome/browser/ui/views/ash/tab_scrubber.cc b/chrome/browser/ui/views/ash/tab_scrubber.cc
index 6a92bf1..04258140fb 100644
--- a/chrome/browser/ui/views/ash/tab_scrubber.cc
+++ b/chrome/browser/ui/views/ash/tab_scrubber.cc
@@ -77,7 +77,8 @@
   if (!scrubbing_) {
     scrubbing_ = true;
     browser_ = browser;
-    Tab* initial_tab = tab_strip->tab_at(browser_->active_index());
+    Tab* initial_tab =
+        tab_strip->tab_at(browser_->tab_strip_model()->active_index());
     scroll_x_ = initial_tab->x();
     scroll_x_ += (x_offset < 0) ?
         kInitialTabOffset : initial_tab->width() - kInitialTabOffset;
diff --git a/chrome/browser/ui/views/constrained_window_views_browsertest.cc b/chrome/browser/ui/views/constrained_window_views_browsertest.cc
index 160b703..b2c2567f 100644
--- a/chrome/browser/ui/views/constrained_window_views_browsertest.cc
+++ b/chrome/browser/ui/views/constrained_window_views_browsertest.cc
@@ -174,7 +174,8 @@
   EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(),
             focus_manager->GetFocusedView());
 
-  int tab_with_constrained_window = browser()->active_index();
+  int tab_with_constrained_window =
+      browser()->tab_strip_model()->active_index();
 
   // Create a new tab.
   chrome::NewTab(browser());
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 1f454c9b..6761807 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1583,7 +1583,7 @@
   // We use index here rather than comparing |contents| because by this time
   // the model has already removed |contents| from its list, so
   // browser_->GetActiveWebContents() will return NULL or something else.
-  if (index == browser_->active_index()) {
+  if (index == browser_->tab_strip_model()->active_index()) {
     // We need to reset the current tab contents to NULL before it gets
     // freed. This is because the focus manager performs some operations
     // on the selected WebContents when it is removed.
diff --git a/chrome/browser/ui/views/keyboard_access_browsertest.cc b/chrome/browser/ui/views/keyboard_access_browsertest.cc
index 66df9d7..0691737 100644
--- a/chrome/browser/ui/views/keyboard_access_browsertest.cc
+++ b/chrome/browser/ui/views/keyboard_access_browsertest.cc
@@ -10,6 +10,7 @@
 #include "base/message_loop.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/browser/ui/views/frame/browser_view.h"
 #include "chrome/browser/ui/views/toolbar_view.h"
 #include "chrome/common/chrome_notification_types.h"
@@ -141,7 +142,7 @@
   ui_test_utils::NavigateToURL(browser(), GURL("about:"));
 
   // The initial tab index should be 0.
-  ASSERT_EQ(0, browser()->active_index());
+  ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
 
   ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
 
@@ -194,7 +195,7 @@
   new_tab_observer.Wait();
 
   // Make sure that the new tab index is 1.
-  ASSERT_EQ(1, browser()->active_index());
+  ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
 }
 
 // http://crbug.com/62310.
@@ -250,16 +251,16 @@
 
   ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
       browser(), ui::VKEY_TAB, true, false, false, false));
-  ASSERT_EQ(0, browser()->active_index());
+  ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
 
   ui_test_utils::NavigateToURLWithDisposition(
       browser(), url, NEW_FOREGROUND_TAB,
       ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
-  ASSERT_EQ(2, browser()->active_index());
+  ASSERT_EQ(2, browser()->tab_strip_model()->active_index());
 
   ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
       browser(), ui::VKEY_W, true, false, false, false));
-  ASSERT_EQ(0, browser()->active_index());
+  ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
 }
 
 }  // namespace
diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc b/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
index 1aecad8..b826912 100644
--- a/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
+++ b/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
@@ -171,7 +171,7 @@
                    auth_requestor_2_));
     selector_2_->Init();
 
-    EXPECT_EQ(2, browser()->active_index());
+    EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
     EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert());
     EXPECT_EQ(mit_davidben_cert_.get(), selector_2_->GetSelectedCert());
   }
diff --git a/chrome/browser/ui/webui/feedback_ui.cc b/chrome/browser/ui/webui/feedback_ui.cc
index f5ff29f..a23d678 100644
--- a/chrome/browser/ui/webui/feedback_ui.cc
+++ b/chrome/browser/ui/webui/feedback_ui.cc
@@ -227,7 +227,8 @@
 
   std::string feedback_url = std::string(chrome::kChromeUIFeedbackURL) + "?" +
       kSessionIDParameter + base::IntToString(browser->session_id().id()) +
-      "&" + kTabIndexParameter + base::IntToString(browser->active_index()) +
+      "&" + kTabIndexParameter +
+      base::IntToString(browser->tab_strip_model()->active_index()) +
       "&" + kDescriptionParameter +
       net::EscapeUrlEncodedData(description_template, false) + "&" +
       kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false);