summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/autocomplete_browsertest.cc2
-rw-r--r--chrome/browser/automation/automation_provider.cc4
-rw-r--r--chrome/browser/browser.cc70
-rw-r--r--chrome/browser/browser.h20
-rw-r--r--chrome/browser/browser_browsertest.cc20
-rw-r--r--chrome/browser/browser_focus_uitest.cc9
-rw-r--r--chrome/browser/browser_init.cc7
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm8
-rw-r--r--chrome/browser/debugger/devtools_window.cc3
-rw-r--r--chrome/browser/dom_ui/filebrowse_ui.cc8
-rw-r--r--chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc3
-rw-r--r--chrome/browser/dom_ui/mediaplayer_ui.cc4
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc2
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc9
-rw-r--r--chrome/browser/find_bar_host_browsertest.cc11
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc2
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc18
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.cc7
-rw-r--r--chrome/browser/importer/importer.cc4
-rw-r--r--chrome/browser/platform_util_chromeos.cc8
-rw-r--r--chrome/browser/sessions/session_restore.cc4
-rw-r--r--chrome/browser/sessions/session_restore_browsertest.cc4
-rw-r--r--chrome/browser/ssl/ssl_browser_tests.cc10
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc44
-rw-r--r--chrome/browser/tabs/tab_strip_model.h60
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc185
-rw-r--r--chrome/browser/task_manager_browsertest.cc4
-rw-r--r--chrome/browser/views/app_launcher.cc21
-rw-r--r--chrome/browser/views/find_bar_host_interactive_uitest.cc2
-rw-r--r--chrome/browser/views/tabs/browser_tab_strip_controller.cc4
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc18
-rw-r--r--chrome/browser/views/tabs/tab_strip_interactive_uitest.cc2
-rw-r--r--chrome/test/browser_with_test_window_test.cc2
-rw-r--r--chrome/test/in_process_browser_test.cc2
34 files changed, 325 insertions, 256 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc
index 742d6d6..a9e25df 100644
--- a/chrome/browser/autocomplete/autocomplete_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc
@@ -136,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) {
location_bar->location_entry()->SetUserText(L"");
browser()->AddTabWithURL(
GURL(chrome::kAboutBlankURL), GURL(), PageTransition::START_PAGE,
- -1, Browser::ADD_SELECTED, NULL, std::string());
+ -1, TabStripModel::ADD_SELECTED, NULL, std::string());
ui_test_utils::WaitForNavigation(
&browser()->GetSelectedTabContents()->controller());
EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL),
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 6692f09..621c80c 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -580,8 +580,8 @@ void AutomationProvider::AppendTab(int handle, const GURL& url,
Browser* browser = browser_tracker_->GetResource(handle);
observer = AddTabStripObserver(browser, reply_message);
TabContents* tab_contents = browser->AddTabWithURL(
- url, GURL(), PageTransition::TYPED, -1, Browser::ADD_SELECTED, NULL,
- std::string());
+ url, GURL(), PageTransition::TYPED, -1, TabStripModel::ADD_SELECTED,
+ NULL, std::string());
if (tab_contents) {
append_tab_response =
GetIndexForNavigationController(&tab_contents->controller(), browser);
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 3ef03bb..753fc57 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -431,7 +431,7 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
browser = Browser::Create(off_the_record_profile);
// TODO(eroman): should we have referrer here?
browser->AddTabWithURL(
- url, GURL(), PageTransition::LINK, -1, Browser::ADD_SELECTED, NULL,
+ url, GURL(), PageTransition::LINK, -1, TabStripModel::ADD_SELECTED, NULL,
std::string());
browser->window()->Show();
}
@@ -564,8 +564,8 @@ TabContents* Browser::OpenApplicationWindow(
Browser* browser = Browser::CreateForApp(app_name, extension, profile,
as_panel);
TabContents* tab_contents = browser->AddTabWithURL(
- url, GURL(), PageTransition::START_PAGE, -1, Browser::ADD_SELECTED, NULL,
- std::string());
+ url, GURL(), PageTransition::START_PAGE, -1, TabStripModel::ADD_SELECTED,
+ NULL, std::string());
tab_contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
tab_contents->render_view_host()->SyncRendererPrefs();
@@ -873,19 +873,12 @@ TabContents* Browser::AddTabWithURL(const GURL& url,
contents = CreateTabContentsForURL(url_to_load, referrer, profile_,
transition, false, instance);
contents->SetExtensionAppById(extension_app_id);
- // TODO(sky): TabStripModel::AddTabContents should take add_types directly.
- tabstrip_model_.AddTabContents(contents, index,
- (add_types & ADD_FORCE_INDEX) != 0,
- transition,
- (add_types & ADD_SELECTED) != 0);
- tabstrip_model_.SetTabPinned(
- tabstrip_model_.GetIndexOfTabContents(contents),
- (add_types & ADD_PINNED) != 0);
-
+ tabstrip_model_.AddTabContents(contents, index, transition, add_types);
+ // TODO(sky): figure out why this is needed. Without it we seem to get
+ // failures in startup tests.
// By default, content believes it is not hidden. When adding contents
// in the background, tell it that it's hidden.
- if ((add_types & ADD_SELECTED) == 0) {
- // TODO(sky): see if this is really needed. I suspect not as
+ if ((add_types & TabStripModel::ADD_SELECTED) == 0) {
// TabStripModel::AddTabContents invokes HideContents if not foreground.
contents->WasHidden();
}
@@ -905,7 +898,8 @@ TabContents* Browser::AddTabWithURL(const GURL& url,
TabContents* Browser::AddTab(TabContents* tab_contents,
PageTransition::Type type) {
- tabstrip_model_.AddTabContents(tab_contents, -1, false, type, true);
+ tabstrip_model_.AddTabContents(
+ tab_contents, -1, type, TabStripModel::ADD_SELECTED);
return tab_contents;
}
@@ -949,7 +943,9 @@ TabContents* Browser::AddRestoredTab(
bool really_pin =
(pin && tab_index == tabstrip_model()->IndexOfFirstNonMiniTab());
- tabstrip_model_.InsertTabContentsAt(tab_index, new_tab, select, false);
+ tabstrip_model_.InsertTabContentsAt(
+ tab_index, new_tab,
+ select ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE);
if (really_pin)
tabstrip_model_.SetTabPinned(tab_index, true);
if (select) {
@@ -1022,8 +1018,8 @@ void Browser::ShowSingletonTab(const GURL& url) {
}
// Otherwise, just create a new tab.
- AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK,
- -1, Browser::ADD_SELECTED, NULL, std::string());
+ AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, -1,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
}
void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) {
@@ -1099,8 +1095,10 @@ TabContents* Browser::GetOrCloneTabForDisposition(
TabContents* current_tab = GetSelectedTabContents();
if (ShouldOpenNewTabForWindowDisposition(disposition)) {
current_tab = current_tab->Clone();
- tabstrip_model_.AddTabContents(current_tab, -1, false, PageTransition::LINK,
- disposition == NEW_FOREGROUND_TAB);
+ tabstrip_model_.AddTabContents(
+ current_tab, -1, PageTransition::LINK,
+ disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED :
+ TabStripModel::ADD_NONE);
}
return current_tab;
}
@@ -1806,8 +1804,8 @@ void Browser::OpenUpdateChromeDialog() {
void Browser::OpenHelpTab() {
GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kHelpContentUrl));
- AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK,
- -1, Browser::ADD_SELECTED, NULL, std::string());
+ AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, -1,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
}
void Browser::OpenThemeGalleryTabAndActivate() {
@@ -2138,7 +2136,7 @@ TabContents* Browser::AddBlankTabAt(int index, bool foreground) {
base::TimeTicks new_tab_start_time = base::TimeTicks::Now();
TabContents* tab_contents = AddTabWithURL(
GURL(chrome::kChromeUINewTabURL), GURL(), PageTransition::TYPED, index,
- foreground ? Browser::ADD_SELECTED : Browser::ADD_NONE, NULL,
+ foreground ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE, NULL,
std::string());
tab_contents->set_new_tab_start_time(new_tab_start_time);
return tab_contents;
@@ -2215,8 +2213,10 @@ void Browser::DuplicateContentsAt(int index) {
// window next to the tab being duplicated.
new_contents = contents->Clone();
pinned = tabstrip_model_.IsTabPinned(index);
- tabstrip_model_.InsertTabContentsAt(index + 1, new_contents, true,
- true, pinned);
+ int add_types = TabStripModel::ADD_SELECTED |
+ TabStripModel::ADD_INHERIT_GROUP |
+ (pinned ? TabStripModel::ADD_PINNED : 0);
+ tabstrip_model_.InsertTabContentsAt(index + 1, new_contents, add_types);
} else {
Browser* browser = NULL;
if (type_ & TYPE_APP) {
@@ -2517,8 +2517,8 @@ void Browser::AddNewContents(TabContents* source,
// AddTabContents method does.
if (type_ & TYPE_APP)
transition = PageTransition::START_PAGE;
- b->tabstrip_model()->AddTabContents(new_contents, -1, false, transition,
- true);
+ b->tabstrip_model()->AddTabContents(
+ new_contents, -1, transition, TabStripModel::ADD_SELECTED);
b->window()->Show();
return;
}
@@ -2531,9 +2531,10 @@ void Browser::AddNewContents(TabContents* source,
initial_pos, user_gesture);
browser->window()->Show();
} else if (disposition != SUPPRESS_OPEN) {
- tabstrip_model_.AddTabContents(new_contents, -1, false,
- PageTransition::LINK,
- disposition == NEW_FOREGROUND_TAB);
+ tabstrip_model_.AddTabContents(
+ new_contents, -1, PageTransition::LINK,
+ disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED :
+ TabStripModel::ADD_NONE);
}
}
@@ -3767,8 +3768,9 @@ void Browser::OpenURLAtIndex(TabContents* source,
return;
} else if (disposition == NEW_WINDOW) {
Browser* browser = Browser::Create(profile_);
- int add_types = force_index ? Browser::ADD_FORCE_INDEX : Browser::ADD_NONE;
- add_types |= Browser::ADD_SELECTED;
+ int add_types = force_index ? TabStripModel::ADD_FORCE_INDEX :
+ TabStripModel::ADD_NONE;
+ add_types |= TabStripModel::ADD_SELECTED;
new_contents = browser->AddTabWithURL(url, referrer, transition, index,
add_types, instance, std::string());
browser->window()->Show();
@@ -3803,9 +3805,9 @@ void Browser::OpenURLAtIndex(TabContents* source,
return;
} else if (disposition != SUPPRESS_OPEN) {
int add_types = disposition != NEW_BACKGROUND_TAB ?
- Browser::ADD_SELECTED : Browser::ADD_NONE;
+ TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE;
if (force_index)
- add_types |= Browser::ADD_FORCE_INDEX;
+ add_types |= TabStripModel::ADD_FORCE_INDEX;
new_contents = AddTabWithURL(url, referrer, transition, index, add_types,
instance, std::string());
}
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 6b7671a..e3add6e 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -104,22 +104,6 @@ class Browser : public TabStripModelDelegate,
MAXIMIZED_STATE_UNMAXIMIZED
};
- // Constants passed to AddTabWithURL.
- enum AddTabTypes {
- // Used to indicate nothing special should happen to the newly inserted
- // tab.
- ADD_NONE = 0,
-
- // The tab should be selected.
- ADD_SELECTED = 1 << 0,
-
- // The tab should be pinned.
- ADD_PINNED = 1 << 1,
-
- // See TabStripModel::AddTabContents for details.
- ADD_FORCE_INDEX = 1 << 2,
- };
-
// Constructors, Creation, Showing //////////////////////////////////////////
// Creates a new browser of the given |type| and for the given |profile|. The
@@ -339,8 +323,8 @@ class Browser : public TabStripModelDelegate,
int GetIndexForInsertionDuringRestore(int relative_index);
// Adds a new tab at the specified index. |add_types| is a bitmask of the
- // values defined by AddTabTypes; see AddTabTypes for details. If |instance|
- // is not null, its process will be used to render the tab. If
+ // values defined by TabStripModel::AddTabTypes; see it for details. If
+ // |instance| is not null, its process will be used to render the tab. If
// |extension_app_id| is non-empty the new tab is an app tab.
TabContents* AddTabWithURL(const GURL& url,
const GURL& referrer,
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc
index 4d4773c..a4bfaf9 100644
--- a/chrome/browser/browser_browsertest.cc
+++ b/chrome/browser/browser_browsertest.cc
@@ -113,7 +113,7 @@ class BrowserTest : public ExtensionBrowserTest {
MSG_ROUTING_NONE, NULL);
app_contents->SetExtensionApp(extension_app);
- model->AddTabContents(app_contents, 0, false, 0, false);
+ model->AddTabContents(app_contents, 0, 0, TabStripModel::ADD_NONE);
model->SetTabPinned(0, true);
ui_test_utils::NavigateToURL(browser(), url);
@@ -206,8 +206,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_JavascriptAlertActivatesTab) {
GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
FilePath(kTitle1File)));
ui_test_utils::NavigateToURL(browser(), url);
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED,
- 0, Browser::ADD_SELECTED, NULL, std::string());
+ browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
EXPECT_EQ(2, browser()->tab_count());
EXPECT_EQ(0, browser()->selected_index());
TabContents* second_tab = browser()->GetTabContentsAt(1);
@@ -238,8 +238,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_ThirtyFourTabs) {
// There is one initial tab.
for (int ix = 0; ix != 33; ++ix) {
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED,
- 0, Browser::ADD_SELECTED, NULL, std::string());
+ browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
}
EXPECT_EQ(34, browser()->tab_count());
@@ -473,7 +473,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) {
MSG_ROUTING_NONE, NULL);
app_contents->SetExtensionApp(extension_app);
- model->AddTabContents(app_contents, 0, false, 0, false);
+ model->AddTabContents(app_contents, 0, 0, TabStripModel::ADD_NONE);
model->SetTabPinned(0, true);
ui_test_utils::NavigateToURL(browser(), url);
@@ -571,7 +571,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) {
TabContents* app_contents = new TabContents(browser()->profile(), NULL,
MSG_ROUTING_NONE, NULL);
app_contents->SetExtensionApp(extension_app);
- model->AddTabContents(app_contents, 0, false, 0, false);
+ model->AddTabContents(app_contents, 0, 0, TabStripModel::ADD_NONE);
model->SetTabPinned(0, true);
ui_test_utils::NavigateToURL(browser(), url);
@@ -928,7 +928,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) {
// Now try opening another tab in the popup browser.
popup_browser->AddTabWithURL(
GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
// The popup should still only have one tab.
EXPECT_EQ(1, popup_browser->tab_count());
@@ -945,7 +945,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) {
// Now try opening another tab in the app browser.
app_browser->AddTabWithURL(
GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
// The popup should still only have one tab.
EXPECT_EQ(1, app_browser->tab_count());
@@ -962,7 +962,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) {
// Now try opening another tab in the app popup browser.
app_popup_browser->AddTabWithURL(
GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
// The popup should still only have one tab.
EXPECT_EQ(1, app_popup_browser->tab_count());
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 93f7998..36fe2d5 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -261,7 +261,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) {
// Create several tabs.
for (int i = 0; i < 4; ++i) {
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
}
// Alternate focus for the tab.
@@ -341,8 +341,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) {
browser()->FocusLocationBar();
// Create a 2nd tab.
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED,
- -1, Browser::ADD_SELECTED, NULL, std::string());
+ browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
// Focus should be on the recently opened tab page.
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
@@ -725,7 +725,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) {
// Open about:blank, focus should be on the location bar.
browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK,
- -1, Browser::ADD_SELECTED, NULL, std::string());
+ -1, TabStripModel::ADD_SELECTED, NULL,
+ std::string());
ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
}
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 7c13be2..23a47be 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -751,10 +751,11 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser(
if (!process_startup && !URLRequest::IsHandledURL(tabs[i].url))
continue;
- int add_types = first_tab ? Browser::ADD_SELECTED : Browser::ADD_NONE;
- add_types |= Browser::ADD_FORCE_INDEX;
+ int add_types = first_tab ? TabStripModel::ADD_SELECTED :
+ TabStripModel::ADD_NONE;
+ add_types |= TabStripModel::ADD_FORCE_INDEX;
if (tabs[i].is_pinned)
- add_types |= Browser::ADD_PINNED;
+ add_types |= TabStripModel::ADD_PINNED;
int index = browser->GetIndexForInsertionDuringRestore(i);
TabContents* tab = browser->AddTabWithURL(
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index e721414..930cc23 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -1400,8 +1400,9 @@ private:
// Insert it into this tab strip. We want it in the foreground and to not
// inherit the current tab's group.
- tabStripModel_->InsertTabContentsAt(modelIndex, contents, true, false,
- pinned);
+ tabStripModel_->InsertTabContentsAt(
+ modelIndex, contents,
+ TabStripModel::ADD_SELECTED | (pinned ? TabStripModel::ADD_PINNED : 0));
}
// Called when the tab strip view changes size. As we only registered for
@@ -1640,7 +1641,8 @@ private:
UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs"),
browser_->profile());
browser_->AddTabWithURL(url, GURL(), PageTransition::TYPED, index,
- Browser::ADD_SELECTED | Browser::ADD_FORCE_INDEX,
+ TabStripModel::ADD_SELECTED |
+ TabStripModel::ADD_FORCE_INDEX,
NULL, std::string());
break;
case CURRENT_TAB:
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc
index 3a390d8..56541e7 100644
--- a/chrome/browser/debugger/devtools_window.cc
+++ b/chrome/browser/debugger/devtools_window.cc
@@ -212,7 +212,8 @@ void DevToolsWindow::CreateDevToolsBrowser() {
browser_ = Browser::CreateForDevTools(profile_);
browser_->tabstrip_model()->AddTabContents(
- tab_contents_, -1, false, PageTransition::START_PAGE, true);
+ tab_contents_, -1, PageTransition::START_PAGE,
+ TabStripModel::ADD_SELECTED);
}
BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() {
diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc
index 0436056..69d39bc 100644
--- a/chrome/browser/dom_ui/filebrowse_ui.cc
+++ b/chrome/browser/dom_ui/filebrowse_ui.cc
@@ -732,8 +732,8 @@ void FilebrowseHandler::OpenNewWindow(const Value* value, bool popup) {
browser = BrowserList::GetLastActive();
}
TabContents* contents = browser->AddTabWithURL(
- GURL(path), GURL(), PageTransition::LINK, -1, Browser::ADD_SELECTED,
- NULL, std::string());
+ GURL(path), GURL(), PageTransition::LINK, -1,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
// AddTabWithURL could have picked another Browser instance to create this
// new tab at. So we have to reset the ptr of the browser that we want to
// talk to.
@@ -1100,8 +1100,8 @@ Browser* FileBrowseUI::OpenPopup(Profile* profile,
}
browser->AddTabWithURL(
- GURL(url), GURL(), PageTransition::LINK, -1, Browser::ADD_SELECTED,
- NULL, std::string());
+ GURL(url), GURL(), PageTransition::LINK, -1,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
browser->window()->SetBounds(gfx::Rect(kPopupLeft,
kPopupTop,
width,
diff --git a/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc b/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc
index 6864386..a2ba5eb 100644
--- a/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc
+++ b/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc
@@ -42,7 +42,8 @@ void HtmlDialogTabContentsDelegate::OpenURLFromTab(
Browser* browser = CreateBrowser();
TabContents* new_contents =
browser->AddTabWithURL(url, referrer, transition, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL,
+ std::string());
DCHECK(new_contents);
browser->window()->Show();
new_contents->Focus();
diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc
index b468ad2..9e08f6d 100644
--- a/chrome/browser/dom_ui/mediaplayer_ui.cc
+++ b/chrome/browser/dom_ui/mediaplayer_ui.cc
@@ -503,7 +503,7 @@ void MediaPlayer::PopupPlaylist(Browser* creator) {
playlist_browser_ = Browser::CreateForPopup(profile);
playlist_browser_->AddTabWithURL(
GURL(kMediaplayerPlaylistURL), GURL(), PageTransition::LINK,
- -1, Browser::ADD_SELECTED, NULL, std::string());
+ -1, TabStripModel::ADD_SELECTED, NULL, std::string());
playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft,
kPopupTop,
kPopupWidth,
@@ -535,7 +535,7 @@ void MediaPlayer::PopupMediaPlayer(Browser* creator) {
#endif
mediaplayer_browser_->AddTabWithURL(
GURL(kMediaplayerURL), GURL(), PageTransition::LINK,
- -1, Browser::ADD_SELECTED, NULL, std::string());
+ -1, TabStripModel::ADD_SELECTED, NULL, std::string());
mediaplayer_browser_->window()->SetBounds(gfx::Rect(kPopupLeft,
kPopupTop,
kPopupWidth,
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 0ee4cb8..364d1b4 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -198,7 +198,7 @@ void ExtensionInstallUI::OnInstallSuccess(Extension* extension) {
url += "/#";
url += hash_params;
browser->AddTabWithURL(GURL(url), GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
}
return;
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 0f58360..ce9511c 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -370,7 +370,7 @@ bool CreateWindowFunction::RunImpl() {
Browser* new_window = new Browser(window_type, window_profile);
new_window->CreateBrowserWindow();
new_window->AddTabWithURL(url, GURL(), PageTransition::LINK, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
new_window->window()->SetBounds(bounds);
new_window->window()->Show();
@@ -569,8 +569,9 @@ bool CreateTabFunction::RunImpl() {
index = tab_strip->count();
}
- int add_types = selected ? Browser::ADD_SELECTED : Browser::ADD_NONE;
- add_types |= Browser::ADD_FORCE_INDEX;
+ int add_types = selected ? TabStripModel::ADD_SELECTED :
+ TabStripModel::ADD_NONE;
+ add_types |= TabStripModel::ADD_FORCE_INDEX;
TabContents* contents = browser->AddTabWithURL(url, GURL(),
PageTransition::LINK, index, add_types, NULL, std::string());
index = tab_strip->GetIndexOfTabContents(contents);
@@ -749,7 +750,7 @@ bool MoveTabFunction::RunImpl() {
new_index = target_tab_strip->count();
target_tab_strip->InsertTabContentsAt(new_index, contents,
- false, true);
+ TabStripModel::ADD_NONE);
if (has_callback())
result_.reset(ExtensionTabUtil::CreateTabValue(contents,
diff --git a/chrome/browser/find_bar_host_browsertest.cc b/chrome/browser/find_bar_host_browsertest.cc
index 9f37987..f2314a1 100644
--- a/chrome/browser/find_bar_host_browsertest.cc
+++ b/chrome/browser/find_bar_host_browsertest.cc
@@ -835,7 +835,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) {
// Create a second tab.
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
browser()->SelectTabContentsAt(1, false);
TabContents* tab2 = browser()->GetSelectedTabContents();
EXPECT_NE(tab1, tab2);
@@ -912,7 +912,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateInNewTab) {
// Now create a second tab and load the same page.
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
browser()->SelectTabContentsAt(1, false);
TabContents* tab2 = browser()->GetSelectedTabContents();
EXPECT_NE(tab1, tab2);
@@ -957,7 +957,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) {
// Now create a second tab and load the same page.
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
browser()->SelectTabContentsAt(1, false);
TabContents* tab2 = browser()->GetSelectedTabContents();
EXPECT_NE(tab1, tab2);
@@ -1034,7 +1034,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) {
Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
Browser* incognito_browser = Browser::Create(incognito_profile);
incognito_browser->AddTabWithURL(url, GURL(), PageTransition::START_PAGE, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL,
+ std::string());
ui_test_utils::WaitForNavigation(
&incognito_browser->GetSelectedTabContents()->controller());
incognito_browser->window()->Show();
@@ -1055,7 +1056,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) {
// Now open a new tab in the original (non-incognito) browser.
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
browser()->SelectTabContentsAt(1, false);
TabContents* tab2 = browser()->GetSelectedTabContents();
EXPECT_NE(tab1, tab2);
diff --git a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
index 8550ee1..c04201e 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
@@ -38,7 +38,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkBarGtkBrowserTest, FindBarTest) {
// Create new tab with an arbitrary URL.
GURL url = server->TestServerPage(kSimplePage);
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
// Switch back to the NTP with the active findbar.
browser()->SelectTabContentsAt(1, false);
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
index 5ba1d37..70ecdb8 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -394,8 +394,10 @@ void DraggedTabControllerGtk::Attach(TabStripGtk* attached_tabstrip,
// changing due to animation).
gfx::Rect bounds = GetDraggedTabTabStripBounds(screen_point);
int index = GetInsertionIndexForDraggedBounds(bounds, false);
- attached_tabstrip_->model()->InsertTabContentsAt(index, dragged_contents_,
- true, false, pinned_);
+ attached_tabstrip_->model()->InsertTabContentsAt(
+ index, dragged_contents_,
+ TabStripModel::ADD_SELECTED |
+ (pinned_ ? TabStripModel::ADD_PINNED : 0));
tab = GetTabMatchingDraggedContents(attached_tabstrip_);
}
@@ -616,8 +618,10 @@ void DraggedTabControllerGtk::RevertDrag() {
// TODO(beng): (Cleanup) seems like we should use Attach() for this
// somehow.
attached_tabstrip_ = source_tabstrip_;
- source_tabstrip_->model()->InsertTabContentsAt(source_model_index_,
- dragged_contents_, true, false, pinned_);
+ source_tabstrip_->model()->InsertTabContentsAt(
+ source_model_index_, dragged_contents_,
+ TabStripModel::ADD_SELECTED |
+ (pinned_ ? TabStripModel::ADD_PINNED : 0));
} else {
// The tab was moved within the tabstrip where the drag was initiated.
// Move it back to the starting location.
@@ -631,8 +635,10 @@ void DraggedTabControllerGtk::RevertDrag() {
// The tab was detached from the tabstrip where the drag began, and has not
// been attached to any other tabstrip. We need to put it back into the
// source tabstrip.
- source_tabstrip_->model()->InsertTabContentsAt(source_model_index_,
- dragged_contents_, true, false, pinned_);
+ source_tabstrip_->model()->InsertTabContentsAt(
+ source_model_index_, dragged_contents_,
+ TabStripModel::ADD_SELECTED |
+ (pinned_ ? TabStripModel::ADD_PINNED : 0));
}
// If we're not attached to any tab strip, or attached to some other tab
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
index a05105a..0a86cb8 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
@@ -1611,8 +1611,8 @@ bool TabStripGtk::CompleteDrop(guchar* data) {
model_->delegate()->CreateTabContentsForURL(
url, GURL(), model_->profile(), PageTransition::TYPED, false,
NULL);
- model_->AddTabContents(contents, drop_index, false,
- PageTransition::GENERATED, true);
+ model_->AddTabContents(contents, drop_index, PageTransition::GENERATED,
+ TabStripModel::ADD_SELECTED);
} else {
model_->GetTabContentsAt(drop_index)->controller().LoadURL(
url, GURL(), PageTransition::GENERATED);
@@ -1982,9 +1982,8 @@ void TabStripGtk::OnNewTabClicked(GtkWidget* widget) {
model_->AddTabContents(
contents,
-1, // index
- false, // force_index
PageTransition::TYPED,
- true); // foreground
+ TabStripModel::ADD_SELECTED);
break;
}
default:
diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc
index 348dcba..fcb8f28 100644
--- a/chrome/browser/importer/importer.cc
+++ b/chrome/browser/importer/importer.cc
@@ -199,8 +199,8 @@ void ImporterHost::StartImportSettings(
BrowsingInstance* instance = new BrowsingInstance(writer_->profile());
SiteInstance* site = instance->GetSiteInstanceForURL(url);
Browser* browser = BrowserList::GetLastActive();
- browser->AddTabWithURL(url, GURL(), PageTransition::TYPED,
- -1, Browser::ADD_SELECTED, site, std::string());
+ browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
+ TabStripModel::ADD_SELECTED, site, std::string());
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
this, &ImporterHost::OnLockViewEnd, false));
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc
index 8d18e78..4c0d8cd4 100644
--- a/chrome/browser/platform_util_chromeos.cc
+++ b/chrome/browser/platform_util_chromeos.cc
@@ -81,8 +81,8 @@ void OpenItem(const FilePath& full_path) {
}
Browser* browser = BrowserList::GetLastActive();
browser->AddTabWithURL(
- GURL(path), GURL(), PageTransition::LINK, -1, Browser::ADD_SELECTED,
- NULL, std::string());
+ GURL(path), GURL(), PageTransition::LINK, -1,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
return;
}
if (ext == ".avi" ||
@@ -114,8 +114,8 @@ void OpenItem(const FilePath& full_path) {
static void OpenURL(const std::string& url) {
Browser* browser = BrowserList::GetLastActive();
browser->AddTabWithURL(
- GURL(url), GURL(), PageTransition::LINK, -1, Browser::ADD_SELECTED,
- NULL, std::string());
+ GURL(url), GURL(), PageTransition::LINK, -1,
+ TabStripModel::ADD_SELECTED, NULL, std::string());
}
void OpenExternal(const GURL& url) {
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index 2537411..9a28c71 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -465,9 +465,9 @@ class SessionRestoreImpl : public NotificationObserver {
void AppendURLsToBrowser(Browser* browser,
const std::vector<GURL>& urls) {
for (size_t i = 0; i < urls.size(); ++i) {
- int add_types = Browser::ADD_FORCE_INDEX;
+ int add_types = TabStripModel::ADD_FORCE_INDEX;
if (i == 0)
- add_types |= Browser::ADD_SELECTED;
+ add_types |= TabStripModel::ADD_SELECTED;
int index = browser->GetIndexForInsertionDuringRestore(i);
browser->AddTabWithURL(urls[i], GURL(), PageTransition::START_PAGE, index,
add_types, NULL, std::string());
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc
index 41edc2a..e2752c1 100644
--- a/chrome/browser/sessions/session_restore_browsertest.cc
+++ b/chrome/browser/sessions/session_restore_browsertest.cc
@@ -77,11 +77,11 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) {
// Add and navigate three tabs.
ui_test_utils::NavigateToURL(browser(), url1);
browser()->AddTabWithURL(url2, GURL(), PageTransition::LINK, 1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
ui_test_utils::WaitForNavigationInCurrentTab(browser());
browser()->AddTabWithURL(url3, GURL(), PageTransition::LINK, 2,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
ui_test_utils::WaitForNavigationInCurrentTab(browser());
TabRestoreService* service = browser()->profile()->GetTabRestoreService();
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index e28ef95..10a1200 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -496,8 +496,8 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) {
GURL url = https_server->TestServerPage(
"files/ssl/page_displays_insecure_content.html");
TabContents* tab2 = browser()->AddTabWithURL(url, GURL(),
- PageTransition::TYPED, 0, Browser::ADD_SELECTED, tab1->GetSiteInstance(),
- std::string());
+ PageTransition::TYPED, 0, TabStripModel::ADD_SELECTED,
+ tab1->GetSiteInstance(), std::string());
ui_test_utils::WaitForNavigation(&(tab2->controller()));
// The new tab has insecure content.
@@ -528,8 +528,8 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) {
GURL url =
https_server->TestServerPage("files/ssl/page_runs_insecure_content.html");
TabContents* tab2 = browser()->AddTabWithURL(url, GURL(),
- PageTransition::TYPED, 0, Browser::ADD_SELECTED, tab1->GetSiteInstance(),
- std::string());
+ PageTransition::TYPED, 0, TabStripModel::ADD_SELECTED,
+ tab1->GetSiteInstance(), std::string());
ui_test_utils::WaitForNavigation(&(tab2->controller()));
// The new tab has insecure content.
@@ -692,7 +692,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) {
// the first tab.
GURL url = http_server->TestServerPage("files/ssl/google.html");
TabContents* tab2 = browser()->AddTabWithURL(
- url, GURL(), PageTransition::TYPED, 0, Browser::ADD_SELECTED, NULL,
+ url, GURL(), PageTransition::TYPED, 0, TabStripModel::ADD_SELECTED, NULL,
std::string());
ui_test_utils::WaitForNavigation(&(tab2->controller()));
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 7db00b0..5304100 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -105,18 +105,18 @@ bool TabStripModel::ContainsIndex(int index) const {
}
void TabStripModel::AppendTabContents(TabContents* contents, bool foreground) {
- // Tabs opened in the foreground using this method inherit the group of the
- // previously selected tab.
int index = order_controller_->DetermineInsertionIndexForAppending();
- InsertTabContentsAt(index, contents, foreground, foreground);
+ InsertTabContentsAt(index, contents,
+ foreground ? (ADD_INHERIT_GROUP | ADD_SELECTED) :
+ ADD_NONE);
}
void TabStripModel::InsertTabContentsAt(int index,
TabContents* contents,
- bool foreground,
- bool inherit_group,
- bool pinned) {
- index = ConstrainInsertionIndex(index, contents->is_app() || pinned);
+ int add_types) {
+ bool foreground = add_types & ADD_SELECTED;
+ index = ConstrainInsertionIndex(index, contents->is_app() ||
+ add_types & ADD_PINNED);
// In tab dragging situations, if the last tab in the window was detached
// then the user aborted the drag, we will have the |closing_all_| member
@@ -129,8 +129,8 @@ void TabStripModel::InsertTabContentsAt(int index,
// since the old contents and the new contents will be the same...
TabContents* selected_contents = GetSelectedTabContents();
TabContentsData* data = new TabContentsData(contents);
- data->pinned = pinned;
- if (inherit_group && selected_contents) {
+ data->pinned = (add_types & ADD_PINNED) == ADD_PINNED;
+ if ((add_types & ADD_INHERIT_GROUP) && selected_contents) {
if (foreground) {
// Forget any existing relationships, we don't want to make things too
// confusing by having multiple groups active at the same time.
@@ -150,9 +150,8 @@ void TabStripModel::InsertTabContentsAt(int index,
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
TabInsertedAt(contents, index, foreground));
- if (foreground) {
+ if (foreground)
ChangeSelectedContentsFrom(selected_contents, index, false);
- }
}
void TabStripModel::ReplaceNavigationControllerAt(
@@ -160,7 +159,9 @@ void TabStripModel::ReplaceNavigationControllerAt(
// This appears to be OK with no flicker since no redraw event
// occurs between the call to add an aditional tab and one to close
// the previous tab.
- InsertTabContentsAt(index + 1, controller->tab_contents(), true, true);
+ InsertTabContentsAt(
+ index + 1, controller->tab_contents(),
+ ADD_SELECTED | ADD_INHERIT_GROUP);
std::vector<int> closing_tabs;
closing_tabs.push_back(index);
InternalCloseTabs(closing_tabs, CLOSE_NONE);
@@ -479,24 +480,24 @@ int TabStripModel::ConstrainInsertionIndex(int index, bool mini_tab) {
void TabStripModel::AddTabContents(TabContents* contents,
int index,
- bool force_index,
PageTransition::Type transition,
- bool foreground) {
+ int add_types) {
// If the newly-opened tab is part of the same task as the parent tab, we want
// to inherit the parent's "group" attribute, so that if this tab is then
// closed we'll jump back to the parent tab.
// TODO(jbs): Perhaps instead of trying to infer this we should expose
// inherit_group directly to callers, who may have more context
- bool inherit_group = false;
+ bool inherit_group = (add_types & ADD_INHERIT_GROUP) == ADD_INHERIT_GROUP;
- if (transition == PageTransition::LINK && !force_index) {
+ if (transition == PageTransition::LINK &&
+ (add_types & ADD_FORCE_INDEX) == 0) {
// We assume tabs opened via link clicks are part of the same task as their
// parent. Note that when |force_index| is true (e.g. when the user
// drag-and-drops a link to the tab strip), callers aren't really handling
// link clicks, they just want to score the navigation like a link click in
// the history backend, so we don't inherit the group in this case.
index = order_controller_->DetermineInsertionIndex(
- contents, transition, foreground);
+ contents, transition, add_types & ADD_SELECTED);
inherit_group = true;
} else {
// For all other types, respect what was passed to us, normalizing -1s and
@@ -514,12 +515,17 @@ void TabStripModel::AddTabContents(TabContents* contents,
// is re-selected, not the next-adjacent.
inherit_group = true;
}
- InsertTabContentsAt(index, contents, foreground, inherit_group);
+ InsertTabContentsAt(
+ index, contents,
+ add_types | (inherit_group ? ADD_INHERIT_GROUP : 0));
// Reset the index, just in case insert ended up moving it on us.
index = GetIndexOfTabContents(contents);
+
if (inherit_group && transition == PageTransition::TYPED)
contents_data_.at(index)->reset_group_on_select = true;
+ // TODO(sky): figure out why this is here and not in InsertTabContentsAt. When
+ // here we seem to get failures in startup perf tests.
// Ensure that the new TabContentsView begins at the same size as the
// previous TabContentsView if it existed. Otherwise, the initial WebKit
// layout will be performed based on a width of 0 pixels, causing a
@@ -529,7 +535,7 @@ void TabStripModel::AddTabContents(TabContents* contents,
// layout is performed with sane view dimensions even when we're opening a
// new background tab.
if (TabContents* old_contents = GetSelectedTabContents()) {
- if (!foreground) {
+ if ((add_types & ADD_SELECTED) == 0) {
contents->view()->SizeContents(old_contents->view()->GetContainerSize());
// We need to hide the contents or else we get and execute paints for
// background tabs. With enough background tabs they will steal the
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index 38954f4..f9cb205 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -303,6 +303,29 @@ class TabStripModel : public NotificationObserver {
CLOSE_CREATE_HISTORICAL_TAB = 1 << 1,
};
+ // Constants used when adding tabs.
+ enum AddTabTypes {
+ // Used to indicate nothing special should happen to the newly inserted
+ // tab.
+ ADD_NONE = 0,
+
+ // The tab should be selected.
+ ADD_SELECTED = 1 << 0,
+
+ // The tab should be pinned.
+ ADD_PINNED = 1 << 1,
+
+ // If not set the insertion index of the TabContents is left up to the Order
+ // Controller associated, so the final insertion index may differ from the
+ // specified index. Otherwise the index supplied is used.
+ ADD_FORCE_INDEX = 1 << 2,
+
+ // If set the newly inserted tab inherits the group of the currently
+ // selected tab. If not set the tab may still inherit the group under
+ // certain situations.
+ ADD_INHERIT_GROUP = 1 << 3,
+ };
+
static const int kNoTab = -1;
// Construct a TabStripModel with a delegate to help it do certain things
@@ -360,24 +383,19 @@ class TabStripModel : public NotificationObserver {
// foreground inherit the group of the previously selected tab.
void AppendTabContents(TabContents* contents, bool foreground);
- // TODO(sky): convert callers over to new variant, and consider using a
- // bitmask rather than bools.
- void InsertTabContentsAt(int index,
- TabContents* contents,
- bool foreground,
- bool inherit_group) {
- InsertTabContentsAt(index, contents, foreground, inherit_group, false);
- }
-
- // Adds the specified TabContents in the specified location. If
- // |inherit_group| is true, the new contents is linked to the current tab's
- // group. This adjusts the index such that all app tabs occur before non-app
- // tabs.
+ // Adds the specified TabContents at the specified location. |add_types| is a
+ // bitmask of AddTypes; see it for details.
+ //
+ // All append/insert methods end up in this method.
+ //
+ // NOTE: adding a tab using this method does NOT query the order controller,
+ // as such the ADD_FORCE_INDEX AddType is meaningless here. The only time the
+ // |index| is changed is if using the index would result in breaking the
+ // constraint that all mini-tabs occur before non-mini-tabs.
+ // See also AddTabContents.
void InsertTabContentsAt(int index,
TabContents* contents,
- bool foreground,
- bool inherit_group,
- bool pinned);
+ int add_types);
// Closes the TabContents at the specified index. This causes the TabContents
// to be destroyed, but it may not happen immediately (e.g. if it's a
@@ -546,15 +564,13 @@ class TabStripModel : public NotificationObserver {
// Command level API /////////////////////////////////////////////////////////
// Adds a TabContents at the best position in the TabStripModel given the
- // specified insertion index, transition, etc. If |force_index|
- // is false, the insertion index of the TabContents is left up to the Order
- // Controller associated with this TabStripModel, so the final insertion index
- // may differ from |index|.
+ // specified insertion index, transition, etc. |add_types| is a bitmask of
+ // AddTypes; see it for details. This method ends up calling into
+ // InsertTabContentsAt to do the actual inertion.
void AddTabContents(TabContents* contents,
int index,
- bool force_index,
PageTransition::Type transition,
- bool foreground);
+ int add_types);
// Closes the selected TabContents.
void CloseSelectedTab();
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index 11fb91d..7089226 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -352,7 +352,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) {
// Test InsertTabContentsAt, foreground tab.
TabContents* contents2 = CreateTabContents();
{
- tabstrip.InsertTabContentsAt(1, contents2, true, false);
+ tabstrip.InsertTabContentsAt(1, contents2, TabStripModel::ADD_SELECTED);
EXPECT_EQ(2, tabstrip.count());
EXPECT_EQ(2, observer.GetStateCount());
@@ -368,7 +368,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) {
// Test InsertTabContentsAt, background tab.
TabContents* contents3 = CreateTabContents();
{
- tabstrip.InsertTabContentsAt(2, contents3, false, false);
+ tabstrip.InsertTabContentsAt(2, contents3, TabStripModel::ADD_NONE);
EXPECT_EQ(3, tabstrip.count());
EXPECT_EQ(1, observer.GetStateCount());
@@ -533,11 +533,16 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) {
// We use |InsertTabContentsAt| here instead of AppendTabContents so that
// openership relationships are preserved.
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents1, false, true);
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents2, false, true);
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents3, false, true);
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents4, false, true);
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents5, false, true);
+ tabstrip.InsertTabContentsAt(tabstrip.count(), contents1,
+ TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip.InsertTabContentsAt(tabstrip.count(), contents2,
+ TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip.InsertTabContentsAt(tabstrip.count(), contents3,
+ TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip.InsertTabContentsAt(tabstrip.count(), contents4,
+ TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip.InsertTabContentsAt(tabstrip.count(), contents5,
+ TabStripModel::ADD_INHERIT_GROUP);
// All the tabs should have the same opener.
for (int i = 1; i < tabstrip.count(); ++i)
@@ -580,11 +585,11 @@ static void InsertTabContentses(TabStripModel* tabstrip,
TabContents* contents2,
TabContents* contents3) {
tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents1),
- contents1, false, true);
+ contents1, TabStripModel::ADD_INHERIT_GROUP);
tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents2),
- contents2, false, true);
+ contents2, TabStripModel::ADD_INHERIT_GROUP);
tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents3),
- contents3, false, true);
+ contents3, TabStripModel::ADD_INHERIT_GROUP);
}
// Tests opening background tabs.
@@ -699,7 +704,9 @@ TEST_F(TabStripModelTest, TestInsertionIndexDetermination) {
int insert_index = tabstrip.order_controller()->DetermineInsertionIndex(
fg_link_contents, PageTransition::LINK, true);
EXPECT_EQ(1, insert_index);
- tabstrip.InsertTabContentsAt(insert_index, fg_link_contents, true, true);
+ tabstrip.InsertTabContentsAt(insert_index, fg_link_contents,
+ TabStripModel::ADD_SELECTED |
+ TabStripModel::ADD_INHERIT_GROUP);
EXPECT_EQ(1, tabstrip.selected_index());
EXPECT_EQ(fg_link_contents, tabstrip.GetSelectedTabContents());
@@ -713,7 +720,8 @@ TEST_F(TabStripModelTest, TestInsertionIndexDetermination) {
fg_nonlink_contents, PageTransition::AUTO_BOOKMARK, true);
EXPECT_EQ(tabstrip.count(), insert_index);
// We break the opener relationship...
- tabstrip.InsertTabContentsAt(insert_index, fg_nonlink_contents, false, false);
+ tabstrip.InsertTabContentsAt(insert_index, fg_nonlink_contents,
+ TabStripModel::ADD_NONE);
// Now select it, so that user_gesture == true causes the opener relationship
// to be forgotten...
tabstrip.SelectTabContentsAt(tabstrip.count() - 1, true);
@@ -801,10 +809,12 @@ TEST_F(TabStripModelTest, TestSelectOnClose) {
// Finally test that when a tab has no "siblings" that the opener is
// selected.
TabContents* other_contents = CreateTabContents();
- tabstrip.InsertTabContentsAt(1, other_contents, false, false);
+ tabstrip.InsertTabContentsAt(1, other_contents, TabStripModel::ADD_NONE);
EXPECT_EQ(2, tabstrip.count());
TabContents* opened_contents = CreateTabContents();
- tabstrip.InsertTabContentsAt(2, opened_contents, true, true);
+ tabstrip.InsertTabContentsAt(2, opened_contents,
+ TabStripModel::ADD_SELECTED |
+ TabStripModel::ADD_INHERIT_GROUP);
EXPECT_EQ(2, tabstrip.selected_index());
tabstrip.CloseTabContentsAt(2, TabStripModel::CLOSE_NONE);
EXPECT_EQ(0, tabstrip.selected_index());
@@ -960,12 +970,14 @@ TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
+ homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
+ TabStripModel::ADD_SELECTED);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, false, PageTransition::TYPED, true);
+ typed_page_contents, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
EXPECT_EQ(2, tabstrip.count());
@@ -976,13 +988,16 @@ TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) {
// page.
TabContents* middle_click_contents1 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents1, -1, false, PageTransition::LINK, false);
+ middle_click_contents1, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
TabContents* middle_click_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents2, -1, false, PageTransition::LINK, false);
+ middle_click_contents2, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
TabContents* middle_click_contents3 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents3, -1, false, PageTransition::LINK, false);
+ middle_click_contents3, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
EXPECT_EQ(5, tabstrip.count());
@@ -1024,12 +1039,14 @@ TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
+ homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
+ TabStripModel::ADD_SELECTED);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, false, PageTransition::TYPED, true);
+ typed_page_contents, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
EXPECT_EQ(2, tabstrip.count());
@@ -1038,8 +1055,8 @@ TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) {
// Open a tab by simulating a left click on a link that opens in a new tab.
TabContents* left_click_contents = CreateTabContents();
- tabstrip.AddTabContents(left_click_contents, -1, false, PageTransition::LINK,
- true);
+ tabstrip.AddTabContents(left_click_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_SELECTED);
// Verify the state meets our expectations.
EXPECT_EQ(3, tabstrip.count());
@@ -1072,12 +1089,14 @@ TEST_F(TabStripModelTest, AddTabContents_CreateNewBlankTab) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
+ homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
+ TabStripModel::ADD_SELECTED);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, false, PageTransition::TYPED, true);
+ typed_page_contents, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
EXPECT_EQ(2, tabstrip.count());
@@ -1086,8 +1105,8 @@ TEST_F(TabStripModelTest, AddTabContents_CreateNewBlankTab) {
// Open a new blank tab in the foreground.
TabContents* new_blank_contents = CreateTabContents();
- tabstrip.AddTabContents(new_blank_contents, -1, false, PageTransition::TYPED,
- true);
+ tabstrip.AddTabContents(new_blank_contents, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
// Verify the state of the tabstrip.
EXPECT_EQ(3, tabstrip.count());
@@ -1098,10 +1117,12 @@ TEST_F(TabStripModelTest, AddTabContents_CreateNewBlankTab) {
// Now open a couple more blank tabs in the background.
TabContents* background_blank_contents1 = CreateTabContents();
tabstrip.AddTabContents(
- background_blank_contents1, -1, false, PageTransition::TYPED, false);
+ background_blank_contents1, -1, PageTransition::TYPED,
+ TabStripModel::ADD_NONE);
TabContents* background_blank_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- background_blank_contents2, -1, false, PageTransition::GENERATED, false);
+ background_blank_contents2, -1, PageTransition::GENERATED,
+ TabStripModel::ADD_NONE);
EXPECT_EQ(5, tabstrip.count());
EXPECT_EQ(homepage_contents, tabstrip.GetTabContentsAt(0));
EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(1));
@@ -1123,12 +1144,14 @@ TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
+ homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
+ TabStripModel::ADD_SELECTED);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, false, PageTransition::TYPED, true);
+ typed_page_contents, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
EXPECT_EQ(2, tabstrip.count());
@@ -1139,13 +1162,16 @@ TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) {
// page.
TabContents* middle_click_contents1 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents1, -1, false, PageTransition::LINK, false);
+ middle_click_contents1, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
TabContents* middle_click_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents2, -1, false, PageTransition::LINK, false);
+ middle_click_contents2, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
TabContents* middle_click_contents3 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents3, -1, false, PageTransition::LINK, false);
+ middle_click_contents3, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
// Break out of the context by selecting a tab in a different context.
EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(4));
@@ -1184,12 +1210,14 @@ TEST_F(TabStripModelTest, AppendContentsReselectionTest) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
+ homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
+ TabStripModel::ADD_SELECTED);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, false, PageTransition::TYPED, false);
+ typed_page_contents, -1, PageTransition::TYPED,
+ TabStripModel::ADD_NONE);
// The selected tab should still be the first.
EXPECT_EQ(0, tabstrip.selected_index());
@@ -1214,15 +1242,16 @@ TEST_F(TabStripModelTest, ReselectionConsidersChildrenTest) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
strip.AddTabContents(
- page_a_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
+ page_a_contents, -1, PageTransition::AUTO_BOOKMARK,
+ TabStripModel::ADD_SELECTED);
// Simulate middle click to open page A.A and A.B
TabContents* page_a_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_a_contents, -1, false, PageTransition::LINK,
- false);
+ strip.AddTabContents(page_a_a_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
TabContents* page_a_b_contents = CreateTabContents();
- strip.AddTabContents(page_a_b_contents, -1, false, PageTransition::LINK,
- false);
+ strip.AddTabContents(page_a_b_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
// Select page A.A
strip.SelectTabContentsAt(1, true);
@@ -1230,8 +1259,8 @@ TEST_F(TabStripModelTest, ReselectionConsidersChildrenTest) {
// Simulate a middle click to open page A.A.A
TabContents* page_a_a_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_a_a_contents, -1, false, PageTransition::LINK,
- false);
+ strip.AddTabContents(page_a_a_a_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
EXPECT_EQ(page_a_a_a_contents, strip.GetTabContentsAt(2));
@@ -1263,24 +1292,27 @@ TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_contents, -1, false, PageTransition::START_PAGE,
- true);
+ strip.AddTabContents(page_a_contents, -1, PageTransition::START_PAGE,
+ TabStripModel::ADD_SELECTED);
// Open pages B, C and D in the background from links on page A...
TabContents* page_b_contents = CreateTabContents();
TabContents* page_c_contents = CreateTabContents();
TabContents* page_d_contents = CreateTabContents();
- strip.AddTabContents(page_b_contents, -1, false, PageTransition::LINK, false);
- strip.AddTabContents(page_c_contents, -1, false, PageTransition::LINK, false);
- strip.AddTabContents(page_d_contents, -1, false, PageTransition::LINK, false);
+ strip.AddTabContents(page_b_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_c_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_d_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
// Switch to page B's tab.
strip.SelectTabContentsAt(1, true);
// Open a New Tab at the end of the strip (simulate Ctrl+T)
TabContents* new_tab_contents = CreateTabContents();
- strip.AddTabContents(new_tab_contents, -1, false, PageTransition::TYPED,
- true);
+ strip.AddTabContents(new_tab_contents, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
EXPECT_EQ(4, strip.GetIndexOfTabContents(new_tab_contents));
EXPECT_EQ(4, strip.selected_index());
@@ -1295,7 +1327,8 @@ TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) {
// This is like typing a URL in the address bar and pressing Alt+Enter. The
// behavior should be the same as above.
TabContents* page_e_contents = CreateTabContents();
- strip.AddTabContents(page_e_contents, -1, false, PageTransition::TYPED, true);
+ strip.AddTabContents(page_e_contents, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
EXPECT_EQ(4, strip.GetIndexOfTabContents(page_e_contents));
EXPECT_EQ(4, strip.selected_index());
@@ -1310,8 +1343,8 @@ TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) {
// in New Tab". No opener relationship should be preserved between this Tab
// and the one that was active when the gesture was performed.
TabContents* page_f_contents = CreateTabContents();
- strip.AddTabContents(page_f_contents, -1, false,
- PageTransition::AUTO_BOOKMARK, true);
+ strip.AddTabContents(page_f_contents, -1, PageTransition::AUTO_BOOKMARK,
+ TabStripModel::ADD_SELECTED);
EXPECT_EQ(4, strip.GetIndexOfTabContents(page_f_contents));
EXPECT_EQ(4, strip.selected_index());
@@ -1335,21 +1368,24 @@ TEST_F(TabStripModelTest, NavigationForgetsOpeners) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_contents, -1, false, PageTransition::START_PAGE,
- true);
+ strip.AddTabContents(page_a_contents, -1, PageTransition::START_PAGE,
+ TabStripModel::ADD_SELECTED);
// Open pages B, C and D in the background from links on page A...
TabContents* page_b_contents = CreateTabContents();
TabContents* page_c_contents = CreateTabContents();
TabContents* page_d_contents = CreateTabContents();
- strip.AddTabContents(page_b_contents, -1, false, PageTransition::LINK, false);
- strip.AddTabContents(page_c_contents, -1, false, PageTransition::LINK, false);
- strip.AddTabContents(page_d_contents, -1, false, PageTransition::LINK, false);
+ strip.AddTabContents(page_b_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_c_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_d_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
// Open page E in a different opener group from page A.
TabContents* page_e_contents = CreateTabContents();
- strip.AddTabContents(page_e_contents, -1, false,
- PageTransition::START_PAGE, false);
+ strip.AddTabContents(page_e_contents, -1, PageTransition::START_PAGE,
+ TabStripModel::ADD_NONE);
// Tell the TabStripModel that we are navigating page D via a link click.
strip.SelectTabContentsAt(3, true);
@@ -1381,15 +1417,18 @@ TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) {
// Open a tab and several tabs from it, then select one of the tabs that was
// opened.
TabContents* page_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_contents, -1, false, PageTransition::START_PAGE,
- true);
+ strip.AddTabContents(page_a_contents, -1, PageTransition::START_PAGE,
+ TabStripModel::ADD_SELECTED);
TabContents* page_b_contents = CreateTabContents();
TabContents* page_c_contents = CreateTabContents();
TabContents* page_d_contents = CreateTabContents();
- strip.AddTabContents(page_b_contents, -1, false, PageTransition::LINK, false);
- strip.AddTabContents(page_c_contents, -1, false, PageTransition::LINK, false);
- strip.AddTabContents(page_d_contents, -1, false, PageTransition::LINK, false);
+ strip.AddTabContents(page_b_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_c_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_d_contents, -1, PageTransition::LINK,
+ TabStripModel::ADD_NONE);
strip.SelectTabContentsAt(2, true);
@@ -1399,8 +1438,8 @@ TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) {
// Now simulate opening a new tab at the end of the TabStrip.
TabContents* new_tab_contents1 = CreateTabContents();
- strip.AddTabContents(new_tab_contents1, -1, false, PageTransition::TYPED,
- true);
+ strip.AddTabContents(new_tab_contents1, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
// At this point, if we close this tab the last selected one should be
// re-selected.
@@ -1413,8 +1452,8 @@ TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) {
// Open a new tab again.
TabContents* new_tab_contents2 = CreateTabContents();
- strip.AddTabContents(new_tab_contents2, -1, false, PageTransition::TYPED,
- true);
+ strip.AddTabContents(new_tab_contents2, -1, PageTransition::TYPED,
+ TabStripModel::ADD_SELECTED);
// Now select the first tab.
strip.SelectTabContentsAt(0, true);
@@ -1526,7 +1565,7 @@ TEST_F(TabStripModelTest, Apps) {
// Attempt to insert tab1 (an app tab) at position 1. This isn't a legal
// position and tab1 should end up at position 0.
{
- tabstrip.InsertTabContentsAt(1, contents1, false, false);
+ tabstrip.InsertTabContentsAt(1, contents1, TabStripModel::ADD_NONE);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents1, 0, MockTabStripModelObserver::INSERT);
@@ -1540,7 +1579,7 @@ TEST_F(TabStripModelTest, Apps) {
// Insert tab 2 at position 1.
{
- tabstrip.InsertTabContentsAt(1, contents2, false, false);
+ tabstrip.InsertTabContentsAt(1, contents2, TabStripModel::ADD_NONE);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents2, 1, MockTabStripModelObserver::INSERT);
@@ -1596,7 +1635,7 @@ TEST_F(TabStripModelTest, Apps) {
tabstrip.DetachTabContentsAt(2);
observer.ClearStates();
- tabstrip.InsertTabContentsAt(0, contents3, false, false);
+ tabstrip.InsertTabContentsAt(0, contents3, TabStripModel::ADD_NONE);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents3, 2, MockTabStripModelObserver::INSERT);
@@ -1757,7 +1796,7 @@ TEST_F(TabStripModelTest, Pinning) {
// Insert "4" between "1" and "3". As "1" and "4" are pinned, "4" should end
// up after them.
{
- tabstrip.InsertTabContentsAt(1, contents4, false, false);
+ tabstrip.InsertTabContentsAt(1, contents4, TabStripModel::ADD_NONE);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents4, 2, MockTabStripModelObserver::INSERT);
diff --git a/chrome/browser/task_manager_browsertest.cc b/chrome/browser/task_manager_browsertest.cc
index e60d6d7..8751db0 100644
--- a/chrome/browser/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager_browsertest.cc
@@ -102,7 +102,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) {
GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
FilePath(kTitle1File)));
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
WaitForResourceChange(3);
// Close the tab and verify that we notice.
@@ -251,7 +251,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest,
GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
FilePath(kTitle1File)));
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
WaitForResourceChange(3);
// Check that we get some value for the cache columns.
diff --git a/chrome/browser/views/app_launcher.cc b/chrome/browser/views/app_launcher.cc
index 1bb36f1..a2555c8 100644
--- a/chrome/browser/views/app_launcher.cc
+++ b/chrome/browser/views/app_launcher.cc
@@ -390,9 +390,10 @@ void AppLauncher::AddTabWithURL(const GURL& url,
case chromeos::StatusAreaView::OPEN_TABS_ON_LEFT: {
// Add the new tab at the first non-pinned location.
int index = browser_->tabstrip_model()->IndexOfFirstNonMiniTab();
- browser_->AddTabWithURL(url, GURL(), transition, index,
- Browser::ADD_SELECTED | Browser::ADD_FORCE_INDEX,
- NULL, std::string());
+ browser_->AddTabWithURL(
+ url, GURL(), transition, index,
+ TabStripModel::ADD_SELECTED | TabStripModel::ADD_FORCE_INDEX, NULL,
+ std::string());
break;
}
case chromeos::StatusAreaView::OPEN_TABS_CLOBBER: {
@@ -401,16 +402,18 @@ void AppLauncher::AddTabWithURL(const GURL& url,
break;
}
case chromeos::StatusAreaView::OPEN_TABS_ON_RIGHT: {
- browser_->AddTabWithURL(url, GURL(), transition, -1,
- Browser::ADD_SELECTED | Browser::ADD_FORCE_INDEX,
- NULL, std::string());
+ browser_->AddTabWithURL(
+ url, GURL(), transition, -1,
+ TabStripModel::ADD_SELECTED | TabStripModel::ADD_FORCE_INDEX, NULL,
+ std::string());
break;
}
}
#else
- browser_->AddTabWithURL(url, GURL(), transition, -1,
- Browser::ADD_SELECTED | Browser::ADD_FORCE_INDEX,
- NULL, std::string());
+ browser_->AddTabWithURL(
+ url, GURL(), transition, -1,
+ TabStripModel::ADD_SELECTED | TabStripModel::ADD_FORCE_INDEX, NULL,
+ std::string());
#endif
}
diff --git a/chrome/browser/views/find_bar_host_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc
index 6e9bfbe..51080bf 100644
--- a/chrome/browser/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/views/find_bar_host_interactive_uitest.cc
@@ -99,7 +99,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
// Open another tab (tab B).
browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
browser()->Find();
EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID());
diff --git a/chrome/browser/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/views/tabs/browser_tab_strip_controller.cc
index 6b00128..dcb41dd 100644
--- a/chrome/browser/views/tabs/browser_tab_strip_controller.cc
+++ b/chrome/browser/views/tabs/browser_tab_strip_controller.cc
@@ -254,8 +254,8 @@ void BrowserTabStripController::PerformDrop(bool drop_before,
// Insert a new tab.
TabContents* contents = model_->delegate()->CreateTabContentsForURL(
url, GURL(), model_->profile(), PageTransition::TYPED, false, NULL);
- model_->AddTabContents(contents, index, false,
- PageTransition::GENERATED, true);
+ model_->AddTabContents(contents, index, PageTransition::GENERATED,
+ TabStripModel::ADD_SELECTED);
} else {
UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLOnTab"),
model_->profile());
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 5778f0b..d0587bf 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -848,8 +848,10 @@ void DraggedTabController::Attach(BaseTabStrip* attached_tabstrip,
gfx::Rect bounds = GetDraggedViewTabStripBounds(screen_point);
int index = GetInsertionIndexForDraggedBounds(bounds, false);
attached_tabstrip_->set_attaching_dragged_tab(true);
- GetModel(attached_tabstrip_)->InsertTabContentsAt(index, dragged_contents_,
- true, false, pinned_);
+ GetModel(attached_tabstrip_)->InsertTabContentsAt(
+ index, dragged_contents_,
+ TabStripModel::ADD_SELECTED |
+ (pinned_ ? TabStripModel::ADD_PINNED : 0));
attached_tabstrip_->set_attaching_dragged_tab(false);
tab = GetTabMatchingDraggedContents(attached_tabstrip_);
@@ -1101,8 +1103,10 @@ void DraggedTabController::RevertDrag() {
// TODO(beng): (Cleanup) seems like we should use Attach() for this
// somehow.
attached_tabstrip_ = source_tabstrip_;
- GetModel(source_tabstrip_)->InsertTabContentsAt(source_model_index_,
- dragged_contents_, true, false, pinned_);
+ GetModel(source_tabstrip_)->InsertTabContentsAt(
+ source_model_index_, dragged_contents_,
+ TabStripModel::ADD_SELECTED |
+ (pinned_ ? TabStripModel::ADD_PINNED : 0));
} else {
// The Tab was moved within the TabStrip where the drag was initiated.
// Move it back to the starting location.
@@ -1117,8 +1121,10 @@ void DraggedTabController::RevertDrag() {
// The Tab was detached from the TabStrip where the drag began, and has not
// been attached to any other TabStrip. We need to put it back into the
// source TabStrip.
- GetModel(source_tabstrip_)->InsertTabContentsAt(source_model_index_,
- dragged_contents_, true, false, pinned_);
+ GetModel(source_tabstrip_)->InsertTabContentsAt(
+ source_model_index_, dragged_contents_,
+ TabStripModel::ADD_SELECTED |
+ (pinned_ ? TabStripModel::ADD_PINNED : 0));
}
// If we're not attached to any TabStrip, or attached to some other TabStrip,
diff --git a/chrome/browser/views/tabs/tab_strip_interactive_uitest.cc b/chrome/browser/views/tabs/tab_strip_interactive_uitest.cc
index a598d44..b6a5d4a 100644
--- a/chrome/browser/views/tabs/tab_strip_interactive_uitest.cc
+++ b/chrome/browser/views/tabs/tab_strip_interactive_uitest.cc
@@ -24,7 +24,7 @@ IN_PROC_BROWSER_TEST_F(TabStripTest, Close) {
browser()->AddTabWithURL(
GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
views::RootView* root =
views::Widget::FindRootView(browser()->window()->GetNativeHandle());
ASSERT_TRUE(root);
diff --git a/chrome/test/browser_with_test_window_test.cc b/chrome/test/browser_with_test_window_test.cc
index d1b6c49..b0ab2ef 100644
--- a/chrome/test/browser_with_test_window_test.cc
+++ b/chrome/test/browser_with_test_window_test.cc
@@ -57,7 +57,7 @@ TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab(
void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) {
TabContents* new_tab = browser->AddTabWithURL(
- url, GURL(), PageTransition::TYPED, 0, Browser::ADD_SELECTED, NULL,
+ url, GURL(), PageTransition::TYPED, 0, TabStripModel::ADD_SELECTED, NULL,
std::string());
CommitPendingLoad(&new_tab->controller());
}
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index ac307de..3be8b01 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -249,7 +249,7 @@ Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
browser->AddTabWithURL(GURL(chrome::kAboutBlankURL), GURL(),
PageTransition::START_PAGE, -1,
- Browser::ADD_SELECTED, NULL, std::string());
+ TabStripModel::ADD_SELECTED, NULL, std::string());
// Wait for the page to finish loading.
ui_test_utils::WaitForNavigation(