summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-26 20:08:41 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-26 20:08:41 +0000
commit976702be5e77999463d8fb2218aa088871d083a6 (patch)
treef90c3280ebab60af30fc79bdd492dc0301f1d8e7
parentdbc72567eb49a59a0aa3135c7fcbc61221f3265b (diff)
downloadchromium_src-976702be5e77999463d8fb2218aa088871d083a6.zip
chromium_src-976702be5e77999463d8fb2218aa088871d083a6.tar.gz
chromium_src-976702be5e77999463d8fb2218aa088871d083a6.tar.bz2
Remove TabContents from TabStripModel::InsertTabContentsAt.
BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11348115 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169472 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/tabs/tabs.cc6
-rw-r--r--chrome/browser/ui/ash/launcher/browser_launcher_item_controller_unittest.cc46
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc6
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.h4
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_app_tab_helper.cc7
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h3
-rw-r--r--chrome/browser/ui/browser.h2
-rw-r--r--chrome/browser/ui/browser_commands.cc11
-rw-r--r--chrome/browser/ui/browser_tab_strip_model_delegate.cc5
-rw-r--r--chrome/browser/ui/browser_tab_strip_model_delegate.h1
-rw-r--r--chrome/browser/ui/browser_tabrestore.cc23
-rw-r--r--chrome/browser/ui/browser_tabstrip.cc15
-rw-r--r--chrome/browser/ui/browser_tabstrip.h15
-rw-r--r--chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm4
-rw-r--r--chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc12
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents.h4
-rw-r--r--chrome/browser/ui/tabs/tab_strip_model.cc33
-rw-r--r--chrome/browser/ui/tabs/tab_strip_model.h5
-rw-r--r--chrome/browser/ui/tabs/tab_strip_model_delegate.h5
-rw-r--r--chrome/browser/ui/tabs/tab_strip_model_order_controller.cc1
-rw-r--r--chrome/browser/ui/tabs/tab_strip_model_order_controller.h3
-rw-r--r--chrome/browser/ui/tabs/tab_strip_model_unittest.cc62
-rw-r--r--chrome/browser/ui/tabs/test_tab_strip_model_delegate.cc17
-rw-r--r--chrome/browser/ui/tabs/test_tab_strip_model_delegate.h1
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller.cc12
25 files changed, 138 insertions, 165 deletions
diff --git a/chrome/browser/extensions/api/tabs/tabs.cc b/chrome/browser/extensions/api/tabs/tabs.cc
index 1277138..ddc431b 100644
--- a/chrome/browser/extensions/api/tabs/tabs.cc
+++ b/chrome/browser/extensions/api/tabs/tabs.cc
@@ -628,7 +628,7 @@ bool CreateWindowFunction::RunImpl() {
}
if (contents) {
TabStripModel* target_tab_strip = new_window->tab_strip_model();
- target_tab_strip->InsertTabContentsAt(urls.size(), contents,
+ target_tab_strip->InsertWebContentsAt(urls.size(), contents->web_contents(),
TabStripModel::ADD_NONE);
} else if (urls.empty()) {
chrome::NewTab(new_window);
@@ -1484,8 +1484,8 @@ bool MoveTabsFunction::RunImpl() {
if (new_index > target_tab_strip->count() || new_index < 0)
new_index = target_tab_strip->count();
- target_tab_strip->InsertTabContentsAt(
- new_index, tab_contents, TabStripModel::ADD_NONE);
+ target_tab_strip->InsertWebContentsAt(
+ new_index, tab_contents->web_contents(), TabStripModel::ADD_NONE);
if (has_callback()) {
tab_values.Append(ExtensionTabUtil::CreateTabValue(
diff --git a/chrome/browser/ui/ash/launcher/browser_launcher_item_controller_unittest.cc b/chrome/browser/ui/ash/launcher/browser_launcher_item_controller_unittest.cc
index 2d98acc..538e642 100644
--- a/chrome/browser/ui/ash/launcher/browser_launcher_item_controller_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/browser_launcher_item_controller_unittest.cc
@@ -11,11 +11,11 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -28,14 +28,6 @@
#include "ui/aura/window_delegate.h"
#include "ui/base/events/event.h"
-// TODO(avi): Kill this when TabContents goes away.
-class BrowserLauncherItemControllerContentsCreator {
- public:
- static TabContents* CreateTabContents(content::WebContents* contents) {
- return TabContents::Factory::CreateTabContents(contents);
- }
-};
-
namespace {
const int kExpectedAppIndex = 1;
@@ -48,17 +40,17 @@ class AppTabHelperImpl : public ChromeLauncherController::AppTabHelper {
// Sets the id for the specified tab. The id is removed if Remove() is
// invoked.
- void SetAppID(TabContents* tab, const std::string& id) {
+ void SetAppID(content::WebContents* tab, const std::string& id) {
tab_id_map_[tab] = id;
}
// Returns true if there is an id registered for |tab|.
- bool HasAppID(TabContents* tab) const {
+ bool HasAppID(content::WebContents* tab) const {
return tab_id_map_.find(tab) != tab_id_map_.end();
}
// AppTabHelper implementation:
- virtual std::string GetAppID(TabContents* tab) OVERRIDE {
+ virtual std::string GetAppID(content::WebContents* tab) OVERRIDE {
return tab_id_map_.find(tab) != tab_id_map_.end() ? tab_id_map_[tab] :
std::string();
}
@@ -73,7 +65,7 @@ class AppTabHelperImpl : public ChromeLauncherController::AppTabHelper {
}
private:
- typedef std::map<TabContents*, std::string> TabToStringMap;
+ typedef std::map<content::WebContents*, std::string> TabToStringMap;
TabToStringMap tab_id_map_;
@@ -227,9 +219,7 @@ class BrowserLauncherItemControllerTest
TEST_F(BrowserLauncherItemControllerTest, TabbedSetup) {
size_t initial_size = launcher_model_->items().size();
{
- scoped_ptr<TabContents> tab_contents(
- BrowserLauncherItemControllerContentsCreator::CreateTabContents(
- CreateTestWebContents()));
+ scoped_ptr<content::WebContents> web_contents(CreateTestWebContents());
State state(this, std::string(),
BrowserLauncherItemController::TYPE_TABBED);
@@ -244,14 +234,12 @@ TEST_F(BrowserLauncherItemControllerTest, TabbedSetup) {
// Do the same, but this time add the tab first.
{
- scoped_ptr<TabContents> tab_contents(
- BrowserLauncherItemControllerContentsCreator::CreateTabContents(
- CreateTestWebContents()));
+ scoped_ptr<content::WebContents> web_contents(CreateTestWebContents());
TestTabStripModelDelegate tab_strip_delegate;
TabStripModel tab_strip(&tab_strip_delegate, profile());
- tab_strip.InsertTabContentsAt(0,
- tab_contents.get(),
+ tab_strip.InsertWebContentsAt(0,
+ web_contents.get(),
TabStripModel::ADD_ACTIVE);
aura::Window window(NULL);
window.Init(ui::LAYER_NOT_DRAWN);
@@ -278,11 +266,9 @@ TEST_F(BrowserLauncherItemControllerTest, PanelItem) {
aura::Window window(NULL);
TestTabStripModelDelegate tab_strip_delegate;
TabStripModel tab_strip(&tab_strip_delegate, profile());
- scoped_ptr<TabContents> panel_tab(
- BrowserLauncherItemControllerContentsCreator::CreateTabContents(
- CreateTestWebContents()));
+ scoped_ptr<content::WebContents> panel_tab(CreateTestWebContents());
app_tab_helper_->SetAppID(panel_tab.get(), "1"); // Panels are apps.
- tab_strip.InsertTabContentsAt(0,
+ tab_strip.InsertWebContentsAt(0,
panel_tab.get(),
TabStripModel::ADD_ACTIVE);
BrowserLauncherItemController updater(
@@ -300,11 +286,9 @@ TEST_F(BrowserLauncherItemControllerTest, PanelItem) {
aura::Window window(NULL);
TestTabStripModelDelegate tab_strip_delegate;
TabStripModel tab_strip(&tab_strip_delegate, profile());
- scoped_ptr<TabContents> panel_tab(
- BrowserLauncherItemControllerContentsCreator::CreateTabContents(
- CreateTestWebContents()));
+ scoped_ptr<content::WebContents> panel_tab(CreateTestWebContents());
app_tab_helper_->SetAppID(panel_tab.get(), "1"); // Panels are apps.
- tab_strip.InsertTabContentsAt(0,
+ tab_strip.InsertWebContentsAt(0,
panel_tab.get(),
TabStripModel::ADD_ACTIVE);
BrowserLauncherItemController updater(
@@ -321,9 +305,7 @@ TEST_F(BrowserLauncherItemControllerTest, PanelItem) {
// Verifies pinned apps are persisted and restored.
TEST_F(BrowserLauncherItemControllerTest, PersistPinned) {
size_t initial_size = launcher_model_->items().size();
- scoped_ptr<TabContents> tab1(
- BrowserLauncherItemControllerContentsCreator::CreateTabContents(
- CreateTestWebContents()));
+ scoped_ptr<content::WebContents> tab1(CreateTestWebContents());
app_tab_helper_->SetAppID(tab1.get(), "1");
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index 6a0cfd1..f48a815 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -458,7 +458,7 @@ extensions::ExtensionPrefs::LaunchType ChromeLauncherController::GetLaunchType(
extensions::ExtensionPrefs::LAUNCH_DEFAULT);
}
-std::string ChromeLauncherController::GetAppID(TabContents* tab) {
+std::string ChromeLauncherController::GetAppID(content::WebContents* tab) {
return app_tab_helper_->GetAppID(tab);
}
@@ -602,11 +602,11 @@ void ChromeLauncherController::RemoveTabFromRunningApp(
void ChromeLauncherController::UpdateAppState(content::WebContents* contents,
AppState app_state) {
- TabContents* tab = TabContents::FromWebContents(contents);
- std::string app_id = GetAppID(tab);
+ std::string app_id = GetAppID(contents);
// Check the old |app_id| for a tab. If the contents has changed we need to
// remove it from the previous app.
+ TabContents* tab = TabContents::FromWebContents(contents);
if (tab_contents_to_app_id_.find(tab) != tab_contents_to_app_id_.end()) {
std::string last_app_id = tab_contents_to_app_id_[tab];
if (last_app_id != app_id)
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
index 9d438fb..2171031 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
@@ -83,7 +83,7 @@ class ChromeLauncherController
// Returns the app id of the specified tab, or an empty string if there is
// no app.
- virtual std::string GetAppID(TabContents* tab) = 0;
+ virtual std::string GetAppID(content::WebContents* tab) = 0;
// Returns true if |id| is valid. Used during restore to ignore no longer
// valid extensions.
@@ -179,7 +179,7 @@ class ChromeLauncherController
extensions::ExtensionPrefs::LaunchType GetLaunchType(ash::LauncherID id);
// Returns the id of the app for the specified tab.
- std::string GetAppID(TabContents* tab);
+ std::string GetAppID(content::WebContents* tab);
ash::LauncherID GetLauncherIDForAppID(const std::string& app_id);
std::string GetAppIDForLauncherID(ash::LauncherID id);
diff --git a/chrome/browser/ui/ash/launcher/launcher_app_tab_helper.cc b/chrome/browser/ui/ash/launcher/launcher_app_tab_helper.cc
index dd8d81b..eaa4104 100644
--- a/chrome/browser/ui/ash/launcher/launcher_app_tab_helper.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_app_tab_helper.cc
@@ -6,18 +6,17 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/web_contents.h"
namespace {
const extensions::Extension* GetExtensionForTab(Profile* profile,
- TabContents* tab) {
+ content::WebContents* tab) {
ExtensionService* extension_service = profile->GetExtensionService();
if (!extension_service)
return NULL;
- return extension_service->GetInstalledApp(tab->web_contents()->GetURL());
+ return extension_service->GetInstalledApp(tab->GetURL());
}
const extensions::Extension* GetExtensionByID(Profile* profile,
@@ -37,7 +36,7 @@ LauncherAppTabHelper::LauncherAppTabHelper(Profile* profile)
LauncherAppTabHelper::~LauncherAppTabHelper() {
}
-std::string LauncherAppTabHelper::GetAppID(TabContents* tab) {
+std::string LauncherAppTabHelper::GetAppID(content::WebContents* tab) {
const extensions::Extension* extension = GetExtensionForTab(profile_, tab);
return extension ? extension->id() : std::string();
}
diff --git a/chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h b/chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h
index b46abd7..ec763bf 100644
--- a/chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h
+++ b/chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h
@@ -11,7 +11,6 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
class Profile;
-class TabContents;
// Default implementation of LauncherUpdater::AppTabHelper that interacts
// with ExtensionService.
@@ -21,7 +20,7 @@ class LauncherAppTabHelper : public ChromeLauncherController::AppTabHelper {
virtual ~LauncherAppTabHelper();
// AppTabHelper:
- virtual std::string GetAppID(TabContents* tab) OVERRIDE;
+ virtual std::string GetAppID(content::WebContents* tab) OVERRIDE;
virtual bool IsValidID(const std::string& id) OVERRIDE;
private:
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index b7f3962..e3ed320 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -66,6 +66,7 @@ struct WebApplicationInfo;
namespace chrome {
class BrowserCommandController;
class BrowserInstantController;
+class BrowserTabStripModelDelegate;
class UnloadController;
namespace search {
struct Mode;
@@ -424,6 +425,7 @@ class Browser : public TabStripModelObserver,
class Adoption {
private:
friend class Browser;
+ friend class chrome::BrowserTabStripModelDelegate;
// Chrome Frame is a special case. Chrome Frame is defined as a complete
// tab of Chrome inside of an IE window, so it has the unique privilege of
// asking Browser to set up a WebContents to have the full complement of tab
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index 644c5cc..601032f 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -583,8 +583,8 @@ TabContents* DuplicateTabAt(Browser* browser, int index) {
int add_types = TabStripModel::ADD_ACTIVE |
TabStripModel::ADD_INHERIT_GROUP |
(pinned ? TabStripModel::ADD_PINNED : 0);
- browser->tab_strip_model()->InsertTabContentsAt(
- index + 1, contents_dupe, add_types);
+ browser->tab_strip_model()->InsertWebContentsAt(
+ index + 1, contents_dupe->web_contents(), add_types);
} else {
Browser* browser = NULL;
if (browser->is_app()) {
@@ -1025,9 +1025,10 @@ void ViewSource(Browser* browser,
int index = browser->tab_strip_model()->GetIndexOfTabContents(contents);
int add_types = TabStripModel::ADD_ACTIVE |
TabStripModel::ADD_INHERIT_GROUP;
- browser->tab_strip_model()->InsertTabContentsAt(index + 1,
- view_source_contents,
- add_types);
+ browser->tab_strip_model()->InsertWebContentsAt(
+ index + 1,
+ view_source_contents->web_contents(),
+ add_types);
} else {
Browser* b = new Browser(
Browser::CreateParams(Browser::TYPE_TABBED, browser->profile()));
diff --git a/chrome/browser/ui/browser_tab_strip_model_delegate.cc b/chrome/browser/ui/browser_tab_strip_model_delegate.cc
index ab777f6..1d55d26 100644
--- a/chrome/browser/ui/browser_tab_strip_model_delegate.cc
+++ b/chrome/browser/ui/browser_tab_strip_model_delegate.cc
@@ -81,6 +81,11 @@ Browser* BrowserTabStripModelDelegate::CreateNewStripWithContents(
return browser;
}
+void BrowserTabStripModelDelegate::WillAddWebContents(
+ content::WebContents* contents) {
+ Browser::Adoption::AdoptAsTabContents(contents);
+}
+
int BrowserTabStripModelDelegate::GetDragActions() const {
return TabStripModelDelegate::TAB_TEAROFF_ACTION |
(browser_->tab_count() > 1 ? TabStripModelDelegate::TAB_MOVE_ACTION : 0);
diff --git a/chrome/browser/ui/browser_tab_strip_model_delegate.h b/chrome/browser/ui/browser_tab_strip_model_delegate.h
index d109a3e..3410689 100644
--- a/chrome/browser/ui/browser_tab_strip_model_delegate.h
+++ b/chrome/browser/ui/browser_tab_strip_model_delegate.h
@@ -24,6 +24,7 @@ class BrowserTabStripModelDelegate : public TabStripModelDelegate {
const gfx::Rect& window_bounds,
const DockInfo& dock_info,
bool maximize) OVERRIDE;
+ virtual void WillAddWebContents(content::WebContents* contents) OVERRIDE;
virtual int GetDragActions() const OVERRIDE;
virtual bool CanDuplicateContentsAt(int index) OVERRIDE;
virtual void DuplicateContentsAt(int index) OVERRIDE;
diff --git a/chrome/browser/ui/browser_tabrestore.cc b/chrome/browser/ui/browser_tabrestore.cc
index 3e82bc6..0e5190c 100644
--- a/chrome/browser/ui/browser_tabrestore.cc
+++ b/chrome/browser/ui/browser_tabrestore.cc
@@ -10,9 +10,7 @@
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/tab_contents/tab_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/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
@@ -38,7 +36,7 @@ NavigationController::RestoreType GetRestoreType(Browser* browser,
NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY;
}
-TabContents* CreateRestoredTab(
+WebContents* CreateRestoredTab(
Browser* browser,
const std::vector<TabNavigation>& navigations,
int selected_navigation,
@@ -54,13 +52,13 @@ TabContents* CreateRestoredTab(
// into the map.
content::SessionStorageNamespaceMap session_storage_namespace_map;
session_storage_namespace_map[""] = session_storage_namespace;
- TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory(
+ WebContents* web_contents = content::WebContents::CreateWithSessionStorage(
browser->profile(),
tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url),
MSG_ROUTING_NONE,
- chrome::GetActiveWebContents(browser),
+ browser->tab_strip_model()->GetActiveWebContents(),
session_storage_namespace_map);
- WebContents* web_contents = tab_contents->web_contents();
+ extensions::TabHelper::CreateForWebContents(web_contents);
extensions::TabHelper::FromWebContents(web_contents)->
SetExtensionAppById(extension_app_id);
std::vector<NavigationEntry*> entries =
@@ -72,7 +70,7 @@ TabContents* CreateRestoredTab(
&entries);
DCHECK_EQ(0u, entries.size());
- return tab_contents;
+ return web_contents;
}
} // namespace
@@ -88,14 +86,13 @@ content::WebContents* AddRestoredTab(
bool from_last_session,
content::SessionStorageNamespace* session_storage_namespace,
const std::string& user_agent_override) {
- TabContents* tab_contents = CreateRestoredTab(browser,
+ WebContents* web_contents = CreateRestoredTab(browser,
navigations,
selected_navigation,
extension_app_id,
from_last_session,
session_storage_namespace,
user_agent_override);
- WebContents* web_contents = tab_contents->web_contents();
int add_types = select ? TabStripModel::ADD_ACTIVE
: TabStripModel::ADD_NONE;
@@ -105,7 +102,7 @@ content::WebContents* AddRestoredTab(
tab_index = std::min(tab_index, first_mini_tab_idx);
add_types |= TabStripModel::ADD_PINNED;
}
- browser->tab_strip_model()->InsertTabContentsAt(tab_index, tab_contents,
+ browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents,
add_types);
if (select) {
browser->window()->Activate();
@@ -135,7 +132,7 @@ void ReplaceRestoredTab(
const std::string& extension_app_id,
content::SessionStorageNamespace* session_storage_namespace,
const std::string& user_agent_override) {
- TabContents* tab_contents = CreateRestoredTab(browser,
+ WebContents* web_contents = CreateRestoredTab(browser,
navigations,
selected_navigation,
extension_app_id,
@@ -145,9 +142,9 @@ void ReplaceRestoredTab(
// ReplaceTabContentsAt won't animate in the restoration, so do it manually.
int insertion_index = browser->active_index();
- browser->tab_strip_model()->InsertTabContentsAt(
+ browser->tab_strip_model()->InsertWebContentsAt(
insertion_index + 1,
- tab_contents,
+ web_contents,
TabStripModel::ADD_ACTIVE | TabStripModel::ADD_INHERIT_GROUP);
browser->tab_strip_model()->CloseTabContentsAt(
insertion_index, TabStripModel::CLOSE_NONE);
diff --git a/chrome/browser/ui/browser_tabstrip.cc b/chrome/browser/ui/browser_tabstrip.cc
index d7e82cb..7783c56 100644
--- a/chrome/browser/ui/browser_tabstrip.cc
+++ b/chrome/browser/ui/browser_tabstrip.cc
@@ -153,19 +153,4 @@ TabContents* TabContentsFactory(
base_web_contents));
}
-TabContents* TabContentsWithSessionStorageFactory(
- Profile* profile,
- content::SiteInstance* site_instance,
- int routing_id,
- const content::WebContents* base_web_contents,
- const content::SessionStorageNamespaceMap& session_storage_namespace_map) {
- return BrowserTabstripTabContentsCreator::CreateTabContents(
- content::WebContents::CreateWithSessionStorage(
- profile,
- site_instance,
- routing_id,
- base_web_contents,
- session_storage_namespace_map));
-}
-
} // namespace chrome
diff --git a/chrome/browser/ui/browser_tabstrip.h b/chrome/browser/ui/browser_tabstrip.h
index 470064c..c8e8e09 100644
--- a/chrome/browser/ui/browser_tabstrip.h
+++ b/chrome/browser/ui/browser_tabstrip.h
@@ -63,21 +63,6 @@ TabContents* TabContentsFactory(
int routing_id,
const content::WebContents* base_web_contents);
-// Same as TabContentsFactory, but allows specifying the initial
-// |session_storage_namespace_map|. This is for supporting session restore
-// where we reconstitute the session storage namespaces for a browsing context.
-//
-// You do not want to call this. If you think you do, make sure you completely
-// understand when SessionStorageNamespace objects should be cloned, why
-// they should not be shared by multiple WebContents, and what bad things
-// can happen if you share the object.
-TabContents* TabContentsWithSessionStorageFactory(
- Profile* profile,
- content::SiteInstance* site_instance,
- int routing_id,
- const content::WebContents* base_web_contents,
- const content::SessionStorageNamespaceMap& session_storage_namespace_map);
-
} // namespace chrome
#endif // CHROME_BROWSER_UI_BROWSER_TABSTRIP_H_
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index 4ff41ba..70a0957 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -1733,8 +1733,8 @@ private:
// Insert it into this tab strip. We want it in the foreground and to not
// inherit the current tab's group.
- tabStripModel_->InsertTabContentsAt(
- modelIndex, contents,
+ tabStripModel_->InsertWebContentsAt(
+ modelIndex, contents->web_contents(),
TabStripModel::ADD_ACTIVE | (pinned ? TabStripModel::ADD_PINNED : 0));
}
diff --git a/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc
index d433bc3..f8517fb 100644
--- a/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -460,8 +460,8 @@ void DraggedTabControllerGtk::Attach(TabStripGtk* attached_tabstrip,
GetDraggedViewTabStripBounds(GetDraggedViewPoint(screen_point));
int index = GetInsertionIndexForDraggedBounds(GetEffectiveBounds(bounds));
for (size_t i = 0; i < drag_data_->size(); ++i) {
- attached_tabstrip_->model()->InsertTabContentsAt(
- index + i, drag_data_->get(i)->contents_,
+ attached_tabstrip_->model()->InsertWebContentsAt(
+ index + i, drag_data_->get(i)->contents_->web_contents(),
drag_data_->GetAddTypesForDraggedTabAt(i));
}
RestoreSelection(attached_tabstrip_->model());
@@ -702,9 +702,9 @@ void DraggedTabControllerGtk::RevertDrag() {
for (size_t i = 0; i < drag_data_->size(); ++i) {
if (!drag_data_->get(i)->contents_)
continue;
- attached_tabstrip_->model()->InsertTabContentsAt(
+ attached_tabstrip_->model()->InsertWebContentsAt(
drag_data_->get(i)->source_model_index_,
- drag_data_->get(i)->contents_,
+ drag_data_->get(i)->contents_->web_contents(),
drag_data_->GetAddTypesForDraggedTabAt(i));
}
} else {
@@ -729,9 +729,9 @@ void DraggedTabControllerGtk::RevertDrag() {
for (size_t i = 0; i < drag_data_->size(); ++i) {
if (!drag_data_->get(i)->contents_)
continue;
- source_tabstrip_->model()->InsertTabContentsAt(
+ source_tabstrip_->model()->InsertWebContentsAt(
drag_data_->get(i)->source_model_index_,
- drag_data_->get(i)->contents_,
+ drag_data_->get(i)->contents_->web_contents(),
drag_data_->GetAddTypesForDraggedTabAt(i));
}
}
diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h
index f3fd3ae..3df0b3d 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.h
+++ b/chrome/browser/ui/tab_contents/tab_contents.h
@@ -13,7 +13,6 @@
class Browser;
class BrowserCommandsTabContentsCreator;
-class BrowserLauncherItemControllerContentsCreator;
class BrowserTabstripTabContentsCreator;
class ChromeWebContentsHandler;
class ConstrainedWebDialogDelegateBase;
@@ -23,6 +22,7 @@ class OffscreenTabContentsCreator;
class PanelHost;
class Profile;
class TabStripModel;
+class TestTabStripModelDelegate;
namespace extensions {
class WebAuthFlow;
@@ -57,7 +57,6 @@ class TabContents : public content::WebContentsObserver {
friend class Browser;
friend class BrowserCommandsTabContentsCreator;
- friend class BrowserLauncherItemControllerContentsCreator;
friend class BrowserTabstripTabContentsCreator;
friend class ChromeWebContentsHandler;
friend class ConstrainedWebDialogDelegateBase;
@@ -70,6 +69,7 @@ class TabContents : public content::WebContentsObserver {
// See crbug.com/153587
friend class TabAndroid;
friend class TabStripModel;
+ friend class TestTabStripModelDelegate;
FRIEND_TEST_ALL_PREFIXES(SessionRestoreTest, SessionStorageAfterTabReplace);
static TabContents* CreateTabContents(content::WebContents* contents);
diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc
index 1252aa8..35acf6c 100644
--- a/chrome/browser/ui/tabs/tab_strip_model.cc
+++ b/chrome/browser/ui/tabs/tab_strip_model.cc
@@ -83,18 +83,20 @@ bool TabStripModel::ContainsIndex(int index) const {
void TabStripModel::AppendTabContents(TabContents* contents,
bool foreground) {
- InsertTabContentsAt(count(), contents,
+ InsertWebContentsAt(count(), contents->web_contents(),
foreground ? (ADD_INHERIT_GROUP | ADD_ACTIVE) :
ADD_NONE);
}
-void TabStripModel::InsertTabContentsAt(int index,
- TabContents* contents,
+void TabStripModel::InsertWebContentsAt(int index,
+ WebContents* contents,
int add_types) {
+ delegate_->WillAddWebContents(contents);
+
bool active = add_types & ADD_ACTIVE;
// Force app tabs to be pinned.
extensions::TabHelper* extensions_tab_helper =
- extensions::TabHelper::FromWebContents(contents->web_contents());
+ extensions::TabHelper::FromWebContents(contents);
bool pin = extensions_tab_helper->is_app() || add_types & ADD_PINNED;
index = ConstrainInsertionIndex(index, pin);
@@ -108,7 +110,7 @@ void TabStripModel::InsertTabContentsAt(int index,
// otherwise we run into problems when we try to change the active contents
// since the old contents and the new contents will be the same...
WebContents* active_contents = GetActiveWebContents();
- WebContentsData* data = new WebContentsData(contents->web_contents());
+ WebContentsData* data = new WebContentsData(contents);
data->pinned = pin;
if ((add_types & ADD_INHERIT_GROUP) && active_contents) {
if (active) {
@@ -132,7 +134,7 @@ void TabStripModel::InsertTabContentsAt(int index,
selection_model_.IncrementFrom(index);
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
- TabInsertedAt(contents->web_contents(), index, active));
+ TabInsertedAt(contents, index, active));
if (active) {
TabStripSelectionModel new_model;
new_model.Copy(selection_model_);
@@ -141,14 +143,6 @@ void TabStripModel::InsertTabContentsAt(int index,
}
}
-void TabStripModel::InsertWebContentsAt(int index,
- WebContents* contents,
- int add_types) {
- TabContents* tab_contents = TabContents::FromWebContents(contents);
- DCHECK(tab_contents);
- InsertTabContentsAt(index, tab_contents, add_types);
-}
-
TabContents* TabStripModel::ReplaceTabContentsAt(int index,
TabContents* new_contents) {
DCHECK(ContainsIndex(index));
@@ -627,8 +621,8 @@ void TabStripModel::AddTabContents(TabContents* contents,
// drag-and-drops a link to the tab strip), callers aren't really handling
// link clicks, they just want to score the navigation like a link click in
// the history backend, so we don't inherit the group in this case.
- index = order_controller_->DetermineInsertionIndex(
- contents, transition, add_types & ADD_ACTIVE);
+ index = order_controller_->DetermineInsertionIndex(transition,
+ add_types & ADD_ACTIVE);
inherit_group = true;
} else {
// For all other types, respect what was passed to us, normalizing -1s and
@@ -646,15 +640,16 @@ void TabStripModel::AddTabContents(TabContents* contents,
// is re-selected, not the next-adjacent.
inherit_group = true;
}
- InsertTabContentsAt(
- index, contents, add_types | (inherit_group ? ADD_INHERIT_GROUP : 0));
+ InsertWebContentsAt(index,
+ contents->web_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);
if (inherit_group && transition == content::PAGE_TRANSITION_TYPED)
contents_data_[index]->reset_group_on_select = true;
- // TODO(sky): figure out why this is here and not in InsertTabContentsAt. When
+ // TODO(sky): figure out why this is here and not in InsertWebContentsAt. When
// here we seem to get failures in startup perf tests.
// Ensure that the new WebContentsView begins at the same size as the
// previous WebContentsView if it existed. Otherwise, the initial WebKit
diff --git a/chrome/browser/ui/tabs/tab_strip_model.h b/chrome/browser/ui/tabs/tab_strip_model.h
index 1962f87..8b95f4e 100644
--- a/chrome/browser/ui/tabs/tab_strip_model.h
+++ b/chrome/browser/ui/tabs/tab_strip_model.h
@@ -176,9 +176,6 @@ class TabStripModel : public content::NotificationObserver {
// 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.
- void InsertTabContentsAt(int index,
- TabContents* contents,
- int add_types);
void InsertWebContentsAt(int index,
content::WebContents* contents,
int add_types);
@@ -386,7 +383,7 @@ class TabStripModel : public content::NotificationObserver {
// Adds a TabContents 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
- // InsertTabContentsAt to do the actual insertion. Pass -1 for |index| to
+ // InsertWebContentsAt to do the actual insertion. Pass -1 for |index| to
// append the contents to the end of the tab strip.
void AddTabContents(TabContents* contents,
int index,
diff --git a/chrome/browser/ui/tabs/tab_strip_model_delegate.h b/chrome/browser/ui/tabs/tab_strip_model_delegate.h
index 5de2441..d4eb434 100644
--- a/chrome/browser/ui/tabs/tab_strip_model_delegate.h
+++ b/chrome/browser/ui/tabs/tab_strip_model_delegate.h
@@ -67,6 +67,11 @@ class TabStripModelDelegate {
const DockInfo& dock_info,
bool maximize) = 0;
+ // Notifies the delegate that the specified WebContents will be added to the
+ // tab strip (via insertion/appending/replacing existing) and allows it to do
+ // any preparation that it deems necessary.
+ virtual void WillAddWebContents(content::WebContents* contents) = 0;
+
// Determines what drag actions are possible for the specified strip.
virtual int GetDragActions() const = 0;
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 f4050d1..0801412 100644
--- a/chrome/browser/ui/tabs/tab_strip_model_order_controller.cc
+++ b/chrome/browser/ui/tabs/tab_strip_model_order_controller.cc
@@ -21,7 +21,6 @@ TabStripModelOrderController::~TabStripModelOrderController() {
}
int TabStripModelOrderController::DetermineInsertionIndex(
- TabContents* new_contents,
content::PageTransition transition,
bool foreground) {
int tab_count = tabstrip_->count();
diff --git a/chrome/browser/ui/tabs/tab_strip_model_order_controller.h b/chrome/browser/ui/tabs/tab_strip_model_order_controller.h
index 7869cd5..b94cd00 100644
--- a/chrome/browser/ui/tabs/tab_strip_model_order_controller.h
+++ b/chrome/browser/ui/tabs/tab_strip_model_order_controller.h
@@ -23,8 +23,7 @@ class TabStripModelOrderController : public TabStripModelObserver {
// Determine where to place a newly opened tab by using the supplied
// transition and foreground flag to figure out how it was opened.
- int DetermineInsertionIndex(TabContents* new_contents,
- content::PageTransition transition,
+ int DetermineInsertionIndex(content::PageTransition transition,
bool foreground);
// Determine where to shift selection after a tab is closed.
diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
index ada146a..71bc0f6 100644
--- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
@@ -386,12 +386,12 @@ TEST_F(TabStripModelTest, TestBasicAPI) {
}
EXPECT_EQ("1", GetTabStripStateString(tabstrip));
- // Test InsertTabContentsAt, foreground tab.
+ // Test InsertWebContentsAt, foreground tab.
TabContents* tab_contents2 = CreateTabContents();
WebContents* contents2 = tab_contents2->web_contents();
SetID(contents2, 2);
{
- tabstrip.InsertTabContentsAt(1, tab_contents2, TabStripModel::ADD_ACTIVE);
+ tabstrip.InsertWebContentsAt(1, contents2, TabStripModel::ADD_ACTIVE);
EXPECT_EQ(2, tabstrip.count());
EXPECT_EQ(4, observer.GetStateCount());
@@ -411,12 +411,12 @@ TEST_F(TabStripModelTest, TestBasicAPI) {
}
EXPECT_EQ("1 2", GetTabStripStateString(tabstrip));
- // Test InsertTabContentsAt, background tab.
+ // Test InsertWebContentsAt, background tab.
TabContents* tab_contents3 = CreateTabContents();
WebContents* contents3 = tab_contents3->web_contents();
SetID(contents3, 3);
{
- tabstrip.InsertTabContentsAt(2, tab_contents3, TabStripModel::ADD_NONE);
+ tabstrip.InsertWebContentsAt(2, contents3, TabStripModel::ADD_NONE);
EXPECT_EQ(3, tabstrip.count());
EXPECT_EQ(1, observer.GetStateCount());
@@ -607,17 +607,17 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) {
TabContents* contents4 = CreateTabContents();
TabContents* contents5 = CreateTabContents();
- // We use |InsertTabContentsAt| here instead of AppendTabContents so that
+ // We use |InsertWebContentsAt| here instead of AppendTabContents so that
// openership relationships are preserved.
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents1,
+ tabstrip.InsertWebContentsAt(tabstrip.count(), contents1->web_contents(),
TabStripModel::ADD_INHERIT_GROUP);
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents2,
+ tabstrip.InsertWebContentsAt(tabstrip.count(), contents2->web_contents(),
TabStripModel::ADD_INHERIT_GROUP);
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents3,
+ tabstrip.InsertWebContentsAt(tabstrip.count(), contents3->web_contents(),
TabStripModel::ADD_INHERIT_GROUP);
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents4,
+ tabstrip.InsertWebContentsAt(tabstrip.count(), contents4->web_contents(),
TabStripModel::ADD_INHERIT_GROUP);
- tabstrip.InsertTabContentsAt(tabstrip.count(), contents5,
+ tabstrip.InsertWebContentsAt(tabstrip.count(), contents5->web_contents(),
TabStripModel::ADD_INHERIT_GROUP);
// All the tabs should have the same opener.
@@ -666,22 +666,24 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) {
EXPECT_TRUE(tabstrip.empty());
}
-static int GetInsertionIndex(TabStripModel* tabstrip,
- TabContents* contents) {
+static int GetInsertionIndex(TabStripModel* tabstrip) {
return tabstrip->order_controller()->DetermineInsertionIndex(
- contents, content::PAGE_TRANSITION_LINK, false);
+ content::PAGE_TRANSITION_LINK, false);
}
static void InsertTabContentses(TabStripModel* tabstrip,
TabContents* contents1,
TabContents* contents2,
TabContents* contents3) {
- tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents1),
- contents1, TabStripModel::ADD_INHERIT_GROUP);
- tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents2),
- contents2, TabStripModel::ADD_INHERIT_GROUP);
- tabstrip->InsertTabContentsAt(GetInsertionIndex(tabstrip, contents3),
- contents3, TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip),
+ contents1->web_contents(),
+ TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip),
+ contents2->web_contents(),
+ TabStripModel::ADD_INHERIT_GROUP);
+ tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip),
+ contents3->web_contents(),
+ TabStripModel::ADD_INHERIT_GROUP);
}
// Tests opening background tabs.
@@ -748,9 +750,9 @@ TEST_F(TabStripModelTest, TestInsertionIndexDetermination) {
// opener tab.
TabContents* fg_link_contents = CreateTabContents();
int insert_index = tabstrip.order_controller()->DetermineInsertionIndex(
- fg_link_contents, content::PAGE_TRANSITION_LINK, true);
+ content::PAGE_TRANSITION_LINK, true);
EXPECT_EQ(1, insert_index);
- tabstrip.InsertTabContentsAt(insert_index, fg_link_contents,
+ tabstrip.InsertWebContentsAt(insert_index, fg_link_contents->web_contents(),
TabStripModel::ADD_ACTIVE |
TabStripModel::ADD_INHERIT_GROUP);
EXPECT_EQ(1, tabstrip.active_index());
@@ -763,10 +765,11 @@ TEST_F(TabStripModelTest, TestInsertionIndexDetermination) {
// Now open a new empty tab. It should open at the end of the strip.
TabContents* fg_nonlink_contents = CreateTabContents();
insert_index = tabstrip.order_controller()->DetermineInsertionIndex(
- fg_nonlink_contents, content::PAGE_TRANSITION_AUTO_BOOKMARK, true);
+ content::PAGE_TRANSITION_AUTO_BOOKMARK, true);
EXPECT_EQ(tabstrip.count(), insert_index);
// We break the opener relationship...
- tabstrip.InsertTabContentsAt(insert_index, fg_nonlink_contents,
+ tabstrip.InsertWebContentsAt(insert_index,
+ fg_nonlink_contents->web_contents(),
TabStripModel::ADD_NONE);
// Now select it, so that user_gesture == true causes the opener relationship
// to be forgotten...
@@ -854,10 +857,11 @@ TEST_F(TabStripModelTest, TestSelectOnClose) {
// Finally test that when a tab has no "siblings" that the opener is
// selected.
TabContents* other_contents = CreateTabContents();
- tabstrip.InsertTabContentsAt(1, other_contents, TabStripModel::ADD_NONE);
+ tabstrip.InsertWebContentsAt(1, other_contents->web_contents(),
+ TabStripModel::ADD_NONE);
EXPECT_EQ(2, tabstrip.count());
TabContents* opened_contents = CreateTabContents();
- tabstrip.InsertTabContentsAt(2, opened_contents,
+ tabstrip.InsertWebContentsAt(2, opened_contents->web_contents(),
TabStripModel::ADD_ACTIVE |
TabStripModel::ADD_INHERIT_GROUP);
EXPECT_EQ(2, tabstrip.active_index());
@@ -1759,7 +1763,7 @@ TEST_F(TabStripModelTest, Apps) {
// Attempt to insert tab1 (an app tab) at position 1. This isn't a legal
// position and tab1 should end up at position 0.
{
- tabstrip.InsertTabContentsAt(1, tab_contents1, TabStripModel::ADD_NONE);
+ tabstrip.InsertWebContentsAt(1, contents1, TabStripModel::ADD_NONE);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents1, 0, MockTabStripModelObserver::INSERT);
@@ -1773,7 +1777,7 @@ TEST_F(TabStripModelTest, Apps) {
// Insert tab 2 at position 1.
{
- tabstrip.InsertTabContentsAt(1, tab_contents2, TabStripModel::ADD_NONE);
+ tabstrip.InsertWebContentsAt(1, contents2, TabStripModel::ADD_NONE);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents2, 1, MockTabStripModelObserver::INSERT);
@@ -1829,7 +1833,7 @@ TEST_F(TabStripModelTest, Apps) {
tabstrip.DetachTabContentsAt(2);
observer.ClearStates();
- tabstrip.InsertTabContentsAt(0, tab_contents3, TabStripModel::ADD_NONE);
+ tabstrip.InsertWebContentsAt(0, contents3, TabStripModel::ADD_NONE);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents3, 2, MockTabStripModelObserver::INSERT);
@@ -2000,7 +2004,7 @@ TEST_F(TabStripModelTest, Pinning) {
// Insert "4" between "1" and "3". As "1" and "4" are pinned, "4" should end
// up after them.
{
- tabstrip.InsertTabContentsAt(1, tab_contents4, TabStripModel::ADD_NONE);
+ tabstrip.InsertWebContentsAt(1, contents4, TabStripModel::ADD_NONE);
ASSERT_EQ(1, observer.GetStateCount());
State state(contents4, 2, MockTabStripModelObserver::INSERT);
diff --git a/chrome/browser/ui/tabs/test_tab_strip_model_delegate.cc b/chrome/browser/ui/tabs/test_tab_strip_model_delegate.cc
index 5f20dfc..4cc4b3f 100644
--- a/chrome/browser/ui/tabs/test_tab_strip_model_delegate.cc
+++ b/chrome/browser/ui/tabs/test_tab_strip_model_delegate.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h"
+#include "chrome/browser/extensions/tab_helper.h"
+#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+
TestTabStripModelDelegate::TestTabStripModelDelegate() {
}
@@ -21,6 +25,19 @@ Browser* TestTabStripModelDelegate::CreateNewStripWithContents(
return NULL;
}
+void TestTabStripModelDelegate::WillAddWebContents(
+ content::WebContents* contents) {
+ // TEMPORARY: Until TabStripModel is fully de-TabContents-ed, it requires all
+ // items in it to be TabContentses.
+ if (!TabContents::FromWebContents(contents))
+ TabContents::Factory::CreateTabContents(contents);
+
+ // Required to determine reloadability of tabs.
+ CoreTabHelper::CreateForWebContents(contents);
+ // Required to determine if tabs are app tabs.
+ extensions::TabHelper::CreateForWebContents(contents);
+}
+
int TestTabStripModelDelegate::GetDragActions() const {
return 0;
}
diff --git a/chrome/browser/ui/tabs/test_tab_strip_model_delegate.h b/chrome/browser/ui/tabs/test_tab_strip_model_delegate.h
index a55773e..d36990a 100644
--- a/chrome/browser/ui/tabs/test_tab_strip_model_delegate.h
+++ b/chrome/browser/ui/tabs/test_tab_strip_model_delegate.h
@@ -22,6 +22,7 @@ class TestTabStripModelDelegate : public TabStripModelDelegate {
const gfx::Rect& window_bounds,
const DockInfo& dock_info,
bool maximize) OVERRIDE;
+ virtual void WillAddWebContents(content::WebContents* contents) OVERRIDE;
virtual int GetDragActions() const OVERRIDE;
virtual bool CanDuplicateContentsAt(int index) OVERRIDE;
virtual void DuplicateContentsAt(int index) OVERRIDE;
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
index 6673eacf..c31c7d1 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -1179,8 +1179,8 @@ void TabDragController::Attach(TabStrip* attached_tabstrip,
}
if (drag_data_[i].pinned)
add_types |= TabStripModel::ADD_PINNED;
- GetModel(attached_tabstrip_)->InsertTabContentsAt(
- index + i, drag_data_[i].contents, add_types);
+ GetModel(attached_tabstrip_)->InsertWebContentsAt(
+ index + i, drag_data_[i].contents->web_contents(), add_types);
}
tabs = GetTabsMatchingDraggedContents(attached_tabstrip_);
@@ -1714,8 +1714,8 @@ void TabDragController::RevertDragAt(size_t drag_index) {
GetModel(attached_tabstrip_)->DetachTabContentsAt(index);
// TODO(beng): (Cleanup) seems like we should use Attach() for this
// somehow.
- GetModel(source_tabstrip_)->InsertTabContentsAt(
- data->source_model_index, data->contents,
+ GetModel(source_tabstrip_)->InsertWebContentsAt(
+ data->source_model_index, data->contents->web_contents(),
(data->pinned ? TabStripModel::ADD_PINNED : 0));
} else {
// The Tab was moved within the TabStrip where the drag was initiated.
@@ -1727,8 +1727,8 @@ void TabDragController::RevertDragAt(size_t drag_index) {
// The Tab was detached from the TabStrip where the drag began, and has not
// been attached to any other TabStrip. We need to put it back into the
// source TabStrip.
- GetModel(source_tabstrip_)->InsertTabContentsAt(
- data->source_model_index, data->contents,
+ GetModel(source_tabstrip_)->InsertWebContentsAt(
+ data->source_model_index, data->contents->web_contents(),
(data->pinned ? TabStripModel::ADD_PINNED : 0));
}
}