summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-14 22:15:00 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-14 22:15:00 +0000
commit81898992dcbade4de1c6e6ca8953e7fdf0669599 (patch)
tree6c58bf4ce15c75cf4f45331a2bf2fa73ecfbb0eb
parente87b8b518d43c0342367c0f710299a5dc9ef2e4b (diff)
downloadchromium_src-81898992dcbade4de1c6e6ca8953e7fdf0669599.zip
chromium_src-81898992dcbade4de1c6e6ca8953e7fdf0669599.tar.gz
chromium_src-81898992dcbade4de1c6e6ca8953e7fdf0669599.tar.bz2
Moves NavigationController::session_id into RestoreTabHelper.
BUG=none TEST=none R=nick@chromium.org,mpcomplete@chromium.org,jam@chromium.org Review URL: http://codereview.chromium.org/7104064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89083 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/aeropeek_manager.cc27
-rw-r--r--chrome/browser/aeropeek_manager.h7
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc22
-rw-r--r--chrome/browser/automation/automation_provider_win.cc7
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc19
-rw-r--r--chrome/browser/browser_keyevents_browsertest.cc4
-rw-r--r--chrome/browser/debugger/debugger_remote_service.cc12
-rw-r--r--chrome/browser/debugger/devtools_http_protocol_handler.cc11
-rw-r--r--chrome/browser/debugger/devtools_remote_service.cc14
-rw-r--r--chrome/browser/debugger/devtools_window.cc25
-rw-r--r--chrome/browser/debugger/devtools_window.h2
-rw-r--r--chrome/browser/debugger/extension_ports_remote_service.cc10
-rw-r--r--chrome/browser/debugger/inspectable_tab_proxy.cc15
-rw-r--r--chrome/browser/debugger/inspectable_tab_proxy.h19
-rw-r--r--chrome/browser/extensions/extension_tab_helper.cc5
-rw-r--r--chrome/browser/extensions/extension_tab_helper.h4
-rw-r--r--chrome/browser/extensions/extension_tab_id_map.cc19
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc14
-rw-r--r--chrome/browser/extensions/page_action_apitest.cc11
-rw-r--r--chrome/browser/external_tab_container_win.h3
-rw-r--r--chrome/browser/printing/background_printing_manager.cc3
-rw-r--r--chrome/browser/printing/print_preview_tab_controller.cc7
-rw-r--r--chrome/browser/sessions/restore_tab_helper.cc38
-rw-r--r--chrome/browser/sessions/restore_tab_helper.h44
-rw-r--r--chrome/browser/sessions/session_id.h18
-rw-r--r--chrome/browser/sessions/session_restore.cc2
-rw-r--r--chrome/browser/sessions/session_service.cc145
-rw-r--r--chrome/browser/sessions/session_service.h11
-rw-r--r--chrome/browser/sessions/tab_restore_service_delegate.h1
-rw-r--r--chrome/browser/sync/glue/session_change_processor.cc48
-rw-r--r--chrome/browser/sync/glue/session_model_associator.cc43
-rw-r--r--chrome/browser/sync/glue/session_model_associator.h21
-rw-r--r--chrome/browser/tabs/tab_finder.cc6
-rw-r--r--chrome/browser/ui/browser.cc39
-rw-r--r--chrome/browser/ui/browser.h2
-rw-r--r--chrome/browser/ui/browser_tab_restore_service_delegate.cc1
-rw-r--r--chrome/browser/ui/cocoa/applescript/tab_applescript.mm5
-rw-r--r--chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm6
-rw-r--r--chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc6
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_wrapper.cc12
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_wrapper.h16
-rw-r--r--chrome/browser/ui/views/browser_actions_container.cc6
-rw-r--r--chrome/browser/ui/views/file_manager_dialog.cc6
-rw-r--r--chrome/browser/ui/webui/print_preview_handler.cc7
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--content/browser/DEPS2
-rw-r--r--content/browser/tab_contents/navigation_controller.cc7
-rw-r--r--content/browser/tab_contents/navigation_controller.h16
-rw-r--r--content/browser/tab_contents/navigation_controller_unittest.cc36
-rw-r--r--content/browser/tab_contents/tab_contents.cc3
-rw-r--r--content/browser/tab_contents/tab_contents.h7
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.cc4
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.h3
-rw-r--r--content/common/notification_type.h6
54 files changed, 457 insertions, 372 deletions
diff --git a/chrome/browser/aeropeek_manager.cc b/chrome/browser/aeropeek_manager.cc
index 79107e1..f4a2da6 100644
--- a/chrome/browser/aeropeek_manager.cc
+++ b/chrome/browser/aeropeek_manager.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/app_icon_win.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/tab_contents/thumbnail_generator.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser_list.h"
@@ -1040,12 +1041,12 @@ void AeroPeekManager::DeleteAeroPeekWindowForTab(TabContentsWrapper* tab) {
// Delete the AeroPeekWindow object associated with this tab and all its
// resources. (AeroPeekWindow::Destory() also removes this tab from the tab
// list of Windows.)
- AeroPeekWindow* window = GetAeroPeekWindow(GetTabID(tab->tab_contents()));
+ AeroPeekWindow* window = GetAeroPeekWindow(GetTabID(tab));
if (!window)
return;
window->Destroy();
- DeleteAeroPeekWindow(GetTabID(tab->tab_contents()));
+ DeleteAeroPeekWindow(GetTabID(tab));
}
AeroPeekWindow* AeroPeekManager::GetAeroPeekWindow(int tab_id) const {
@@ -1061,13 +1062,13 @@ AeroPeekWindow* AeroPeekManager::GetAeroPeekWindow(int tab_id) const {
void AeroPeekManager::CreateAeroPeekWindowIfNecessary(TabContentsWrapper* tab,
bool foreground) {
- if (GetAeroPeekWindow(GetTabID(tab->tab_contents())))
+ if (GetAeroPeekWindow(GetTabID(tab)))
return;
AeroPeekWindow* window =
new AeroPeekWindow(application_window_,
this,
- GetTabID(tab->tab_contents()),
+ GetTabID(tab),
foreground,
tab->tab_contents()->GetTitle(),
tab->favicon_tab_helper()->GetFavicon());
@@ -1076,17 +1077,16 @@ void AeroPeekManager::CreateAeroPeekWindowIfNecessary(TabContentsWrapper* tab,
TabContents* AeroPeekManager::GetTabContents(int tab_id) const {
for (TabContentsIterator iterator; !iterator.done(); ++iterator) {
- TabContents* target_contents = (*iterator)->tab_contents();
- if (target_contents->controller().session_id().id() == tab_id)
- return target_contents;
+ if (GetTabID(*iterator) == tab_id)
+ return (*iterator)->tab_contents();
}
return NULL;
}
-int AeroPeekManager::GetTabID(TabContents* contents) const {
+int AeroPeekManager::GetTabID(TabContentsWrapper* contents) const {
if (!contents)
return -1;
- return contents->controller().session_id().id();
+ return contents->restore_tab_helper()->session_id().id();
}
///////////////////////////////////////////////////////////////////////////////
@@ -1121,15 +1121,13 @@ void AeroPeekManager::ActiveTabChanged(TabContentsWrapper* old_contents,
// Deactivate the old window in the thumbnail list and activate the new one
// to synchronize the thumbnail list with TabStrip.
if (old_contents) {
- AeroPeekWindow* old_window =
- GetAeroPeekWindow(GetTabID(old_contents->tab_contents()));
+ AeroPeekWindow* old_window = GetAeroPeekWindow(GetTabID(old_contents));
if (old_window)
old_window->Deactivate();
}
if (new_contents) {
- AeroPeekWindow* new_window =
- GetAeroPeekWindow(GetTabID(new_contents->tab_contents()));
+ AeroPeekWindow* new_window = GetAeroPeekWindow(GetTabID(new_contents));
if (new_window)
new_window->Activate();
}
@@ -1164,8 +1162,7 @@ void AeroPeekManager::TabChangedAt(TabContentsWrapper* contents,
// Retrieve the AeroPeekWindow object associated with this tab, update its
// title, and post a task that update its thumbnail image if necessary.
- AeroPeekWindow* window =
- GetAeroPeekWindow(GetTabID(contents->tab_contents()));
+ AeroPeekWindow* window = GetAeroPeekWindow(GetTabID(contents));
if (!window)
return;
diff --git a/chrome/browser/aeropeek_manager.h b/chrome/browser/aeropeek_manager.h
index f19b606..06818b2 100644
--- a/chrome/browser/aeropeek_manager.h
+++ b/chrome/browser/aeropeek_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -19,6 +19,7 @@ class Size;
class AeroPeekWindow;
class SkBitmap;
class TabContents;
+class TabContentsWrapper;
// A class which defines interfaces called from AeroPeekWindow.
// This class is used for dispatching an event received by a thumbnail window
@@ -168,8 +169,8 @@ class AeroPeekManager : public TabStripModelObserver,
// we need to check if the tab is still alive.
TabContents* GetTabContents(int tab_id) const;
- // Returns the tab ID from the specified TabContents.
- int GetTabID(TabContents* contents) const;
+ // Returns the tab ID from the specified TabContentsWrapper.
+ int GetTabID(TabContentsWrapper* contents) const;
private:
// The parent window of the place-holder windows used by AeroPeek.
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 3fad593..a78d153 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -44,6 +44,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/tab_contents/thumbnail_generator.h"
@@ -329,7 +330,10 @@ void TabStripNotificationObserver::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
if (type == notification_) {
- ObserveTab(Source<NavigationController>(source).ptr());
+ if (type == NotificationType::TAB_PARENTED)
+ ObserveTab(&(Source<TabContentsWrapper>(source).ptr()->controller()));
+ else
+ ObserveTab(Source<NavigationController>(source).ptr());
delete this;
} else {
NOTREACHED();
@@ -833,7 +837,11 @@ void BrowserOpenedNotificationObserver::Observe(
Source<Browser>(source).ptr());
} else if (type.value == NotificationType::LOAD_STOP) {
// Only send the result if the loaded tab is in the new window.
- int window_id = Source<NavigationController>(source)->window_id().id();
+ NavigationController* controller =
+ Source<NavigationController>(source).ptr();
+ TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents(
+ controller->tab_contents());
+ int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1;
if (window_id == new_window_id_) {
if (for_browser_command_) {
AutomationMsg_WindowExecuteCommand::WriteReplyParams(
@@ -2134,7 +2142,12 @@ void AppLaunchObserver::Observe(NotificationType type,
return;
} else {
// The app has launched only if the loaded tab is in the new window.
- int window_id = Source<NavigationController>(source)->window_id().id();
+ NavigationController* controller =
+ Source<NavigationController>(source).ptr();
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ controller->tab_contents());
+ int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1;
if (window_id == new_window_id_) {
if (automation_) {
AutomationJSONReply(automation_,
@@ -2491,7 +2504,8 @@ void NewTabObserver::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK_EQ(NotificationType::TAB_PARENTED, type.value);
- NavigationController* controller = Source<NavigationController>(source).ptr();
+ NavigationController* controller =
+ &(Source<TabContentsWrapper>(source).ptr()->controller());
if (automation_) {
// TODO(phajdan.jr): Clean up this hack. We write the correct return type
// here, but don't send the message. NavigationNotificationObserver
diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc
index 16538e2..997cfe0 100644
--- a/chrome/browser/automation/automation_provider_win.cc
+++ b/chrome/browser/automation/automation_provider_win.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/automation/ui_controls.h"
#include "chrome/browser/external_tab_container_win.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -257,7 +258,8 @@ void AutomationProvider::CreateExternalTab(
*tab_handle = external_tab_container->tab_handle();
*tab_container_window = external_tab_container->GetNativeView();
*tab_window = tab_contents->GetNativeView();
- *session_id = tab_contents->controller().session_id().id();
+ *session_id = external_tab_container->tab_contents_wrapper()->
+ restore_tab_helper()->session_id().id();
} else {
external_tab_container->Uninitialize();
}
@@ -395,7 +397,8 @@ void AutomationProvider::ConnectExternalTab(
*tab_handle = external_tab_container->tab_handle();
*tab_container_window = external_tab_container->GetNativeView();
*tab_window = tab_contents->GetNativeView();
- *session_id = tab_contents->controller().session_id().id();
+ *session_id = external_tab_container->tab_contents_wrapper()->
+ restore_tab_helper()->session_id().id();
} else {
external_tab_container->Uninitialize();
}
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 9c2db89..06e3ab0 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -64,6 +64,7 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/tab_contents/link_infobar_delegate.h"
@@ -5415,15 +5416,18 @@ void TestingAutomationProvider::GetIndicesFromTab(
return;
}
int id = id_or_handle;
- if (has_handle)
- id = tab_tracker_->GetResource(id_or_handle)->session_id().id();
+ if (has_handle) {
+ TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents(
+ tab_tracker_->GetResource(id_or_handle)->tab_contents());
+ id = tab->restore_tab_helper()->session_id().id();
+ }
BrowserList::const_iterator iter = BrowserList::begin();
int browser_index = 0;
for (; iter != BrowserList::end(); ++iter, ++browser_index) {
Browser* browser = *iter;
for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) {
- TabContents* tab = browser->GetTabContentsAt(tab_index);
- if (tab->controller().session_id().id() == id) {
+ TabContentsWrapper* tab = browser->GetTabContentsWrapperAt(tab_index);
+ if (tab->restore_tab_helper()->session_id().id() == id) {
DictionaryValue dict;
dict.SetInteger("windex", browser_index);
dict.SetInteger("tab_index", tab_index);
@@ -5640,7 +5644,8 @@ void TestingAutomationProvider::GetTabIds(
for (; iter != BrowserList::end(); ++iter) {
Browser* browser = *iter;
for (int i = 0; i < browser->tab_count(); ++i) {
- int id = browser->GetTabContentsAt(i)->controller().session_id().id();
+ int id = browser->GetTabContentsWrapperAt(i)->restore_tab_helper()->
+ session_id().id();
id_list->Append(Value::CreateIntegerValue(id));
}
}
@@ -5662,8 +5667,8 @@ void TestingAutomationProvider::IsTabIdValid(
for (; iter != BrowserList::end(); ++iter) {
Browser* browser = *iter;
for (int i = 0; i < browser->tab_count(); ++i) {
- TabContents* tab = browser->GetTabContentsAt(i);
- if (tab->controller().session_id().id() == id) {
+ TabContentsWrapper* tab = browser->GetTabContentsWrapperAt(i);
+ if (tab->restore_tab_helper()->session_id().id() == id) {
is_valid = true;
break;
}
diff --git a/chrome/browser/browser_keyevents_browsertest.cc b/chrome/browser/browser_keyevents_browsertest.cc
index bb0231d..9d03c40 100644
--- a/chrome/browser/browser_keyevents_browsertest.cc
+++ b/chrome/browser/browser_keyevents_browsertest.cc
@@ -681,8 +681,8 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, DISABLED_ReservedAccelerators) {
EXPECT_NO_FATAL_FAILURE(TestKeyEvent(0, kTestCtrlOrCmdT));
ASSERT_NO_FATAL_FAILURE(
- wait_for_new_tab.WaitFor(Source<NavigationController>(
- &browser()->GetTabContentsAt(1)->controller())));
+ wait_for_new_tab.WaitFor(Source<TabContentsWrapper>(
+ browser()->GetTabContentsWrapperAt(1))));
int result_length;
ASSERT_NO_FATAL_FAILURE(GetResultLength(0, &result_length));
diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc
index 8f814a8..47ccdae 100644
--- a/chrome/browser/debugger/debugger_remote_service.cc
+++ b/chrome/browser/debugger/debugger_remote_service.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -17,6 +17,7 @@
#include "chrome/browser/debugger/devtools_protocol_handler.h"
#include "chrome/browser/debugger/devtools_remote_message.h"
#include "chrome/browser/debugger/inspectable_tab_proxy.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/render_messages.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -132,11 +133,10 @@ void DebuggerRemoteService::SendResponse(const Value& response,
// Gets a TabContents instance corresponding to the |tab_uid| using the
// InspectableTabProxy controllers map, or NULL if none found.
TabContents* DebuggerRemoteService::ToTabContents(int32 tab_uid) {
- const InspectableTabProxy::ControllersMap& navcon_map =
- delegate_->inspectable_tab_proxy()->controllers_map();
- InspectableTabProxy::ControllersMap::const_iterator it =
- navcon_map.find(tab_uid);
- if (it != navcon_map.end()) {
+ const InspectableTabProxy::TabMap& tab_map =
+ delegate_->inspectable_tab_proxy()->tab_map();
+ InspectableTabProxy::TabMap::const_iterator it = tab_map.find(tab_uid);
+ if (it != tab_map.end()) {
TabContents* tab_contents = it->second->tab_contents();
if (tab_contents == NULL) {
return NULL;
diff --git a/chrome/browser/debugger/devtools_http_protocol_handler.cc b/chrome/browser/debugger/devtools_http_protocol_handler.cc
index b0763b0..1c67f8d 100644
--- a/chrome/browser/debugger/devtools_http_protocol_handler.cc
+++ b/chrome/browser/debugger/devtools_http_protocol_handler.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/debugger/devtools_client_host.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/devtools_ui.h"
#include "content/browser/browser_thread.h"
@@ -254,7 +255,7 @@ static PageList GeneratePageList(
GetDevToolsClientHostFor(tab_contents->tab_contents()->
render_view_host());
PageInfo page_info;
- page_info.id = controller.session_id().id();
+ page_info.id = tab_contents->restore_tab_helper()->session_id().id();
page_info.attached = client_host != NULL;
page_info.url = entry->url().spec();
page_info.title = UTF16ToUTF8(EscapeForHTML(entry->title()));
@@ -522,11 +523,9 @@ TabContents* DevToolsHttpProtocolHandler::GetTabContents(int session_id) {
for (InspectableTabs::iterator it = inspectable_tabs.begin();
it != inspectable_tabs.end(); ++it) {
- TabContentsWrapper* tab_contents = *it;
- NavigationController& controller =
- tab_contents->controller();
- if (controller.session_id().id() == session_id)
- return controller.tab_contents();
+ TabContentsWrapper* tab = *it;
+ if (tab->restore_tab_helper()->session_id().id() == session_id)
+ return tab->tab_contents();
}
return NULL;
}
diff --git a/chrome/browser/debugger/devtools_remote_service.cc b/chrome/browser/debugger/devtools_remote_service.cc
index 048a6bf..a8f57a3 100644
--- a/chrome/browser/debugger/devtools_remote_service.cc
+++ b/chrome/browser/debugger/devtools_remote_service.cc
@@ -14,6 +14,8 @@
#include "chrome/browser/debugger/devtools_protocol_handler.h"
#include "chrome/browser/debugger/devtools_remote_message.h"
#include "chrome/browser/debugger/inspectable_tab_proxy.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/browser/tab_contents/navigation_controller.h"
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/common/devtools_messages.h"
@@ -75,18 +77,18 @@ void DevToolsRemoteService::ProcessJson(DictionaryValue* json,
response.SetString(kDataKey, kVersion);
} else if (command == DevToolsRemoteServiceCommand::kListTabs) {
ListValue* data = new ListValue();
- const InspectableTabProxy::ControllersMap& navcon_map =
- delegate_->inspectable_tab_proxy()->controllers_map();
- for (InspectableTabProxy::ControllersMap::const_iterator it =
- navcon_map.begin(), end = navcon_map.end(); it != end; ++it) {
- NavigationEntry* entry = it->second->GetActiveEntry();
+ const InspectableTabProxy::TabMap& tab_map =
+ delegate_->inspectable_tab_proxy()->tab_map();
+ for (InspectableTabProxy::TabMap::const_iterator it =
+ tab_map.begin(), end = tab_map.end(); it != end; ++it) {
+ NavigationEntry* entry = it->second->controller().GetActiveEntry();
if (entry == NULL) {
continue;
}
if (entry->url().is_valid()) {
ListValue* tab = new ListValue();
tab->Append(Value::CreateIntegerValue(
- static_cast<int32>(it->second->session_id().id())));
+ it->second->restore_tab_helper()->session_id().id()));
tab->Append(Value::CreateStringValue(entry->url().spec()));
data->Append(tab);
}
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc
index 89b32a6..4dbf6fd 100644
--- a/chrome/browser/debugger/devtools_window.cc
+++ b/chrome/browser/debugger/devtools_window.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
@@ -91,7 +92,8 @@ DevToolsWindow::DevToolsWindow(Profile* profile,
Source<NavigationController>(&tab_contents_->controller()));
registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
NotificationService::AllSources());
- inspected_tab_ = inspected_rvh->delegate()->GetAsTabContents();
+ inspected_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(
+ inspected_rvh->delegate()->GetAsTabContents());
}
DevToolsWindow::~DevToolsWindow() {
@@ -132,7 +134,7 @@ void DevToolsWindow::InspectedTabClosing() {
void DevToolsWindow::TabReplaced(TabContentsWrapper* new_tab) {
DCHECK_EQ(profile_, new_tab->profile());
- inspected_tab_ = new_tab->tab_contents();
+ inspected_tab_ = new_tab;
}
void DevToolsWindow::Show(DevToolsToggleAction action) {
@@ -288,7 +290,8 @@ void DevToolsWindow::UpdateFrontendAttachedState() {
void DevToolsWindow::AddDevToolsExtensionsToClient() {
if (inspected_tab_) {
- FundamentalValue tabId(inspected_tab_->controller().session_id().id());
+ FundamentalValue tabId(
+ inspected_tab_->restore_tab_helper()->session_id().id());
CallClientFunction(ASCIIToUTF16("WebInspector.setInspectedTabId"), tabId);
}
ListValue results;
@@ -317,11 +320,10 @@ void DevToolsWindow::OpenURLFromTab(TabContents* source,
const GURL& referrer,
WindowOpenDisposition disposition,
PageTransition::Type transition) {
- if (inspected_tab_)
- inspected_tab_->OpenURL(url,
- GURL(),
- NEW_FOREGROUND_TAB,
- PageTransition::LINK);
+ if (inspected_tab_) {
+ inspected_tab_->tab_contents()->OpenURL(
+ url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
+ }
}
void DevToolsWindow::CallClientFunction(const string16& function_name,
@@ -430,11 +432,8 @@ void DevToolsWindow::AddNewContents(TabContents* source,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture) {
- inspected_tab_->delegate()->AddNewContents(source,
- new_contents,
- disposition,
- initial_pos,
- user_gesture);
+ inspected_tab_->tab_contents()->delegate()->AddNewContents(
+ source, new_contents, disposition, initial_pos, user_gesture);
}
bool DevToolsWindow::CanReloadContents(TabContents* source) const {
diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h
index 42a3fa9..23c724b 100644
--- a/chrome/browser/debugger/devtools_window.h
+++ b/chrome/browser/debugger/devtools_window.h
@@ -97,7 +97,7 @@ class DevToolsWindow
virtual void FrameNavigating(const std::string& url) {}
Profile* profile_;
- TabContents* inspected_tab_;
+ TabContentsWrapper* inspected_tab_;
TabContentsWrapper* tab_contents_;
Browser* browser_;
bool docked_;
diff --git a/chrome/browser/debugger/extension_ports_remote_service.cc b/chrome/browser/debugger/extension_ports_remote_service.cc
index 1cf8155..bf960e3 100644
--- a/chrome/browser/debugger/extension_ports_remote_service.cc
+++ b/chrome/browser/debugger/extension_ports_remote_service.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/debugger/devtools_remote_message.h"
#include "chrome/browser/debugger/inspectable_tab_proxy.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/extensions/extension_messages.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/devtools_messages.h"
@@ -302,12 +303,11 @@ void ExtensionPortsRemoteService::ConnectCommand(
data->GetInteger(kTabIdKey, &tab_id); // optional.
int port_id;
if (tab_id != -1) { // Resolve the tab ID.
- const InspectableTabProxy::ControllersMap& navcon_map =
- delegate_->inspectable_tab_proxy()->controllers_map();
- InspectableTabProxy::ControllersMap::const_iterator it =
- navcon_map.find(tab_id);
+ const InspectableTabProxy::TabMap& tab_map =
+ delegate_->inspectable_tab_proxy()->tab_map();
+ InspectableTabProxy::TabMap::const_iterator it = tab_map.find(tab_id);
TabContents* tab_contents = NULL;
- if (it != navcon_map.end())
+ if (it != tab_map.end())
tab_contents = it->second->tab_contents();
if (!tab_contents) {
VLOG(1) << "tab not found: " << tab_id;
diff --git a/chrome/browser/debugger/inspectable_tab_proxy.cc b/chrome/browser/debugger/inspectable_tab_proxy.cc
index 6f73bd8..ccbb0ec 100644
--- a/chrome/browser/debugger/inspectable_tab_proxy.cc
+++ b/chrome/browser/debugger/inspectable_tab_proxy.cc
@@ -8,6 +8,7 @@
#include "base/string_util.h"
#include "chrome/browser/debugger/debugger_remote_service.h"
#include "chrome/browser/debugger/devtools_client_host.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/sessions/session_id.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser_list.h"
@@ -50,7 +51,7 @@ void DevToolsClientHostImpl::SendMessageToClient(
void DevToolsClientHostImpl::TabReplaced(TabContentsWrapper* new_tab) {
map_->erase(id_);
- id_ = new_tab->controller().session_id().id();
+ id_ = new_tab->restore_tab_helper()->session_id().id();
(*map_)[id_] = this;
}
@@ -70,19 +71,17 @@ InspectableTabProxy::InspectableTabProxy() {}
InspectableTabProxy::~InspectableTabProxy() {}
-const InspectableTabProxy::ControllersMap&
- InspectableTabProxy::controllers_map() {
- controllers_map_.clear();
+const InspectableTabProxy::TabMap& InspectableTabProxy::tab_map() {
+ tab_map_.clear();
for (BrowserList::const_iterator it = BrowserList::begin(),
end = BrowserList::end(); it != end; ++it) {
TabStripModel* model = (*it)->tabstrip_model();
for (int i = 0, size = model->count(); i < size; ++i) {
- NavigationController& controller =
- model->GetTabContentsAt(i)->controller();
- controllers_map_[controller.session_id().id()] = &controller;
+ TabContentsWrapper* tab = model->GetTabContentsAt(i);
+ tab_map_[tab->restore_tab_helper()->session_id().id()] = tab;
}
}
- return controllers_map_;
+ return tab_map_;
}
DevToolsClientHostImpl* InspectableTabProxy::ClientHostForTabId(
diff --git a/chrome/browser/debugger/inspectable_tab_proxy.h b/chrome/browser/debugger/inspectable_tab_proxy.h
index 55fd8c6..1b6e336 100644
--- a/chrome/browser/debugger/inspectable_tab_proxy.h
+++ b/chrome/browser/debugger/inspectable_tab_proxy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,25 +15,24 @@
class DebuggerRemoteService;
class DevToolsClientHost;
class DevToolsClientHostImpl;
-class NavigationController;
struct DevToolsMessageData;
+class TabContentsWrapper;
-// Proxies debugged tabs' NavigationControllers using their UIDs.
+// Proxies debugged tabs' TabContentsWrapper using their UIDs.
// Keeps track of tabs being debugged so that we can detach from
// them on remote debugger connection loss.
class InspectableTabProxy {
public:
- typedef base::hash_map<int32, NavigationController*> ControllersMap;
+ typedef base::hash_map<int32, TabContentsWrapper*> TabMap;
typedef base::hash_map<int32, DevToolsClientHostImpl*> IdToClientHostMap;
InspectableTabProxy();
virtual ~InspectableTabProxy();
- // Returns a map of NavigationControllerKeys to NavigationControllers
- // for all Browser instances. Clients should not keep the result around
- // for extended periods of time as tabs might get closed thus invalidating
- // the map.
- const ControllersMap& controllers_map();
+ // Returns a map of SessionID to TabContentsWrapper for all Browser
+ // instances. Clients should not keep the result around for extended periods
+ // of time as tabs might get closed thus invalidating the map.
+ const TabMap& tab_map();
// Returns a DevToolsClientHostImpl for the given tab |id|.
DevToolsClientHostImpl* ClientHostForTabId(int32 id);
@@ -51,7 +50,7 @@ class InspectableTabProxy {
void OnRemoteDebuggerDetached();
private:
- ControllersMap controllers_map_;
+ TabMap tab_map_;
IdToClientHostMap id_to_client_host_map_;
DISALLOW_COPY_AND_ASSIGN(InspectableTabProxy);
};
diff --git a/chrome/browser/extensions/extension_tab_helper.cc b/chrome/browser/extensions/extension_tab_helper.cc
index e927d19..0b9ead9 100644
--- a/chrome/browser/extensions/extension_tab_helper.cc
+++ b/chrome/browser/extensions/extension_tab_helper.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -94,7 +95,7 @@ void ExtensionTabHelper::DidNavigateMainFramePostCommit(
service->extensions()->at(i)->browser_action();
if (browser_action) {
browser_action->ClearAllValuesForTab(
- tab_contents()->controller().session_id().id());
+ wrapper_->restore_tab_helper()->session_id().id());
NotificationService::current()->Notify(
NotificationType::EXTENSION_BROWSER_ACTION_UPDATED,
Source<ExtensionAction>(browser_action),
@@ -105,7 +106,7 @@ void ExtensionTabHelper::DidNavigateMainFramePostCommit(
service->extensions()->at(i)->page_action();
if (page_action) {
page_action->ClearAllValuesForTab(
- tab_contents()->controller().session_id().id());
+ wrapper_->restore_tab_helper()->session_id().id());
PageActionStateChanged();
}
}
diff --git a/chrome/browser/extensions/extension_tab_helper.h b/chrome/browser/extensions/extension_tab_helper.h
index 9590e68..b528fd7 100644
--- a/chrome/browser/extensions/extension_tab_helper.h
+++ b/chrome/browser/extensions/extension_tab_helper.h
@@ -68,6 +68,10 @@ class ExtensionTabHelper : public TabContentsObserver,
// Extension::EXTENSION_ICON_SMALLISH).
SkBitmap* GetExtensionAppIcon();
+ TabContentsWrapper* tab_contents_wrapper() {
+ return wrapper_;
+ }
+
TabContents* tab_contents() const {
return TabContentsObserver::tab_contents();
}
diff --git a/chrome/browser/extensions/extension_tab_id_map.cc b/chrome/browser/extensions/extension_tab_id_map.cc
index 0d12ce5..ec319c0 100644
--- a/chrome/browser/extensions/extension_tab_id_map.cc
+++ b/chrome/browser/extensions/extension_tab_id_map.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/extensions/extension_tab_id_map.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/browser/browser_thread.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -56,6 +58,10 @@ void ExtensionTabIdMap::TabObserver::Observe(
switch (type.value) {
case NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB: {
TabContents* contents = Source<TabContents>(source).ptr();
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(contents);
+ if (!tab)
+ break;
RenderViewHost* host = Details<RenderViewHost>(details).ptr();
// TODO(mpcmoplete): How can we tell if window_id is bogus? It may not
// have been set yet.
@@ -65,22 +71,21 @@ void ExtensionTabIdMap::TabObserver::Observe(
ExtensionTabIdMap::GetInstance(),
&ExtensionTabIdMap::SetTabAndWindowId,
host->process()->id(), host->routing_id(),
- contents->controller().session_id().id(),
- contents->controller().window_id().id()));
+ tab->restore_tab_helper()->session_id().id(),
+ tab->restore_tab_helper()->window_id().id()));
break;
}
case NotificationType::TAB_PARENTED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- RenderViewHost* host = controller->tab_contents()->render_view_host();
+ TabContentsWrapper* tab = Source<TabContentsWrapper>(source).ptr();
+ RenderViewHost* host = tab->render_view_host();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
ExtensionTabIdMap::GetInstance(),
&ExtensionTabIdMap::SetTabAndWindowId,
host->process()->id(), host->routing_id(),
- controller->session_id().id(),
- controller->window_id().id()));
+ tab->restore_tab_helper()->session_id().id(),
+ tab->restore_tab_helper()->window_id().id()));
break;
}
case NotificationType::RENDER_VIEW_HOST_DELETED: {
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 07ff984..bfe2e70 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tabs_module_constants.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/translate/translate_tab_helper.h"
#include "chrome/browser/ui/browser.h"
@@ -143,16 +144,22 @@ int ExtensionTabUtil::GetWindowId(const Browser* browser) {
return browser->session_id().id();
}
+// TODO: this function should really take a TabContentsWrapper.
int ExtensionTabUtil::GetTabId(const TabContents* tab_contents) {
- return tab_contents->controller().session_id().id();
+ const TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(tab_contents);
+ return tab ? tab->restore_tab_helper()->session_id().id() : -1;
}
std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) {
return is_loading ? keys::kStatusValueLoading : keys::kStatusValueComplete;
}
+// TODO: this function should really take a TabContentsWrapper.
int ExtensionTabUtil::GetWindowIdOfTab(const TabContents* tab_contents) {
- return tab_contents->controller().window_id().id();
+ const TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(tab_contents);
+ return tab ? tab->restore_tab_helper()->window_id().id() : -1;
}
DictionaryValue* ExtensionTabUtil::CreateTabValue(
@@ -302,7 +309,8 @@ bool ExtensionTabUtil::GetTabById(int tab_id,
for (int i = 0; i < target_tab_strip->count(); ++i) {
TabContentsWrapper* target_contents =
target_tab_strip->GetTabContentsAt(i);
- if (target_contents->controller().session_id().id() == tab_id) {
+ if (target_contents->restore_tab_helper()->session_id().id() ==
+ tab_id) {
if (browser)
*browser = target_browser;
if (tab_strip)
diff --git a/chrome/browser/extensions/page_action_apitest.cc b/chrome/browser/extensions/page_action_apitest.cc
index f0d3269..d3a6376 100644
--- a/chrome/browser/extensions/page_action_apitest.cc
+++ b/chrome/browser/extensions/page_action_apitest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,9 +7,11 @@
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/test/ui_test_utils.h"
@@ -29,8 +31,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) {
}
// Test that we received the changes.
- int tab_id =
- browser()->GetSelectedTabContents()->controller().session_id().id();
+ int tab_id = browser()->GetSelectedTabContentsWrapper()->
+ restore_tab_helper()->session_id().id();
ExtensionAction* action = extension->page_action();
ASSERT_TRUE(action);
EXPECT_EQ("Modified", action->GetTitle(tab_id));
@@ -55,7 +57,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) {
}
// Test that we received the changes.
- tab_id = browser()->GetSelectedTabContents()->controller().session_id().id();
+ tab_id = browser()->GetSelectedTabContentsWrapper()->restore_tab_helper()->
+ session_id().id();
EXPECT_FALSE(action->GetIcon(tab_id).isNull());
}
diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h
index 6b33a1b..46dd0dd 100644
--- a/chrome/browser/external_tab_container_win.h
+++ b/chrome/browser/external_tab_container_win.h
@@ -57,9 +57,10 @@ class ExternalTabContainer : public TabContentsDelegate,
typedef std::map<uintptr_t, scoped_refptr<ExternalTabContainer> > PendingTabs;
ExternalTabContainer(AutomationProvider* automation,
- AutomationResourceMessageFilter* filter);
+ AutomationResourceMessageFilter* filter);
TabContents* tab_contents() const;
+ TabContentsWrapper* tab_contents_wrapper() { return tab_contents_.get(); }
// Temporary hack so we can send notifications back
void SetTabHandle(int handle);
diff --git a/chrome/browser/printing/background_printing_manager.cc b/chrome/browser/printing/background_printing_manager.cc
index cc35751..2b19e5a 100644
--- a/chrome/browser/printing/background_printing_manager.cc
+++ b/chrome/browser/printing/background_printing_manager.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -42,7 +43,7 @@ void BackgroundPrintingManager::OwnTabContents(TabContentsWrapper* contents) {
// Detach |contents| from its tab strip.
Browser* browser = BrowserList::FindBrowserWithID(
- contents->controller().window_id().id());
+ contents->restore_tab_helper()->window_id().id());
TabStripModel* tabstrip = browser->tabstrip_model();
tabstrip->DetachTabContentsAt(tabstrip->GetIndexOfTabContents(contents));
diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc
index f0d2edb..0d94be1 100644
--- a/chrome/browser/printing/print_preview_tab_controller.cc
+++ b/chrome/browser/printing/print_preview_tab_controller.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
@@ -178,8 +179,12 @@ TabContents* PrintPreviewTabController::GetInitiatorTab(
TabContents* PrintPreviewTabController::CreatePrintPreviewTab(
TabContents* initiator_tab) {
+ // TODO: this should be converted to TabContentsWrapper.
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
+ DCHECK(tab);
Browser* current_browser = BrowserList::FindBrowserWithID(
- initiator_tab->controller().window_id().id());
+ tab->restore_tab_helper()->window_id().id());
if (!current_browser) {
if (initiator_tab->delegate()->IsExternalTabContainer()) {
current_browser = Browser::CreateForType(Browser::TYPE_POPUP,
diff --git a/chrome/browser/sessions/restore_tab_helper.cc b/chrome/browser/sessions/restore_tab_helper.cc
new file mode 100644
index 0000000..16a2c3c
--- /dev/null
+++ b/chrome/browser/sessions/restore_tab_helper.cc
@@ -0,0 +1,38 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sessions/restore_tab_helper.h"
+
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/common/extensions/extension_messages.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/common/notification_service.h"
+#include "content/common/notification_type.h"
+
+RestoreTabHelper::RestoreTabHelper(TabContentsWrapper* tab)
+ : TabContentsObserver(tab->tab_contents()),
+ tab_(tab) {
+}
+
+RestoreTabHelper::~RestoreTabHelper() {
+}
+
+void RestoreTabHelper::SetWindowID(const SessionID& id) {
+ window_id_ = id;
+ NotificationService::current()->Notify(
+ NotificationType::TAB_PARENTED,
+ Source<TabContentsWrapper>(tab_),
+ NotificationService::NoDetails());
+
+ // Extension code in the renderer holds the ID of the window that hosts it.
+ // Notify it that the window ID changed.
+ tab_->render_view_host()->Send(new ExtensionMsg_UpdateBrowserWindowId(
+ tab_->render_view_host()->routing_id(), id.id()));
+}
+
+void RestoreTabHelper::RenderViewCreated(RenderViewHost* render_view_host) {
+ render_view_host->Send(
+ new ExtensionMsg_UpdateBrowserWindowId(render_view_host->routing_id(),
+ window_id_.id()));
+}
diff --git a/chrome/browser/sessions/restore_tab_helper.h b/chrome/browser/sessions/restore_tab_helper.h
new file mode 100644
index 0000000..63aee3b
--- /dev/null
+++ b/chrome/browser/sessions/restore_tab_helper.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SESSIONS_RESTORE_TAB_HELPER_H_
+#define CHROME_BROWSER_SESSIONS_RESTORE_TAB_HELPER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "chrome/browser/sessions/session_id.h"
+#include "content/browser/tab_contents/tab_contents_observer.h"
+
+class TabContentsWrapper;
+
+class RestoreTabHelper : public TabContentsObserver {
+ public:
+ explicit RestoreTabHelper(TabContentsWrapper* tab);
+ ~RestoreTabHelper();
+
+ // Returns the identifier used by session restore for this tab.
+ const SessionID& session_id() const { return session_id_; }
+
+ // Identifier of the window the tab is in.
+ void SetWindowID(const SessionID& id);
+ const SessionID& window_id() const { return window_id_; }
+
+ // TabContentsObserver:
+ virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
+
+ private:
+ TabContentsWrapper* tab_;
+
+ // Unique identifier of the tab for session restore. This id is only unique
+ // within the current session, and is not guaranteed to be unique across
+ // sessions.
+ const SessionID session_id_;
+
+ // Unique identifier of the window the tab is in.
+ SessionID window_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(RestoreTabHelper);
+};
+
+#endif // CHROME_BROWSER_SESSIONS_RESTORE_TAB_HELPER_H_
diff --git a/chrome/browser/sessions/session_id.h b/chrome/browser/sessions/session_id.h
index 248d602..383aaf2 100644
--- a/chrome/browser/sessions/session_id.h
+++ b/chrome/browser/sessions/session_id.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,12 +8,6 @@
#include "base/basictypes.h"
-class NavigationController;
-class SessionService;
-namespace browser_sync {
- class SessionModelAssociator;
-}
-
// Uniquely identifies a tab or window for the duration of a session.
class SessionID {
public:
@@ -23,18 +17,10 @@ class SessionID {
~SessionID() {}
// Returns the underlying id.
+ void set_id(id_type id) { id_ = id; }
id_type id() const { return id_; }
private:
- friend class NavigationController;
- friend class SessionService;
- friend class browser_sync::SessionModelAssociator;
-
- explicit SessionID(id_type id) : id_(id) {}
-
- // Resets the id. This is used when restoring a session
- void set_id(id_type id) { id_ = id; }
-
id_type id_;
};
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index 8838139..d52ccd9 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -733,7 +733,7 @@ class SessionRestoreImpl : public NotificationObserver {
SessionService* session_service =
SessionServiceFactory::GetForProfile(profile_);
for (int i = initial_count; i < browser->tab_count(); ++i)
- session_service->TabRestored(&browser->GetTabContentsAt(i)->controller(),
+ session_service->TabRestored(browser->GetTabContentsWrapperAt(i),
browser->tabstrip_model()->IsTabPinned(i));
}
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index 506f86b..c4c30a8 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/extensions/extension_tab_helper.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/sessions/session_backend.h"
#include "chrome/browser/sessions/session_command.h"
#include "chrome/browser/sessions/session_restore.h"
@@ -367,12 +368,11 @@ void SessionService::UpdateTabNavigation(const SessionID& window_id,
tab_id.id(), index, entry));
}
-void SessionService::TabRestored(NavigationController* controller,
- bool pinned) {
- if (!ShouldTrackChangesToWindow(controller->window_id()))
+void SessionService::TabRestored(TabContentsWrapper* tab, bool pinned) {
+ if (!ShouldTrackChangesToWindow(tab->restore_tab_helper()->window_id()))
return;
- BuildCommandsForTab(controller->window_id(), controller, -1,
+ BuildCommandsForTab(tab->restore_tab_helper()->window_id(), tab, -1,
pinned, &pending_commands(), NULL);
StartSaveTimer();
}
@@ -519,43 +519,49 @@ void SessionService::Observe(NotificationType type,
}
case NotificationType::TAB_PARENTED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- SetTabWindow(controller->window_id(), controller->session_id());
- TabContentsWrapper* wrapper =
- TabContentsWrapper::GetCurrentWrapperForContents(
- controller->tab_contents());
- if (wrapper->extension_tab_helper()->extension_app()) {
+ TabContentsWrapper* tab = Source<TabContentsWrapper>(source).ptr();
+ SetTabWindow(tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id());
+ if (tab->extension_tab_helper()->extension_app()) {
SetTabExtensionAppID(
- controller->window_id(),
- controller->session_id(),
- wrapper->extension_tab_helper()->extension_app()->id());
+ tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id(),
+ tab->extension_tab_helper()->extension_app()->id());
}
break;
}
case NotificationType::TAB_CLOSED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- TabClosed(controller->window_id(), controller->session_id(),
- controller->tab_contents()->closed_by_user_gesture());
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<NavigationController>(source).ptr()->tab_contents());
+ if (!tab)
+ break;
+ TabClosed(tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id(),
+ tab->tab_contents()->closed_by_user_gesture());
RecordSessionUpdateHistogramData(NotificationType::TAB_CLOSED,
&last_updated_tab_closed_time_);
break;
}
case NotificationType::NAV_LIST_PRUNED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<NavigationController>(source).ptr()->tab_contents());
+ if (!tab)
+ break;
Details<content::PrunedDetails> pruned_details(details);
if (pruned_details->from_front) {
- TabNavigationPathPrunedFromFront(controller->window_id(),
- controller->session_id(),
- pruned_details->count);
+ TabNavigationPathPrunedFromFront(
+ tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id(),
+ pruned_details->count);
} else {
- TabNavigationPathPrunedFromBack(controller->window_id(),
- controller->session_id(),
- controller->entry_count());
+ TabNavigationPathPrunedFromBack(
+ tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id(),
+ tab->controller().entry_count());
}
RecordSessionUpdateHistogramData(NotificationType::NAV_LIST_PRUNED,
&last_updated_nav_list_pruned_time_);
@@ -563,24 +569,34 @@ void SessionService::Observe(NotificationType type,
}
case NotificationType::NAV_ENTRY_CHANGED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<NavigationController>(source).ptr()->tab_contents());
+ if (!tab)
+ break;
Details<content::EntryChangedDetails> changed(details);
- UpdateTabNavigation(controller->window_id(), controller->session_id(),
- changed->index, *changed->changed_entry);
+ UpdateTabNavigation(
+ tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id(),
+ changed->index, *changed->changed_entry);
break;
}
case NotificationType::NAV_ENTRY_COMMITTED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- int current_entry_index = controller->GetCurrentEntryIndex();
- SetSelectedNavigationIndex(controller->window_id(),
- controller->session_id(),
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<NavigationController>(source).ptr()->tab_contents());
+ if (!tab)
+ break;
+ int current_entry_index = tab->controller().GetCurrentEntryIndex();
+ SetSelectedNavigationIndex(tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id(),
current_entry_index);
- UpdateTabNavigation(controller->window_id(), controller->session_id(),
- current_entry_index,
- *controller->GetEntryAtIndex(current_entry_index));
+ UpdateTabNavigation(
+ tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id(),
+ current_entry_index,
+ *tab->controller().GetEntryAtIndex(current_entry_index));
Details<content::LoadCommittedDetails> changed(details);
if (changed->type == NavigationType::NEW_PAGE ||
changed->type == NavigationType::EXISTING_PAGE) {
@@ -594,10 +610,11 @@ void SessionService::Observe(NotificationType type,
ExtensionTabHelper* extension_tab_helper =
Source<ExtensionTabHelper>(source).ptr();
if (extension_tab_helper->extension_app()) {
- SetTabExtensionAppID(
- extension_tab_helper->tab_contents()->controller().window_id(),
- extension_tab_helper->tab_contents()->controller().session_id(),
- extension_tab_helper->extension_app()->id());
+ RestoreTabHelper* helper =
+ extension_tab_helper->tab_contents_wrapper()->restore_tab_helper();
+ SetTabExtensionAppID(helper->window_id(),
+ helper->session_id(),
+ extension_tab_helper->extension_app()->id());
}
break;
}
@@ -1058,58 +1075,52 @@ bool SessionService::CreateTabsAndWindows(
void SessionService::BuildCommandsForTab(
const SessionID& window_id,
- NavigationController* controller,
+ TabContentsWrapper* tab,
int index_in_window,
bool is_pinned,
std::vector<SessionCommand*>* commands,
IdToRange* tab_to_available_range) {
- DCHECK(controller && commands && window_id.id());
- commands->push_back(
- CreateSetTabWindowCommand(window_id, controller->session_id()));
- const int current_index = controller->GetCurrentEntryIndex();
+ DCHECK(tab && commands && window_id.id());
+ const SessionID& session_id(tab->restore_tab_helper()->session_id());
+ commands->push_back(CreateSetTabWindowCommand(window_id, session_id));
+ const int current_index = tab->controller().GetCurrentEntryIndex();
const int min_index = std::max(0,
current_index - max_persist_navigation_count);
const int max_index = std::min(current_index + max_persist_navigation_count,
- controller->entry_count());
- const int pending_index = controller->pending_entry_index();
+ tab->controller().entry_count());
+ const int pending_index = tab->controller().pending_entry_index();
if (tab_to_available_range) {
- (*tab_to_available_range)[controller->session_id().id()] =
+ (*tab_to_available_range)[session_id.id()] =
std::pair<int, int>(min_index, max_index);
}
if (is_pinned) {
- commands->push_back(
- CreatePinnedStateCommand(controller->session_id(), true));
+ commands->push_back(CreatePinnedStateCommand(session_id, true));
}
TabContentsWrapper* wrapper =
- TabContentsWrapper::GetCurrentWrapperForContents(
- controller->tab_contents());
+ TabContentsWrapper::GetCurrentWrapperForContents(tab->tab_contents());
if (wrapper->extension_tab_helper()->extension_app()) {
commands->push_back(
CreateSetTabExtensionAppIDCommand(
- kCommandSetExtensionAppID,
- controller->session_id().id(),
+ kCommandSetExtensionAppID, session_id.id(),
wrapper->extension_tab_helper()->extension_app()->id()));
}
for (int i = min_index; i < max_index; ++i) {
const NavigationEntry* entry = (i == pending_index) ?
- controller->pending_entry() : controller->GetEntryAtIndex(i);
+ tab->controller().pending_entry() :
+ tab->controller().GetEntryAtIndex(i);
DCHECK(entry);
if (ShouldTrackEntry(entry->virtual_url())) {
commands->push_back(
- CreateUpdateTabNavigationCommand(kCommandUpdateTabNavigation,
- controller->session_id().id(),
- i,
- *entry));
+ CreateUpdateTabNavigationCommand(
+ kCommandUpdateTabNavigation, session_id.id(), i, *entry));
}
}
commands->push_back(
- CreateSetSelectedNavigationIndexCommand(controller->session_id(),
- current_index));
+ CreateSetSelectedNavigationIndexCommand(session_id, current_index));
if (index_in_window != -1) {
commands->push_back(
- CreateSetTabIndexInWindowCommand(controller->session_id(),
- index_in_window));
+ CreateSetTabIndexInWindowCommand(session_id, index_in_window));
}
}
@@ -1131,10 +1142,10 @@ void SessionService::BuildCommandsForBrowser(
bool added_to_windows_to_track = false;
for (int i = 0; i < browser->tab_count(); ++i) {
- TabContents* tab = browser->GetTabContentsAt(i);
+ TabContentsWrapper* tab = browser->GetTabContentsWrapperAt(i);
DCHECK(tab);
if (tab->profile() == profile() || profile() == NULL) {
- BuildCommandsForTab(browser->session_id(), &tab->controller(), i,
+ BuildCommandsForTab(browser->session_id(), tab, i,
browser->tabstrip_model()->IsTabPinned(i),
commands, tab_to_available_range);
if (windows_to_track && !added_to_windows_to_track) {
diff --git a/chrome/browser/sessions/session_service.h b/chrome/browser/sessions/session_service.h
index 1541537..4ddaf24 100644
--- a/chrome/browser/sessions/session_service.h
+++ b/chrome/browser/sessions/session_service.h
@@ -20,12 +20,12 @@
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
-class NavigationController;
class NavigationEntry;
class Profile;
class SessionCommand;
struct SessionTab;
struct SessionWindow;
+class TabContentsWrapper;
// SessionService ------------------------------------------------------------
@@ -133,8 +133,7 @@ class SessionService : public BaseSessionService,
// Notification that a tab has restored its entries or a closed tab is being
// reused.
- void TabRestored(NavigationController* controller,
- bool pinned);
+ void TabRestored(TabContentsWrapper* tab, bool pinned);
// Sets the index of the selected entry in the navigation controller for the
// specified tab.
@@ -303,13 +302,13 @@ class SessionService : public BaseSessionService,
std::map<int, SessionWindow*>* windows);
// Adds commands to commands that will recreate the state of the specified
- // NavigationController. This adds at most kMaxNavigationCountToPersist
- // navigations (in each direction from the current navigation index).
+ // tab. This adds at most kMaxNavigationCountToPersist navigations (in each
+ // direction from the current navigation index).
// A pair is added to tab_to_available_range indicating the range of
// indices that were written.
void BuildCommandsForTab(
const SessionID& window_id,
- NavigationController* controller,
+ TabContentsWrapper* tab,
int index_in_window,
bool is_pinned,
std::vector<SessionCommand*>* commands,
diff --git a/chrome/browser/sessions/tab_restore_service_delegate.h b/chrome/browser/sessions/tab_restore_service_delegate.h
index 1ac7914..23beff0 100644
--- a/chrome/browser/sessions/tab_restore_service_delegate.h
+++ b/chrome/browser/sessions/tab_restore_service_delegate.h
@@ -10,6 +10,7 @@
#include "chrome/browser/sessions/session_id.h"
+class NavigationController;
class Profile;
class SessionStorageNamespace;
class TabContents;
diff --git a/chrome/browser/sync/glue/session_change_processor.cc b/chrome/browser/sync/glue/session_change_processor.cc
index 8c8a452..2b33c7b 100644
--- a/chrome/browser/sync/glue/session_change_processor.cc
+++ b/chrome/browser/sync/glue/session_change_processor.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/sync/engine/syncapi.h"
#include "chrome/browser/sync/glue/session_model_associator.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/browser/tab_contents/navigation_controller.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/notification_details.h"
@@ -60,7 +61,7 @@ void SessionChangeProcessor::Observe(NotificationType type,
DCHECK(profile_);
// Track which windows and/or tabs are modified.
- std::vector<TabContents*> modified_tabs;
+ std::vector<TabContentsWrapper*> modified_tabs;
bool windows_changed = false;
switch (type.value) {
case NotificationType::BROWSER_OPENED: {
@@ -74,54 +75,57 @@ void SessionChangeProcessor::Observe(NotificationType type,
}
case NotificationType::TAB_PARENTED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- if (controller->profile() != profile_) {
+ TabContentsWrapper* tab = Source<TabContentsWrapper>(source).ptr();
+ if (tab->profile() != profile_) {
return;
}
windows_changed = true;
- modified_tabs.push_back(controller->tab_contents());
+ modified_tabs.push_back(tab);
break;
}
case NotificationType::TAB_CLOSED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- if (controller->profile() != profile_) {
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<NavigationController>(source).ptr()->tab_contents());
+ if (!tab || tab->profile() != profile_) {
return;
}
windows_changed = true;
- modified_tabs.push_back(controller->tab_contents());
+ modified_tabs.push_back(tab);
break;
}
case NotificationType::NAV_LIST_PRUNED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- if (controller->profile() != profile_) {
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<NavigationController>(source).ptr()->tab_contents());
+ if (!tab || tab->profile() != profile_) {
return;
}
- modified_tabs.push_back(controller->tab_contents());
+ modified_tabs.push_back(tab);
break;
}
case NotificationType::NAV_ENTRY_CHANGED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- if (controller->profile() != profile_) {
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<NavigationController>(source).ptr()->tab_contents());
+ if (!tab || tab->profile() != profile_) {
return;
}
- modified_tabs.push_back(controller->tab_contents());
+ modified_tabs.push_back(tab);
break;
}
case NotificationType::NAV_ENTRY_COMMITTED: {
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- if (controller->profile() != profile_) {
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<NavigationController>(source).ptr()->tab_contents());
+ if (!tab || tab->profile() != profile_) {
return;
}
- modified_tabs.push_back(controller->tab_contents());
+ modified_tabs.push_back(tab);
break;
}
@@ -132,7 +136,7 @@ void SessionChangeProcessor::Observe(NotificationType type,
return;
}
if (extension_tab_helper->extension_app()) {
- modified_tabs.push_back(extension_tab_helper->tab_contents());
+ modified_tabs.push_back(extension_tab_helper->tab_contents_wrapper());
}
break;
}
diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc
index 257db3d..67992c8 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "chrome/browser/extensions/extension_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/syncable/syncable.h"
@@ -95,7 +96,7 @@ int64 SessionModelAssociator::GetSyncIdFromSessionTag(const std::string& tag) {
return node.GetId();
}
-const TabContents*
+const TabContentsWrapper*
SessionModelAssociator::GetChromeNodeFromSyncId(int64 sync_id) {
NOTREACHED();
return NULL;
@@ -141,11 +142,11 @@ void SessionModelAssociator::ReassociateWindows(bool reload_tabs) {
// Store the order of tabs.
bool found_tabs = false;
for (int j = 0; j < (*i)->tab_count(); ++j) {
- TabContents* tab = (*i)->GetTabContentsAt(j);
+ TabContentsWrapper* tab = (*i)->GetTabContentsWrapperAt(j);
DCHECK(tab);
- if (IsValidTab(*tab)) {
+ if (IsValidTab(*(tab->tab_contents()))) {
found_tabs = true;
- window_s.add_tab(tab->controller().session_id().id());
+ window_s.add_tab(tab->restore_tab_helper()->session_id().id());
if (reload_tabs) {
ReassociateTab(*tab);
}
@@ -176,23 +177,23 @@ bool SessionModelAssociator::ShouldSyncWindow(const Browser* browser) {
}
void SessionModelAssociator::ReassociateTabs(
- const std::vector<TabContents*>& tabs) {
+ const std::vector<TabContentsWrapper*>& tabs) {
DCHECK(CalledOnValidThread());
- for (std::vector<TabContents*>::const_iterator i = tabs.begin();
+ for (std::vector<TabContentsWrapper*>::const_iterator i = tabs.begin();
i != tabs.end();
++i) {
ReassociateTab(**i);
}
}
-void SessionModelAssociator::ReassociateTab(const TabContents& tab) {
+void SessionModelAssociator::ReassociateTab(const TabContentsWrapper& tab) {
DCHECK(CalledOnValidThread());
- if (!IsValidTab(tab))
+ if (!IsValidTab(*(tab.tab_contents())))
return;
int64 sync_id;
- SessionID::id_type id = tab.controller().session_id().id();
- if (tab.is_being_destroyed()) {
+ SessionID::id_type id = tab.restore_tab_helper()->session_id().id();
+ if (tab.tab_contents()->is_being_destroyed()) {
// This tab is closing.
TabLinksMap::iterator tab_iter = tab_map_.find(id);
if (tab_iter == tab_map_.end()) {
@@ -215,11 +216,12 @@ void SessionModelAssociator::ReassociateTab(const TabContents& tab) {
Associate(&tab, sync_id);
}
-void SessionModelAssociator::Associate(const TabContents* tab, int64 sync_id) {
+void SessionModelAssociator::Associate(const TabContentsWrapper* tab,
+ int64 sync_id) {
DCHECK(CalledOnValidThread());
- SessionID::id_type session_id = tab->controller().session_id().id();
+ SessionID::id_type session_id = tab->restore_tab_helper()->session_id().id();
Browser* browser = BrowserList::FindBrowserWithID(
- tab->controller().window_id().id());
+ tab->restore_tab_helper()->window_id().id());
if (!browser) // Can happen for weird things like developer console.
return;
@@ -232,7 +234,7 @@ void SessionModelAssociator::Associate(const TabContents* tab, int64 sync_id) {
bool SessionModelAssociator::WriteTabContentsToSyncModel(
const Browser& browser,
- const TabContents& tab,
+ const TabContentsWrapper& tab,
int64 sync_id,
sync_api::WriteTransaction* trans) {
DCHECK(CalledOnValidThread());
@@ -246,24 +248,21 @@ bool SessionModelAssociator::WriteTabContentsToSyncModel(
session_s.set_session_tag(GetCurrentMachineTag());
sync_pb::SessionTab* tab_s = session_s.mutable_tab();
- SessionID::id_type tab_id = tab.controller().session_id().id();
+ SessionID::id_type tab_id = tab.restore_tab_helper()->session_id().id();
tab_s->set_tab_id(tab_id);
- tab_s->set_window_id(tab.controller().window_id().id());
+ tab_s->set_window_id(tab.restore_tab_helper()->window_id().id());
const int current_index = tab.controller().GetCurrentEntryIndex();
const int min_index = std::max(0,
current_index - max_sync_navigation_count);
const int max_index = std::min(current_index + max_sync_navigation_count,
tab.controller().entry_count());
const int pending_index = tab.controller().pending_entry_index();
- int index_in_window = browser.tabstrip_model()->GetWrapperIndex(&tab);
+ int index_in_window = browser.tabstrip_model()->GetIndexOfTabContents(&tab);
DCHECK(index_in_window != TabStripModel::kNoTab);
tab_s->set_pinned(browser.tabstrip_model()->IsTabPinned(index_in_window));
- TabContentsWrapper* wrapper =
- TabContentsWrapper::GetCurrentWrapperForContents(
- const_cast<TabContents*>(&tab));
- if (wrapper->extension_tab_helper()->extension_app()) {
+ if (tab.extension_tab_helper()->extension_app()) {
tab_s->set_extension_app_id(
- wrapper->extension_tab_helper()->extension_app()->id());
+ tab.extension_tab_helper()->extension_app()->id());
}
for (int i = min_index; i < max_index; ++i) {
const NavigationEntry* entry = (i == pending_index) ?
diff --git a/chrome/browser/sync/glue/session_model_associator.h b/chrome/browser/sync/glue/session_model_associator.h
index 8c7972b..a66a146 100644
--- a/chrome/browser/sync/glue/session_model_associator.h
+++ b/chrome/browser/sync/glue/session_model_associator.h
@@ -27,6 +27,7 @@
#include "chrome/browser/sync/protocol/session_specifics.pb.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/browser/tab_contents/tab_contents.h"
class Profile;
@@ -49,7 +50,7 @@ static const char kSessionsTag[] = "google_chrome_sessions";
// Contains all logic for associating the Chrome sessions model and
// the sync sessions model.
class SessionModelAssociator
- : public PerDataTypeAssociatorInterface<TabContents, size_t>,
+ : public PerDataTypeAssociatorInterface<TabContentsWrapper, size_t>,
public base::NonThreadSafe {
public:
// Does not take ownership of sync_service.
@@ -82,7 +83,7 @@ class SessionModelAssociator
virtual int64 GetSyncIdFromSessionTag(const std::string& tag);
// Not used.
- virtual const TabContents* GetChromeNodeFromSyncId(int64 sync_id);
+ virtual const TabContentsWrapper* GetChromeNodeFromSyncId(int64 sync_id);
// Not used.
virtual bool InitSyncNodeFromChromeId(const size_t& id,
@@ -98,15 +99,15 @@ class SessionModelAssociator
void ReassociateWindows(bool reload_tabs);
// Loads and reassociates the local tabs referenced in |tabs|.
- void ReassociateTabs(const std::vector<TabContents*>& tabs);
+ void ReassociateTabs(const std::vector<TabContentsWrapper*>& tabs);
// Reassociates a single tab with the sync model. Will check if the tab
// already is associated with a sync node and allocate one if necessary.
- void ReassociateTab(const TabContents& tab);
+ void ReassociateTab(const TabContentsWrapper& tab);
// Associate a local tab and it's sync node. Will overwrite the contents of
// the sync node with new specifics built from the tab.
- virtual void Associate(const TabContents* tab, int64 sync_id);
+ virtual void Associate(const TabContentsWrapper* tab, int64 sync_id);
// Looks up the specified sync node, and marks that tab as closed, then marks
// the node as free and deletes association.
@@ -198,10 +199,10 @@ class SessionModelAssociator
// We only ever have either a SessionTab (for foreign tabs), or a
// TabContents (for local tabs).
- TabLinks(int64 sync_id, const TabContents* tab)
+ TabLinks(int64 sync_id, const TabContentsWrapper* tab)
: sync_id_(sync_id),
session_tab_(NULL) {
- tab_ = const_cast<TabContents*>(tab);
+ tab_ = const_cast<TabContentsWrapper*>(tab);
}
TabLinks(int64 sync_id, const SessionTab* session_tab)
: sync_id_(sync_id),
@@ -211,11 +212,11 @@ class SessionModelAssociator
inline int64 sync_id() const { return sync_id_; }
inline const SessionTab* session_tab() const { return session_tab_; }
- inline const TabContents* tab() const { return tab_; }
+ inline const TabContentsWrapper* tab() const { return tab_; }
private:
int64 sync_id_;
SessionTab* session_tab_;
- TabContents* tab_;
+ TabContentsWrapper* tab_;
};
// A pool for managing free/used tab sync nodes. Performs lazy creation
@@ -326,7 +327,7 @@ class SessionModelAssociator
// Fills a tab sync node with data from a TabContents object.
// (from a local navigation event)
bool WriteTabContentsToSyncModel(const Browser& browser,
- const TabContents& tab,
+ const TabContentsWrapper& tab,
const int64 sync_id,
sync_api::WriteTransaction* trans);
diff --git a/chrome/browser/tabs/tab_finder.cc b/chrome/browser/tabs/tab_finder.cc
index 2280b62..637245f 100644
--- a/chrome/browser/tabs/tab_finder.cc
+++ b/chrome/browser/tabs/tab_finder.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "content/browser/tab_contents/navigation_details.h"
#include "content/browser/tab_contents/navigation_entry.h"
@@ -114,9 +115,8 @@ void TabFinder::Observe(NotificationType type,
DCHECK_EQ(type.value, NotificationType::TAB_PARENTED);
// The tab was added to a browser. Query for its state now.
- NavigationController* controller =
- Source<NavigationController>(source).ptr();
- TrackTab(controller->tab_contents());
+ TabContentsWrapper* tab = Source<TabContentsWrapper>(source).ptr();
+ TrackTab(tab->tab_contents());
}
TabFinder::TabFinder() {
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 41d8957..3f8be81 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -61,6 +61,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sessions/session_types.h"
@@ -103,7 +104,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/profiling.h"
#include "chrome/common/url_constants.h"
@@ -1157,7 +1157,7 @@ TabContents* Browser::AddRestoredTab(
SessionService* session_service =
SessionServiceFactory::GetForProfileIfExisting(profile_);
if (session_service)
- session_service->TabRestored(&new_tab->controller(), pin);
+ session_service->TabRestored(wrapper, pin);
return new_tab;
}
@@ -2700,7 +2700,6 @@ void Browser::DuplicateContentsAt(int index) {
TabContentsWrapper* contents = GetTabContentsWrapperAt(index);
CHECK(contents);
TabContentsWrapper* contents_dupe = contents->Clone();
- TabContents* new_contents = contents_dupe->tab_contents();
bool pinned = false;
if (CanSupportWindowFeature(FEATURE_TABSTRIP)) {
@@ -2743,7 +2742,7 @@ void Browser::DuplicateContentsAt(int index) {
SessionService* session_service =
SessionServiceFactory::GetForProfileIfExisting(profile_);
if (session_service)
- session_service->TabRestored(&new_contents->controller(), pinned);
+ session_service->TabRestored(contents_dupe, pinned);
}
void Browser::CloseFrameAfterDragSession() {
@@ -2857,14 +2856,7 @@ void Browser::TabInsertedAt(TabContentsWrapper* contents,
int index,
bool foreground) {
SetAsDelegate(contents, this);
- contents->controller().SetWindowID(session_id());
-
- // Extension code in the renderer holds the ID of the window that hosts it.
- // Notify it that the window ID changed.
- // TODO(sky): move this to a better place.
- contents->render_view_host()->Send(new ExtensionMsg_UpdateBrowserWindowId(
- contents->render_view_host()->routing_id(),
- contents->controller().window_id().id()));
+ contents->restore_tab_helper()->SetWindowID(session_id());
SyncHistoryWithTabs(index);
@@ -2991,8 +2983,7 @@ void Browser::TabReplacedAt(TabStripModel* tab_strip_model,
// The new_contents may end up with a different navigation stack. Force
// the session service to update itself.
session_service->TabRestored(
- &new_contents->controller(),
- tab_handler_->GetTabStripModel()->IsTabPinned(index));
+ new_contents, tab_handler_->GetTabStripModel()->IsTabPinned(index));
}
DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
@@ -3006,7 +2997,7 @@ void Browser::TabPinnedStateChanged(TabContentsWrapper* contents, int index) {
if (session_service) {
session_service->SetPinnedState(
session_id(),
- GetTabContentsAt(index)->controller().session_id(),
+ GetTabContentsWrapperAt(index)->restore_tab_helper()->session_id(),
tab_handler_->GetTabStripModel()->IsTabPinned(index));
}
}
@@ -3439,14 +3430,6 @@ content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() {
return GetJavaScriptDialogCreatorInstance();
}
-void Browser::RenderViewCreated(TabContents* source, RenderViewHost* host) {
- // TODO(sky): move this to a TabContentsObserver hung off TabContentsWrapper,
- // then nuke this method.
- host->Send(new ExtensionMsg_UpdateBrowserWindowId(
- host->routing_id(),
- source->controller().window_id().id()));
-}
-
///////////////////////////////////////////////////////////////////////////////
// Browser, TabContentsWrapperDelegate implementation:
@@ -4250,13 +4233,13 @@ void Browser::SyncHistoryWithTabs(int index) {
SessionServiceFactory::GetForProfileIfExisting(profile());
if (session_service) {
for (int i = index; i < tab_count(); ++i) {
- TabContents* contents = GetTabContentsAt(i);
- if (contents) {
+ TabContentsWrapper* tab = GetTabContentsWrapperAt(i);
+ if (tab) {
session_service->SetTabIndexInWindow(
- session_id(), contents->controller().session_id(), i);
+ session_id(), tab->restore_tab_helper()->session_id(), i);
session_service->SetPinnedState(
session_id(),
- contents->controller().session_id(),
+ tab->restore_tab_helper()->session_id(),
tab_handler_->GetTabStripModel()->IsTabPinned(i));
}
}
@@ -4700,7 +4683,7 @@ void Browser::ViewSource(TabContentsWrapper* contents,
SessionService* session_service =
SessionServiceFactory::GetForProfileIfExisting(profile_);
if (session_service)
- session_service->TabRestored(&view_source_contents->controller(), false);
+ session_service->TabRestored(view_source_contents, false);
}
int Browser::GetContentRestrictionsForSelectedTab() {
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 8a9c9cd..e2404ca 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -855,8 +855,6 @@ class Browser : public TabHandlerDelegate,
const MainFrameCommitDetails& details);
virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator()
OVERRIDE;
- virtual void RenderViewCreated(TabContents* source,
- RenderViewHost* host) OVERRIDE;
// Overridden from TabContentsWrapperDelegate:
virtual void OnDidGetApplicationInfo(TabContentsWrapper* source,
diff --git a/chrome/browser/ui/browser_tab_restore_service_delegate.cc b/chrome/browser/ui/browser_tab_restore_service_delegate.cc
index 4d8976d..5644175 100644
--- a/chrome/browser/ui/browser_tab_restore_service_delegate.cc
+++ b/chrome/browser/ui/browser_tab_restore_service_delegate.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
+#include "content/browser/tab_contents/navigation_controller.h"
void BrowserTabRestoreServiceDelegate::ShowBrowserWindow() {
browser_->window()->Show();
diff --git a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm
index 151e74b..1e212c9b1 100644
--- a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm
+++ b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm
@@ -10,6 +10,7 @@
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/download/save_package.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/sessions/session_id.h"
#include "chrome/browser/ui/cocoa/applescript/error_applescript.h"
#include "chrome/browser/ui/download/download_tab_helper.h"
@@ -61,7 +62,7 @@
tabContents_ = aTabContent;
scoped_nsobject<NSNumber> numID(
[[NSNumber alloc]
- initWithInt:tabContents_->controller().session_id().id()]);
+ initWithInt:tabContents_->restore_tab_helper()->session_id().id()]);
[self setUniqueID:numID];
}
return self;
@@ -75,7 +76,7 @@
tabContents_ = aTabContent;
scoped_nsobject<NSNumber> numID(
[[NSNumber alloc]
- initWithInt:tabContents_->controller().session_id().id()]);
+ initWithInt:tabContents_->restore_tab_helper()->session_id().id()]);
[self setUniqueID:numID];
[self setURL:[self tempURL]];
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
index 279be6c..b07ceb8 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
@@ -14,7 +14,9 @@
#include "chrome/browser/extensions/extension_toolbar_model.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
#import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h"
#import "chrome/browser/ui/cocoa/extensions/chevron_menu_button.h"
@@ -843,11 +845,11 @@ class ExtensionServiceObserverBridge : public NotificationObserver,
}
- (int)currentTabId {
- TabContents* selected_tab = browser_->GetSelectedTabContents();
+ TabContentsWrapper* selected_tab = browser_->GetSelectedTabContentsWrapper();
if (!selected_tab)
return -1;
- return selected_tab->controller().session_id().id();
+ return selected_tab->restore_tab_helper()->session_id().id();
}
#pragma mark -
diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
index 38ca6dc..3f4692a 100644
--- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/gtk/cairo_cached_surface.h"
#include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h"
@@ -24,6 +25,7 @@
#include "chrome/browser/ui/gtk/hover_controller_gtk.h"
#include "chrome/browser/ui/gtk/menu_gtk.h"
#include "chrome/browser/ui/gtk/view_id_util.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/extension_resource.h"
@@ -460,11 +462,11 @@ BrowserActionsToolbarGtk::~BrowserActionsToolbarGtk() {
}
int BrowserActionsToolbarGtk::GetCurrentTabId() {
- TabContents* selected_tab = browser_->GetSelectedTabContents();
+ TabContentsWrapper* selected_tab = browser_->GetSelectedTabContentsWrapper();
if (!selected_tab)
return -1;
- return selected_tab->controller().session_id().id();
+ return selected_tab->restore_tab_helper()->session_id().id();
}
void BrowserActionsToolbarGtk::Update() {
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
index ffff38e..da70f2d 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
@@ -32,6 +32,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/renderer_preferences_util.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/safe_browsing/client_side_detection_host.h"
#include "chrome/browser/tab_contents/blocked_infobar_delegate.h"
#include "chrome/browser/tab_contents/infobar_delegate.h"
@@ -119,6 +120,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents)
favicon_tab_helper_.reset(new FaviconTabHelper(contents));
find_tab_helper_.reset(new FindTabHelper(contents));
history_tab_helper_.reset(new HistoryTabHelper(contents));
+ restore_tab_helper_.reset(new RestoreTabHelper(this));
password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this));
password_manager_.reset(
new PasswordManager(contents, password_manager_delegate_.get()));
@@ -337,6 +339,7 @@ void TabContentsWrapper::CaptureSnapshot() {
Send(new ViewMsg_CaptureSnapshot(routing_id()));
}
+// static
TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents(
TabContents* contents) {
TabContentsWrapper** wrapper =
@@ -345,6 +348,15 @@ TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents(
return wrapper ? *wrapper : NULL;
}
+// static
+const TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents(
+ const TabContents* contents) {
+ TabContentsWrapper* const* wrapper =
+ property_accessor()->GetProperty(contents->property_bag());
+
+ return wrapper ? *wrapper : NULL;
+}
+
////////////////////////////////////////////////////////////////////////////////
// TabContentsWrapper implementation:
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h
index ea266b4..b072627 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h
@@ -46,6 +46,7 @@ class OmniboxSearchHint;
class PasswordManager;
class PasswordManagerDelegate;
class PluginObserver;
+class RestoreTabHelper;
class SearchEngineTabHelper;
class TabContentsSSLHelper;
class TabContentsWrapperDelegate;
@@ -98,6 +99,8 @@ class TabContentsWrapper : public TabContentsObserver,
// chrome/ code instead of TabContents.
static TabContentsWrapper* GetCurrentWrapperForContents(
TabContents* contents);
+ static const TabContentsWrapper* GetCurrentWrapperForContents(
+ const TabContents* contents);
TabContentsWrapperDelegate* delegate() const { return delegate_; }
void set_delegate(TabContentsWrapperDelegate* d) { delegate_ = d; }
@@ -141,6 +144,10 @@ class TabContentsWrapper : public TabContentsObserver,
return extension_tab_helper_.get();
}
+ const ExtensionTabHelper* extension_tab_helper() const {
+ return extension_tab_helper_.get();
+ }
+
FindTabHelper* find_tab_helper() { return find_tab_helper_.get(); }
FaviconTabHelper* favicon_tab_helper() { return favicon_tab_helper_.get(); }
@@ -173,6 +180,14 @@ class TabContentsWrapper : public TabContentsObserver,
return prerender_observer_.get();
}
+ RestoreTabHelper* restore_tab_helper() {
+ return restore_tab_helper_.get();
+ }
+
+ const RestoreTabHelper* restore_tab_helper() const {
+ return restore_tab_helper_.get();
+ }
+
// Overrides -----------------------------------------------------------------
// TabContentsObserver overrides:
@@ -264,6 +279,7 @@ class TabContentsWrapper : public TabContentsObserver,
scoped_ptr<FaviconTabHelper> favicon_tab_helper_;
scoped_ptr<FindTabHelper> find_tab_helper_;
scoped_ptr<HistoryTabHelper> history_tab_helper_;
+ scoped_ptr<RestoreTabHelper> restore_tab_helper_;
// PasswordManager and its delegate. The delegate must outlive the manager,
// per documentation in password_manager.h.
diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc
index f7649f7..31e038f 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -12,8 +12,10 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/detachable_toolbar_view.h"
#include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
@@ -414,8 +416,8 @@ void BrowserActionsContainer::Init() {
}
int BrowserActionsContainer::GetCurrentTabId() const {
- TabContents* tab_contents = browser_->GetSelectedTabContents();
- return tab_contents ? tab_contents->controller().session_id().id() : -1;
+ TabContentsWrapper* tab = browser_->GetSelectedTabContentsWrapper();
+ return tab ? tab->restore_tab_helper()->session_id().id() : -1;
}
BrowserActionView* BrowserActionsContainer::GetBrowserActionView(
diff --git a/chrome/browser/ui/views/file_manager_dialog.cc b/chrome/browser/ui/views/file_manager_dialog.cc
index 543d347..d8c82ab 100644
--- a/chrome/browser/ui/views/file_manager_dialog.cc
+++ b/chrome/browser/ui/views/file_manager_dialog.cc
@@ -8,9 +8,11 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/extensions/extension_file_browser_private_api.h"
#include "chrome/browser/extensions/file_manager_util.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/views/extensions/extension_dialog.h"
#include "chrome/browser/ui/views/window.h"
#include "content/browser/browser_thread.h"
@@ -107,8 +109,8 @@ void FileManagerDialog::SelectFileImpl(
this /* ExtensionDialog::Observer */);
// Connect our listener to FileDialogFunction's per-tab callbacks.
- TabContents* contents = owner_browser->GetSelectedTabContents();
- int32 tab_id = (contents ? contents->controller().session_id().id() : 0);
+ TabContentsWrapper* tab = owner_browser->GetSelectedTabContentsWrapper();
+ int32 tab_id = (tab ? tab->restore_tab_helper()->session_id().id() : 0);
FileDialogFunction::Callback::Add(tab_id, listener_, params);
tab_id_ = tab_id;
diff --git a/chrome/browser/ui/webui/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview_handler.cc
index b696a04..582814d 100644
--- a/chrome/browser/ui/webui/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview_handler.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/printer_manager_dialog.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -614,8 +615,12 @@ TabContents* PrintPreviewHandler::GetInitiatorTab() {
}
void PrintPreviewHandler::ClosePrintPreviewTab() {
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(preview_tab());
+ if (!tab)
+ return;
Browser* preview_tab_browser = BrowserList::FindBrowserWithID(
- preview_tab()->controller().window_id().id());
+ tab->restore_tab_helper()->window_id().id());
if (!preview_tab_browser)
return;
TabStripModel* tabstrip = preview_tab_browser->tabstrip_model();
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 803d64a..9a85de0 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1862,6 +1862,8 @@
'browser/service/service_process_control.h',
'browser/sessions/base_session_service.cc',
'browser/sessions/base_session_service.h',
+ 'browser/sessions/restore_tab_helper.cc',
+ 'browser/sessions/restore_tab_helper.h',
'browser/sessions/session_backend.cc',
'browser/sessions/session_backend.h',
'browser/sessions/session_command.cc',
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 1480204..9778438 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -26,8 +26,6 @@ include_rules = [
# http://crbug.com/76788
"+chrome/browser/profiles/profile.h",
- "+chrome/browser/sessions/session_id.h",
-
"+chrome/browser/tab_contents/render_view_host_delegate_helper.h",
# ONLY USED BY TESTS
diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc
index 538bbfb..c4574b7 100644
--- a/content/browser/tab_contents/navigation_controller.cc
+++ b/content/browser/tab_contents/navigation_controller.cc
@@ -1047,13 +1047,6 @@ void NavigationController::InsertOrReplaceEntry(NavigationEntry* entry,
tab_contents_->UpdateMaxPageID(entry->page_id());
}
-void NavigationController::SetWindowID(const SessionID& id) {
- window_id_ = id;
- NotificationService::current()->Notify(NotificationType::TAB_PARENTED,
- Source<NavigationController>(this),
- NotificationService::NoDetails());
-}
-
void NavigationController::NavigateToPendingEntry(ReloadType reload_type) {
needs_reload_ = false;
diff --git a/content/browser/tab_contents/navigation_controller.h b/content/browser/tab_contents/navigation_controller.h
index e6cfbff..a4132ce 100644
--- a/content/browser/tab_contents/navigation_controller.h
+++ b/content/browser/tab_contents/navigation_controller.h
@@ -14,7 +14,6 @@
#include "base/memory/linked_ptr.h"
#include "base/time.h"
#include "googleurl/src/gurl.h"
-#include "chrome/browser/sessions/session_id.h"
#include "content/browser/ssl/ssl_manager.h"
#include "content/common/navigation_types.h"
#include "content/common/page_transition_types.h"
@@ -277,13 +276,6 @@ class NavigationController {
// Random data ---------------------------------------------------------------
- // Returns the identifier used by session restore.
- const SessionID& session_id() const { return session_id_; }
-
- // Identifier of the window we're in.
- void SetWindowID(const SessionID& id);
- const SessionID& window_id() const { return window_id_; }
-
SSLManager* ssl_manager() { return &ssl_manager_; }
// Returns true if a reload happens when activated (SetActive(true) is
@@ -463,14 +455,6 @@ class NavigationController {
// Whether we need to be reloaded when made active.
bool needs_reload_;
- // Unique identifier of this controller for session restore. This id is only
- // unique within the current session, and is not guaranteed to be unique
- // across sessions.
- SessionID session_id_;
-
- // Unique identifier of the window we're in. Used by session restore.
- SessionID window_id_;
-
// The time ticks at which the last document was loaded.
base::TimeTicks last_document_loaded_;
diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc
index 089a9ca..4f82e49 100644
--- a/content/browser/tab_contents/navigation_controller_unittest.cc
+++ b/content/browser/tab_contents/navigation_controller_unittest.cc
@@ -1857,7 +1857,6 @@ TEST_F(NavigationControllerTest, SubframeWhilePending) {
// Tests CopyStateFromAndPrune with 2 urls in source, 1 in dest.
TEST_F(NavigationControllerTest, CopyStateFromAndPrune) {
- SessionID id(controller().session_id());
const GURL url1("http://foo1");
const GURL url2("http://foo2");
const GURL url3("http://foo3");
@@ -1867,7 +1866,6 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune) {
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
NavigationController& other_controller = other_contents->controller();
- SessionID other_id(other_controller.session_id());
other_contents->NavigateAndCommit(url3);
other_controller.CopyStateFromAndPrune(&controller(), false);
@@ -1880,16 +1878,11 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune) {
EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->url());
EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->url());
EXPECT_EQ(url3, other_controller.GetEntryAtIndex(2)->url());
-
- // Make sure session ids didn't change.
- EXPECT_EQ(id.id(), controller().session_id().id());
- EXPECT_EQ(other_id.id(), other_controller.session_id().id());
}
// Test CopyStateFromAndPrune with 2 urls, the first selected and nothing in
// the target.
TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) {
- SessionID id(controller().session_id());
const GURL url1("http://foo1");
const GURL url2("http://foo2");
const GURL url3("http://foo3");
@@ -1900,7 +1893,6 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) {
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
NavigationController& other_controller = other_contents->controller();
- SessionID other_id(other_controller.session_id());
other_controller.CopyStateFromAndPrune(&controller(), false);
// other_controller should now contain the 1 url: url1.
@@ -1910,16 +1902,11 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) {
ASSERT_EQ(0, other_controller.GetCurrentEntryIndex());
EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->url());
-
- // Make sure session ids didn't change.
- EXPECT_EQ(id.id(), controller().session_id().id());
- EXPECT_EQ(other_id.id(), other_controller.session_id().id());
}
// Test CopyStateFromAndPrune with 2 urls, the first selected and nothing in
// the target.
TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) {
- SessionID id(controller().session_id());
const GURL url1("http://foo1");
const GURL url2("http://foo2");
const GURL url3("http://foo3");
@@ -1930,7 +1917,6 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) {
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
NavigationController& other_controller = other_contents->controller();
- SessionID other_id(other_controller.session_id());
other_controller.LoadURL(url3, GURL(), PageTransition::TYPED);
other_controller.CopyStateFromAndPrune(&controller(), false);
@@ -1947,23 +1933,17 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) {
ASSERT_TRUE(other_controller.pending_entry());
EXPECT_EQ(url3, other_controller.pending_entry()->url());
-
- // Make sure session ids didn't change.
- EXPECT_EQ(id.id(), controller().session_id().id());
- EXPECT_EQ(other_id.id(), other_controller.session_id().id());
}
// Test CopyStateFromAndPrune with 1 url in source, nothing in target and
// remove_first = true.
TEST_F(NavigationControllerTest, CopyStateFromAndPrune4) {
- SessionID id(controller().session_id());
const GURL url1("http://foo1");
NavigateAndCommit(url1);
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
NavigationController& other_controller = other_contents->controller();
- SessionID other_id(other_controller.session_id());
other_controller.CopyStateFromAndPrune(&controller(), true);
// other_controller should now contain 1 entry for url1.
@@ -1976,16 +1956,11 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune4) {
// And there should be a pending entry for url3.
ASSERT_FALSE(other_controller.pending_entry());
-
- // Make sure session ids didn't change.
- EXPECT_EQ(id.id(), controller().session_id().id());
- EXPECT_EQ(other_id.id(), other_controller.session_id().id());
}
// Test CopyStateFromAndPrune with 1 url in source, 1 in target and
// remove_first = true.
TEST_F(NavigationControllerTest, CopyStateFromAndPrune5) {
- SessionID id(controller().session_id());
const GURL url1("http://foo1");
const GURL url2("http://foo2");
@@ -1993,7 +1968,6 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune5) {
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
NavigationController& other_controller = other_contents->controller();
- SessionID other_id(other_controller.session_id());
other_contents->NavigateAndCommit(url2);
other_controller.CopyStateFromAndPrune(&controller(), true);
@@ -2005,16 +1979,11 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune5) {
// And there should be a pending entry for url3.
ASSERT_FALSE(other_controller.pending_entry());
-
- // Make sure session ids didn't change.
- EXPECT_EQ(id.id(), controller().session_id().id());
- EXPECT_EQ(other_id.id(), other_controller.session_id().id());
}
// Test CopyStateFromAndPrune with 1 url in source, 2 in target and
// remove_first = true.
TEST_F(NavigationControllerTest, CopyStateFromAndPrune6) {
- SessionID id(controller().session_id());
const GURL url1("http://foo1");
const GURL url2("http://foo2");
const GURL url3("http://foo2");
@@ -2023,7 +1992,6 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune6) {
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
NavigationController& other_controller = other_contents->controller();
- SessionID other_id(other_controller.session_id());
other_contents->NavigateAndCommit(url2);
other_controller.LoadURL(url3, GURL(), PageTransition::TYPED);
other_controller.CopyStateFromAndPrune(&controller(), true);
@@ -2036,10 +2004,6 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune6) {
// And there should be a pending entry for url3.
ASSERT_TRUE(other_controller.pending_entry());
EXPECT_EQ(url3, other_controller.pending_entry()->url());
-
- // Make sure session ids didn't change.
- EXPECT_EQ(id.id(), controller().session_id().id());
- EXPECT_EQ(other_id.id(), other_controller.session_id().id());
}
// Tests that navigations initiated from the page (with the history object)
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index db5db15..cc80505 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -1272,9 +1272,6 @@ void TabContents::RenderViewCreated(RenderViewHost* render_view_host) {
FOR_EACH_OBSERVER(
TabContentsObserver, observers_, RenderViewCreated(render_view_host));
-
- if (delegate())
- delegate()->RenderViewCreated(this, render_view_host);
}
void TabContents::RenderViewReady(RenderViewHost* rvh) {
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 1d64851..02814dd 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -723,6 +723,10 @@ class TabContents : public PageNavigator,
// via WillClose() when it is being destroyed.
void AddConstrainedDialog(ConstrainedWindow* window);
+ // Stores random bits of data for others to associate with this object.
+ // WARNING: this needs to be deleted after NavigationController.
+ PropertyBag property_bag_;
+
// Data for core operation ---------------------------------------------------
// Delegate for notifying our owner about stuff. Not owned by us.
@@ -739,9 +743,6 @@ class TabContents : public PageNavigator,
// Manages creation and swapping of render views.
RenderViewHostManager render_manager_;
- // Stores random bits of data for others to associate with this object.
- PropertyBag property_bag_;
-
// Registers and unregisters us for notifications.
NotificationRegistrar registrar_;
diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc
index 96e99fc..df709a7 100644
--- a/content/browser/tab_contents/tab_contents_delegate.cc
+++ b/content/browser/tab_contents/tab_contents_delegate.cc
@@ -237,9 +237,5 @@ TabContentsDelegate::GetJavaScriptDialogCreator() {
return JavaScriptDialogCreatorStub::GetInstance();
}
-void TabContentsDelegate::RenderViewCreated(TabContents* source,
- RenderViewHost* host) {
-}
-
TabContentsDelegate::~TabContentsDelegate() {
}
diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h
index 76ee9da..0645128 100644
--- a/content/browser/tab_contents/tab_contents_delegate.h
+++ b/content/browser/tab_contents/tab_contents_delegate.h
@@ -308,9 +308,6 @@ class TabContentsDelegate {
// and displays nothing.
virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator();
- // Invoked when a new renderer is created.
- virtual void RenderViewCreated(TabContents* source, RenderViewHost* host);
-
protected:
virtual ~TabContentsDelegate();
};
diff --git a/content/common/notification_type.h b/content/common/notification_type.h
index 8e0c076..f92998a 100644
--- a/content/common/notification_type.h
+++ b/content/common/notification_type.h
@@ -293,9 +293,9 @@ class NotificationType {
// TabContentsDelegate and the details is the TabContents.
TAB_ADDED,
- // This notification is sent after a tab has been appended to the
- // tab_strip. The source is a Source<NavigationController> with a pointer
- // to controller for the added tab. There are no details.
+ // This notification is sent after a tab has been appended to the tab_strip.
+ // The source is a Source<TabContentsWrapper> of the tab being added. There
+ // are no details.
TAB_PARENTED,
// This message is sent before a tab has been closed. The source is a