diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/debugger/devtools_window.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/browser_browsertest.cc | 20 | ||||
-rw-r--r-- | chrome/browser/ui/browser_commands.cc | 48 | ||||
-rw-r--r-- | chrome/browser/ui/browser_instant_controller.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/browser_navigator.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/tabs/tab_strip_model.cc | 25 | ||||
-rw-r--r-- | chrome/browser/ui/tabs/tab_strip_model.h | 18 | ||||
-rw-r--r-- | chrome/browser/ui/tabs/tab_strip_model_order_controller.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/tabs/tab_strip_model_unittest.cc | 596 |
11 files changed, 341 insertions, 384 deletions
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index c376f53..6802c2c 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -398,8 +398,8 @@ void DevToolsWindow::CreateDevToolsBrowser() { } browser_ = new Browser(Browser::CreateParams::CreateForDevTools(profile_)); - browser_->tab_strip_model()->AddTabContents( - tab_contents_, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, + browser_->tab_strip_model()->AddWebContents( + tab_contents_->web_contents(), -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, TabStripModel::ADD_ACTIVE); } diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index d34825b..5f4caab 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -991,7 +991,7 @@ void Browser::RequestMediaAccessPermissionHelper( void Browser::UpdateUIForNavigationInTab(TabContents* contents, content::PageTransition transition, bool user_initiated) { - tab_strip_model_->TabNavigating(contents, transition); + tab_strip_model_->TabNavigating(contents->web_contents(), transition); bool contents_is_selected = contents == tab_strip_model_->GetActiveTabContents(); diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index ed9321a..5283ceb 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -36,7 +36,6 @@ #include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/browser/ui/tabs/pinned_tab_codec.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_notification_types.h" @@ -871,13 +870,14 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { ui_test_utils::NavigateToURL(browser(), url); - TabContents* app_contents = chrome::TabContentsFactory( + WebContents* app_contents = WebContents::Create( browser()->profile(), NULL, MSG_ROUTING_NONE, NULL); + extensions::TabHelper::CreateForWebContents(app_contents); extensions::TabHelper* extensions_tab_helper = - extensions::TabHelper::FromWebContents(app_contents->web_contents()); + extensions::TabHelper::FromWebContents(app_contents); extensions_tab_helper->SetExtensionApp(extension_app); - model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), + model->AddWebContents(app_contents, 0, content::PageTransitionFromInt(0), TabStripModel::ADD_NONE); model->SetTabPinned(0, true); ui_test_utils::NavigateToURL(browser(), url); @@ -992,12 +992,13 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); const Extension* extension_app = GetExtension(); ui_test_utils::NavigateToURL(browser(), url); - TabContents* app_contents = chrome::TabContentsFactory( + WebContents* app_contents = WebContents::Create( browser()->profile(), NULL, MSG_ROUTING_NONE, NULL); + extensions::TabHelper::CreateForWebContents(app_contents); extensions::TabHelper* extensions_tab_helper = - extensions::TabHelper::FromWebContents(app_contents->web_contents()); + extensions::TabHelper::FromWebContents(app_contents); extensions_tab_helper->SetExtensionApp(extension_app); - model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), + model->AddWebContents(app_contents, 0, content::PageTransitionFromInt(0), TabStripModel::ADD_NONE); model->SetTabPinned(0, true); ui_test_utils::NavigateToURL(browser(), url); @@ -1049,12 +1050,11 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { EXPECT_FALSE(new_model->IsTabPinned(2)); EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), - new_model->GetTabContentsAt(2)->web_contents()->GetURL()); + new_model->GetWebContentsAt(2)->GetURL()); EXPECT_TRUE( extensions::TabHelper::FromWebContents( - new_model->GetTabContentsAt(0)->web_contents())-> - extension_app() == extension_app); + new_model->GetWebContentsAt(0))->extension_app() == extension_app); } #endif // !defined(OS_CHROMEOS) diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index f2f1056..996b027 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc @@ -95,14 +95,6 @@ using content::SSLStatus; using content::UserMetricsAction; using content::WebContents; -// TODO(avi): Kill this when TabContents goes away. -class BrowserCommandsTabContentsCreator { - public: - static TabContents* CreateTabContents(content::WebContents* contents) { - return TabContents::Factory::CreateTabContents(contents); - } -}; - namespace chrome { namespace { @@ -138,25 +130,21 @@ void BookmarkCurrentPageInternal(Browser* browser, bool from_star) { WebContents* GetOrCloneTabForDisposition(Browser* browser, WindowOpenDisposition disposition) { - TabContents* current_tab = browser->tab_strip_model()->GetActiveTabContents(); + WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); switch (disposition) { case NEW_FOREGROUND_TAB: case NEW_BACKGROUND_TAB: { - current_tab = - BrowserCommandsTabContentsCreator::CreateTabContents( - current_tab->web_contents()->Clone()); - browser->tab_strip_model()->AddTabContents( + current_tab = current_tab->Clone(); + browser->tab_strip_model()->AddWebContents( current_tab, -1, content::PAGE_TRANSITION_LINK, disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE); break; } case NEW_WINDOW: { - current_tab = - BrowserCommandsTabContentsCreator::CreateTabContents( - current_tab->web_contents()->Clone()); + current_tab = current_tab->Clone(); Browser* b = new Browser(Browser::CreateParams(browser->profile())); - b->tab_strip_model()->AddTabContents( + b->tab_strip_model()->AddWebContents( current_tab, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_ACTIVE); b->window()->Show(); @@ -165,7 +153,7 @@ WebContents* GetOrCloneTabForDisposition(Browser* browser, default: break; } - return current_tab->web_contents(); + return current_tab; } void ReloadInternal(Browser* browser, @@ -570,8 +558,7 @@ bool CanDuplicateTab(const Browser* browser) { WebContents* DuplicateTabAt(Browser* browser, int index) { WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(index); CHECK(contents); - TabContents* contents_dupe = - BrowserCommandsTabContentsCreator::CreateTabContents(contents->Clone()); + WebContents* contents_dupe = contents->Clone(); bool pinned = false; if (browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)) { @@ -583,7 +570,7 @@ WebContents* DuplicateTabAt(Browser* browser, int index) { TabStripModel::ADD_INHERIT_GROUP | (pinned ? TabStripModel::ADD_PINNED : 0); browser->tab_strip_model()->InsertWebContentsAt( - index + 1, contents_dupe->web_contents(), add_types); + index + 1, contents_dupe, add_types); } else { Browser* browser = NULL; if (browser->is_app()) { @@ -610,7 +597,7 @@ WebContents* DuplicateTabAt(Browser* browser, int index) { browser->window()->Show(); // The page transition below is only for the purpose of inserting the tab. - browser->tab_strip_model()->AddTabContents(contents_dupe, -1, + browser->tab_strip_model()->AddWebContents(contents_dupe, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_ACTIVE); } @@ -618,8 +605,8 @@ WebContents* DuplicateTabAt(Browser* browser, int index) { SessionService* session_service = SessionServiceFactory::GetForProfileIfExisting(browser->profile()); if (session_service) - session_service->TabRestored(contents_dupe->web_contents(), pinned); - return contents_dupe->web_contents(); + session_service->TabRestored(contents_dupe, pinned); + return contents_dupe; } bool CanDuplicateTabAt(Browser* browser, int index) { @@ -997,11 +984,10 @@ void ViewSource(Browser* browser, // Note that Clone does not copy the pending or transient entries, so the // active entry in view_source_contents will be the last committed entry. - TabContents* view_source_contents = - BrowserCommandsTabContentsCreator::CreateTabContents(contents->Clone()); - view_source_contents->web_contents()->GetController().PruneAllButActive(); + WebContents* view_source_contents = contents->Clone(); + view_source_contents->GetController().PruneAllButActive(); NavigationEntry* active_entry = - view_source_contents->web_contents()->GetController().GetActiveEntry(); + view_source_contents->GetController().GetActiveEntry(); if (!active_entry) return; @@ -1025,7 +1011,7 @@ void ViewSource(Browser* browser, TabStripModel::ADD_INHERIT_GROUP; browser->tab_strip_model()->InsertWebContentsAt( index + 1, - view_source_contents->web_contents(), + view_source_contents, add_types); } else { Browser* b = new Browser( @@ -1042,7 +1028,7 @@ void ViewSource(Browser* browser, b->window()->Show(); // The page transition below is only for the purpose of inserting the tab. - b->tab_strip_model()->AddTabContents(view_source_contents, -1, + b->tab_strip_model()->AddWebContents(view_source_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_ACTIVE); } @@ -1050,7 +1036,7 @@ void ViewSource(Browser* browser, SessionService* session_service = SessionServiceFactory::GetForProfileIfExisting(browser->profile()); if (session_service) - session_service->TabRestored(view_source_contents->web_contents(), false); + session_service->TabRestored(view_source_contents, false); } void ViewSelectedSource(Browser* browser) { diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc index e8f9dba..3cab847 100644 --- a/chrome/browser/ui/browser_instant_controller.cc +++ b/chrome/browser/ui/browser_instant_controller.cc @@ -92,7 +92,7 @@ void BrowserInstantController::CommitInstant(TabContents* preview, bool in_new_tab) { if (in_new_tab) { // TabStripModel takes ownership of |preview|. - browser_->tab_strip_model()->AddTabContents(preview, -1, + browser_->tab_strip_model()->AddWebContents(preview->web_contents(), -1, instant_.last_transition_type(), TabStripModel::ADD_ACTIVE); } else { TabContents* active_tab = diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index 60db09f..0813846 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -486,7 +486,7 @@ void Navigate(NavigateParams* params) { // By default, content believes it is not hidden. When adding contents // in the background, tell it that it's hidden. if ((params->tabstrip_add_types & TabStripModel::ADD_ACTIVE) == 0) { - // TabStripModel::AddTabContents invokes WasHidden if not foreground. + // TabStripModel::AddWebContents invokes WasHidden if not foreground. params->target_contents->web_contents()->WasHidden(); } } else { @@ -538,8 +538,8 @@ void Navigate(NavigateParams* params) { params->tabstrip_add_types |= TabStripModel::ADD_FORCE_INDEX; // The navigation should insert a new tab into the target Browser. - params->browser->tab_strip_model()->AddTabContents( - params->target_contents, + params->browser->tab_strip_model()->AddWebContents( + params->target_contents->web_contents(), params->tabstrip_index, params->transition, params->tabstrip_add_types); diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h index f3026f3..f8bc705 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.h +++ b/chrome/browser/ui/tab_contents/tab_contents.h @@ -12,7 +12,6 @@ #include "content/public/browser/web_contents_observer.h" class Browser; -class BrowserCommandsTabContentsCreator; class BrowserTabstripTabContentsCreator; class ChromeWebContentsHandler; class ConstrainedWebDialogDelegateBase; @@ -56,7 +55,6 @@ class TabContents : public content::WebContentsObserver { // do so. friend class Browser; - friend class BrowserCommandsTabContentsCreator; friend class BrowserTabstripTabContentsCreator; friend class ChromeWebContentsHandler; friend class ConstrainedWebDialogDelegateBase; diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc index a1f1707..264fcf5 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.cc +++ b/chrome/browser/ui/tabs/tab_strip_model.cc @@ -427,7 +427,7 @@ int TabStripModel::GetIndexOfLastWebContentsOpenedBy(const WebContents* opener, return kNoTab; } -void TabStripModel::TabNavigating(TabContents* contents, +void TabStripModel::TabNavigating(WebContents* contents, content::PageTransition transition) { if (ShouldForgetOpenersForTransition(transition)) { // Don't forget the openers if this tab is a New Tab page opened at the @@ -444,7 +444,7 @@ void TabStripModel::TabNavigating(TabContents* contents, ForgetAllOpeners(); // In this specific case we also want to reset the group relationship, // since it is now technically invalid. - ForgetGroup(contents->web_contents()); + ForgetGroup(contents); } } } @@ -603,7 +603,7 @@ void TabStripModel::SetSelectionFromModel( SetSelection(source, NOTIFY_DEFAULT); } -void TabStripModel::AddTabContents(TabContents* contents, +void TabStripModel::AddWebContents(WebContents* contents, int index, content::PageTransition transition, int add_types) { @@ -638,11 +638,10 @@ void TabStripModel::AddTabContents(TabContents* contents, // is re-selected, not the next-adjacent. inherit_group = true; } - InsertWebContentsAt(index, - contents->web_contents(), + InsertWebContentsAt(index, contents, add_types | (inherit_group ? ADD_INHERIT_GROUP : 0)); // Reset the index, just in case insert ended up moving it on us. - index = GetIndexOfTabContents(contents); + index = GetIndexOfWebContents(contents); if (inherit_group && transition == content::PAGE_TRANSITION_TYPED) contents_data_[index]->reset_group_on_select = true; @@ -659,12 +658,12 @@ void TabStripModel::AddTabContents(TabContents* contents, // new background tab. if (WebContents* old_contents = GetActiveWebContents()) { if ((add_types & ADD_ACTIVE) == 0) { - contents->web_contents()->GetView()-> - SizeContents(old_contents->GetView()->GetContainerSize()); + contents->GetView()->SizeContents( + old_contents->GetView()->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->web_contents()->WasHidden(); + contents->WasHidden(); } } } @@ -1018,12 +1017,12 @@ std::vector<int> TabStripModel::GetIndicesForCommand(int index) const { return selection_model_.selected_indices(); } -bool TabStripModel::IsNewTabAtEndOfTabStrip(TabContents* contents) const { - const GURL& url = contents->web_contents()->GetURL(); +bool TabStripModel::IsNewTabAtEndOfTabStrip(WebContents* contents) const { + const GURL& url = contents->GetURL(); return url.SchemeIs(chrome::kChromeUIScheme) && url.host() == chrome::kChromeUINewTabHost && - contents == GetTabContentsAtImpl(count() - 1) && - contents->web_contents()->GetController().GetEntryCount() == 1; + contents == GetWebContentsAtImpl(count() - 1) && + contents->GetController().GetEntryCount() == 1; } bool TabStripModel::InternalCloseTabs(const std::vector<int>& indices, diff --git a/chrome/browser/ui/tabs/tab_strip_model.h b/chrome/browser/ui/tabs/tab_strip_model.h index 0bac2d5..c80c06f 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.h +++ b/chrome/browser/ui/tabs/tab_strip_model.h @@ -175,7 +175,7 @@ class TabStripModel : public content::NotificationObserver { // as such the ADD_FORCE_INDEX AddTabTypes 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. + // See also AddWebContents. void InsertWebContentsAt(int index, content::WebContents* contents, int add_types); @@ -294,11 +294,11 @@ class TabStripModel : public content::NotificationObserver { int GetIndexOfLastWebContentsOpenedBy(const content::WebContents* opener, int start_index) const; - // Called by the Browser when a navigation is about to occur in the specified - // TabContents. Depending on the tab, and the transition type of the + // To be called when a navigation is about to occur in the specified + // WebContents. Depending on the tab, and the transition type of the // navigation, the TabStripModel may adjust its selection and grouping // behavior. - void TabNavigating(TabContents* contents, + void TabNavigating(content::WebContents* contents, content::PageTransition transition); // Forget all Opener relationships that are stored (but _not_ group @@ -380,12 +380,12 @@ class TabStripModel : public content::NotificationObserver { // Command level API ///////////////////////////////////////////////////////// - // Adds a TabContents at the best position in the TabStripModel given + // Adds a WebContents at the best position in the TabStripModel given // the specified insertion index, transition, etc. |add_types| is a bitmask of // AddTabTypes; see it for details. This method ends up calling into - // InsertWebContentsAt to do the actual insertion. Pass -1 for |index| to + // InsertWebContentsAt to do the actual insertion. Pass kNoTab for |index| to // append the contents to the end of the tab strip. - void AddTabContents(TabContents* contents, + void AddWebContents(content::WebContents* contents, int index, content::PageTransition transition, int add_types); @@ -474,12 +474,12 @@ class TabStripModel : public content::NotificationObserver { // determine which indices the command applies to. std::vector<int> GetIndicesForCommand(int index) const; - // Returns true if the specified TabContents is a New Tab at the end of + // Returns true if the specified WebContents is a New Tab at the end of // the tabstrip. We check for this because opener relationships are _not_ // forgotten for the New Tab page opened as a result of a New Tab gesture // (e.g. Ctrl+T, etc) since the user may open a tab transiently to look up // something related to their current activity. - bool IsNewTabAtEndOfTabStrip(TabContents* contents) const; + bool IsNewTabAtEndOfTabStrip(content::WebContents* contents) const; // Closes the WebContentses at the specified indices. This causes the // WebContentses to be destroyed, but it may not happen immediately. If diff --git a/chrome/browser/ui/tabs/tab_strip_model_order_controller.cc b/chrome/browser/ui/tabs/tab_strip_model_order_controller.cc index 0801412..d83ca2d 100644 --- a/chrome/browser/ui/tabs/tab_strip_model_order_controller.cc +++ b/chrome/browser/ui/tabs/tab_strip_model_order_controller.cc @@ -105,7 +105,7 @@ void TabStripModelOrderController::ActiveTabChanged( old_opener = tabstrip_->GetOpenerOfWebContentsAt(index); // Forget any group/opener relationships that need to be reset whenever - // selection changes (see comment in TabStripModel::AddTabContentsAt). + // selection changes (see comment in TabStripModel::AddWebContentsAt). if (tabstrip_->ShouldResetGroupOnSelect(old_contents)) tabstrip_->ForgetGroup(old_contents); } diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc index b693b67..46397c4 100644 --- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc @@ -117,11 +117,17 @@ class TabStripModelTest : public ChromeRenderViewHostTestHarness { return chrome::TabContentsFactory(profile(), NULL, MSG_ROUTING_NONE, NULL); } - TabContents* CreateTabContentsWithSharedRPH(WebContents* web_contents) { - TabContents* retval = chrome::TabContentsFactory(profile(), - web_contents->GetRenderViewHost()->GetSiteInstance(), MSG_ROUTING_NONE, + WebContents* CreateWebContents() { + return WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL); + } + + WebContents* CreateWebContentsWithSharedRPH(WebContents* web_contents) { + WebContents* retval = WebContents::Create( + profile(), + web_contents->GetRenderViewHost()->GetSiteInstance(), + MSG_ROUTING_NONE, NULL); - EXPECT_EQ(retval->web_contents()->GetRenderProcessHost(), + EXPECT_EQ(retval->GetRenderProcessHost(), web_contents->GetRenderProcessHost()); return retval; } @@ -181,9 +187,9 @@ class TabStripModelTest : public ChromeRenderViewHostTestHarness { int pinned_count, const std::string& selected_tabs) { for (int i = 0; i < tab_count; ++i) { - TabContents* contents = CreateTabContents(); - SetID(contents->web_contents(), i); - model->AppendWebContents(contents->web_contents(), true); + WebContents* contents = CreateWebContents(); + SetID(contents, i); + model->AppendWebContents(contents, true); } for (int i = 0; i < pinned_count; ++i) model->SetTabPinned(i, true); @@ -358,8 +364,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) { typedef MockTabStripModelObserver::State State; - TabContents* tab_contents1 = CreateTabContents(); - WebContents* contents1 = tab_contents1->web_contents(); + WebContents* contents1 = CreateWebContents(); SetID(contents1, 1); // Note! The ordering of these tests is important, each subsequent test @@ -387,8 +392,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) { EXPECT_EQ("1", GetTabStripStateString(tabstrip)); // Test InsertWebContentsAt, foreground tab. - TabContents* tab_contents2 = CreateTabContents(); - WebContents* contents2 = tab_contents2->web_contents(); + WebContents* contents2 = CreateWebContents(); SetID(contents2, 2); { tabstrip.InsertWebContentsAt(1, contents2, TabStripModel::ADD_ACTIVE); @@ -412,8 +416,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) { EXPECT_EQ("1 2", GetTabStripStateString(tabstrip)); // Test InsertWebContentsAt, background tab. - TabContents* tab_contents3 = CreateTabContents(); - WebContents* contents3 = tab_contents3->web_contents(); + WebContents* contents3 = CreateWebContents(); SetID(contents3, 3); { tabstrip.InsertWebContentsAt(2, contents3, TabStripModel::ADD_NONE); @@ -537,16 +540,11 @@ TEST_F(TabStripModelTest, TestBasicAPI) { // Test Getters { - EXPECT_EQ(tab_contents2, tabstrip.GetActiveTabContents()); EXPECT_EQ(contents2, tabstrip.GetActiveWebContents()); - EXPECT_EQ(tab_contents2, tabstrip.GetTabContentsAt(0)); - EXPECT_EQ(tab_contents1, tabstrip.GetTabContentsAt(1)); EXPECT_EQ(contents2, tabstrip.GetWebContentsAt(0)); EXPECT_EQ(contents1, tabstrip.GetWebContentsAt(1)); - EXPECT_EQ(0, tabstrip.GetIndexOfTabContents(tab_contents2)); - EXPECT_EQ(1, tabstrip.GetIndexOfTabContents(tab_contents1)); - EXPECT_EQ(0, tabstrip.GetIndexOfWebContents(tab_contents2->web_contents())); - EXPECT_EQ(1, tabstrip.GetIndexOfWebContents(tab_contents1->web_contents())); + EXPECT_EQ(0, tabstrip.GetIndexOfWebContents(contents2)); + EXPECT_EQ(1, tabstrip.GetIndexOfWebContents(contents1)); } // Test UpdateWebContentsStateAt @@ -594,30 +592,29 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) { TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - // This is a basic test of opener functionality. opener_contents is created + // This is a basic test of opener functionality. opener is created // as the first tab in the strip and then we create 5 other tabs in the - // background with opener_contents set as their opener. + // background with opener set as their opener. - TabContents* opener_contents = CreateTabContents(); - WebContents* opener = opener_contents->web_contents(); + WebContents* opener = CreateWebContents(); tabstrip.AppendWebContents(opener, true); - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - TabContents* contents3 = CreateTabContents(); - TabContents* contents4 = CreateTabContents(); - TabContents* contents5 = CreateTabContents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); + WebContents* contents4 = CreateWebContents(); + WebContents* contents5 = CreateWebContents(); // We use |InsertWebContentsAt| here instead of |AppendWebContents| so that // openership relationships are preserved. - tabstrip.InsertWebContentsAt(tabstrip.count(), contents1->web_contents(), + tabstrip.InsertWebContentsAt(tabstrip.count(), contents1, TabStripModel::ADD_INHERIT_GROUP); - tabstrip.InsertWebContentsAt(tabstrip.count(), contents2->web_contents(), + tabstrip.InsertWebContentsAt(tabstrip.count(), contents2, TabStripModel::ADD_INHERIT_GROUP); - tabstrip.InsertWebContentsAt(tabstrip.count(), contents3->web_contents(), + tabstrip.InsertWebContentsAt(tabstrip.count(), contents3, TabStripModel::ADD_INHERIT_GROUP); - tabstrip.InsertWebContentsAt(tabstrip.count(), contents4->web_contents(), + tabstrip.InsertWebContentsAt(tabstrip.count(), contents4, TabStripModel::ADD_INHERIT_GROUP); - tabstrip.InsertWebContentsAt(tabstrip.count(), contents5->web_contents(), + tabstrip.InsertWebContentsAt(tabstrip.count(), contents5, TabStripModel::ADD_INHERIT_GROUP); // All the tabs should have the same opener. @@ -637,9 +634,10 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) { // For a tab that has opened no other tabs, the return value should always be // -1... - WebContents* o1 = contents1->web_contents(); - EXPECT_EQ(-1, tabstrip.GetIndexOfNextWebContentsOpenedBy(o1, 3, false)); - EXPECT_EQ(-1, tabstrip.GetIndexOfLastWebContentsOpenedBy(o1, 3)); + EXPECT_EQ(-1, + tabstrip.GetIndexOfNextWebContentsOpenedBy(contents1, 3, false)); + EXPECT_EQ(-1, + tabstrip.GetIndexOfLastWebContentsOpenedBy(contents1, 3)); // ForgetAllOpeners should destroy all opener relationships. tabstrip.ForgetAllOpeners(); @@ -648,19 +646,18 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) { EXPECT_EQ(-1, tabstrip.GetIndexOfLastWebContentsOpenedBy(opener, 1)); // Specify the last tab as the opener of the others. - WebContents* o5 = contents5->web_contents(); for (int i = 0; i < tabstrip.count() - 1; ++i) - tabstrip.SetOpenerOfWebContentsAt(i, o5); + tabstrip.SetOpenerOfWebContentsAt(i, contents5); for (int i = 0; i < tabstrip.count() - 1; ++i) - EXPECT_EQ(o5, tabstrip.GetOpenerOfWebContentsAt(i)); + EXPECT_EQ(contents5, tabstrip.GetOpenerOfWebContentsAt(i)); // If there is a next adjacent item, then the index should be of that item. - EXPECT_EQ(2, tabstrip.GetIndexOfNextWebContentsOpenedBy(o5, 1, false)); + EXPECT_EQ(2, tabstrip.GetIndexOfNextWebContentsOpenedBy(contents5, 1, false)); // If the last tab in the group is closed, the preceding tab in the same // group should be selected. - EXPECT_EQ(3, tabstrip.GetIndexOfNextWebContentsOpenedBy(o5, 4, false)); + EXPECT_EQ(3, tabstrip.GetIndexOfNextWebContentsOpenedBy(contents5, 4, false)); tabstrip.CloseAllTabs(); EXPECT_TRUE(tabstrip.empty()); @@ -671,18 +668,18 @@ static int GetInsertionIndex(TabStripModel* tabstrip) { content::PAGE_TRANSITION_LINK, false); } -static void InsertTabContentses(TabStripModel* tabstrip, - TabContents* contents1, - TabContents* contents2, - TabContents* contents3) { +static void InsertWebContentses(TabStripModel* tabstrip, + WebContents* contents1, + WebContents* contents2, + WebContents* contents3) { tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip), - contents1->web_contents(), + contents1, TabStripModel::ADD_INHERIT_GROUP); tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip), - contents2->web_contents(), + contents2, TabStripModel::ADD_INHERIT_GROUP); tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip), - contents3->web_contents(), + contents3, TabStripModel::ADD_INHERIT_GROUP); } @@ -692,19 +689,18 @@ TEST_F(TabStripModelTest, TestLTRInsertionOptions) { TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - TabContents* opener_contents = CreateTabContents(); - WebContents* opener = opener_contents->web_contents(); + WebContents* opener = CreateWebContents(); tabstrip.AppendWebContents(opener, true); - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - TabContents* contents3 = CreateTabContents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); // Test LTR - InsertTabContentses(&tabstrip, contents1, contents2, contents3); - EXPECT_EQ(contents1, tabstrip.GetTabContentsAt(1)); - EXPECT_EQ(contents2, tabstrip.GetTabContentsAt(2)); - EXPECT_EQ(contents3, tabstrip.GetTabContentsAt(3)); + InsertWebContentses(&tabstrip, contents1, contents2, contents3); + EXPECT_EQ(contents1, tabstrip.GetWebContentsAt(1)); + EXPECT_EQ(contents2, tabstrip.GetWebContentsAt(2)); + EXPECT_EQ(contents3, tabstrip.GetWebContentsAt(3)); tabstrip.CloseAllTabs(); EXPECT_TRUE(tabstrip.empty()); @@ -721,27 +717,25 @@ TEST_F(TabStripModelTest, TestInsertionIndexDetermination) { TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - TabContents* opener_contents = CreateTabContents(); - WebContents* opener = opener_contents->web_contents(); + WebContents* opener = CreateWebContents(); tabstrip.AppendWebContents(opener, true); // Open some other random unrelated tab in the background to monkey with our // insertion index. - TabContents* other_contents = CreateTabContents(); - WebContents* other = other_contents->web_contents(); + WebContents* other = CreateWebContents(); tabstrip.AppendWebContents(other, false); - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - TabContents* contents3 = CreateTabContents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); - // Start by testing LTR - InsertTabContentses(&tabstrip, contents1, contents2, contents3); - EXPECT_EQ(opener_contents, tabstrip.GetTabContentsAt(0)); - EXPECT_EQ(contents1, tabstrip.GetTabContentsAt(1)); - EXPECT_EQ(contents2, tabstrip.GetTabContentsAt(2)); - EXPECT_EQ(contents3, tabstrip.GetTabContentsAt(3)); - EXPECT_EQ(other_contents, tabstrip.GetTabContentsAt(4)); + // Start by testing LTR. + InsertWebContentses(&tabstrip, contents1, contents2, contents3); + EXPECT_EQ(opener, tabstrip.GetWebContentsAt(0)); + EXPECT_EQ(contents1, tabstrip.GetWebContentsAt(1)); + EXPECT_EQ(contents2, tabstrip.GetWebContentsAt(2)); + EXPECT_EQ(contents3, tabstrip.GetWebContentsAt(3)); + EXPECT_EQ(other, tabstrip.GetWebContentsAt(4)); // The opener API should work... EXPECT_EQ(3, tabstrip.GetIndexOfNextWebContentsOpenedBy(opener, 2, false)); @@ -750,34 +744,34 @@ TEST_F(TabStripModelTest, TestInsertionIndexDetermination) { // Now open a foreground tab from a link. It should be opened adjacent to the // opener tab. - TabContents* fg_link_contents = CreateTabContents(); + WebContents* fg_link_contents = CreateWebContents(); int insert_index = tabstrip.order_controller()->DetermineInsertionIndex( content::PAGE_TRANSITION_LINK, true); EXPECT_EQ(1, insert_index); - tabstrip.InsertWebContentsAt(insert_index, fg_link_contents->web_contents(), + tabstrip.InsertWebContentsAt(insert_index, fg_link_contents, TabStripModel::ADD_ACTIVE | TabStripModel::ADD_INHERIT_GROUP); EXPECT_EQ(1, tabstrip.active_index()); - EXPECT_EQ(fg_link_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(fg_link_contents, tabstrip.GetActiveWebContents()); // Now close this contents. The selection should move to the opener contents. tabstrip.CloseSelectedTabs(); EXPECT_EQ(0, tabstrip.active_index()); // Now open a new empty tab. It should open at the end of the strip. - TabContents* fg_nonlink_contents = CreateTabContents(); + WebContents* fg_nonlink_contents = CreateWebContents(); insert_index = tabstrip.order_controller()->DetermineInsertionIndex( content::PAGE_TRANSITION_AUTO_BOOKMARK, true); EXPECT_EQ(tabstrip.count(), insert_index); // We break the opener relationship... tabstrip.InsertWebContentsAt(insert_index, - fg_nonlink_contents->web_contents(), + fg_nonlink_contents, TabStripModel::ADD_NONE); // Now select it, so that user_gesture == true causes the opener relationship // to be forgotten... tabstrip.ActivateTabAt(tabstrip.count() - 1, true); EXPECT_EQ(tabstrip.count() - 1, tabstrip.active_index()); - EXPECT_EQ(fg_nonlink_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(fg_nonlink_contents, tabstrip.GetActiveWebContents()); // Verify that all opener relationships are forgotten. EXPECT_EQ(-1, tabstrip.GetIndexOfNextWebContentsOpenedBy(opener, 2, false)); @@ -805,20 +799,19 @@ TEST_F(TabStripModelTest, TestSelectOnClose) { TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - TabContents* opener_contents = CreateTabContents(); - WebContents* opener = opener_contents->web_contents(); + WebContents* opener = CreateWebContents(); tabstrip.AppendWebContents(opener, true); - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - TabContents* contents3 = CreateTabContents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); // Note that we use Detach instead of Close throughout this test to avoid - // having to keep reconstructing these TabContentses. + // having to keep reconstructing these WebContentses. // First test that closing tabs that are in the background doesn't adjust the // current selection. - InsertTabContentses(&tabstrip, contents1, contents2, contents3); + InsertWebContentses(&tabstrip, contents1, contents2, contents3); EXPECT_EQ(0, tabstrip.active_index()); tabstrip.DetachTabContentsAt(1); @@ -829,7 +822,7 @@ TEST_F(TabStripModelTest, TestSelectOnClose) { // Now test that when a tab doesn't have an opener, selection shifts to the // right when the tab is closed. - InsertTabContentses(&tabstrip, contents1, contents2, contents3); + InsertWebContentses(&tabstrip, contents1, contents2, contents3); EXPECT_EQ(0, tabstrip.active_index()); tabstrip.ForgetAllOpeners(); @@ -847,7 +840,7 @@ TEST_F(TabStripModelTest, TestSelectOnClose) { // Now test that when a tab does have an opener, it selects the next tab // opened by the same opener scanning LTR when it is closed. - InsertTabContentses(&tabstrip, contents1, contents2, contents3); + InsertWebContentses(&tabstrip, contents1, contents2, contents3); EXPECT_EQ(0, tabstrip.active_index()); tabstrip.ActivateTabAt(2, false); EXPECT_EQ(2, tabstrip.active_index()); @@ -859,12 +852,12 @@ TEST_F(TabStripModelTest, TestSelectOnClose) { EXPECT_EQ(0, tabstrip.active_index()); // Finally test that when a tab has no "siblings" that the opener is // selected. - TabContents* other_contents = CreateTabContents(); - tabstrip.InsertWebContentsAt(1, other_contents->web_contents(), + WebContents* other_contents = CreateWebContents(); + tabstrip.InsertWebContentsAt(1, other_contents, TabStripModel::ADD_NONE); EXPECT_EQ(2, tabstrip.count()); - TabContents* opened_contents = CreateTabContents(); - tabstrip.InsertWebContentsAt(2, opened_contents->web_contents(), + WebContents* opened_contents = CreateWebContents(); + tabstrip.InsertWebContentsAt(2, opened_contents, TabStripModel::ADD_ACTIVE | TabStripModel::ADD_INHERIT_GROUP); EXPECT_EQ(2, tabstrip.active_index()); @@ -1051,15 +1044,14 @@ TEST_F(TabStripModelTest, TestContextMenuCloseCommands) { TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - TabContents* opener_contents = CreateTabContents(); - WebContents* opener = opener_contents->web_contents(); + WebContents* opener = CreateWebContents(); tabstrip.AppendWebContents(opener, true); - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - TabContents* contents3 = CreateTabContents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); - InsertTabContentses(&tabstrip, contents1, contents2, contents3); + InsertWebContentses(&tabstrip, contents1, contents2, contents3); EXPECT_EQ(0, tabstrip.active_index()); tabstrip.ExecuteContextMenuCommand(2, TabStripModel::CommandCloseTab); @@ -1067,26 +1059,25 @@ TEST_F(TabStripModelTest, TestContextMenuCloseCommands) { tabstrip.ExecuteContextMenuCommand(0, TabStripModel::CommandCloseTabsToRight); EXPECT_EQ(1, tabstrip.count()); - EXPECT_EQ(opener_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(opener, tabstrip.GetActiveWebContents()); - TabContents* dummy_contents = CreateTabContents(); - WebContents* dummy = dummy_contents->web_contents(); + WebContents* dummy = CreateWebContents(); tabstrip.AppendWebContents(dummy, false); - contents1 = CreateTabContents(); - contents2 = CreateTabContents(); - contents3 = CreateTabContents(); - InsertTabContentses(&tabstrip, contents1, contents2, contents3); + contents1 = CreateWebContents(); + contents2 = CreateWebContents(); + contents3 = CreateWebContents(); + InsertWebContentses(&tabstrip, contents1, contents2, contents3); EXPECT_EQ(5, tabstrip.count()); int dummy_index = tabstrip.count() - 1; tabstrip.ActivateTabAt(dummy_index, true); - EXPECT_EQ(dummy_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(dummy, tabstrip.GetActiveWebContents()); tabstrip.ExecuteContextMenuCommand(dummy_index, TabStripModel::CommandCloseOtherTabs); EXPECT_EQ(1, tabstrip.count()); - EXPECT_EQ(dummy_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(dummy, tabstrip.GetActiveWebContents()); tabstrip.CloseAllTabs(); EXPECT_TRUE(tabstrip.empty()); @@ -1098,11 +1089,11 @@ TEST_F(TabStripModelTest, GetIndicesClosedByCommand) { TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - WebContents* contents1 = CreateTabContents()->web_contents(); - WebContents* contents2 = CreateTabContents()->web_contents(); - WebContents* contents3 = CreateTabContents()->web_contents(); - WebContents* contents4 = CreateTabContents()->web_contents(); - WebContents* contents5 = CreateTabContents()->web_contents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); + WebContents* contents4 = CreateWebContents(); + WebContents* contents5 = CreateWebContents(); tabstrip.AppendWebContents(contents1, true); tabstrip.AppendWebContents(contents2, true); @@ -1139,23 +1130,23 @@ TEST_F(TabStripModelTest, GetIndicesClosedByCommand) { EXPECT_TRUE(tabstrip.empty()); } -// Tests whether or not TabContentses are inserted in the correct position +// Tests whether or not WebContentses are inserted in the correct position // using this "smart" function with a simulated middle click action on a series // of links on the home page. -TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) { +TEST_F(TabStripModelTest, AddWebContents_MiddleClickLinksAndClose) { TabStripDummyDelegate delegate; TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); // Open the Home Page. - TabContents* homepage_contents = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* homepage_contents = CreateWebContents(); + tabstrip.AddWebContents( homepage_contents, -1, content::PAGE_TRANSITION_AUTO_BOOKMARK, TabStripModel::ADD_ACTIVE); // Open some other tab, by user typing. - TabContents* typed_page_contents = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* typed_page_contents = CreateWebContents(); + tabstrip.AddWebContents( typed_page_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); @@ -1166,42 +1157,42 @@ TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) { // Open a bunch of tabs by simulating middle clicking on links on the home // page. - TabContents* middle_click_contents1 = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* middle_click_contents1 = CreateWebContents(); + tabstrip.AddWebContents( middle_click_contents1, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - TabContents* middle_click_contents2 = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* middle_click_contents2 = CreateWebContents(); + tabstrip.AddWebContents( middle_click_contents2, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - TabContents* middle_click_contents3 = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* middle_click_contents3 = CreateWebContents(); + tabstrip.AddWebContents( middle_click_contents3, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); EXPECT_EQ(5, tabstrip.count()); - EXPECT_EQ(homepage_contents, tabstrip.GetTabContentsAt(0)); - EXPECT_EQ(middle_click_contents1, tabstrip.GetTabContentsAt(1)); - EXPECT_EQ(middle_click_contents2, tabstrip.GetTabContentsAt(2)); - EXPECT_EQ(middle_click_contents3, tabstrip.GetTabContentsAt(3)); - EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(4)); + EXPECT_EQ(homepage_contents, tabstrip.GetWebContentsAt(0)); + EXPECT_EQ(middle_click_contents1, tabstrip.GetWebContentsAt(1)); + EXPECT_EQ(middle_click_contents2, tabstrip.GetWebContentsAt(2)); + EXPECT_EQ(middle_click_contents3, tabstrip.GetWebContentsAt(3)); + EXPECT_EQ(typed_page_contents, tabstrip.GetWebContentsAt(4)); // Now simulate selecting a tab in the middle of the group of tabs opened from - // the home page and start closing them. Each TabContents in the group + // the home page and start closing them. Each WebContents in the group // should be closed, right to left. This test is constructed to start at the - // middle TabContents in the group to make sure the cursor wraps around - // to the first TabContents in the group before closing the opener or - // any other TabContents. + // middle WebContents in the group to make sure the cursor wraps around + // to the first WebContents in the group before closing the opener or + // any other WebContents. tabstrip.ActivateTabAt(2, true); tabstrip.CloseSelectedTabs(); - EXPECT_EQ(middle_click_contents3, tabstrip.GetActiveTabContents()); + EXPECT_EQ(middle_click_contents3, tabstrip.GetActiveWebContents()); tabstrip.CloseSelectedTabs(); - EXPECT_EQ(middle_click_contents1, tabstrip.GetActiveTabContents()); + EXPECT_EQ(middle_click_contents1, tabstrip.GetActiveWebContents()); tabstrip.CloseSelectedTabs(); - EXPECT_EQ(homepage_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(homepage_contents, tabstrip.GetActiveWebContents()); tabstrip.CloseSelectedTabs(); - EXPECT_EQ(typed_page_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(typed_page_contents, tabstrip.GetActiveWebContents()); EXPECT_EQ(1, tabstrip.count()); @@ -1209,23 +1200,23 @@ TEST_F(TabStripModelTest, AddTabContents_MiddleClickLinksAndClose) { EXPECT_TRUE(tabstrip.empty()); } -// Tests whether or not a TabContents created by a left click on a link +// Tests whether or not a WebContents created by a left click on a link // that opens a new tab is inserted correctly adjacent to the tab that spawned // it. -TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) { +TEST_F(TabStripModelTest, AddWebContents_LeftClickPopup) { TabStripDummyDelegate delegate; TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - // Open the Home Page - TabContents* homepage_contents = CreateTabContents(); - tabstrip.AddTabContents( + // Open the Home Page. + WebContents* homepage_contents = CreateWebContents(); + tabstrip.AddWebContents( homepage_contents, -1, content::PAGE_TRANSITION_AUTO_BOOKMARK, TabStripModel::ADD_ACTIVE); // Open some other tab, by user typing. - TabContents* typed_page_contents = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* typed_page_contents = CreateWebContents(); + tabstrip.AddWebContents( typed_page_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); @@ -1235,24 +1226,24 @@ TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) { tabstrip.ActivateTabAt(0, true); // 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, + WebContents* left_click_contents = CreateWebContents(); + tabstrip.AddWebContents(left_click_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_ACTIVE); // Verify the state meets our expectations. EXPECT_EQ(3, tabstrip.count()); - EXPECT_EQ(homepage_contents, tabstrip.GetTabContentsAt(0)); - EXPECT_EQ(left_click_contents, tabstrip.GetTabContentsAt(1)); - EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(2)); + EXPECT_EQ(homepage_contents, tabstrip.GetWebContentsAt(0)); + EXPECT_EQ(left_click_contents, tabstrip.GetWebContentsAt(1)); + EXPECT_EQ(typed_page_contents, tabstrip.GetWebContentsAt(2)); // The newly created tab should be selected. - EXPECT_EQ(left_click_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(left_click_contents, tabstrip.GetActiveWebContents()); // After closing the selected tab, the selection should move to the left, to // the opener. tabstrip.CloseSelectedTabs(); - EXPECT_EQ(homepage_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(homepage_contents, tabstrip.GetActiveWebContents()); EXPECT_EQ(2, tabstrip.count()); @@ -1263,20 +1254,20 @@ TEST_F(TabStripModelTest, AddTabContents_LeftClickPopup) { // Tests whether or not new tabs that should split context (typed pages, // generated urls, also blank tabs) open at the end of the tabstrip instead of // in the middle. -TEST_F(TabStripModelTest, AddTabContents_CreateNewBlankTab) { +TEST_F(TabStripModelTest, AddWebContents_CreateNewBlankTab) { TabStripDummyDelegate delegate; TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - // Open the Home Page - TabContents* homepage_contents = CreateTabContents(); - tabstrip.AddTabContents( + // Open the Home Page. + WebContents* homepage_contents = CreateWebContents(); + tabstrip.AddWebContents( homepage_contents, -1, content::PAGE_TRANSITION_AUTO_BOOKMARK, TabStripModel::ADD_ACTIVE); // Open some other tab, by user typing. - TabContents* typed_page_contents = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* typed_page_contents = CreateWebContents(); + tabstrip.AddWebContents( typed_page_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); @@ -1286,32 +1277,32 @@ TEST_F(TabStripModelTest, AddTabContents_CreateNewBlankTab) { tabstrip.ActivateTabAt(0, true); // Open a new blank tab in the foreground. - TabContents* new_blank_contents = CreateTabContents(); - tabstrip.AddTabContents(new_blank_contents, -1, + WebContents* new_blank_contents = CreateWebContents(); + tabstrip.AddWebContents(new_blank_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); // Verify the state of the tabstrip. EXPECT_EQ(3, tabstrip.count()); - EXPECT_EQ(homepage_contents, tabstrip.GetTabContentsAt(0)); - EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(1)); - EXPECT_EQ(new_blank_contents, tabstrip.GetTabContentsAt(2)); + EXPECT_EQ(homepage_contents, tabstrip.GetWebContentsAt(0)); + EXPECT_EQ(typed_page_contents, tabstrip.GetWebContentsAt(1)); + EXPECT_EQ(new_blank_contents, tabstrip.GetWebContentsAt(2)); // Now open a couple more blank tabs in the background. - TabContents* background_blank_contents1 = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* background_blank_contents1 = CreateWebContents(); + tabstrip.AddWebContents( background_blank_contents1, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_NONE); - TabContents* background_blank_contents2 = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* background_blank_contents2 = CreateWebContents(); + tabstrip.AddWebContents( background_blank_contents2, -1, content::PAGE_TRANSITION_GENERATED, TabStripModel::ADD_NONE); EXPECT_EQ(5, tabstrip.count()); - EXPECT_EQ(homepage_contents, tabstrip.GetTabContentsAt(0)); - EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(1)); - EXPECT_EQ(new_blank_contents, tabstrip.GetTabContentsAt(2)); - EXPECT_EQ(background_blank_contents1, tabstrip.GetTabContentsAt(3)); - EXPECT_EQ(background_blank_contents2, tabstrip.GetTabContentsAt(4)); + EXPECT_EQ(homepage_contents, tabstrip.GetWebContentsAt(0)); + EXPECT_EQ(typed_page_contents, tabstrip.GetWebContentsAt(1)); + EXPECT_EQ(new_blank_contents, tabstrip.GetWebContentsAt(2)); + EXPECT_EQ(background_blank_contents1, tabstrip.GetWebContentsAt(3)); + EXPECT_EQ(background_blank_contents2, tabstrip.GetWebContentsAt(4)); tabstrip.CloseAllTabs(); EXPECT_TRUE(tabstrip.empty()); @@ -1319,20 +1310,20 @@ TEST_F(TabStripModelTest, AddTabContents_CreateNewBlankTab) { // Tests whether opener state is correctly forgotten when the user switches // context. -TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) { +TEST_F(TabStripModelTest, AddWebContents_ForgetOpeners) { TabStripDummyDelegate delegate; TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); // Open the Home Page - TabContents* homepage_contents = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* homepage_contents = CreateWebContents(); + tabstrip.AddWebContents( homepage_contents, -1, content::PAGE_TRANSITION_AUTO_BOOKMARK, TabStripModel::ADD_ACTIVE); // Open some other tab, by user typing. - TabContents* typed_page_contents = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* typed_page_contents = CreateWebContents(); + tabstrip.AddWebContents( typed_page_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); @@ -1343,39 +1334,39 @@ TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) { // Open a bunch of tabs by simulating middle clicking on links on the home // page. - TabContents* middle_click_contents1 = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* middle_click_contents1 = CreateWebContents(); + tabstrip.AddWebContents( middle_click_contents1, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - TabContents* middle_click_contents2 = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* middle_click_contents2 = CreateWebContents(); + tabstrip.AddWebContents( middle_click_contents2, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - TabContents* middle_click_contents3 = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* middle_click_contents3 = CreateWebContents(); + tabstrip.AddWebContents( middle_click_contents3, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); // Break out of the context by selecting a tab in a different context. - EXPECT_EQ(typed_page_contents, tabstrip.GetTabContentsAt(4)); + EXPECT_EQ(typed_page_contents, tabstrip.GetWebContentsAt(4)); tabstrip.SelectLastTab(); - EXPECT_EQ(typed_page_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(typed_page_contents, tabstrip.GetActiveWebContents()); // Step back into the context by selecting a tab inside it. tabstrip.ActivateTabAt(2, true); - EXPECT_EQ(middle_click_contents2, tabstrip.GetActiveTabContents()); + EXPECT_EQ(middle_click_contents2, tabstrip.GetActiveWebContents()); // Now test that closing tabs selects to the right until there are no more, // then to the left, as if there were no context (context has been // successfully forgotten). tabstrip.CloseSelectedTabs(); - EXPECT_EQ(middle_click_contents3, tabstrip.GetActiveTabContents()); + EXPECT_EQ(middle_click_contents3, tabstrip.GetActiveWebContents()); tabstrip.CloseSelectedTabs(); - EXPECT_EQ(typed_page_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(typed_page_contents, tabstrip.GetActiveWebContents()); tabstrip.CloseSelectedTabs(); - EXPECT_EQ(middle_click_contents1, tabstrip.GetActiveTabContents()); + EXPECT_EQ(middle_click_contents1, tabstrip.GetActiveWebContents()); tabstrip.CloseSelectedTabs(); - EXPECT_EQ(homepage_contents, tabstrip.GetActiveTabContents()); + EXPECT_EQ(homepage_contents, tabstrip.GetActiveWebContents()); EXPECT_EQ(1, tabstrip.count()); @@ -1390,14 +1381,14 @@ TEST_F(TabStripModelTest, AppendContentsReselectionTest) { EXPECT_TRUE(tabstrip.empty()); // Open the Home Page. - TabContents* homepage_contents = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* homepage_contents = CreateWebContents(); + tabstrip.AddWebContents( homepage_contents, -1, content::PAGE_TRANSITION_AUTO_BOOKMARK, TabStripModel::ADD_ACTIVE); // Open some other tab, by user typing. - TabContents* typed_page_contents = CreateTabContents(); - tabstrip.AddTabContents( + WebContents* typed_page_contents = CreateWebContents(); + tabstrip.AddWebContents( typed_page_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_NONE); @@ -1406,8 +1397,7 @@ TEST_F(TabStripModelTest, AppendContentsReselectionTest) { // Now simulate a link click that opens a new tab (by virtue of target=_blank) // and make sure the correct tab gets selected when the new tab is closed. - TabContents* target_blank_contents = CreateTabContents(); - WebContents* target_blank = target_blank_contents->web_contents(); + WebContents* target_blank = CreateWebContents(); tabstrip.AppendWebContents(target_blank, true); EXPECT_EQ(2, tabstrip.active_index()); tabstrip.CloseWebContentsAt(2, TabStripModel::CLOSE_NONE); @@ -1423,82 +1413,82 @@ TEST_F(TabStripModelTest, ReselectionConsidersChildrenTest) { TabStripModel strip(&delegate, profile()); // Open page A - TabContents* page_a_contents = CreateTabContents(); - strip.AddTabContents( + WebContents* page_a_contents = CreateWebContents(); + strip.AddWebContents( page_a_contents, -1, content::PAGE_TRANSITION_AUTO_BOOKMARK, TabStripModel::ADD_ACTIVE); // Simulate middle click to open page A.A and A.B - TabContents* page_a_a_contents = CreateTabContents(); - strip.AddTabContents(page_a_a_contents, -1, content::PAGE_TRANSITION_LINK, + WebContents* page_a_a_contents = CreateWebContents(); + strip.AddWebContents(page_a_a_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - TabContents* page_a_b_contents = CreateTabContents(); - strip.AddTabContents(page_a_b_contents, -1, content::PAGE_TRANSITION_LINK, + WebContents* page_a_b_contents = CreateWebContents(); + strip.AddWebContents(page_a_b_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); // Select page A.A strip.ActivateTabAt(1, true); - EXPECT_EQ(page_a_a_contents, strip.GetActiveTabContents()); + EXPECT_EQ(page_a_a_contents, strip.GetActiveWebContents()); // 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, content::PAGE_TRANSITION_LINK, + WebContents* page_a_a_a_contents = CreateWebContents(); + strip.AddWebContents(page_a_a_a_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - EXPECT_EQ(page_a_a_a_contents, strip.GetTabContentsAt(2)); + EXPECT_EQ(page_a_a_a_contents, strip.GetWebContentsAt(2)); // Close page A.A strip.CloseWebContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE); // Page A.A.A should be selected, NOT A.B - EXPECT_EQ(page_a_a_a_contents, strip.GetActiveTabContents()); + EXPECT_EQ(page_a_a_a_contents, strip.GetActiveWebContents()); // Close page A.A.A strip.CloseWebContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE); // Page A.B should be selected - EXPECT_EQ(page_a_b_contents, strip.GetActiveTabContents()); + EXPECT_EQ(page_a_b_contents, strip.GetActiveWebContents()); // Close page A.B strip.CloseWebContentsAt(strip.active_index(), TabStripModel::CLOSE_NONE); // Page A should be selected - EXPECT_EQ(page_a_contents, strip.GetActiveTabContents()); + EXPECT_EQ(page_a_contents, strip.GetActiveWebContents()); // Clean up. strip.CloseAllTabs(); } -TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) { +TEST_F(TabStripModelTest, AddWebContents_NewTabAtEndOfStripInheritsGroup) { TabStripDummyDelegate delegate; TabStripModel strip(&delegate, profile()); // Open page A - TabContents* page_a_contents = CreateTabContents(); - strip.AddTabContents(page_a_contents, -1, + WebContents* page_a_contents = CreateWebContents(); + strip.AddWebContents(page_a_contents, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, TabStripModel::ADD_ACTIVE); // 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, content::PAGE_TRANSITION_LINK, + WebContents* page_b_contents = CreateWebContents(); + WebContents* page_c_contents = CreateWebContents(); + WebContents* page_d_contents = CreateWebContents(); + strip.AddWebContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, + strip.AddWebContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - strip.AddTabContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, + strip.AddWebContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); // Switch to page B's tab. strip.ActivateTabAt(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, content::PAGE_TRANSITION_TYPED, + WebContents* new_contents = CreateWebContents(); + strip.AddWebContents(new_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); - EXPECT_EQ(4, strip.GetIndexOfTabContents(new_tab_contents)); + EXPECT_EQ(4, strip.GetIndexOfWebContents(new_contents)); EXPECT_EQ(4, strip.active_index()); // Close the New Tab that was just opened. We should be returned to page B's @@ -1510,11 +1500,11 @@ TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) { // Open a non-New Tab tab at the end of the strip, with a TYPED transition. // 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, content::PAGE_TRANSITION_TYPED, + WebContents* page_e_contents = CreateWebContents(); + strip.AddWebContents(page_e_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); - EXPECT_EQ(4, strip.GetIndexOfTabContents(page_e_contents)); + EXPECT_EQ(4, strip.GetIndexOfWebContents(page_e_contents)); EXPECT_EQ(4, strip.active_index()); // Close the Tab. Selection should shift back to page B's Tab. @@ -1526,12 +1516,12 @@ TEST_F(TabStripModelTest, AddTabContents_NewTabAtEndOfStripInheritsGroup) { // transition. This is like right clicking on a bookmark and choosing "Open // 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, + WebContents* page_f_contents = CreateWebContents(); + strip.AddWebContents(page_f_contents, -1, content::PAGE_TRANSITION_AUTO_BOOKMARK, TabStripModel::ADD_ACTIVE); - EXPECT_EQ(4, strip.GetIndexOfTabContents(page_f_contents)); + EXPECT_EQ(4, strip.GetIndexOfWebContents(page_f_contents)); EXPECT_EQ(4, strip.active_index()); // Close the Tab. The next-adjacent should be selected. @@ -1552,25 +1542,25 @@ TEST_F(TabStripModelTest, NavigationForgetsOpeners) { TabStripModel strip(&delegate, profile()); // Open page A - TabContents* page_a_contents = CreateTabContents(); - strip.AddTabContents(page_a_contents, -1, + WebContents* page_a_contents = CreateWebContents(); + strip.AddWebContents(page_a_contents, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, TabStripModel::ADD_ACTIVE); // 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, content::PAGE_TRANSITION_LINK, + WebContents* page_b_contents = CreateWebContents(); + WebContents* page_c_contents = CreateWebContents(); + WebContents* page_d_contents = CreateWebContents(); + strip.AddWebContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, + strip.AddWebContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - strip.AddTabContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, + strip.AddWebContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); // Open page E in a different opener group from page A. - TabContents* page_e_contents = CreateTabContents(); - strip.AddTabContents(page_e_contents, -1, + WebContents* page_e_contents = CreateWebContents(); + strip.AddWebContents(page_e_contents, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, TabStripModel::ADD_NONE); @@ -1588,7 +1578,7 @@ TEST_F(TabStripModelTest, NavigationForgetsOpeners) { // Close page C, page E should be selected. (C is no longer part of the // A-B-C-D group, selection moves to the right). strip.CloseWebContentsAt(2, TabStripModel::CLOSE_NONE); - EXPECT_EQ(page_e_contents, strip.GetTabContentsAt(strip.active_index())); + EXPECT_EQ(page_e_contents, strip.GetWebContentsAt(strip.active_index())); strip.CloseAllTabs(); } @@ -1603,19 +1593,19 @@ 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, + WebContents* page_a_contents = CreateWebContents(); + strip.AddWebContents(page_a_contents, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, TabStripModel::ADD_ACTIVE); - TabContents* page_b_contents = CreateTabContents(); - TabContents* page_c_contents = CreateTabContents(); - TabContents* page_d_contents = CreateTabContents(); - strip.AddTabContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, + WebContents* page_b_contents = CreateWebContents(); + WebContents* page_c_contents = CreateWebContents(); + WebContents* page_d_contents = CreateWebContents(); + strip.AddWebContents(page_b_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - strip.AddTabContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, + strip.AddWebContents(page_c_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); - strip.AddTabContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, + strip.AddWebContents(page_d_contents, -1, content::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); strip.ActivateTabAt(2, true); @@ -1625,22 +1615,22 @@ TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) { // last on. // Now simulate opening a new tab at the end of the TabStrip. - TabContents* new_tab_contents1 = CreateTabContents(); - strip.AddTabContents(new_tab_contents1, -1, content::PAGE_TRANSITION_TYPED, + WebContents* new_contents1 = CreateWebContents(); + strip.AddWebContents(new_contents1, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); // At this point, if we close this tab the last selected one should be // re-selected. strip.CloseWebContentsAt(strip.count() - 1, TabStripModel::CLOSE_NONE); - EXPECT_EQ(page_c_contents, strip.GetTabContentsAt(strip.active_index())); + EXPECT_EQ(page_c_contents, strip.GetWebContentsAt(strip.active_index())); // TEST 2: If the user is in a group of tabs and opens a new tab at the end // of the strip, selecting any other tab in the strip will cause that new // tab's opener relationship to be forgotten. // Open a new tab again. - TabContents* new_tab_contents2 = CreateTabContents(); - strip.AddTabContents(new_tab_contents2, -1, content::PAGE_TRANSITION_TYPED, + WebContents* new_contents2 = CreateWebContents(); + strip.AddWebContents(new_contents2, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); // Now select the first tab. @@ -1651,7 +1641,7 @@ TEST_F(TabStripModelTest, NavigationForgettingDoesntAffectNewTab) { // Now close the last tab. The next adjacent should be selected. strip.CloseWebContentsAt(strip.count() - 1, TabStripModel::CLOSE_NONE); - EXPECT_EQ(page_d_contents, strip.GetTabContentsAt(strip.active_index())); + EXPECT_EQ(page_d_contents, strip.GetWebContentsAt(strip.active_index())); strip.CloseAllTabs(); } @@ -1668,9 +1658,8 @@ TEST_F(TabStripModelTest, FastShutdown) { // Make sure fast shutdown is attempted when tabs that share a RPH are shut // down. { - WebContents* contents1 = CreateTabContents()->web_contents(); - WebContents* contents2 = - CreateTabContentsWithSharedRPH(contents1)->web_contents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContentsWithSharedRPH(contents1); SetID(contents1, 1); SetID(contents2, 2); @@ -1696,9 +1685,8 @@ TEST_F(TabStripModelTest, FastShutdown) { // Make sure fast shutdown is not attempted when only some tabs that share a // RPH are shut down. { - WebContents* contents1 = CreateTabContents()->web_contents(); - WebContents* contents2 = - CreateTabContentsWithSharedRPH(contents1)->web_contents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContentsWithSharedRPH(contents1); SetID(contents1, 1); SetID(contents2, 2); @@ -1740,16 +1728,15 @@ TEST_F(TabStripModelTest, Apps) { Extension::Create(path, Extension::INVALID, manifest, Extension::NO_FLAGS, &error)); extension_app->launch_web_url_ = "http://www.google.com"; - TabContents* tab_contents1 = CreateTabContents(); - WebContents* contents1 = tab_contents1->web_contents(); + WebContents* contents1 = CreateWebContents(); + extensions::TabHelper::CreateForWebContents(contents1); extensions::TabHelper::FromWebContents(contents1)-> SetExtensionApp(extension_app); - TabContents* tab_contents2 = CreateTabContents(); - WebContents* contents2 = tab_contents2->web_contents(); + WebContents* contents2 = CreateWebContents(); + extensions::TabHelper::CreateForWebContents(contents2); extensions::TabHelper::FromWebContents(contents2)-> SetExtensionApp(extension_app); - TabContents* tab_contents3 = CreateTabContents(); - WebContents* contents3 = tab_contents3->web_contents(); + WebContents* contents3 = CreateWebContents(); SetID(contents1, 1); SetID(contents2, 2); @@ -1863,12 +1850,9 @@ TEST_F(TabStripModelTest, Pinning) { typedef MockTabStripModelObserver::State State; - TabContents* tab_contents1 = CreateTabContents(); - TabContents* tab_contents2 = CreateTabContents(); - TabContents* tab_contents3 = CreateTabContents(); - WebContents* contents1 = tab_contents1->web_contents(); - WebContents* contents2 = tab_contents2->web_contents(); - WebContents* contents3 = tab_contents3->web_contents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); SetID(contents1, 1); SetID(contents2, 2); @@ -2001,8 +1985,7 @@ TEST_F(TabStripModelTest, Pinning) { observer.ClearStates(); } - TabContents* tab_contents4 = CreateTabContents(); - WebContents* contents4 = tab_contents4->web_contents(); + WebContents* contents4 = CreateWebContents(); SetID(contents4, 4); // Insert "4" between "1" and "3". As "1" and "4" are pinned, "4" should end @@ -2028,47 +2011,46 @@ TEST_F(TabStripModelTest, ReplaceSendsSelected) { TabStripDummyDelegate delegate; TabStripModel strip(&delegate, profile()); - TabContents* first_tab_contents = CreateTabContents(); - WebContents* first_contents = first_tab_contents->web_contents(); - strip.AddTabContents(first_tab_contents, -1, content::PAGE_TRANSITION_TYPED, + WebContents* first_contents = CreateWebContents(); + strip.AddWebContents(first_contents, -1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); MockTabStripModelObserver tabstrip_observer(&strip); strip.AddObserver(&tabstrip_observer); - TabContents* new_tab_contents = CreateTabContents(); - WebContents* new_contents = new_tab_contents->web_contents(); - delete strip.ReplaceTabContentsAt(0, new_tab_contents); + TabContents* new_contents = CreateTabContents(); + delete strip.ReplaceTabContentsAt(0, new_contents); ASSERT_EQ(2, tabstrip_observer.GetStateCount()); // First event should be for replaced. - State state(new_contents, 0, MockTabStripModelObserver::REPLACED); + State state( + new_contents->web_contents(), 0, MockTabStripModelObserver::REPLACED); state.src_contents = first_contents; EXPECT_TRUE(tabstrip_observer.StateEquals(0, state)); // And the second for selected. - state = State(new_contents, 0, MockTabStripModelObserver::ACTIVATE); + state = State( + new_contents->web_contents(), 0, MockTabStripModelObserver::ACTIVATE); state.src_contents = first_contents; EXPECT_TRUE(tabstrip_observer.StateEquals(1, state)); // Now add another tab and replace it, making sure we don't get a selected // event this time. - TabContents* third_tab_contents = CreateTabContents(); - WebContents* third_contents = third_tab_contents->web_contents(); - strip.AddTabContents(third_tab_contents, 1, content::PAGE_TRANSITION_TYPED, + WebContents* third_contents = CreateWebContents(); + strip.AddWebContents(third_contents, 1, content::PAGE_TRANSITION_TYPED, TabStripModel::ADD_NONE); tabstrip_observer.ClearStates(); // And replace it. - new_tab_contents = CreateTabContents(); - new_contents = new_tab_contents->web_contents(); - delete strip.ReplaceTabContentsAt(1, new_tab_contents); + new_contents = CreateTabContents(); + delete strip.ReplaceTabContentsAt(1, new_contents); ASSERT_EQ(1, tabstrip_observer.GetStateCount()); - state = State(new_contents, 1, MockTabStripModelObserver::REPLACED); + state = State( + new_contents->web_contents(), 1, MockTabStripModelObserver::REPLACED); state.src_contents = third_contents; EXPECT_TRUE(tabstrip_observer.StateEquals(0, state)); @@ -2083,11 +2065,9 @@ TEST_F(TabStripModelTest, DiscardTabContentsAt) { TabStripModel tabstrip(&delegate, profile()); // Fill it with some tabs. - TabContents* tab_contents1 = CreateTabContents(); - WebContents* contents1 = tab_contents1->web_contents(); + WebContents* contents1 = CreateWebContents(); tabstrip.AppendWebContents(contents1, true); - TabContents* tab_contents2 = CreateTabContents(); - WebContents* contents2 = tab_contents2->web_contents(); + WebContents* contents2 = CreateWebContents(); tabstrip.AppendWebContents(contents2, true); // Start watching for events after the appends to avoid observing state @@ -2101,8 +2081,8 @@ TEST_F(TabStripModelTest, DiscardTabContentsAt) { ASSERT_EQ(2, tabstrip.count()); EXPECT_TRUE(tabstrip.IsTabDiscarded(0)); EXPECT_FALSE(tabstrip.IsTabDiscarded(1)); - ASSERT_EQ(null_tab_contents1, tabstrip.GetTabContentsAt(0)); - ASSERT_EQ(tab_contents2, tabstrip.GetTabContentsAt(1)); + ASSERT_EQ(null_contents1, tabstrip.GetWebContentsAt(0)); + ASSERT_EQ(contents2, tabstrip.GetWebContentsAt(1)); ASSERT_EQ(1, tabstrip_observer.GetStateCount()); State state1(null_contents1, 0, MockTabStripModelObserver::REPLACED); state1.src_contents = contents1; @@ -2115,8 +2095,8 @@ TEST_F(TabStripModelTest, DiscardTabContentsAt) { ASSERT_EQ(2, tabstrip.count()); EXPECT_TRUE(tabstrip.IsTabDiscarded(0)); EXPECT_FALSE(tabstrip.IsTabDiscarded(1)); - ASSERT_EQ(null_tab_contents2, tabstrip.GetTabContentsAt(0)); - ASSERT_EQ(tab_contents2, tabstrip.GetTabContentsAt(1)); + ASSERT_EQ(null_contents2, tabstrip.GetWebContentsAt(0)); + ASSERT_EQ(contents2, tabstrip.GetWebContentsAt(1)); ASSERT_EQ(1, tabstrip_observer.GetStateCount()); State state2(null_contents2, 0, MockTabStripModelObserver::REPLACED); state2.src_contents = null_contents1; @@ -2143,11 +2123,11 @@ TEST_F(TabStripModelTest, DiscardTabContentsAt) { TEST_F(TabStripModelTest, DeleteFromDestroy) { TabStripDummyDelegate delegate; TabStripModel strip(&delegate, profile()); - WebContents* contents1 = CreateTabContents()->web_contents(); - WebContents* contents2 = CreateTabContents()->web_contents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); strip.AppendWebContents(contents1, true); strip.AppendWebContents(contents2, true); - // DeleteTabContentsOnDestroyedObserver deletes contents1 when contents2 sends + // DeleteWebContentsOnDestroyedObserver deletes contents1 when contents2 sends // out notification that it is being destroyed. DeleteWebContentsOnDestroyedObserver observer(contents2, contents1); strip.CloseAllTabs(); @@ -2220,9 +2200,9 @@ TEST_F(TabStripModelTest, MoveSelectedTabsTo) { TEST_F(TabStripModelTest, CloseSelectedTabs) { TabStripDummyDelegate delegate; TabStripModel strip(&delegate, profile()); - WebContents* contents1 = CreateTabContents()->web_contents(); - WebContents* contents2 = CreateTabContents()->web_contents(); - WebContents* contents3 = CreateTabContents()->web_contents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); strip.AppendWebContents(contents1, true); strip.AppendWebContents(contents2, true); strip.AppendWebContents(contents3, true); @@ -2239,14 +2219,10 @@ TEST_F(TabStripModelTest, MultipleSelection) { TabStripDummyDelegate delegate; TabStripModel strip(&delegate, profile()); MockTabStripModelObserver observer(&strip); - TabContents* tab_contents0 = CreateTabContents(); - TabContents* tab_contents1 = CreateTabContents(); - TabContents* tab_contents2 = CreateTabContents(); - TabContents* tab_contents3 = CreateTabContents(); - WebContents* contents0 = tab_contents0->web_contents(); - WebContents* contents1 = tab_contents1->web_contents(); - WebContents* contents2 = tab_contents2->web_contents(); - WebContents* contents3 = tab_contents3->web_contents(); + WebContents* contents0 = CreateWebContents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); + WebContents* contents3 = CreateWebContents(); strip.AppendWebContents(contents0, false); strip.AppendWebContents(contents1, false); strip.AppendWebContents(contents2, false); @@ -2356,10 +2332,8 @@ TEST_F(TabStripModelTest, MultipleToSingle) { TabStripDummyDelegate delegate; TabStripModel strip(&delegate, profile()); - TabContents* tab_contents1 = CreateTabContents(); - TabContents* tab_contents2 = CreateTabContents(); - WebContents* contents1 = tab_contents1->web_contents(); - WebContents* contents2 = tab_contents2->web_contents(); + WebContents* contents1 = CreateWebContents(); + WebContents* contents2 = CreateWebContents(); strip.AppendWebContents(contents1, false); strip.AppendWebContents(contents2, false); strip.ToggleSelectionAt(0); |