diff options
Diffstat (limited to 'chrome/browser')
32 files changed, 275 insertions, 336 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index a9e25df..742d6d6 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, TabStripModel::ADD_SELECTED, NULL, std::string()); + -1, Browser::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 621c80c..6692f09 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, TabStripModel::ADD_SELECTED, - NULL, std::string()); + url, GURL(), PageTransition::TYPED, -1, Browser::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 b41bbbc..5ac9d2c 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -428,7 +428,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, TabStripModel::ADD_SELECTED, NULL, + url, GURL(), PageTransition::LINK, -1, Browser::ADD_SELECTED, NULL, std::string()); browser->window()->Show(); } @@ -561,8 +561,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, TabStripModel::ADD_SELECTED, - NULL, std::string()); + url, GURL(), PageTransition::START_PAGE, -1, Browser::ADD_SELECTED, NULL, + std::string()); tab_contents->GetMutableRendererPrefs()->can_accept_load_drops = false; tab_contents->render_view_host()->SyncRendererPrefs(); @@ -870,7 +870,22 @@ TabContents* Browser::AddTabWithURL(const GURL& url, contents = CreateTabContentsForURL(url_to_load, referrer, profile_, transition, false, instance); contents->SetExtensionAppById(extension_app_id); - tabstrip_model_.AddTabContents(contents, index, transition, add_types); + // 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); + + // 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 + // TabStripModel::AddTabContents invokes HideContents if not foreground. + contents->WasHidden(); + } } else { // We're in an app window or a popup window. Find an existing browser to // open this URL in, creating one if none exists. @@ -887,8 +902,7 @@ TabContents* Browser::AddTabWithURL(const GURL& url, TabContents* Browser::AddTab(TabContents* tab_contents, PageTransition::Type type) { - tabstrip_model_.AddTabContents( - tab_contents, -1, type, TabStripModel::ADD_SELECTED); + tabstrip_model_.AddTabContents(tab_contents, -1, false, type, true); return tab_contents; } @@ -932,9 +946,7 @@ TabContents* Browser::AddRestoredTab( bool really_pin = (pin && tab_index == tabstrip_model()->IndexOfFirstNonMiniTab()); - tabstrip_model_.InsertTabContentsAt( - tab_index, new_tab, - select ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE); + tabstrip_model_.InsertTabContentsAt(tab_index, new_tab, select, false); if (really_pin) tabstrip_model_.SetTabPinned(tab_index, true); if (select) { @@ -1007,8 +1019,8 @@ void Browser::ShowSingletonTab(const GURL& url) { } // Otherwise, just create a new tab. - AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, -1, - TabStripModel::ADD_SELECTED, NULL, std::string()); + AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, + -1, Browser::ADD_SELECTED, NULL, std::string()); } void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { @@ -1084,10 +1096,8 @@ TabContents* Browser::GetOrCloneTabForDisposition( TabContents* current_tab = GetSelectedTabContents(); if (ShouldOpenNewTabForWindowDisposition(disposition)) { current_tab = current_tab->Clone(); - tabstrip_model_.AddTabContents( - current_tab, -1, PageTransition::LINK, - disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED : - TabStripModel::ADD_NONE); + tabstrip_model_.AddTabContents(current_tab, -1, false, PageTransition::LINK, + disposition == NEW_FOREGROUND_TAB); } return current_tab; } @@ -1793,8 +1803,8 @@ void Browser::OpenUpdateChromeDialog() { void Browser::OpenHelpTab() { GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kHelpContentUrl)); - AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, -1, - TabStripModel::ADD_SELECTED, NULL, std::string()); + AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, + -1, Browser::ADD_SELECTED, NULL, std::string()); } void Browser::OpenThemeGalleryTabAndActivate() { @@ -2125,7 +2135,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 ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE, NULL, + foreground ? Browser::ADD_SELECTED : Browser::ADD_NONE, NULL, std::string()); tab_contents->set_new_tab_start_time(new_tab_start_time); return tab_contents; @@ -2202,10 +2212,8 @@ void Browser::DuplicateContentsAt(int index) { // window next to the tab being duplicated. new_contents = contents->Clone(); pinned = tabstrip_model_.IsTabPinned(index); - int add_types = TabStripModel::ADD_SELECTED | - TabStripModel::ADD_INHERIT_GROUP | - (pinned ? TabStripModel::ADD_PINNED : 0); - tabstrip_model_.InsertTabContentsAt(index + 1, new_contents, add_types); + tabstrip_model_.InsertTabContentsAt(index + 1, new_contents, true, + true, pinned); } else { Browser* browser = NULL; if (type_ & TYPE_APP) { @@ -2506,8 +2514,8 @@ void Browser::AddNewContents(TabContents* source, // AddTabContents method does. if (type_ & TYPE_APP) transition = PageTransition::START_PAGE; - b->tabstrip_model()->AddTabContents( - new_contents, -1, transition, TabStripModel::ADD_SELECTED); + b->tabstrip_model()->AddTabContents(new_contents, -1, false, transition, + true); b->window()->Show(); return; } @@ -2520,10 +2528,9 @@ 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, - disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED : - TabStripModel::ADD_NONE); + tabstrip_model_.AddTabContents(new_contents, -1, false, + PageTransition::LINK, + disposition == NEW_FOREGROUND_TAB); } } @@ -3757,9 +3764,8 @@ void Browser::OpenURLAtIndex(TabContents* source, return; } else if (disposition == NEW_WINDOW) { Browser* browser = Browser::Create(profile_); - int add_types = force_index ? TabStripModel::ADD_FORCE_INDEX : - TabStripModel::ADD_NONE; - add_types |= TabStripModel::ADD_SELECTED; + int add_types = force_index ? Browser::ADD_FORCE_INDEX : Browser::ADD_NONE; + add_types |= Browser::ADD_SELECTED; new_contents = browser->AddTabWithURL(url, referrer, transition, index, add_types, instance, std::string()); browser->window()->Show(); @@ -3794,9 +3800,9 @@ void Browser::OpenURLAtIndex(TabContents* source, return; } else if (disposition != SUPPRESS_OPEN) { int add_types = disposition != NEW_BACKGROUND_TAB ? - TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE; + Browser::ADD_SELECTED : Browser::ADD_NONE; if (force_index) - add_types |= TabStripModel::ADD_FORCE_INDEX; + add_types |= Browser::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 e3add6e..6b7671a 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -104,6 +104,22 @@ 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 @@ -323,8 +339,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 TabStripModel::AddTabTypes; see it for details. If - // |instance| is not null, its process will be used to render the tab. If + // values defined by AddTabTypes; see AddTabTypes 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 a4bfaf9..4d4773c 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, 0, TabStripModel::ADD_NONE); + model->AddTabContents(app_contents, 0, false, 0, false); 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, + 0, Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, + 0, Browser::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, 0, TabStripModel::ADD_NONE); + model->AddTabContents(app_contents, 0, false, 0, false); 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, 0, TabStripModel::ADD_NONE); + model->AddTabContents(app_contents, 0, false, 0, false); 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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 36fe2d5..93f7998 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, + -1, Browser::ADD_SELECTED, NULL, std::string()); // Focus should be on the recently opened tab page. ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); @@ -725,8 +725,7 @@ 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, TabStripModel::ADD_SELECTED, NULL, - std::string()); + -1, Browser::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 21eca66..63b6d32 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -751,11 +751,10 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( if (!process_startup && !URLRequest::IsHandledURL(tabs[i].url)) continue; - int add_types = first_tab ? TabStripModel::ADD_SELECTED : - TabStripModel::ADD_NONE; - add_types |= TabStripModel::ADD_FORCE_INDEX; + int add_types = first_tab ? Browser::ADD_SELECTED : Browser::ADD_NONE; + add_types |= Browser::ADD_FORCE_INDEX; if (tabs[i].is_pinned) - add_types |= TabStripModel::ADD_PINNED; + add_types |= Browser::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 930cc23..e721414 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -1400,9 +1400,8 @@ 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, - TabStripModel::ADD_SELECTED | (pinned ? TabStripModel::ADD_PINNED : 0)); + tabStripModel_->InsertTabContentsAt(modelIndex, contents, true, false, + pinned); } // Called when the tab strip view changes size. As we only registered for @@ -1641,8 +1640,7 @@ private: UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs"), browser_->profile()); browser_->AddTabWithURL(url, GURL(), PageTransition::TYPED, index, - TabStripModel::ADD_SELECTED | - TabStripModel::ADD_FORCE_INDEX, + Browser::ADD_SELECTED | Browser::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 56541e7..3a390d8 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -212,8 +212,7 @@ void DevToolsWindow::CreateDevToolsBrowser() { browser_ = Browser::CreateForDevTools(profile_); browser_->tabstrip_model()->AddTabContents( - tab_contents_, -1, PageTransition::START_PAGE, - TabStripModel::ADD_SELECTED); + tab_contents_, -1, false, PageTransition::START_PAGE, true); } BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index 69d39bc..0436056 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + GURL(path), GURL(), PageTransition::LINK, -1, Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + GURL(url), GURL(), PageTransition::LINK, -1, Browser::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 a2ba5eb..6864386 100644 --- a/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc +++ b/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc @@ -42,8 +42,7 @@ void HtmlDialogTabContentsDelegate::OpenURLFromTab( Browser* browser = CreateBrowser(); TabContents* new_contents = browser->AddTabWithURL(url, referrer, transition, -1, - TabStripModel::ADD_SELECTED, NULL, - std::string()); + Browser::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 9e08f6d..b468ad2 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, TabStripModel::ADD_SELECTED, NULL, std::string()); + -1, Browser::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, TabStripModel::ADD_SELECTED, NULL, std::string()); + -1, Browser::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 a55b667..1c9680f4 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -195,7 +195,7 @@ void ExtensionInstallUI::OnInstallSuccess(Extension* extension) { url += "/#"; url += hash_params; browser->AddTabWithURL(GURL(url), GURL(), PageTransition::TYPED, -1, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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 ce9511c..0f58360 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::ADD_SELECTED, NULL, std::string()); new_window->window()->SetBounds(bounds); new_window->window()->Show(); @@ -569,9 +569,8 @@ bool CreateTabFunction::RunImpl() { index = tab_strip->count(); } - int add_types = selected ? TabStripModel::ADD_SELECTED : - TabStripModel::ADD_NONE; - add_types |= TabStripModel::ADD_FORCE_INDEX; + int add_types = selected ? Browser::ADD_SELECTED : Browser::ADD_NONE; + add_types |= Browser::ADD_FORCE_INDEX; TabContents* contents = browser->AddTabWithURL(url, GURL(), PageTransition::LINK, index, add_types, NULL, std::string()); index = tab_strip->GetIndexOfTabContents(contents); @@ -750,7 +749,7 @@ bool MoveTabFunction::RunImpl() { new_index = target_tab_strip->count(); target_tab_strip->InsertTabContentsAt(new_index, contents, - TabStripModel::ADD_NONE); + false, true); 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 f2314a1..9f37987 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::ADD_SELECTED, NULL, std::string()); browser()->SelectTabContentsAt(1, false); TabContents* tab2 = browser()->GetSelectedTabContents(); EXPECT_NE(tab1, tab2); @@ -1034,8 +1034,7 @@ 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, - TabStripModel::ADD_SELECTED, NULL, - std::string()); + Browser::ADD_SELECTED, NULL, std::string()); ui_test_utils::WaitForNavigation( &incognito_browser->GetSelectedTabContents()->controller()); incognito_browser->window()->Show(); @@ -1056,7 +1055,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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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 c04201e..8550ee1 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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 70ecdb8..5ba1d37 100644 --- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc +++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc @@ -394,10 +394,8 @@ 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_, - TabStripModel::ADD_SELECTED | - (pinned_ ? TabStripModel::ADD_PINNED : 0)); + attached_tabstrip_->model()->InsertTabContentsAt(index, dragged_contents_, + true, false, pinned_); tab = GetTabMatchingDraggedContents(attached_tabstrip_); } @@ -618,10 +616,8 @@ 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_, - TabStripModel::ADD_SELECTED | - (pinned_ ? TabStripModel::ADD_PINNED : 0)); + source_tabstrip_->model()->InsertTabContentsAt(source_model_index_, + dragged_contents_, true, false, pinned_); } else { // The tab was moved within the tabstrip where the drag was initiated. // Move it back to the starting location. @@ -635,10 +631,8 @@ 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_, - TabStripModel::ADD_SELECTED | - (pinned_ ? TabStripModel::ADD_PINNED : 0)); + source_tabstrip_->model()->InsertTabContentsAt(source_model_index_, + dragged_contents_, true, false, pinned_); } // 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 0a86cb8..a05105a 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, PageTransition::GENERATED, - TabStripModel::ADD_SELECTED); + model_->AddTabContents(contents, drop_index, false, + PageTransition::GENERATED, true); } else { model_->GetTabContentsAt(drop_index)->controller().LoadURL( url, GURL(), PageTransition::GENERATED); @@ -1982,8 +1982,9 @@ void TabStripGtk::OnNewTabClicked(GtkWidget* widget) { model_->AddTabContents( contents, -1, // index + false, // force_index PageTransition::TYPED, - TabStripModel::ADD_SELECTED); + true); // foreground break; } default: diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index fcb8f28..348dcba 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, - TabStripModel::ADD_SELECTED, site, std::string()); + browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, + -1, Browser::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 4c0d8cd4..8d18e78 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + GURL(path), GURL(), PageTransition::LINK, -1, Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + GURL(url), GURL(), PageTransition::LINK, -1, Browser::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 9a28c71..2537411 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 = TabStripModel::ADD_FORCE_INDEX; + int add_types = Browser::ADD_FORCE_INDEX; if (i == 0) - add_types |= TabStripModel::ADD_SELECTED; + add_types |= Browser::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 e2752c1..41edc2a 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::ADD_SELECTED, NULL, std::string()); ui_test_utils::WaitForNavigationInCurrentTab(browser()); browser()->AddTabWithURL(url3, GURL(), PageTransition::LINK, 2, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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 10a1200..e28ef95 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, TabStripModel::ADD_SELECTED, - tab1->GetSiteInstance(), std::string()); + PageTransition::TYPED, 0, Browser::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, TabStripModel::ADD_SELECTED, - tab1->GetSiteInstance(), std::string()); + PageTransition::TYPED, 0, Browser::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, TabStripModel::ADD_SELECTED, NULL, + url, GURL(), PageTransition::TYPED, 0, Browser::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 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); diff --git a/chrome/browser/task_manager_browsertest.cc b/chrome/browser/task_manager_browsertest.cc index 8751db0..e60d6d7 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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 a2555c8..1bb36f1 100644 --- a/chrome/browser/views/app_launcher.cc +++ b/chrome/browser/views/app_launcher.cc @@ -390,10 +390,9 @@ 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, - TabStripModel::ADD_SELECTED | TabStripModel::ADD_FORCE_INDEX, NULL, - std::string()); + browser_->AddTabWithURL(url, GURL(), transition, index, + Browser::ADD_SELECTED | Browser::ADD_FORCE_INDEX, + NULL, std::string()); break; } case chromeos::StatusAreaView::OPEN_TABS_CLOBBER: { @@ -402,18 +401,16 @@ void AppLauncher::AddTabWithURL(const GURL& url, break; } case chromeos::StatusAreaView::OPEN_TABS_ON_RIGHT: { - browser_->AddTabWithURL( - url, GURL(), transition, -1, - TabStripModel::ADD_SELECTED | TabStripModel::ADD_FORCE_INDEX, NULL, - std::string()); + browser_->AddTabWithURL(url, GURL(), transition, -1, + Browser::ADD_SELECTED | Browser::ADD_FORCE_INDEX, + NULL, std::string()); break; } } #else - browser_->AddTabWithURL( - url, GURL(), transition, -1, - TabStripModel::ADD_SELECTED | TabStripModel::ADD_FORCE_INDEX, NULL, - std::string()); + browser_->AddTabWithURL(url, GURL(), transition, -1, + Browser::ADD_SELECTED | Browser::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 51080bf..6e9bfbe 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::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 dcb41dd..6b00128 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, PageTransition::GENERATED, - TabStripModel::ADD_SELECTED); + model_->AddTabContents(contents, index, false, + PageTransition::GENERATED, true); } 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 0521bc6..bb97cd6 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -847,10 +847,8 @@ 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_, - TabStripModel::ADD_SELECTED | - (pinned_ ? TabStripModel::ADD_PINNED : 0)); + GetModel(attached_tabstrip_)->InsertTabContentsAt(index, dragged_contents_, + true, false, pinned_); attached_tabstrip_->set_attaching_dragged_tab(false); tab = GetTabMatchingDraggedContents(attached_tabstrip_); @@ -1102,10 +1100,8 @@ 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_, - TabStripModel::ADD_SELECTED | - (pinned_ ? TabStripModel::ADD_PINNED : 0)); + GetModel(source_tabstrip_)->InsertTabContentsAt(source_model_index_, + dragged_contents_, true, false, pinned_); } else { // The Tab was moved within the TabStrip where the drag was initiated. // Move it back to the starting location. @@ -1120,10 +1116,8 @@ 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_, - TabStripModel::ADD_SELECTED | - (pinned_ ? TabStripModel::ADD_PINNED : 0)); + GetModel(source_tabstrip_)->InsertTabContentsAt(source_model_index_, + dragged_contents_, true, false, pinned_); } // 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 b6a5d4a..a598d44 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, - TabStripModel::ADD_SELECTED, NULL, std::string()); + Browser::ADD_SELECTED, NULL, std::string()); views::RootView* root = views::Widget::FindRootView(browser()->window()->GetNativeHandle()); ASSERT_TRUE(root); |