summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tabs
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 22:29:49 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 22:29:49 +0000
commit9b7262502272c7ea9016b9ed21b0f828f75b5998 (patch)
treea2166b44d42d3411111db26acad091b61f0d8032 /chrome/browser/tabs
parentf7451d29b7efd0c08007a5f56414006cee20a3ef (diff)
downloadchromium_src-9b7262502272c7ea9016b9ed21b0f828f75b5998.zip
chromium_src-9b7262502272c7ea9016b9ed21b0f828f75b5998.tar.gz
chromium_src-9b7262502272c7ea9016b9ed21b0f828f75b5998.tar.bz2
Revert 50752 - Moves Browser::AddTypes to TabStripModel. This patch is primarily
cleanup before I fix 29933, but has a couple of interesting bits beyond the enum change: . AddTabContents now supports adding pinned. . Nuked duplicate code in Browser::addTabWithURL that invoked wasHidden on the TabContents. This code is already in TabStripModel. . Moved code for setting visibility of tabcontents from TabStripModel::AddTabContents to InsertTabContentsAt. Since everything ends up in InsertTabContentsAt it should be there. . Converted InsertTabContents call in extensionstabmodule to pass in nothing (Rafael said old code was wrong). BUG=29933 TEST=none Review URL: http://codereview.chromium.org/2863021 TBR=sky@chromium.org Review URL: http://codereview.chromium.org/2849025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs')
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc76
-rw-r--r--chrome/browser/tabs/tab_strip_model.h60
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc185
3 files changed, 130 insertions, 191 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 2245011..d65e126 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -106,18 +106,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 ? (ADD_INHERIT_GROUP | ADD_SELECTED) :
- ADD_NONE);
+ InsertTabContentsAt(index, contents, foreground, foreground);
}
void TabStripModel::InsertTabContentsAt(int index,
TabContents* contents,
- int add_types) {
- bool foreground = add_types & ADD_SELECTED;
- index = ConstrainInsertionIndex(index, contents->is_app() ||
- add_types & ADD_PINNED);
+ bool foreground,
+ bool inherit_group,
+ bool pinned) {
+ index = ConstrainInsertionIndex(index, contents->is_app() || 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
@@ -130,8 +130,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 = (add_types & ADD_PINNED) == ADD_PINNED;
- if ((add_types & ADD_INHERIT_GROUP) && selected_contents) {
+ data->pinned = pinned;
+ if (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.
@@ -151,27 +151,8 @@ void TabStripModel::InsertTabContentsAt(int index,
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
TabInsertedAt(contents, index, foreground));
- if (foreground)
+ if (foreground) {
ChangeSelectedContentsFrom(selected_contents, index, false);
-
- // 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
- // very long, narrow, inaccurate layout. Because some scripts on pages (as
- // well as WebKit's anchor link location calculation) are run on the
- // initial layout and not recalculated later, we need to ensure the first
- // layout is performed with sane view dimensions even when we're opening a
- // new background tab.
- if (!foreground) {
- if (selected_contents) {
- contents->view()->SizeContents(
- selected_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
- // backing store of the visible tab causing flashing. See bug 20831.
- contents->HideContents();
- contents->WasHidden();
}
}
@@ -180,9 +161,7 @@ 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(),
- TabStripModel::ADD_SELECTED | TabStripModel::ADD_INHERIT_GROUP);
+ InsertTabContentsAt(index + 1, controller->tab_contents(), true, true);
std::vector<int> closing_tabs;
closing_tabs.push_back(index);
InternalCloseTabs(closing_tabs, CLOSE_NONE);
@@ -507,24 +486,24 @@ int TabStripModel::ConstrainInsertionIndex(int index, bool mini_tab) {
void TabStripModel::AddTabContents(TabContents* contents,
int index,
+ bool force_index,
PageTransition::Type transition,
- int add_types) {
+ bool foreground) {
// 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 = (add_types & ADD_INHERIT_GROUP) == ADD_INHERIT_GROUP;
+ bool inherit_group = false;
- if (transition == PageTransition::LINK &&
- (add_types & ADD_FORCE_INDEX) == 0) {
+ if (transition == PageTransition::LINK && !force_index) {
// 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, add_types & ADD_SELECTED);
+ contents, transition, foreground);
inherit_group = true;
} else {
// For all other types, respect what was passed to us, normalizing -1s and
@@ -542,14 +521,29 @@ void TabStripModel::AddTabContents(TabContents* contents,
// is re-selected, not the next-adjacent.
inherit_group = true;
}
- InsertTabContentsAt(
- index, contents,
- add_types | (inherit_group ? TabStripModel::ADD_INHERIT_GROUP : 0));
+ InsertTabContentsAt(index, contents, foreground, inherit_group);
// Reset the index, just in case insert ended up moving it on us.
index = GetIndexOfTabContents(contents);
-
if (inherit_group && transition == PageTransition::TYPED)
contents_data_[index]->reset_group_on_select = true;
+
+ // 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
+ // very long, narrow, inaccurate layout. Because some scripts on pages (as
+ // well as WebKit's anchor link location calculation) are run on the
+ // initial layout and not recalculated later, we need to ensure the first
+ // layout is performed with sane view dimensions even when we're opening a
+ // new background tab.
+ if (TabContents* old_contents = GetSelectedTabContents()) {
+ if (!foreground) {
+ 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
+ // backing store of the visible tab causing flashing. See bug 20831.
+ contents->HideContents();
+ }
+ }
}
void TabStripModel::CloseSelectedTab() {
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index f9cb205..38954f4 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -303,29 +303,6 @@ 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
@@ -383,19 +360,24 @@ class TabStripModel : public NotificationObserver {
// foreground inherit the group of the previously selected tab.
void AppendTabContents(TabContents* contents, bool foreground);
- // 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.
+ // 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.
void InsertTabContentsAt(int index,
TabContents* contents,
- int add_types);
+ bool foreground,
+ bool inherit_group,
+ bool pinned);
// 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
@@ -564,13 +546,15 @@ class TabStripModel : public NotificationObserver {
// Command level API /////////////////////////////////////////////////////////
// Adds a TabContents at the best position in the TabStripModel given the
- // 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.
+ // 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|.
void AddTabContents(TabContents* contents,
int index,
+ bool force_index,
PageTransition::Type transition,
- int add_types);
+ bool foreground);
// 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 7089226..11fb91d 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, TabStripModel::ADD_SELECTED);
+ tabstrip.InsertTabContentsAt(1, contents2, true, false);
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, TabStripModel::ADD_NONE);
+ tabstrip.InsertTabContentsAt(2, contents3, false, false);
EXPECT_EQ(3, tabstrip.count());
EXPECT_EQ(1, observer.GetStateCount());
@@ -533,16 +533,11 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) {
// We use |InsertTabContentsAt| here instead of AppendTabContents so that
// openership relationships are preserved.
- 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);
+ 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);
// All the tabs should have the same opener.
for (int i = 1; i < tabstrip.count(); ++i)
@@ -585,11 +580,11 @@ static void InsertTabContentses(TabStripModel* tabstrip,
TabContents* contents2,
TabContents* contents3) {
tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents1),
- contents1, TabStripModel::ADD_INHERIT_GROUP);
+ contents1, false, true);
tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents2),
- contents2, TabStripModel::ADD_INHERIT_GROUP);
+ contents2, false, true);
tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents3),
- contents3, TabStripModel::ADD_INHERIT_GROUP);
+ contents3, false, true);
}
// Tests opening background tabs.
@@ -704,9 +699,7 @@ 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,
- TabStripModel::ADD_SELECTED |
- TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip.InsertTabContentsAt(insert_index, fg_link_contents, true, true);
EXPECT_EQ(1, tabstrip.selected_index());
EXPECT_EQ(fg_link_contents, tabstrip.GetSelectedTabContents());
@@ -720,8 +713,7 @@ 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,
- TabStripModel::ADD_NONE);
+ tabstrip.InsertTabContentsAt(insert_index, fg_nonlink_contents, false, false);
// Now select it, so that user_gesture == true causes the opener relationship
// to be forgotten...
tabstrip.SelectTabContentsAt(tabstrip.count() - 1, true);
@@ -809,12 +801,10 @@ 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, TabStripModel::ADD_NONE);
+ tabstrip.InsertTabContentsAt(1, other_contents, false, false);
EXPECT_EQ(2, tabstrip.count());
TabContents* opened_contents = CreateTabContents();
- tabstrip.InsertTabContentsAt(2, opened_contents,
- TabStripModel::ADD_SELECTED |
- TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip.InsertTabContentsAt(2, opened_contents, true, true);
EXPECT_EQ(2, tabstrip.selected_index());
tabstrip.CloseTabContentsAt(2, TabStripModel::CLOSE_NONE);
EXPECT_EQ(0, tabstrip.selected_index());
@@ -970,14 +960,12 @@ TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
- TabStripModel::ADD_SELECTED);
+ homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ typed_page_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(2, tabstrip.count());
@@ -988,16 +976,13 @@ TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) {
// page.
TabContents* middle_click_contents1 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents1, -1, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ middle_click_contents1, -1, false, PageTransition::LINK, false);
TabContents* middle_click_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents2, -1, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ middle_click_contents2, -1, false, PageTransition::LINK, false);
TabContents* middle_click_contents3 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents3, -1, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ middle_click_contents3, -1, false, PageTransition::LINK, false);
EXPECT_EQ(5, tabstrip.count());
@@ -1039,14 +1024,12 @@ TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
- TabStripModel::ADD_SELECTED);
+ homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ typed_page_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(2, tabstrip.count());
@@ -1055,8 +1038,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, PageTransition::LINK,
- TabStripModel::ADD_SELECTED);
+ tabstrip.AddTabContents(left_click_contents, -1, false, PageTransition::LINK,
+ true);
// Verify the state meets our expectations.
EXPECT_EQ(3, tabstrip.count());
@@ -1089,14 +1072,12 @@ TEST_F(TabStripModelTest, AddTabContents_CreateNewBlankTab) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
- TabStripModel::ADD_SELECTED);
+ homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ typed_page_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(2, tabstrip.count());
@@ -1105,8 +1086,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, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ tabstrip.AddTabContents(new_blank_contents, -1, false, PageTransition::TYPED,
+ true);
// Verify the state of the tabstrip.
EXPECT_EQ(3, tabstrip.count());
@@ -1117,12 +1098,10 @@ 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, PageTransition::TYPED,
- TabStripModel::ADD_NONE);
+ background_blank_contents1, -1, false, PageTransition::TYPED, false);
TabContents* background_blank_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- background_blank_contents2, -1, PageTransition::GENERATED,
- TabStripModel::ADD_NONE);
+ background_blank_contents2, -1, false, PageTransition::GENERATED, false);
EXPECT_EQ(5, tabstrip.count());
EXPECT_EQ(homepage_contents, tabstrip.GetTabContentsAt(0));
EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(1));
@@ -1144,14 +1123,12 @@ TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
- TabStripModel::ADD_SELECTED);
+ homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ typed_page_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(2, tabstrip.count());
@@ -1162,16 +1139,13 @@ TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) {
// page.
TabContents* middle_click_contents1 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents1, -1, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ middle_click_contents1, -1, false, PageTransition::LINK, false);
TabContents* middle_click_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents2, -1, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ middle_click_contents2, -1, false, PageTransition::LINK, false);
TabContents* middle_click_contents3 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents3, -1, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ middle_click_contents3, -1, false, PageTransition::LINK, false);
// Break out of the context by selecting a tab in a different context.
EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(4));
@@ -1210,14 +1184,12 @@ TEST_F(TabStripModelTest, AppendContentsReselectionTest) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK,
- TabStripModel::ADD_SELECTED);
+ homepage_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
// Open some other tab, by user typing.
TabContents* typed_page_contents = CreateTabContents();
tabstrip.AddTabContents(
- typed_page_contents, -1, PageTransition::TYPED,
- TabStripModel::ADD_NONE);
+ typed_page_contents, -1, false, PageTransition::TYPED, false);
// The selected tab should still be the first.
EXPECT_EQ(0, tabstrip.selected_index());
@@ -1242,16 +1214,15 @@ TEST_F(TabStripModelTest, ReselectionConsidersChildrenTest) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
strip.AddTabContents(
- page_a_contents, -1, PageTransition::AUTO_BOOKMARK,
- TabStripModel::ADD_SELECTED);
+ page_a_contents, -1, false, PageTransition::AUTO_BOOKMARK, true);
// Simulate middle click to open page A.A and A.B
TabContents* page_a_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_a_contents, -1, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_a_a_contents, -1, false, PageTransition::LINK,
+ false);
TabContents* page_a_b_contents = CreateTabContents();
- strip.AddTabContents(page_a_b_contents, -1, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_a_b_contents, -1, false, PageTransition::LINK,
+ false);
// Select page A.A
strip.SelectTabContentsAt(1, true);
@@ -1259,8 +1230,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, PageTransition::LINK,
- TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_a_a_a_contents, -1, false, PageTransition::LINK,
+ false);
EXPECT_EQ(page_a_a_a_contents, strip.GetTabContentsAt(2));
@@ -1292,27 +1263,24 @@ TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_contents, -1, PageTransition::START_PAGE,
- TabStripModel::ADD_SELECTED);
+ strip.AddTabContents(page_a_contents, -1, false, PageTransition::START_PAGE,
+ true);
// 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, 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.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);
// 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, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ strip.AddTabContents(new_tab_contents, -1, false, PageTransition::TYPED,
+ true);
EXPECT_EQ(4, strip.GetIndexOfTabContents(new_tab_contents));
EXPECT_EQ(4, strip.selected_index());
@@ -1327,8 +1295,7 @@ 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, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ strip.AddTabContents(page_e_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(4, strip.GetIndexOfTabContents(page_e_contents));
EXPECT_EQ(4, strip.selected_index());
@@ -1343,8 +1310,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, PageTransition::AUTO_BOOKMARK,
- TabStripModel::ADD_SELECTED);
+ strip.AddTabContents(page_f_contents, -1, false,
+ PageTransition::AUTO_BOOKMARK, true);
EXPECT_EQ(4, strip.GetIndexOfTabContents(page_f_contents));
EXPECT_EQ(4, strip.selected_index());
@@ -1368,24 +1335,21 @@ TEST_F(TabStripModelTest, NavigationForgetsOpeners) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_contents, -1, PageTransition::START_PAGE,
- TabStripModel::ADD_SELECTED);
+ strip.AddTabContents(page_a_contents, -1, false, PageTransition::START_PAGE,
+ true);
// 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, 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.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);
// Open page E in a different opener group from page A.
TabContents* page_e_contents = CreateTabContents();
- strip.AddTabContents(page_e_contents, -1, PageTransition::START_PAGE,
- TabStripModel::ADD_NONE);
+ strip.AddTabContents(page_e_contents, -1, false,
+ PageTransition::START_PAGE, false);
// Tell the TabStripModel that we are navigating page D via a link click.
strip.SelectTabContentsAt(3, true);
@@ -1417,18 +1381,15 @@ 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, PageTransition::START_PAGE,
- TabStripModel::ADD_SELECTED);
+ strip.AddTabContents(page_a_contents, -1, false, PageTransition::START_PAGE,
+ true);
TabContents* page_b_contents = CreateTabContents();
TabContents* page_c_contents = CreateTabContents();
TabContents* page_d_contents = CreateTabContents();
- 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.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.SelectTabContentsAt(2, true);
@@ -1438,8 +1399,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, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ strip.AddTabContents(new_tab_contents1, -1, false, PageTransition::TYPED,
+ true);
// At this point, if we close this tab the last selected one should be
// re-selected.
@@ -1452,8 +1413,8 @@ TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) {
// Open a new tab again.
TabContents* new_tab_contents2 = CreateTabContents();
- strip.AddTabContents(new_tab_contents2, -1, PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ strip.AddTabContents(new_tab_contents2, -1, false, PageTransition::TYPED,
+ true);
// Now select the first tab.
strip.SelectTabContentsAt(0, true);
@@ -1565,7 +1526,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, TabStripModel::ADD_NONE);
+ tabstrip.InsertTabContentsAt(1, contents1, false, false);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents1, 0, MockTabStripModelObserver::INSERT);
@@ -1579,7 +1540,7 @@ TEST_F(TabStripModelTest, Apps) {
// Insert tab 2 at position 1.
{
- tabstrip.InsertTabContentsAt(1, contents2, TabStripModel::ADD_NONE);
+ tabstrip.InsertTabContentsAt(1, contents2, false, false);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents2, 1, MockTabStripModelObserver::INSERT);
@@ -1635,7 +1596,7 @@ TEST_F(TabStripModelTest, Apps) {
tabstrip.DetachTabContentsAt(2);
observer.ClearStates();
- tabstrip.InsertTabContentsAt(0, contents3, TabStripModel::ADD_NONE);
+ tabstrip.InsertTabContentsAt(0, contents3, false, false);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents3, 2, MockTabStripModelObserver::INSERT);
@@ -1796,7 +1757,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, TabStripModel::ADD_NONE);
+ tabstrip.InsertTabContentsAt(1, contents4, false, false);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents4, 2, MockTabStripModelObserver::INSERT);