diff options
26 files changed, 195 insertions, 112 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 5cf8ce3..61ba92a 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -49,7 +49,7 @@ #include "chrome/browser/renderer_host/chrome_render_message_filter.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_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" @@ -828,7 +828,7 @@ void BrowserOpenedNotificationObserver::Observe( content::Source<NavigationController>(source).ptr(); TabContents* tab = TabContents::FromWebContents(controller->GetWebContents()); - int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; + int window_id = tab ? tab->session_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (use_json_interface_) { AutomationJSONReply(automation_, @@ -2208,7 +2208,7 @@ void AppLaunchObserver::Observe(int type, content::Source<NavigationController>(source).ptr(); TabContents* tab = TabContents::FromWebContents(controller->GetWebContents()); - int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; + int window_id = tab ? tab->session_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (automation_) { AutomationJSONReply(automation_, @@ -2864,7 +2864,7 @@ void BrowserOpenedWithNewProfileNotificationObserver::Observe( content::Source<NavigationController>(source).ptr(); TabContents* tab = TabContents::FromWebContents(controller->GetWebContents()); - int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; + int window_id = tab ? tab->session_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (automation_) { AutomationJSONReply(automation_, reply_message_.release()) @@ -2974,7 +2974,7 @@ void BrowserOpenedWithExistingProfileNotificationObserver::Observe( content::Source<NavigationController>(source).ptr(); TabContents* tab = TabContents::FromWebContents( controller->GetWebContents()); - int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; + int window_id = tab ? tab->session_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_ && --num_loads_ == 0) { if (automation_) { AutomationJSONReply(automation_, reply_message_.release()) diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index d156b5e..cd5443e 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -16,7 +16,7 @@ #include "chrome/browser/external_tab/external_tab_container.h" #include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/sessions/restore_tab_helper.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" @@ -213,7 +213,7 @@ void AutomationProvider::CreateExternalTab( *tab_container_window = external_tab_container->GetExternalTabNativeView(); *tab_window = web_contents->GetNativeView(); *session_id = external_tab_container->GetTabContents()-> - restore_tab_helper()->session_id().id(); + session_tab_helper()->session_id().id(); } else { external_tab_container->Uninitialize(); } @@ -352,7 +352,7 @@ void AutomationProvider::ConnectExternalTab( *tab_container_window = external_tab_container->GetExternalTabNativeView(); *tab_window = tab_contents->GetNativeView(); *session_id = external_tab_container->GetTabContents()-> - restore_tab_helper()->session_id().id(); + session_tab_helper()->session_id().id(); } else { external_tab_container->Uninitialize(); } diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index c927359..f65fad6 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -19,8 +19,8 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/printing/print_preview_tab_controller.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/sessions/restore_tab_helper.h" #include "chrome/browser/sessions/session_id.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -411,7 +411,7 @@ bool SendErrorIfModalDialogActive(AutomationProvider* provider, AutomationId GetIdForTab(const TabContents* tab) { return AutomationId( AutomationId::kTypeTab, - base::IntToString(tab->restore_tab_helper()->session_id().id())); + base::IntToString(tab->session_tab_helper()->session_id().id())); } AutomationId GetIdForExtensionView( @@ -459,7 +459,7 @@ bool GetTabForId(const AutomationId& id, WebContents** tab) { for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); if (base::IntToString( - tab_contents->restore_tab_helper()->session_id().id()) == + tab_contents->session_tab_helper()->session_id().id()) == id.id()) { *tab = tab_contents->web_contents(); return true; @@ -469,7 +469,7 @@ bool GetTabForId(const AutomationId& id, WebContents** tab) { preview_controller->GetPrintPreviewForTab(tab_contents); if (preview_tab_contents) { std::string preview_id = base::IntToString( - preview_tab_contents->restore_tab_helper()->session_id().id()); + preview_tab_contents->session_tab_helper()->session_id().id()); if (preview_id == id.id()) { *tab = preview_tab_contents->web_contents(); return true; diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index ffb1274..2c29e48 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -83,8 +83,8 @@ #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/sessions/session_tab_helper.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/themes/theme_service.h" @@ -5747,7 +5747,7 @@ void TestingAutomationProvider::GetIndicesFromTab( if (has_handle) { TabContents* tab = TabContents::FromWebContents( tab_tracker_->GetResource(id_or_handle)->GetWebContents()); - id = tab->restore_tab_helper()->session_id().id(); + id = tab->session_tab_helper()->session_id().id(); } BrowserList::const_iterator iter = BrowserList::begin(); int browser_index = 0; @@ -5755,7 +5755,7 @@ void TestingAutomationProvider::GetIndicesFromTab( Browser* browser = *iter; for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { TabContents* tab = chrome::GetTabContentsAt(browser, tab_index); - if (tab->restore_tab_helper()->session_id().id() == id) { + if (tab->session_tab_helper()->session_id().id() == id) { DictionaryValue dict; dict.SetInteger("windex", browser_index); dict.SetInteger("tab_index", tab_index); @@ -6398,7 +6398,7 @@ void TestingAutomationProvider::GetTabIds( for (; iter != BrowserList::end(); ++iter) { Browser* browser = *iter; for (int i = 0; i < browser->tab_count(); ++i) { - int id = chrome::GetTabContentsAt(browser, i)->restore_tab_helper()-> + int id = chrome::GetTabContentsAt(browser, i)->session_tab_helper()-> session_id().id(); id_list->Append(Value::CreateIntegerValue(id)); } @@ -6471,7 +6471,7 @@ void TestingAutomationProvider::IsTabIdValid( Browser* browser = *iter; for (int i = 0; i < browser->tab_count(); ++i) { TabContents* tab = chrome::GetTabContentsAt(browser, i); - if (tab->restore_tab_helper()->session_id().id() == id) { + if (tab->session_tab_helper()->session_id().id() == id) { is_valid = true; break; } diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index e1a282b..ce7194f 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -18,7 +18,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/sessions/session_tab_helper.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" @@ -428,7 +428,7 @@ void DevToolsWindow::UpdateFrontendAttachedState() { void DevToolsWindow::AddDevToolsExtensionsToClient() { if (inspected_tab_) { base::FundamentalValue tabId( - inspected_tab_->restore_tab_helper()->session_id().id()); + inspected_tab_->session_tab_helper()->session_id().id()); CallClientFunction("WebInspector.setInspectedTabId", &tabId); } ListValue results; diff --git a/chrome/browser/extensions/api/extension_action/page_action_apitest.cc b/chrome/browser/extensions/api/extension_action/page_action_apitest.cc index b6f1cc6..b2ffd0c 100644 --- a/chrome/browser/extensions/api/extension_action/page_action_apitest.cc +++ b/chrome/browser/extensions/api/extension_action/page_action_apitest.cc @@ -7,7 +7,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/sessions/restore_tab_helper.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" @@ -34,7 +34,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) { } // Test that we received the changes. - int tab_id = chrome::GetActiveTabContents(browser())->restore_tab_helper()-> + int tab_id = chrome::GetActiveTabContents(browser())->session_tab_helper()-> session_id().id(); ExtensionAction* action = extension->page_action(); ASSERT_TRUE(action); @@ -60,7 +60,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) { } // Test that we received the changes. - tab_id = chrome::GetActiveTabContents(browser())->restore_tab_helper()-> + tab_id = chrome::GetActiveTabContents(browser())->session_tab_helper()-> session_id().id(); EXPECT_FALSE(action->GetIcon(tab_id).IsEmpty()); } diff --git a/chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc b/chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc index 850ffaf..95136cd 100644 --- a/chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc +++ b/chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc @@ -9,7 +9,6 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_tab_util.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_tabstrip.h" #include "chrome/browser/ui/browser_window.h" diff --git a/chrome/browser/extensions/api/tabs/tabs.cc b/chrome/browser/extensions/api/tabs/tabs.cc index 1eedf6e..78d1881 100644 --- a/chrome/browser/extensions/api/tabs/tabs.cc +++ b/chrome/browser/extensions/api/tabs/tabs.cc @@ -33,7 +33,6 @@ #include "chrome/browser/prefs/incognito_mode_prefs.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/translate/translate_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" diff --git a/chrome/browser/extensions/extension_keybinding_apitest.cc b/chrome/browser/extensions/extension_keybinding_apitest.cc index aa683ea..fd8794a 100644 --- a/chrome/browser/extensions/extension_keybinding_apitest.cc +++ b/chrome/browser/extensions/extension_keybinding_apitest.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/browser_action_test_util.h" -#include "chrome/browser/sessions/restore_tab_helper.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" @@ -112,7 +112,7 @@ IN_PROC_BROWSER_TEST_F(CommandsApiTest, PageAction) { // Make sure it appears and is the right one. ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); - int tab_id = chrome::GetActiveTabContents(browser())->restore_tab_helper()-> + int tab_id = chrome::GetActiveTabContents(browser())->session_tab_helper()-> session_id().id(); ExtensionAction* action = extension->page_action(); ASSERT_TRUE(action); diff --git a/chrome/browser/extensions/extension_tab_id_map.cc b/chrome/browser/extensions/extension_tab_id_map.cc index 9f590dc..43170ac 100644 --- a/chrome/browser/extensions/extension_tab_id_map.cc +++ b/chrome/browser/extensions/extension_tab_id_map.cc @@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "chrome/browser/sessions/restore_tab_helper.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/tab_contents/retargeting_details.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_notification_types.h" @@ -80,8 +80,8 @@ void ExtensionTabIdMap::TabObserver::Observe( &ExtensionTabIdMap::SetTabAndWindowId, base::Unretained(ExtensionTabIdMap::GetInstance()), host->GetProcess()->GetID(), host->GetRoutingID(), - tab->restore_tab_helper()->session_id().id(), - tab->restore_tab_helper()->window_id().id())); + tab->session_tab_helper()->session_id().id(), + tab->session_tab_helper()->window_id().id())); break; } case chrome::NOTIFICATION_TAB_PARENTED: { @@ -94,8 +94,8 @@ void ExtensionTabIdMap::TabObserver::Observe( &ExtensionTabIdMap::SetTabAndWindowId, base::Unretained(ExtensionTabIdMap::GetInstance()), host->GetProcess()->GetID(), host->GetRoutingID(), - tab->restore_tab_helper()->session_id().id(), - tab->restore_tab_helper()->window_id().id())); + tab->session_tab_helper()->session_id().id(), + tab->session_tab_helper()->window_id().id())); break; } case chrome::NOTIFICATION_RETARGETING: { @@ -112,8 +112,8 @@ void ExtensionTabIdMap::TabObserver::Observe( &ExtensionTabIdMap::SetTabAndWindowId, base::Unretained(ExtensionTabIdMap::GetInstance()), host->GetProcess()->GetID(), host->GetRoutingID(), - tab->restore_tab_helper()->session_id().id(), - tab->restore_tab_helper()->window_id().id())); + tab->session_tab_helper()->session_id().id(), + tab->session_tab_helper()->window_id().id())); break; } case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: { diff --git a/chrome/browser/printing/background_printing_manager.cc b/chrome/browser/printing/background_printing_manager.cc index 1c123c9..7d8201c 100644 --- a/chrome/browser/printing/background_printing_manager.cc +++ b/chrome/browser/printing/background_printing_manager.cc @@ -6,7 +6,6 @@ #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/ui/browser_list.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" diff --git a/chrome/browser/sessions/session_id.cc b/chrome/browser/sessions/session_id.cc index 880f3cd..80f690a 100644 --- a/chrome/browser/sessions/session_id.cc +++ b/chrome/browser/sessions/session_id.cc @@ -4,7 +4,7 @@ #include "chrome/browser/sessions/session_id.h" -#include "chrome/browser/sessions/restore_tab_helper.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" static SessionID::id_type next_id = 1; @@ -14,9 +14,9 @@ SessionID::SessionID() { } SessionID::id_type SessionID::IdForTab(const TabContents* tab) { - return tab ? tab->restore_tab_helper()->session_id().id() : -1; + return tab ? tab->session_tab_helper()->session_id().id() : -1; } SessionID::id_type SessionID::IdForWindowContainingTab(const TabContents* tab) { - return tab ? tab->restore_tab_helper()->window_id().id() : -1; + return tab ? tab->session_tab_helper()->window_id().id() : -1; } diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 9dbb0c9..8174434 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -21,10 +21,10 @@ #include "chrome/browser/extensions/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" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/sessions/session_types.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_tabstrip.h" @@ -447,10 +447,10 @@ void SessionService::UpdateTabNavigation( } void SessionService::TabRestored(TabContents* tab, bool pinned) { - if (!ShouldTrackChangesToWindow(tab->restore_tab_helper()->window_id())) + if (!ShouldTrackChangesToWindow(tab->session_tab_helper()->window_id())) return; - BuildCommandsForTab(tab->restore_tab_helper()->window_id(), tab, -1, + BuildCommandsForTab(tab->session_tab_helper()->window_id(), tab, -1, pinned, &pending_commands(), NULL); StartSaveTimer(); } @@ -607,12 +607,12 @@ void SessionService::Observe(int type, TabContents* tab = content::Source<TabContents>(source).ptr(); if (tab->profile() != profile()) return; - SetTabWindow(tab->restore_tab_helper()->window_id(), - tab->restore_tab_helper()->session_id()); + SetTabWindow(tab->session_tab_helper()->window_id(), + tab->session_tab_helper()->session_id()); if (tab->extension_tab_helper()->extension_app()) { SetTabExtensionAppID( - tab->restore_tab_helper()->window_id(), - tab->restore_tab_helper()->session_id(), + tab->session_tab_helper()->window_id(), + tab->session_tab_helper()->session_id(), tab->extension_tab_helper()->extension_app()->id()); } @@ -626,7 +626,7 @@ void SessionService::Observe(int type, tab->web_contents()->GetController(). GetDefaultSessionStorageNamespace(); ScheduleCommand(CreateSessionStorageAssociatedCommand( - tab->restore_tab_helper()->session_id(), + tab->session_tab_helper()->session_id(), session_storage_namespace->persistent_id())); session_storage_namespace->SetShouldPersist(true); break; @@ -642,8 +642,8 @@ void SessionService::Observe(int type, tab->web_contents()->GetController(). GetDefaultSessionStorageNamespace(); session_storage_namespace->SetShouldPersist(false); - TabClosed(tab->restore_tab_helper()->window_id(), - tab->restore_tab_helper()->session_id(), + TabClosed(tab->session_tab_helper()->window_id(), + tab->session_tab_helper()->session_id(), tab->web_contents()->GetClosedByUserGesture()); RecordSessionUpdateHistogramData(type, &last_updated_tab_closed_time_); break; @@ -658,13 +658,13 @@ void SessionService::Observe(int type, content::Details<content::PrunedDetails> pruned_details(details); if (pruned_details->from_front) { TabNavigationPathPrunedFromFront( - tab->restore_tab_helper()->window_id(), - tab->restore_tab_helper()->session_id(), + tab->session_tab_helper()->window_id(), + tab->session_tab_helper()->session_id(), pruned_details->count); } else { TabNavigationPathPrunedFromBack( - tab->restore_tab_helper()->window_id(), - tab->restore_tab_helper()->session_id(), + tab->session_tab_helper()->window_id(), + tab->session_tab_helper()->session_id(), tab->web_contents()->GetController().GetEntryCount()); } RecordSessionUpdateHistogramData(content::NOTIFICATION_NAV_LIST_PRUNED, @@ -680,8 +680,8 @@ void SessionService::Observe(int type, return; content::Details<content::EntryChangedDetails> changed(details); UpdateTabNavigation( - tab->restore_tab_helper()->window_id(), - tab->restore_tab_helper()->session_id(), + tab->session_tab_helper()->window_id(), + tab->session_tab_helper()->session_id(), changed->index, *changed->changed_entry); break; } @@ -694,12 +694,12 @@ void SessionService::Observe(int type, return; int current_entry_index = tab->web_contents()->GetController().GetCurrentEntryIndex(); - SetSelectedNavigationIndex(tab->restore_tab_helper()->window_id(), - tab->restore_tab_helper()->session_id(), + SetSelectedNavigationIndex(tab->session_tab_helper()->window_id(), + tab->session_tab_helper()->session_id(), current_entry_index); UpdateTabNavigation( - tab->restore_tab_helper()->window_id(), - tab->restore_tab_helper()->session_id(), + tab->session_tab_helper()->window_id(), + tab->session_tab_helper()->session_id(), current_entry_index, *tab->web_contents()->GetController().GetEntryAtIndex( current_entry_index)); @@ -719,8 +719,8 @@ void SessionService::Observe(int type, if (extension_tab_helper->tab_contents()->profile() != profile()) return; if (extension_tab_helper->extension_app()) { - RestoreTabHelper* helper = - extension_tab_helper->tab_contents()->restore_tab_helper(); + SessionTabHelper* helper = + extension_tab_helper->tab_contents()->session_tab_helper(); SetTabExtensionAppID(helper->window_id(), helper->session_id(), extension_tab_helper->extension_app()->id()); @@ -1296,7 +1296,7 @@ void SessionService::BuildCommandsForTab( std::vector<SessionCommand*>* commands, IdToRange* tab_to_available_range) { DCHECK(tab && commands && window_id.id()); - const SessionID& session_id(tab->restore_tab_helper()->session_id()); + const SessionID& session_id(tab->session_tab_helper()->session_id()); commands->push_back(CreateSetTabWindowCommand(window_id, session_id)); const int current_index = @@ -1354,7 +1354,7 @@ void SessionService::BuildCommandsForTab( content::SessionStorageNamespace* session_storage_namespace = tab->web_contents()->GetController().GetDefaultSessionStorageNamespace(); ScheduleCommand(CreateSessionStorageAssociatedCommand( - tab->restore_tab_helper()->session_id(), + tab->session_tab_helper()->session_id(), session_storage_namespace->persistent_id())); } diff --git a/chrome/browser/sessions/session_tab_helper.cc b/chrome/browser/sessions/session_tab_helper.cc new file mode 100644 index 0000000..393276e --- /dev/null +++ b/chrome/browser/sessions/session_tab_helper.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2012 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/session_tab_helper.h" + +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/sessions/session_service.h" +#include "chrome/browser/sessions/session_service_factory.h" +#include "chrome/browser/ui/tab_contents/tab_contents.h" +#include "chrome/common/chrome_notification_types.h" +#include "chrome/common/extensions/extension_messages.h" +#include "content/public/browser/notification_service.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" + +SessionTabHelper::SessionTabHelper(content::WebContents* contents) + : content::WebContentsObserver(contents) { +} + +SessionTabHelper::~SessionTabHelper() { +} + +void SessionTabHelper::SetWindowID(const SessionID& id) { + window_id_ = id; + + // TODO(mpcomplete): Maybe this notification should send out a WebContents. + TabContents* tab = TabContents::FromWebContents(web_contents()); + if (tab) { + content::NotificationService::current()->Notify( + chrome::NOTIFICATION_TAB_PARENTED, + content::Source<TabContents>(tab), + content::NotificationService::NoDetails()); + } + + // Extension code in the renderer holds the ID of the window that hosts it. + // Notify it that the window ID changed. + web_contents()->GetRenderViewHost()->Send( + new ExtensionMsg_UpdateBrowserWindowId( + web_contents()->GetRenderViewHost()->GetRoutingID(), id.id())); +} + +void SessionTabHelper::RenderViewCreated( + content::RenderViewHost* render_view_host) { + render_view_host->Send( + new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(), + window_id_.id())); +} + +void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) { +#if defined(ENABLE_SESSION_SERVICE) + Profile* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); + SessionService* session = SessionServiceFactory::GetForProfile(profile); + if (session) + session->SetTabUserAgentOverride(window_id(), session_id(), user_agent); +#endif +} diff --git a/chrome/browser/sessions/session_tab_helper.h b/chrome/browser/sessions/session_tab_helper.h new file mode 100644 index 0000000..8c30656 --- /dev/null +++ b/chrome/browser/sessions/session_tab_helper.h @@ -0,0 +1,43 @@ +// 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_SESSION_TAB_HELPER_H_ +#define CHROME_BROWSER_SESSIONS_SESSION_TAB_HELPER_H_ + +#include "base/basictypes.h" +#include "chrome/browser/sessions/session_id.h" +#include "content/public/browser/web_contents_observer.h" + +// This class keeps the extension API's windowID up-to-date with the current +// window of the tab. +class SessionTabHelper : public content::WebContentsObserver { + public: + explicit SessionTabHelper(content::WebContents* contents); + virtual ~SessionTabHelper(); + + // 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_; } + + // content::WebContentsObserver: + virtual void RenderViewCreated( + content::RenderViewHost* render_view_host) OVERRIDE; + virtual void UserAgentOverrideSet(const std::string& user_agent) OVERRIDE; + + private: + // 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(SessionTabHelper); +}; + +#endif // CHROME_BROWSER_SESSIONS_SESSION_TAB_HELPER_H_ diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index fe43ebe..a7038e4 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -78,9 +78,9 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/repost_form_warning_controller.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_tab_helper.h" #include "chrome/browser/sessions/session_types.h" #include "chrome/browser/sessions/tab_restore_service.h" #include "chrome/browser/sessions/tab_restore_service_factory.h" @@ -1026,7 +1026,7 @@ void Browser::TabInsertedAt(TabContents* contents, int index, bool foreground) { SetAsDelegate(contents, this); - contents->restore_tab_helper()->SetWindowID(session_id()); + contents->session_tab_helper()->SetWindowID(session_id()); SyncHistoryWithTabs(index); @@ -1184,7 +1184,7 @@ void Browser::TabPinnedStateChanged(TabContents* contents, int index) { if (session_service) { session_service->SetPinnedState( session_id(), - chrome::GetTabContentsAt(this, index)->restore_tab_helper()-> + chrome::GetTabContentsAt(this, index)->session_tab_helper()-> session_id(), tab_strip_model_->IsTabPinned(index)); } @@ -2081,10 +2081,10 @@ void Browser::SyncHistoryWithTabs(int index) { TabContents* tab = chrome::GetTabContentsAt(this, i); if (tab) { session_service->SetTabIndexInWindow( - session_id(), tab->restore_tab_helper()->session_id(), i); + session_id(), tab->session_tab_helper()->session_id(), i); session_service->SetPinnedState( session_id(), - tab->restore_tab_helper()->session_id(), + tab->session_tab_helper()->session_id(), tab_strip_model_->IsTabPinned(i)); } } diff --git a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm index 5d7e98c..31fdcd8 100644 --- a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm +++ b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm @@ -13,8 +13,8 @@ #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/printing/print_view_manager.h" -#include "chrome/browser/sessions/restore_tab_helper.h" #include "chrome/browser/sessions/session_id.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/url_constants.h" @@ -167,7 +167,7 @@ static NSAppleEventDescriptor* valueToDescriptor(Value* value) { tabContents_ = aTabContent; scoped_nsobject<NSNumber> numID( [[NSNumber alloc] - initWithInt:tabContents_->restore_tab_helper()->session_id().id()]); + initWithInt:tabContents_->session_tab_helper()->session_id().id()]); [self setUniqueID:numID]; } return self; @@ -181,7 +181,7 @@ static NSAppleEventDescriptor* valueToDescriptor(Value* value) { tabContents_ = aTabContent; scoped_nsobject<NSNumber> numID( [[NSNumber alloc] - initWithInt:tabContents_->restore_tab_helper()->session_id().id()]); + initWithInt:tabContents_->session_tab_helper()->session_id().id()]); [self setUniqueID:numID]; if ([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 c777f6f..f69478e 100644 --- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm @@ -12,7 +12,7 @@ #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/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" @@ -851,7 +851,7 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver, if (!selected_tab) return -1; - return selected_tab->restore_tab_helper()->session_id().id(); + return selected_tab->session_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 f60b19b..7124bb7 100644 --- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc @@ -19,7 +19,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/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" @@ -595,7 +595,7 @@ int BrowserActionsToolbarGtk::GetCurrentTabId() const { if (!active_tab) return -1; - return active_tab->restore_tab_helper()->session_id().id(); + return active_tab->session_tab_helper()->session_id().id(); } void BrowserActionsToolbarGtk::Update() { diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index 5fc3920..1f8bd11 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -37,7 +37,7 @@ #include "chrome/browser/search_engines/template_url_prepopulate_data.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_tab_helper.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" @@ -538,7 +538,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, // we can easily get the tab ID. (If it's being opened in a new // tab, we don't know the tab ID yet.) log.tab_id = controller_->GetTabContents()-> - restore_tab_helper()->session_id().id(); + session_tab_helper()->session_id().id(); } autocomplete_controller_->AddProvidersInfo(&log.providers_info); content::NotificationService::current()->Notify( diff --git a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc index 68808bf..59474bf 100644 --- a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc +++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/sessions/restore_tab_helper.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/extensions/extension.h" #include "content/public/browser/navigation_controller.h" @@ -21,11 +21,11 @@ TabContentsSyncedTabDelegate::TabContentsSyncedTabDelegate( TabContentsSyncedTabDelegate::~TabContentsSyncedTabDelegate() {} SessionID::id_type TabContentsSyncedTabDelegate::GetWindowId() const { - return tab_contents_->restore_tab_helper()->window_id().id(); + return tab_contents_->session_tab_helper()->window_id().id(); } SessionID::id_type TabContentsSyncedTabDelegate::GetSessionId() const { - return tab_contents_->restore_tab_helper()->session_id().id(); + return tab_contents_->session_tab_helper()->session_id().id(); } bool TabContentsSyncedTabDelegate::IsBeingDestroyed() const { diff --git a/chrome/browser/ui/tab_contents/tab_contents.cc b/chrome/browser/ui/tab_contents/tab_contents.cc index 1396484..ffc240c 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.cc +++ b/chrome/browser/ui/tab_contents/tab_contents.cc @@ -27,9 +27,7 @@ #include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.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_tab_helper.h" #include "chrome/browser/tab_contents/navigation_metrics_recorder.h" #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" #include "chrome/browser/tab_contents/thumbnail_generator.h" @@ -107,9 +105,9 @@ TabContents::TabContents(WebContents* contents) new TabContentsUserData(this)); // Create the tab helpers. - // restore_tab_helper because it sets up the tab ID, and other helpers may + // session_tab_helper because it sets up the tab ID, and other helpers may // rely on that. - restore_tab_helper_.reset(new RestoreTabHelper(contents)); + session_tab_helper_.reset(new SessionTabHelper(contents)); autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); autofill_delegate_.reset(new TabAutofillManagerDelegate(this)); @@ -271,15 +269,3 @@ void TabContents::WebContentsDestroyed(WebContents* tab) { // will attempt to access the WebContents and we'll crash. DCHECK(in_destructor_); } - -void TabContents::UserAgentOverrideSet(const std::string& user_agent) { -#if defined(ENABLE_SESSION_SERVICE) - SessionService* session = - SessionServiceFactory::GetForProfile(profile()); - if (session) { - session->SetTabUserAgentOverride(restore_tab_helper()->window_id(), - restore_tab_helper()->session_id(), - user_agent); - } -#endif -} diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h index 05b8494..2b95c05 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.h +++ b/chrome/browser/ui/tab_contents/tab_contents.h @@ -51,9 +51,9 @@ class PDFTabObserver; class PluginObserver; class PrefsTabHelper; class Profile; -class RestoreTabHelper; class SadTabHelper; class SearchEngineTabHelper; +class SessionTabHelper; class ShellWindow; class SnapshotTabHelper; class TabAutofillManagerDelegate; @@ -276,14 +276,6 @@ class TabContents : public content::WebContentsObserver { return print_view_manager_.get(); } - RestoreTabHelper* restore_tab_helper() { - return restore_tab_helper_.get(); - } - - const RestoreTabHelper* restore_tab_helper() const { - return restore_tab_helper_.get(); - } - SadTabHelper* sad_tab_helper() { return sad_tab_helper_.get(); } SearchEngineTabHelper* search_engine_tab_helper() { @@ -294,6 +286,14 @@ class TabContents : public content::WebContentsObserver { return search_tab_helper_.get(); } + SessionTabHelper* session_tab_helper() { + return session_tab_helper_.get(); + } + + const SessionTabHelper* session_tab_helper() const { + return session_tab_helper_.get(); + } + SnapshotTabHelper* snapshot_tab_helper() { return snapshot_tab_helper_.get(); } @@ -329,7 +329,6 @@ class TabContents : public content::WebContentsObserver { // content::WebContentsObserver overrides: virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; - virtual void UserAgentOverrideSet(const std::string& user_agent) OVERRIDE; private: friend class TabContentsFactory; @@ -379,10 +378,10 @@ class TabContents : public content::WebContentsObserver { // Handles print job for this contents. scoped_ptr<printing::PrintViewManager> print_view_manager_; - scoped_ptr<RestoreTabHelper> restore_tab_helper_; scoped_ptr<SadTabHelper> sad_tab_helper_; scoped_ptr<SearchEngineTabHelper> search_engine_tab_helper_; scoped_ptr<chrome::search::SearchTabHelper> search_tab_helper_; + scoped_ptr<SessionTabHelper> session_tab_helper_; scoped_ptr<SnapshotTabHelper> snapshot_tab_helper_; scoped_ptr<TabContentsSSLHelper> ssl_helper_; scoped_ptr<browser_sync::SyncedTabDelegate> synced_tab_delegate_; diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc index 2df4fd2..6cd8e2b 100644 --- a/chrome/browser/ui/views/browser_actions_container.cc +++ b/chrome/browser/ui/views/browser_actions_container.cc @@ -8,7 +8,7 @@ #include "chrome/browser/extensions/extension_service.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/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" @@ -457,7 +457,7 @@ void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { int BrowserActionsContainer::GetCurrentTabId() const { TabContents* tab = chrome::GetActiveTabContents(browser_); - return tab ? tab->restore_tab_helper()->session_id().id() : -1; + return tab ? tab->session_tab_helper()->session_id().id() : -1; } void BrowserActionsContainer::OnBrowserActionExecuted( diff --git a/chrome/browser/ui/views/select_file_dialog_extension.cc b/chrome/browser/ui/views/select_file_dialog_extension.cc index 82ecf9f..2c56c29 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension.cc @@ -17,7 +17,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/shell_window_registry.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/sessions/restore_tab_helper.h" +#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/base_window.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" @@ -301,7 +301,7 @@ void SelectFileDialogExtension::SelectFileImpl( // possible. If there is no tab contents use a tab_id of 0. A dialog without // an associated tab contents will be shown fully screen; only one at a time // is allowed in this state. - int32 tab_id = tab ? tab->restore_tab_helper()->session_id().id() : 0; + int32 tab_id = tab ? tab->session_tab_helper()->session_id().id() : 0; if (PendingExists(tab_id)) { DLOG(WARNING) << "Pending dialog exists with id " << tab_id; return; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 641d14d..7cbd1e7 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1640,8 +1640,6 @@ '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', @@ -1655,6 +1653,8 @@ 'browser/sessions/session_service.h', 'browser/sessions/session_service_factory.cc', 'browser/sessions/session_service_factory.h', + 'browser/sessions/session_tab_helper.cc', + 'browser/sessions/session_tab_helper.h', 'browser/sessions/session_types.cc', 'browser/sessions/session_types.h', 'browser/sessions/tab_restore_service.cc', |