diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 20:35:15 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 20:35:15 +0000 |
commit | ea01ff29254d392ad31b28f739837b4c39bbc418 (patch) | |
tree | adb65771476e6224ab6a754cbc9f74fbfffdc77a | |
parent | c7872edee4401939930a980abd6933416714e5e5 (diff) | |
download | chromium_src-ea01ff29254d392ad31b28f739837b4c39bbc418.zip chromium_src-ea01ff29254d392ad31b28f739837b4c39bbc418.tar.gz chromium_src-ea01ff29254d392ad31b28f739837b4c39bbc418.tar.bz2 |
Remove TabContents from TabStripModel::AppendTabContents.
BUG=107201
TEST=no visible change
Review URL: https://chromiumcodereview.appspot.com/11416203
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169728 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 109 insertions, 107 deletions
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index 601032f..8886b03 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc @@ -98,9 +98,6 @@ 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); - } static TabContents* CloneTabContents(TabContents* contents) { return TabContents::Factory::CloneTabContents(contents); } @@ -634,7 +631,7 @@ void ConvertPopupToTabbedBrowser(Browser* browser) { TabContents* contents = browser->tab_strip_model()->DetachTabContentsAt(browser->active_index()); Browser* b = new Browser(Browser::CreateParams(browser->profile())); - b->tab_strip_model()->AppendTabContents(contents, true); + b->tab_strip_model()->AppendWebContents(contents->web_contents(), true); b->window()->Show(); } @@ -1086,12 +1083,7 @@ void ConvertTabToAppWindow(Browser* browser, Browser* app_browser = new Browser( Browser::CreateParams::CreateForApp( Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); - TabContents* tab_contents = TabContents::FromWebContents(contents); - if (!tab_contents) { - tab_contents = - BrowserCommandsTabContentsCreator::CreateTabContents(contents); - } - app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); + app_browser->tab_strip_model()->AppendWebContents(contents, true); contents->GetMutableRendererPrefs()->can_accept_load_drops = false; contents->GetRenderViewHost()->SyncRendererPrefs(); diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm index 26db023d..157661f 100644 --- a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm @@ -6,7 +6,6 @@ #include "base/mac/mac_util.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/cocoa/browser_window_controller.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" @@ -67,10 +66,10 @@ class FullscreenExitBubbleControllerTest : public CocoaProfileTest { } void AppendTabToStrip() { - TabContents* tab_contents = chrome::TabContentsFactory( + WebContents* web_contents = WebContents::Create( profile(), site_instance_, MSG_ROUTING_NONE, NULL); - browser()->tab_strip_model()->AppendTabContents( - tab_contents, /*foreground=*/true); + browser()->tab_strip_model()->AppendWebContents( + web_contents, /*foreground=*/true); } scoped_refptr<SiteInstance> site_instance_; @@ -86,7 +85,8 @@ TEST_F(FullscreenExitBubbleControllerTest, DISABLED_DenyExitsFullscreen) { [bwc showWindow:nil]; AppendTabToStrip(); - WebContents* fullscreen_tab = chrome::GetActiveWebContents(browser()); + WebContents* fullscreen_tab = + browser()->tab_strip_model()->GetActiveWebContents(); { base::mac::ScopedNSAutoreleasePool pool; content::WindowedNotificationObserver fullscreen_observer( diff --git a/chrome/browser/ui/cocoa/tabpose_window_unittest.mm b/chrome/browser/ui/cocoa/tabpose_window_unittest.mm index e84d65e..add4d03 100644 --- a/chrome/browser/ui/cocoa/tabpose_window_unittest.mm +++ b/chrome/browser/ui/cocoa/tabpose_window_unittest.mm @@ -5,12 +5,12 @@ #import "chrome/browser/ui/cocoa/tabpose_window.h" #include "base/mac/mac_util.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "content/public/browser/site_instance.h" +#include "content/public/browser/web_contents.h" #include "ipc/ipc_message.h" #include "testing/gtest/include/gtest/gtest.h" @@ -26,10 +26,10 @@ class TabposeWindowTest : public CocoaProfileTest { } void AppendTabToStrip() { - TabContents* tab_contents = chrome::TabContentsFactory( + content::WebContents* web_contents = content::WebContents::Create( profile(), site_instance_, MSG_ROUTING_NONE, NULL); - browser()->tab_strip_model()->AppendTabContents( - tab_contents, /*foreground=*/true); + browser()->tab_strip_model()->AppendWebContents( + web_contents, /*foreground=*/true); } scoped_refptr<SiteInstance> site_instance_; diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm index 0b9fba5..ef22797 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm @@ -4,7 +4,6 @@ #import <Cocoa/Cocoa.h> -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #import "chrome/browser/ui/cocoa/new_tab_button.h" @@ -12,7 +11,6 @@ #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" #import "chrome/browser/ui/cocoa/tabs/tab_view.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" @@ -104,9 +102,9 @@ class TabStripControllerTest : public CocoaProfileTest { TabView* CreateTab() { SiteInstance* instance = SiteInstance::Create(profile()); - TabContents* tab_contents = chrome::TabContentsFactory( + WebContents* web_contents = WebContents::Create( profile(), instance, MSG_ROUTING_NONE, NULL); - model_->AppendTabContents(tab_contents, true); + model_->AppendWebContents(web_contents, true); const NSUInteger tab_count = [controller_.get() viewsCount]; return static_cast<TabView*>([controller_.get() viewAtIndex:tab_count - 1]); } diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc index 05a2915..52126ab 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.cc +++ b/chrome/browser/ui/tabs/tab_strip_model.cc @@ -79,9 +79,9 @@ bool TabStripModel::ContainsIndex(int index) const { return index >= 0 && index < count(); } -void TabStripModel::AppendTabContents(TabContents* contents, +void TabStripModel::AppendWebContents(WebContents* contents, bool foreground) { - InsertWebContentsAt(count(), contents->web_contents(), + InsertWebContentsAt(count(), contents, foreground ? (ADD_INHERIT_GROUP | ADD_ACTIVE) : ADD_NONE); } diff --git a/chrome/browser/ui/tabs/tab_strip_model.h b/chrome/browser/ui/tabs/tab_strip_model.h index 8b95f4e..9718291 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.h +++ b/chrome/browser/ui/tabs/tab_strip_model.h @@ -162,9 +162,9 @@ class TabStripModel : public content::NotificationObserver { // Determines if the specified index is contained within the TabStripModel. bool ContainsIndex(int index) const; - // Adds the specified TabContents in the default location. Tabs opened + // Adds the specified WebContents in the default location. Tabs opened // in the foreground inherit the group of the previously active tab. - void AppendTabContents(TabContents* contents, bool foreground); + void AppendWebContents(content::WebContents* contents, bool foreground); // Adds the specified WebContents at the specified location. // |add_types| is a bitmask of AddTabTypes; see it for details. diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc index 71bc0f6..8180e57 100644 --- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc @@ -48,32 +48,32 @@ using extensions::Extension; namespace { -// Class used to delete a TabContents when another TabContents is destroyed. -class DeleteTabContentsOnDestroyedObserver +// Class used to delete a WebContents when another WebContents is destroyed. +class DeleteWebContentsOnDestroyedObserver : public content::NotificationObserver { public: - DeleteTabContentsOnDestroyedObserver(TabContents* source, - TabContents* tab_to_delete) + DeleteWebContentsOnDestroyedObserver(WebContents* source, + WebContents* tab_to_delete) : source_(source), tab_to_delete_(tab_to_delete) { registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, - content::Source<WebContents>(source->web_contents())); + content::Source<WebContents>(source)); } virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - TabContents* tab_to_delete = tab_to_delete_; + WebContents* tab_to_delete = tab_to_delete_; tab_to_delete_ = NULL; delete tab_to_delete; } private: - TabContents* source_; - TabContents* tab_to_delete_; + WebContents* source_; + WebContents* tab_to_delete_; content::NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(DeleteTabContentsOnDestroyedObserver); + DISALLOW_COPY_AND_ASSIGN(DeleteWebContentsOnDestroyedObserver); }; class TabStripDummyDelegate : public TestTabStripModelDelegate { @@ -183,7 +183,7 @@ class TabStripModelTest : public ChromeRenderViewHostTestHarness { for (int i = 0; i < tab_count; ++i) { TabContents* contents = CreateTabContents(); SetID(contents->web_contents(), i); - model->AppendTabContents(contents, true); + model->AppendWebContents(contents->web_contents(), true); } for (int i = 0; i < pinned_count; ++i) model->SetTabPinned(i, true); @@ -366,10 +366,10 @@ TEST_F(TabStripModelTest, TestBasicAPI) { // builds on the state established in the previous. This is important if you // ever insert tests rather than append. - // Test AppendTabContents, ContainsIndex + // Test AppendWebContents, ContainsIndex { EXPECT_FALSE(tabstrip.ContainsIndex(0)); - tabstrip.AppendTabContents(tab_contents1, true); + tabstrip.AppendWebContents(contents1, true); EXPECT_TRUE(tabstrip.ContainsIndex(0)); EXPECT_EQ(1, tabstrip.count()); EXPECT_EQ(3, observer.GetStateCount()); @@ -451,7 +451,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) { TabContents* detached_tab = tabstrip.DetachTabContentsAt(2); WebContents* detached = detached_tab->web_contents(); // ... and append again because we want this for later. - tabstrip.AppendTabContents(detached_tab, true); + tabstrip.AppendWebContents(detached, true); EXPECT_EQ(8, observer.GetStateCount()); State s1(detached, 2, MockTabStripModelObserver::DETACH); EXPECT_TRUE(observer.StateEquals(0, s1)); @@ -600,14 +600,14 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) { TabContents* opener_contents = CreateTabContents(); WebContents* opener = opener_contents->web_contents(); - tabstrip.AppendTabContents(opener_contents, true); + tabstrip.AppendWebContents(opener, true); TabContents* contents1 = CreateTabContents(); TabContents* contents2 = CreateTabContents(); TabContents* contents3 = CreateTabContents(); TabContents* contents4 = CreateTabContents(); TabContents* contents5 = CreateTabContents(); - // We use |InsertWebContentsAt| here instead of AppendTabContents so that + // We use |InsertWebContentsAt| here instead of |AppendWebContents| so that // openership relationships are preserved. tabstrip.InsertWebContentsAt(tabstrip.count(), contents1->web_contents(), TabStripModel::ADD_INHERIT_GROUP); @@ -693,7 +693,8 @@ TEST_F(TabStripModelTest, TestLTRInsertionOptions) { EXPECT_TRUE(tabstrip.empty()); TabContents* opener_contents = CreateTabContents(); - tabstrip.AppendTabContents(opener_contents, true); + WebContents* opener = opener_contents->web_contents(); + tabstrip.AppendWebContents(opener, true); TabContents* contents1 = CreateTabContents(); TabContents* contents2 = CreateTabContents(); @@ -722,12 +723,13 @@ TEST_F(TabStripModelTest, TestInsertionIndexDetermination) { TabContents* opener_contents = CreateTabContents(); WebContents* opener = opener_contents->web_contents(); - tabstrip.AppendTabContents(opener_contents, true); + tabstrip.AppendWebContents(opener, true); // Open some other random unrelated tab in the background to monkey with our // insertion index. TabContents* other_contents = CreateTabContents(); - tabstrip.AppendTabContents(other_contents, false); + WebContents* other = other_contents->web_contents(); + tabstrip.AppendWebContents(other, false); TabContents* contents1 = CreateTabContents(); TabContents* contents2 = CreateTabContents(); @@ -804,7 +806,8 @@ TEST_F(TabStripModelTest, TestSelectOnClose) { EXPECT_TRUE(tabstrip.empty()); TabContents* opener_contents = CreateTabContents(); - tabstrip.AppendTabContents(opener_contents, true); + WebContents* opener = opener_contents->web_contents(); + tabstrip.AppendWebContents(opener, true); TabContents* contents1 = CreateTabContents(); TabContents* contents2 = CreateTabContents(); @@ -1049,7 +1052,8 @@ TEST_F(TabStripModelTest, TestContextMenuCloseCommands) { EXPECT_TRUE(tabstrip.empty()); TabContents* opener_contents = CreateTabContents(); - tabstrip.AppendTabContents(opener_contents, true); + WebContents* opener = opener_contents->web_contents(); + tabstrip.AppendWebContents(opener, true); TabContents* contents1 = CreateTabContents(); TabContents* contents2 = CreateTabContents(); @@ -1066,7 +1070,8 @@ TEST_F(TabStripModelTest, TestContextMenuCloseCommands) { EXPECT_EQ(opener_contents, tabstrip.GetActiveTabContents()); TabContents* dummy_contents = CreateTabContents(); - tabstrip.AppendTabContents(dummy_contents, false); + WebContents* dummy = dummy_contents->web_contents(); + tabstrip.AppendWebContents(dummy, false); contents1 = CreateTabContents(); contents2 = CreateTabContents(); @@ -1093,17 +1098,17 @@ TEST_F(TabStripModelTest, GetIndicesClosedByCommand) { TabStripModel tabstrip(&delegate, profile()); EXPECT_TRUE(tabstrip.empty()); - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - TabContents* contents3 = CreateTabContents(); - TabContents* contents4 = CreateTabContents(); - TabContents* contents5 = CreateTabContents(); + 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(); - tabstrip.AppendTabContents(contents1, true); - tabstrip.AppendTabContents(contents2, true); - tabstrip.AppendTabContents(contents3, true); - tabstrip.AppendTabContents(contents4, true); - tabstrip.AppendTabContents(contents5, true); + tabstrip.AppendWebContents(contents1, true); + tabstrip.AppendWebContents(contents2, true); + tabstrip.AppendWebContents(contents3, true); + tabstrip.AppendWebContents(contents4, true); + tabstrip.AppendWebContents(contents5, true); EXPECT_EQ("4 3 2 1", GetIndicesClosedByCommandAsString( tabstrip, 0, TabStripModel::CommandCloseTabsToRight)); @@ -1402,7 +1407,8 @@ 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(); - tabstrip.AppendTabContents(target_blank_contents, true); + WebContents* target_blank = target_blank_contents->web_contents(); + tabstrip.AppendWebContents(target_blank, true); EXPECT_EQ(2, tabstrip.active_index()); tabstrip.CloseTabContentsAt(2, TabStripModel::CLOSE_NONE); EXPECT_EQ(0, tabstrip.active_index()); @@ -1662,15 +1668,15 @@ TEST_F(TabStripModelTest, FastShutdown) { // Make sure fast shutdown is attempted when tabs that share a RPH are shut // down. { - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = - CreateTabContentsWithSharedRPH(contents1->web_contents()); + WebContents* contents1 = CreateTabContents()->web_contents(); + WebContents* contents2 = + CreateTabContentsWithSharedRPH(contents1)->web_contents(); - SetID(contents1->web_contents(), 1); - SetID(contents2->web_contents(), 2); + SetID(contents1, 1); + SetID(contents2, 2); - tabstrip.AppendTabContents(contents1, true); - tabstrip.AppendTabContents(contents2, true); + tabstrip.AppendWebContents(contents1, true); + tabstrip.AppendWebContents(contents2, true); // Turn on the fake unload listener so the tabs don't actually get shut // down when we call CloseAllTabs()---we need to be able to check that @@ -1679,8 +1685,7 @@ TEST_F(TabStripModelTest, FastShutdown) { tabstrip.CloseAllTabs(); // On a mock RPH this checks whether we *attempted* fast shutdown. // A real RPH would reject our attempt since there is an unload handler. - EXPECT_TRUE(contents1->web_contents()-> - GetRenderProcessHost()->FastShutdownStarted()); + EXPECT_TRUE(contents1->GetRenderProcessHost()->FastShutdownStarted()); EXPECT_EQ(2, tabstrip.count()); delegate.set_run_unload_listener(false); @@ -1691,19 +1696,18 @@ TEST_F(TabStripModelTest, FastShutdown) { // Make sure fast shutdown is not attempted when only some tabs that share a // RPH are shut down. { - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = - CreateTabContentsWithSharedRPH(contents1->web_contents()); + WebContents* contents1 = CreateTabContents()->web_contents(); + WebContents* contents2 = + CreateTabContentsWithSharedRPH(contents1)->web_contents(); - SetID(contents1->web_contents(), 1); - SetID(contents2->web_contents(), 2); + SetID(contents1, 1); + SetID(contents2, 2); - tabstrip.AppendTabContents(contents1, true); - tabstrip.AppendTabContents(contents2, true); + tabstrip.AppendWebContents(contents1, true); + tabstrip.AppendWebContents(contents2, true); tabstrip.CloseTabContentsAt(1, TabStripModel::CLOSE_NONE); - EXPECT_FALSE(contents1->web_contents()-> - GetRenderProcessHost()->FastShutdownStarted()); + EXPECT_FALSE(contents1->GetRenderProcessHost()->FastShutdownStarted()); EXPECT_EQ(1, tabstrip.count()); tabstrip.CloseAllTabs(); @@ -1756,7 +1760,7 @@ TEST_F(TabStripModelTest, Apps) { // ever insert tests rather than append. // Initial state, tab3 only and selected. - tabstrip.AppendTabContents(tab_contents3, true); + tabstrip.AppendWebContents(contents3, true); observer.ClearStates(); @@ -1875,9 +1879,9 @@ TEST_F(TabStripModelTest, Pinning) { // ever insert tests rather than append. // Initial state, three tabs, first selected. - tabstrip.AppendTabContents(tab_contents1, true); - tabstrip.AppendTabContents(tab_contents2, false); - tabstrip.AppendTabContents(tab_contents3, false); + tabstrip.AppendWebContents(contents1, true); + tabstrip.AppendWebContents(contents2, false); + tabstrip.AppendWebContents(contents3, false); observer.ClearStates(); @@ -2081,9 +2085,10 @@ TEST_F(TabStripModelTest, DiscardTabContentsAt) { // Fill it with some tabs. TabContents* tab_contents1 = CreateTabContents(); WebContents* contents1 = tab_contents1->web_contents(); - tabstrip.AppendTabContents(tab_contents1, true); + tabstrip.AppendWebContents(contents1, true); TabContents* tab_contents2 = CreateTabContents(); - tabstrip.AppendTabContents(tab_contents2, true); + WebContents* contents2 = tab_contents2->web_contents(); + tabstrip.AppendWebContents(contents2, true); // Start watching for events after the appends to avoid observing state // transitions that aren't relevant to this test. @@ -2138,13 +2143,13 @@ TEST_F(TabStripModelTest, DiscardTabContentsAt) { TEST_F(TabStripModelTest, DeleteFromDestroy) { TabStripDummyDelegate delegate; TabStripModel strip(&delegate, profile()); - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - strip.AppendTabContents(contents1, true); - strip.AppendTabContents(contents2, true); + WebContents* contents1 = CreateTabContents()->web_contents(); + WebContents* contents2 = CreateTabContents()->web_contents(); + strip.AppendWebContents(contents1, true); + strip.AppendWebContents(contents2, true); // DeleteTabContentsOnDestroyedObserver deletes contents1 when contents2 sends // out notification that it is being destroyed. - DeleteTabContentsOnDestroyedObserver observer(contents2, contents1); + DeleteWebContentsOnDestroyedObserver observer(contents2, contents1); strip.CloseAllTabs(); } @@ -2215,12 +2220,12 @@ TEST_F(TabStripModelTest, MoveSelectedTabsTo) { TEST_F(TabStripModelTest, CloseSelectedTabs) { TabStripDummyDelegate delegate; TabStripModel strip(&delegate, profile()); - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - TabContents* contents3 = CreateTabContents(); - strip.AppendTabContents(contents1, true); - strip.AppendTabContents(contents2, true); - strip.AppendTabContents(contents3, true); + WebContents* contents1 = CreateTabContents()->web_contents(); + WebContents* contents2 = CreateTabContents()->web_contents(); + WebContents* contents3 = CreateTabContents()->web_contents(); + strip.AppendWebContents(contents1, true); + strip.AppendWebContents(contents2, true); + strip.AppendWebContents(contents3, true); strip.ToggleSelectionAt(1); strip.CloseSelectedTabs(); EXPECT_EQ(1, strip.count()); @@ -2239,11 +2244,13 @@ TEST_F(TabStripModelTest, MultipleSelection) { 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(); - strip.AppendTabContents(tab_contents0, false); - strip.AppendTabContents(tab_contents1, false); - strip.AppendTabContents(tab_contents2, false); - strip.AppendTabContents(tab_contents3, false); + strip.AppendWebContents(contents0, false); + strip.AppendWebContents(contents1, false); + strip.AppendWebContents(contents2, false); + strip.AppendWebContents(contents3, false); strip.AddObserver(&observer); // Selection and active tab change. @@ -2351,9 +2358,10 @@ TEST_F(TabStripModelTest, MultipleToSingle) { TabStripModel strip(&delegate, profile()); TabContents* tab_contents1 = CreateTabContents(); TabContents* tab_contents2 = CreateTabContents(); + WebContents* contents1 = tab_contents1->web_contents(); WebContents* contents2 = tab_contents2->web_contents(); - strip.AppendTabContents(tab_contents1, false); - strip.AppendTabContents(tab_contents2, false); + strip.AppendWebContents(contents1, false); + strip.AppendWebContents(contents2, false); strip.ToggleSelectionAt(0); strip.ToggleSelectionAt(1); diff --git a/chrome/browser/ui/views/constrained_window_views_browsertest.cc b/chrome/browser/ui/views/constrained_window_views_browsertest.cc index af168bc..0d223b2 100644 --- a/chrome/browser/ui/views/constrained_window_views_browsertest.cc +++ b/chrome/browser/ui/views/constrained_window_views_browsertest.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include "base/memory/weak_ptr.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/constrained_window_tab_helper.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/views/constrained_window_views.h" @@ -107,7 +107,8 @@ class ConstrainedWindowViewTest : public InProcessBrowserTest { // *) Constrained windows that are queued don't register themselves as // accelerator targets until they are displayed. IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) { - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents != NULL); ConstrainedWindowTabHelper* constrained_window_helper = ConstrainedWindowTabHelper::FromWebContents(web_contents); @@ -164,7 +165,8 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) { EXPECT_NE(test_dialog2->GetInitiallyFocusedView(), focus_manager->GetFocusedView()); - chrome::ActivateTabAt(browser(), tab_with_constrained_window, false); + browser()->tab_strip_model()->ActivateTabAt(tab_with_constrained_window, + false); // Activating the previous tab should bring focus to the constrained window. EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(), @@ -181,7 +183,8 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) { // Tests that the constrained window is closed properly when its tab is // closed. IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabCloseTest) { - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents != NULL); ConstrainedWindowTabHelper* constrained_window_helper = ConstrainedWindowTabHelper::FromWebContents(web_contents); @@ -205,7 +208,8 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabCloseTest) { // Tests that the constrained window is hidden when an other tab is selected and // shown when its tab is selected again. IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabSwitchTest) { - content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents != NULL); // Create a constrained dialog. It will attach itself to tab_contents. @@ -216,8 +220,8 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabSwitchTest) { EXPECT_TRUE(window->IsVisible()); // Open a new tab. The constrained window should hide itself. - browser()->tab_strip_model()->AppendTabContents( - chrome::TabContentsFactory( + browser()->tab_strip_model()->AppendWebContents( + content::WebContents::Create( browser()->profile(), NULL, MSG_ROUTING_NONE, NULL), true); EXPECT_FALSE(window->IsVisible()); |