summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 06:44:39 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 06:44:39 +0000
commit5a4940befecc4e2c5e73ade51683ced6b2247ee6 (patch)
treef198619bbca9cc404ae1270866d779b32dc1c3cb
parent53761253f5a95f72bbd2bf5acaf91a0cbe6a55f7 (diff)
downloadchromium_src-5a4940befecc4e2c5e73ade51683ced6b2247ee6.zip
chromium_src-5a4940befecc4e2c5e73ade51683ced6b2247ee6.tar.gz
chromium_src-5a4940befecc4e2c5e73ade51683ced6b2247ee6.tar.bz2
honor index in createTab()
BUG=11200 R=brettw,beng Review URL: http://codereview.chromium.org/99300 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15392 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc2
-rw-r--r--chrome/browser/browser.cc36
-rw-r--r--chrome/browser/browser.h6
-rw-r--r--chrome/browser/browser_focus_uitest.cc2
-rw-r--r--chrome/browser/browser_init.cc2
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc14
-rw-r--r--chrome/browser/extensions/extensions_service.cc2
-rw-r--r--chrome/browser/importer/importer.cc2
-rw-r--r--chrome/browser/profile_manager.cc3
-rw-r--r--chrome/browser/sessions/session_restore.cc2
-rw-r--r--chrome/browser/ssl/ssl_browser_tests.cc4
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc10
-rw-r--r--chrome/browser/tabs/tab_strip_model.h9
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc94
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc4
-rw-r--r--chrome/test/browser_with_test_window_test.cc2
-rw-r--r--chrome/test/data/extensions/samples/tabs/tabs_api.html1
-rw-r--r--chrome/test/in_process_browser_test.cc3
18 files changed, 110 insertions, 88 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index b14e286..9e87744 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1083,7 +1083,7 @@ void AutomationProvider::AppendTab(int handle, const GURL& url,
reply_message);
TabContents* tab_contents = browser->AddTabWithURL(url, GURL(),
PageTransition::TYPED,
- true, -1, NULL);
+ true, -1, false, NULL);
if (tab_contents) {
append_tab_response =
GetIndexForNavigationController(&tab_contents->controller(), browser);
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index c2e3bf8..45c6108 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -307,7 +307,8 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
if (!browser)
browser = Browser::Create(off_the_record_profile);
// TODO(eroman): should we have referrer here?
- browser->AddTabWithURL(url, GURL(), PageTransition::LINK, true, -1, NULL);
+ browser->AddTabWithURL(url, GURL(), PageTransition::LINK, true, -1, false,
+ NULL);
browser->window()->Show();
}
@@ -318,7 +319,7 @@ void Browser::OpenApplicationWindow(Profile* profile, const GURL& url) {
Browser* browser = Browser::CreateForApp(app_name, profile, false);
browser->AddTabWithURL(url, GURL(), PageTransition::START_PAGE, true, -1,
- NULL);
+ false, NULL);
browser->window()->Show();
// TODO(jcampan): http://crbug.com/8123 we should not need to set the initial
// focus explicitly.
@@ -511,7 +512,8 @@ void Browser::InProgressDownloadResponse(bool cancel_downloads) {
TabContents* Browser::AddTabWithURL(
const GURL& url, const GURL& referrer, PageTransition::Type transition,
- bool foreground, int index, SiteInstance* instance) {
+ bool foreground, int index, bool force_index,
+ SiteInstance* instance) {
TabContents* contents = NULL;
if (type_ == TYPE_NORMAL || tabstrip_model()->empty()) {
GURL url_to_load = url;
@@ -519,7 +521,8 @@ TabContents* Browser::AddTabWithURL(
url_to_load = GetHomePage();
contents = CreateTabContentsForURL(url_to_load, referrer, profile_,
transition, false, instance);
- tabstrip_model_.AddTabContents(contents, index, transition, foreground);
+ tabstrip_model_.AddTabContents(contents, index, force_index,
+ transition, foreground);
// By default, content believes it is not hidden. When adding contents
// in the background, tell it that it's hidden.
if (!foreground)
@@ -529,7 +532,7 @@ TabContents* Browser::AddTabWithURL(
// open this URL in, creating one if none exists.
Browser* b = GetOrCreateTabbedBrowser();
contents = b->AddTabWithURL(url, referrer, transition, foreground, index,
- instance);
+ force_index, instance);
b->window()->Show();
}
return contents;
@@ -539,7 +542,7 @@ TabContents* Browser::AddTabWithURL(
TabContents* Browser::AddTabWithNavigationController(
NavigationController* ctrl, PageTransition::Type type) {
TabContents* tc = ctrl->tab_contents();
- tabstrip_model_.AddTabContents(tc, -1, type, true);
+ tabstrip_model_.AddTabContents(tc, -1, false, type, true);
return tc;
}
@@ -615,7 +618,8 @@ void Browser::ShowSingleDOMUITab(const GURL& url) {
}
// Otherwise, just create a new tab.
- AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1, NULL);
+ AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1,
+ false, NULL);
}
///////////////////////////////////////////////////////////////////////////////
@@ -640,7 +644,7 @@ void Browser::GoBack(WindowOpenDisposition disposition) {
if (disposition == NEW_FOREGROUND_TAB ||
disposition == NEW_BACKGROUND_TAB) {
TabContents* cloned = GetSelectedTabContents()->Clone();
- tabstrip_model_.AddTabContents(cloned, -1,
+ tabstrip_model_.AddTabContents(cloned, -1, false,
PageTransition::LINK,
disposition == NEW_FOREGROUND_TAB);
controller = &cloned->controller();
@@ -660,7 +664,7 @@ void Browser::GoForward(WindowOpenDisposition disp) {
NavigationController* controller = 0;
if (disp == NEW_FOREGROUND_TAB || disp == NEW_BACKGROUND_TAB) {
TabContents* cloned = GetSelectedTabContents()->Clone();
- tabstrip_model_.AddTabContents(cloned, -1,
+ tabstrip_model_.AddTabContents(cloned, -1, false,
PageTransition::LINK,
disp == NEW_FOREGROUND_TAB);
controller = &cloned->controller();
@@ -1141,7 +1145,7 @@ void Browser::OpenAboutChromeDialog() {
void Browser::OpenHelpTab() {
GURL help_url(WideToASCII(l10n_util::GetString(IDS_HELP_CONTENT_URL)));
AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1,
- NULL);
+ false, NULL);
}
///////////////////////////////////////////////////////////////////////////////
@@ -1375,7 +1379,7 @@ TabContents* Browser::AddBlankTab(bool foreground) {
TabContents* Browser::AddBlankTabAt(int index, bool foreground) {
return AddTabWithURL(GURL(chrome::kChromeUINewTabURL), GURL(),
- PageTransition::TYPED, foreground, index, NULL);
+ PageTransition::TYPED, foreground, index, false, NULL);
}
Browser* Browser::CreateNewStripWithContents(TabContents* detached_contents,
@@ -1441,7 +1445,7 @@ void Browser::DuplicateContentsAt(int index) {
// the new tab to appear in index position 2, not 6).
if (tabstrip_model_.selected_index() != index)
tabstrip_model_.SelectTabContentsAt(index, true);
- tabstrip_model_.AddTabContents(new_contents, index + 1,
+ tabstrip_model_.AddTabContents(new_contents, index + 1, false,
PageTransition::LINK, true);
} else {
Browser* browser = NULL;
@@ -1725,7 +1729,7 @@ void Browser::OpenURLFromTab(TabContents* source,
} else if (disposition == NEW_WINDOW) {
Browser* browser = Browser::Create(profile_);
new_contents = browser->AddTabWithURL(url, referrer, transition, true, -1,
- instance);
+ false, instance);
browser->window()->Show();
} else if ((disposition == CURRENT_TAB) && current_tab) {
tabstrip_model_.TabNavigating(current_tab, transition);
@@ -1747,7 +1751,7 @@ void Browser::OpenURLFromTab(TabContents* source,
return;
} else if (disposition != SUPPRESS_OPEN) {
new_contents = AddTabWithURL(url, referrer, transition,
- disposition != NEW_BACKGROUND_TAB, -1,
+ disposition != NEW_BACKGROUND_TAB, -1, false,
instance);
}
@@ -1794,7 +1798,7 @@ void Browser::AddNewContents(TabContents* source,
// AddTabContents method does.
if (type_ & TYPE_APP)
transition = PageTransition::START_PAGE;
- b->tabstrip_model()->AddTabContents(new_contents, -1, transition, true);
+ b->tabstrip_model()->AddTabContents(new_contents, -1, false, transition, true);
b->window()->Show();
return;
}
@@ -1807,7 +1811,7 @@ void Browser::AddNewContents(TabContents* source,
initial_pos, user_gesture);
browser->window()->Show();
} else if (disposition != SUPPRESS_OPEN) {
- tabstrip_model_.AddTabContents(new_contents, -1, PageTransition::LINK,
+ tabstrip_model_.AddTabContents(new_contents, -1, false, PageTransition::LINK,
disposition == NEW_FOREGROUND_TAB);
}
}
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 7e2a435..2a5db13 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -216,11 +216,13 @@ class Browser : public TabStripModelDelegate,
// Tab adding/showing functions /////////////////////////////////////////////
// Add a new tab with the specified URL. If instance is not null, its process
- // will be used to render the tab.
+ // will be used to render the tab. |force_index| is passed through to
+ // TabStripModel::AddTabContents and it's meaning is documented with it's
+ // declaration.
TabContents* AddTabWithURL(
const GURL& url, const GURL& referrer,
PageTransition::Type transition, bool foreground, int index,
- SiteInstance* instance);
+ bool force_index, SiteInstance* instance);
// Add a new tab, given a NavigationController. A TabContents appropriate to
// display the last committed entry is created and returned.
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 4738ea25..9e6c7af 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -122,7 +122,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) {
// Create several tabs.
for (int i = 0; i < 4; ++i) {
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1,
+ browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1, false,
NULL);
}
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 4e213eb..67f24f8 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -439,7 +439,7 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser(
for (size_t i = 0; i < urls.size(); ++i) {
TabContents* tab = browser->AddTabWithURL(
- urls[i], GURL(), PageTransition::START_PAGE, (i == 0), -1, NULL);
+ urls[i], GURL(), PageTransition::START_PAGE, (i == 0), -1, false, NULL);
if (i == 0 && process_startup)
AddCrashedInfoBarIfNecessary(tab);
}
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index d219152..5a39d67 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -201,13 +201,9 @@ bool CreateWindowFunction::RunImpl() {
}
Browser *new_window = Browser::Create(dispatcher_->profile());
- if (url->is_valid()) {
- new_window->AddTabWithURL(*(url.get()),
- GURL(), PageTransition::LINK,
- true, -1, NULL);
- } else {
- new_window->NewTab();
- }
+ new_window->AddTabWithURL(*(url.get()), GURL(), PageTransition::LINK, true,
+ -1, false, NULL);
+
new_window->window()->SetBounds(bounds);
new_window->window()->Show();
@@ -315,7 +311,7 @@ bool CreateTabFunction::RunImpl() {
// -favIconUrl
std::string url_string;
- scoped_ptr<GURL> url;
+ scoped_ptr<GURL> url(new GURL());
if (args->HasKey(kUrlKey)) {
EXTENSION_FUNCTION_VALIDATE(args->GetString(kUrlKey, &url_string));
url.reset(new GURL(url_string));
@@ -346,7 +342,7 @@ bool CreateTabFunction::RunImpl() {
}
TabContents* contents = browser->AddTabWithURL(*(url.get()), GURL(),
- PageTransition::LINK, selected, index, NULL);
+ PageTransition::LINK, selected, index, true, NULL);
index = tab_strip->GetIndexOfTabContents(contents);
// Return data about the newly created tab.
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 5e9c221..338a2ce 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -206,7 +206,7 @@ void ExtensionsService::OnExtensionInstalled(Extension* extension,
!browser->window()->IsBookmarkBarVisible() &&
!extension->toolstrips().empty())
browser->AddTabWithURL(GURL(chrome::kChromeUINewTabURL), GURL(),
- PageTransition::LINK, true, -1, NULL);
+ PageTransition::LINK, true, -1, false, NULL);
}
ExtensionView* ExtensionsService::CreateView(Extension* extension,
diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc
index 2209541..d46b4de 100644
--- a/chrome/browser/importer/importer.cc
+++ b/chrome/browser/importer/importer.cc
@@ -528,7 +528,7 @@ void ImporterHost::StartImportSettings(const ProfileInfo& profile_info,
BrowsingInstance* instance = new BrowsingInstance(writer_->GetProfile());
SiteInstance* site = instance->GetSiteInstanceForURL(url);
Browser* browser = BrowserList::GetLastActive();
- browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1,
+ browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1, false,
site);
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
diff --git a/chrome/browser/profile_manager.cc b/chrome/browser/profile_manager.cc
index 26650cc..ae95ec9 100644
--- a/chrome/browser/profile_manager.cc
+++ b/chrome/browser/profile_manager.cc
@@ -133,7 +133,8 @@ Profile* ProfileManager::AddProfileByPath(const FilePath& path) {
void ProfileManager::NewWindowWithProfile(Profile* profile) {
DCHECK(profile);
Browser* browser = Browser::Create(profile);
- browser->AddTabWithURL(GURL(), GURL(), PageTransition::TYPED, true, -1, NULL);
+ browser->AddTabWithURL(GURL(), GURL(), PageTransition::TYPED, true, -1,
+ false, NULL);
browser->window()->Show();
}
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index e1319e9..1304aa1 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -371,7 +371,7 @@ class SessionRestoreImpl : public NotificationObserver {
void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) {
for (size_t i = 0; i < urls.size(); ++i) {
browser->AddTabWithURL(urls[i], GURL(), PageTransition::START_PAGE,
- (i == 0), -1, NULL);
+ (i == 0), -1, false, NULL);
}
}
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index a6d5772..184932a 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -339,7 +339,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestMixedContentsTwoTabs) {
TabContents* tab2 = browser()->AddTabWithURL(url,
GURL(),
PageTransition::TYPED, true, 0,
- NULL);
+ false, NULL);
ui_test_utils::WaitForNavigation(&(tab2->controller()));
// The new tab has mixed content.
@@ -478,7 +478,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestCloseTabWithUnsafePopup) {
TabContents* tab2 = browser()->AddTabWithURL(url,
GURL(),
PageTransition::TYPED,
- true, 0, NULL);
+ true, 0, false, NULL);
ui_test_utils::WaitForNavigation(&(tab2->controller()));
// Close the first tab.
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index dd06cc1..e1a93f3 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -102,8 +102,13 @@ void TabStripModel::InsertTabContentsAt(int index,
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
TabInsertedAt(contents, index, foreground));
- if (foreground)
+ if (foreground) {
ChangeSelectedContentsFrom(selected_contents, index, false);
+ } else if (index <= selected_index_) {
+ // If a tab is inserted before the current selected index that is not
+ // foreground, |selected_index| needs to be incremented.
+ ++selected_index_;
+ }
}
void TabStripModel::ReplaceNavigationControllerAt(
@@ -327,9 +332,10 @@ bool TabStripModel::ShouldResetGroupOnSelect(TabContents* contents) const {
void TabStripModel::AddTabContents(TabContents* contents,
int index,
+ bool force_index,
PageTransition::Type transition,
bool foreground) {
- if (transition == PageTransition::LINK) {
+ if (transition == PageTransition::LINK && !force_index) {
// Only try to be clever if we're opening a LINK.
index = order_controller_->DetermineInsertionIndex(
contents, transition, foreground);
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index 66c6b395..7f496c8 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -372,12 +372,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. Ultimately, 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. 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,
bool foreground);
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index 0c77cba..a5b63a7 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -743,12 +743,12 @@ TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK, true);
+ 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, true);
+ typed_page_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(2, tabstrip.count());
@@ -759,13 +759,13 @@ TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) {
// page.
TabContents* middle_click_contents1 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents1, -1, PageTransition::LINK, false);
+ middle_click_contents1, -1, false, PageTransition::LINK, false);
TabContents* middle_click_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents2, -1, PageTransition::LINK, false);
+ middle_click_contents2, -1, false, PageTransition::LINK, false);
TabContents* middle_click_contents3 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents3, -1, PageTransition::LINK, false);
+ middle_click_contents3, -1, false, PageTransition::LINK, false);
EXPECT_EQ(5, tabstrip.count());
@@ -807,12 +807,12 @@ TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK, true);
+ 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, true);
+ typed_page_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(2, tabstrip.count());
@@ -821,7 +821,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, true);
+ tabstrip.AddTabContents(left_click_contents, -1, false, PageTransition::LINK,
+ true);
// Verify the state meets our expectations.
EXPECT_EQ(3, tabstrip.count());
@@ -854,12 +855,12 @@ TEST_F(TabStripModelTest, AddTabContents_CreateNewBlankTab) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK, true);
+ 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, true);
+ typed_page_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(2, tabstrip.count());
@@ -868,7 +869,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, true);
+ tabstrip.AddTabContents(new_blank_contents, -1, false, PageTransition::TYPED,
+ true);
// Verify the state of the tabstrip.
EXPECT_EQ(3, tabstrip.count());
@@ -879,10 +881,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, false);
+ background_blank_contents1, -1, false, PageTransition::TYPED, false);
TabContents* background_blank_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- background_blank_contents2, -1, PageTransition::GENERATED, false);
+ 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));
@@ -904,12 +906,12 @@ TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK, true);
+ 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, true);
+ typed_page_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(2, tabstrip.count());
@@ -920,13 +922,13 @@ TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) {
// page.
TabContents* middle_click_contents1 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents1, -1, PageTransition::LINK, false);
+ middle_click_contents1, -1, false, PageTransition::LINK, false);
TabContents* middle_click_contents2 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents2, -1, PageTransition::LINK, false);
+ middle_click_contents2, -1, false, PageTransition::LINK, false);
TabContents* middle_click_contents3 = CreateTabContents();
tabstrip.AddTabContents(
- middle_click_contents3, -1, PageTransition::LINK, false);
+ 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));
@@ -965,12 +967,12 @@ TEST_F(TabStripModelTest, AppendContentsReselectionTest) {
// Open the Home Page
TabContents* homepage_contents = CreateTabContents();
tabstrip.AddTabContents(
- homepage_contents, -1, PageTransition::AUTO_BOOKMARK, true);
+ 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, false);
+ typed_page_contents, -1, false, PageTransition::TYPED, false);
// The selected tab should still be the first.
EXPECT_EQ(0, tabstrip.selected_index());
@@ -995,13 +997,15 @@ TEST_F(TabStripModelTest, ReselectionConsidersChildrenTest) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
strip.AddTabContents(
- page_a_contents, -1, PageTransition::AUTO_BOOKMARK, true);
+ 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, false);
+ 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, false);
+ strip.AddTabContents(page_a_b_contents, -1, false, PageTransition::LINK,
+ false);
// Select page A.A
strip.SelectTabContentsAt(1, true);
@@ -1009,7 +1013,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, false);
+ strip.AddTabContents(page_a_a_a_contents, -1, false, PageTransition::LINK,
+ false);
EXPECT_EQ(page_a_a_a_contents, strip.GetTabContentsAt(2));
@@ -1041,22 +1046,23 @@ TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_contents, -1, PageTransition::START_PAGE, true);
+ 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, false);
- strip.AddTabContents(page_c_contents, -1, PageTransition::LINK, false);
- strip.AddTabContents(page_d_contents, -1, PageTransition::LINK, false);
+ 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, true);
+ strip.AddTabContents(new_tab_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(4, strip.GetIndexOfTabContents(new_tab_contents));
EXPECT_EQ(4, strip.selected_index());
@@ -1071,7 +1077,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, true);
+ strip.AddTabContents(page_e_contents, -1, false, PageTransition::TYPED, true);
EXPECT_EQ(4, strip.GetIndexOfTabContents(page_e_contents));
EXPECT_EQ(4, strip.selected_index());
@@ -1086,7 +1092,7 @@ 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,
+ strip.AddTabContents(page_f_contents, -1, false, PageTransition::AUTO_BOOKMARK,
true);
EXPECT_EQ(4, strip.GetIndexOfTabContents(page_f_contents));
@@ -1111,19 +1117,20 @@ TEST_F(TabStripModelTest, NavigationForgetsOpeners) {
// Open page A
TabContents* page_a_contents = CreateTabContents();
- strip.AddTabContents(page_a_contents, -1, PageTransition::START_PAGE, true);
+ 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, false);
- strip.AddTabContents(page_c_contents, -1, PageTransition::LINK, false);
- strip.AddTabContents(page_d_contents, -1, PageTransition::LINK, false);
+ 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, false);
+ 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);
@@ -1155,14 +1162,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, true);
+ 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, false);
- strip.AddTabContents(page_c_contents, -1, PageTransition::LINK, false);
- strip.AddTabContents(page_d_contents, -1, PageTransition::LINK, false);
+ 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);
@@ -1172,7 +1180,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, true);
+ 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.
@@ -1185,7 +1194,8 @@ TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) {
// Open a new tab again.
TabContents* new_tab_contents2 = CreateTabContents();
- strip.AddTabContents(new_tab_contents2, -1, PageTransition::TYPED, true);
+ strip.AddTabContents(new_tab_contents2, -1, false, PageTransition::TYPED,
+ true);
// Now select the first tab.
strip.SelectTabContentsAt(0, true);
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index fce1297..5f41cc8 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -698,8 +698,8 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) {
model_->delegate()->CreateTabContentsForURL(
url, GURL(), model_->profile(), PageTransition::TYPED, false,
NULL);
- model_->AddTabContents(contents, drop_index, PageTransition::GENERATED,
- true);
+ model_->AddTabContents(contents, drop_index, false,
+ PageTransition::GENERATED, true);
} else {
UserMetrics::RecordAction(L"Tab_DropURLOnTab", model_->profile());
diff --git a/chrome/test/browser_with_test_window_test.cc b/chrome/test/browser_with_test_window_test.cc
index 38e3d58..e4820e5 100644
--- a/chrome/test/browser_with_test_window_test.cc
+++ b/chrome/test/browser_with_test_window_test.cc
@@ -51,7 +51,7 @@ TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab(
void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) {
TabContents* new_tab = browser->AddTabWithURL(url, GURL(),
PageTransition::TYPED, true,
- 0, NULL);
+ 0, false, NULL);
CommitPendingLoad(&new_tab->controller());
}
diff --git a/chrome/test/data/extensions/samples/tabs/tabs_api.html b/chrome/test/data/extensions/samples/tabs/tabs_api.html
index af4a735..56cd878 100644
--- a/chrome/test/data/extensions/samples/tabs/tabs_api.html
+++ b/chrome/test/data/extensions/samples/tabs/tabs_api.html
@@ -75,6 +75,7 @@ function createTabData(id) {
return {
'index': parseInt(document.getElementById('index_' + id).value),
'windowId': parseInt(document.getElementById('windowId_' + id).value),
+ 'index': parseInt(document.getElementById('index_' + id).value),
'url': document.getElementById('url_' + id).value,
'selected': document.getElementById('selected_' + id).value ? true : false
}
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 80819b8..c9642fe 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -163,7 +163,8 @@ Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
Browser* browser = Browser::Create(profile);
browser->AddTabWithURL(
- GURL("about:blank"), GURL(), PageTransition::START_PAGE, true, -1, NULL);
+ GURL("about:blank"), GURL(), PageTransition::START_PAGE, true, -1, false,
+ NULL);
// Wait for the page to finish loading.
ui_test_utils::WaitForNavigation(