summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sessions
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-17 02:49:55 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-17 02:49:55 +0000
commit3b265315f3c7ca648828a1a1174f064d2d071423 (patch)
treeef07ad6f05725d062a5588e27669903cc81d46d9 /chrome/browser/sessions
parent62f02416c5b7e95081571f053f68ad519e2205b0 (diff)
downloadchromium_src-3b265315f3c7ca648828a1a1174f064d2d071423.zip
chromium_src-3b265315f3c7ca648828a1a1174f064d2d071423.tar.gz
chromium_src-3b265315f3c7ca648828a1a1174f064d2d071423.tar.bz2
Plumb HostDesktopType through tab restore.
BUG=129187 TEST=Tabs restored via the "Recently closed tabs" menu, if they need to create a window, do so on the desktop the action was initiated from. TODO=Make this work via non-webUI interaction (e.g. close a tab on the desktop and open it via the context menu of the tabstrip of an Ash window; it currently still re-opens on the native desktop) Review URL: https://chromiumcodereview.appspot.com/11959014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sessions')
-rw-r--r--chrome/browser/sessions/in_memory_tab_restore_service.cc8
-rw-r--r--chrome/browser/sessions/in_memory_tab_restore_service.h4
-rw-r--r--chrome/browser/sessions/persistent_tab_restore_service.cc8
-rw-r--r--chrome/browser/sessions/persistent_tab_restore_service.h4
-rw-r--r--chrome/browser/sessions/session_restore_browsertest.cc8
-rw-r--r--chrome/browser/sessions/tab_restore_service.h12
-rw-r--r--chrome/browser/sessions/tab_restore_service_delegate.h8
-rw-r--r--chrome/browser/sessions/tab_restore_service_helper.cc17
-rw-r--r--chrome/browser/sessions/tab_restore_service_helper.h17
9 files changed, 60 insertions, 26 deletions
diff --git a/chrome/browser/sessions/in_memory_tab_restore_service.cc b/chrome/browser/sessions/in_memory_tab_restore_service.cc
index 1122bbd..c7f81f2 100644
--- a/chrome/browser/sessions/in_memory_tab_restore_service.cc
+++ b/chrome/browser/sessions/in_memory_tab_restore_service.cc
@@ -51,8 +51,9 @@ const TabRestoreService::Entries& InMemoryTabRestoreService::entries() const {
}
void InMemoryTabRestoreService::RestoreMostRecentEntry(
- TabRestoreServiceDelegate* delegate) {
- helper_.RestoreMostRecentEntry(delegate);
+ TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type) {
+ helper_.RestoreMostRecentEntry(delegate, host_desktop_type);
}
TabRestoreService::Tab* InMemoryTabRestoreService::RemoveTabEntryById(
@@ -63,8 +64,9 @@ TabRestoreService::Tab* InMemoryTabRestoreService::RemoveTabEntryById(
void InMemoryTabRestoreService::RestoreEntryById(
TabRestoreServiceDelegate* delegate,
SessionID::id_type id,
+ chrome::HostDesktopType host_desktop_type,
WindowOpenDisposition disposition) {
- helper_.RestoreEntryById(delegate, id, disposition);
+ helper_.RestoreEntryById(delegate, id, host_desktop_type, disposition);
}
void InMemoryTabRestoreService::LoadTabsFromLastSession() {
diff --git a/chrome/browser/sessions/in_memory_tab_restore_service.h b/chrome/browser/sessions/in_memory_tab_restore_service.h
index 88a5a05..760447b 100644
--- a/chrome/browser/sessions/in_memory_tab_restore_service.h
+++ b/chrome/browser/sessions/in_memory_tab_restore_service.h
@@ -32,10 +32,12 @@ class InMemoryTabRestoreService : public TabRestoreService {
virtual void ClearEntries() OVERRIDE;
virtual const Entries& entries() const OVERRIDE;
virtual void RestoreMostRecentEntry(
- TabRestoreServiceDelegate* delegate) OVERRIDE;
+ TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type) OVERRIDE;
virtual Tab* RemoveTabEntryById(SessionID::id_type id) OVERRIDE;
virtual void RestoreEntryById(TabRestoreServiceDelegate* delegate,
SessionID::id_type id,
+ chrome::HostDesktopType host_desktop_type,
WindowOpenDisposition disposition) OVERRIDE;
virtual void LoadTabsFromLastSession() OVERRIDE;
virtual bool IsLoaded() const OVERRIDE;
diff --git a/chrome/browser/sessions/persistent_tab_restore_service.cc b/chrome/browser/sessions/persistent_tab_restore_service.cc
index 3ddc168..1bc05a6 100644
--- a/chrome/browser/sessions/persistent_tab_restore_service.cc
+++ b/chrome/browser/sessions/persistent_tab_restore_service.cc
@@ -937,8 +937,9 @@ const TabRestoreService::Entries& PersistentTabRestoreService::entries() const {
}
void PersistentTabRestoreService::RestoreMostRecentEntry(
- TabRestoreServiceDelegate* delegate) {
- helper_.RestoreMostRecentEntry(delegate);
+ TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type) {
+ helper_.RestoreMostRecentEntry(delegate, host_desktop_type);
}
TabRestoreService::Tab* PersistentTabRestoreService::RemoveTabEntryById(
@@ -949,8 +950,9 @@ TabRestoreService::Tab* PersistentTabRestoreService::RemoveTabEntryById(
void PersistentTabRestoreService::RestoreEntryById(
TabRestoreServiceDelegate* delegate,
SessionID::id_type id,
+ chrome::HostDesktopType host_desktop_type,
WindowOpenDisposition disposition) {
- helper_.RestoreEntryById(delegate, id, disposition);
+ helper_.RestoreEntryById(delegate, id, host_desktop_type, disposition);
}
bool PersistentTabRestoreService::IsLoaded() const {
diff --git a/chrome/browser/sessions/persistent_tab_restore_service.h b/chrome/browser/sessions/persistent_tab_restore_service.h
index f43e14a..fccce69 100644
--- a/chrome/browser/sessions/persistent_tab_restore_service.h
+++ b/chrome/browser/sessions/persistent_tab_restore_service.h
@@ -32,10 +32,12 @@ class PersistentTabRestoreService : public TabRestoreService {
virtual void ClearEntries() OVERRIDE;
virtual const Entries& entries() const OVERRIDE;
virtual void RestoreMostRecentEntry(
- TabRestoreServiceDelegate* delegate) OVERRIDE;
+ TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type) OVERRIDE;
virtual Tab* RemoveTabEntryById(SessionID::id_type id) OVERRIDE;
virtual void RestoreEntryById(TabRestoreServiceDelegate* delegate,
SessionID::id_type id,
+ chrome::HostDesktopType host_desktop_type,
WindowOpenDisposition disposition) OVERRIDE;
virtual void LoadTabsFromLastSession() OVERRIDE;
virtual bool IsLoaded() const OVERRIDE;
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc
index b321e41..152bb7d 100644
--- a/chrome/browser/sessions/session_restore_browsertest.cc
+++ b/chrome/browser/sessions/session_restore_browsertest.cc
@@ -288,6 +288,8 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) {
TabRestoreServiceFactory::GetForProfile(browser()->profile());
service->ClearEntries();
+ chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type();
+
browser()->window()->Close();
// Expect a window with three tabs.
@@ -306,7 +308,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) {
// If this tab held url2, then restore this single tab.
if (tab.navigations[0].virtual_url() == url2) {
timestamp = SessionTypesTestHelper::GetTimestamp(tab.navigations[0]);
- service->RestoreEntryById(NULL, tab.id, UNKNOWN);
+ service->RestoreEntryById(NULL, tab.id, host_desktop_type, UNKNOWN);
break;
}
}
@@ -342,6 +344,8 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, WindowWithOneTab) {
service->ClearEntries();
EXPECT_EQ(0U, service->entries().size());
+ chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type();
+
// Close the window.
browser()->window()->Close();
@@ -352,7 +356,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, WindowWithOneTab) {
static_cast<TabRestoreService::Tab*>(service->entries().front());
// Restore the tab.
- service->RestoreEntryById(NULL, tab->id, UNKNOWN);
+ service->RestoreEntryById(NULL, tab->id, host_desktop_type, UNKNOWN);
// Make sure the restore was successful.
EXPECT_EQ(0U, service->entries().size());
diff --git a/chrome/browser/sessions/tab_restore_service.h b/chrome/browser/sessions/tab_restore_service.h
index 74538f0..f55ba2d 100644
--- a/chrome/browser/sessions/tab_restore_service.h
+++ b/chrome/browser/sessions/tab_restore_service.h
@@ -14,6 +14,7 @@
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/browser/sessions/session_id.h"
#include "chrome/browser/sessions/session_types.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "content/public/browser/session_storage_namespace.h"
#include "webkit/glue/window_open_disposition.h"
@@ -152,8 +153,11 @@ class TabRestoreService : public ProfileKeyedService {
// Restores the most recently closed entry. Does nothing if there are no
// entries to restore. If the most recently restored entry is a tab, it is
- // added to |delegate|.
- virtual void RestoreMostRecentEntry(TabRestoreServiceDelegate* delegate) = 0;
+ // added to |delegate|. If a new browser needs to be created for this entry,
+ // it will be created on the desktop specified by |host_desktop_type|.
+ virtual void RestoreMostRecentEntry(
+ TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type) = 0;
// Removes the Tab with id |id| from the list and returns it; ownership is
// passed to the caller.
@@ -163,9 +167,11 @@ class TabRestoreService : public ProfileKeyedService {
// this does nothing. If |delegate| is NULL, this creates a new window for the
// entry. |disposition| is respected, but the attributes (tabstrip index,
// browser window) of the tab when it was closed will be respected if
- // disposition is UNKNOWN.
+ // disposition is UNKNOWN. If a new browser needs to be created for this
+ // entry, it will be created on the desktop specified by |host_desktop_type|.
virtual void RestoreEntryById(TabRestoreServiceDelegate* delegate,
SessionID::id_type id,
+ chrome::HostDesktopType host_desktop_type,
WindowOpenDisposition disposition) = 0;
// Loads the tabs and previous session. This does nothing if the tabs
diff --git a/chrome/browser/sessions/tab_restore_service_delegate.h b/chrome/browser/sessions/tab_restore_service_delegate.h
index a6bba69..96d9ec56 100644
--- a/chrome/browser/sessions/tab_restore_service_delegate.h
+++ b/chrome/browser/sessions/tab_restore_service_delegate.h
@@ -8,7 +8,9 @@
#include <string>
#include <vector>
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_id.h"
+#include "chrome/browser/ui/host_desktop.h"
class Profile;
class TabNavigation;
@@ -63,8 +65,10 @@ class TabRestoreServiceDelegate {
virtual void CloseTab() = 0;
// see Browser::Create
- static TabRestoreServiceDelegate* Create(Profile* profile,
- const std::string& app_name);
+ static TabRestoreServiceDelegate* Create(
+ Profile* profile,
+ chrome::HostDesktopType host_desktop_type,
+ const std::string& app_name);
// see browser::FindBrowserForWebContents
static TabRestoreServiceDelegate* FindDelegateForWebContents(
diff --git a/chrome/browser/sessions/tab_restore_service_helper.cc b/chrome/browser/sessions/tab_restore_service_helper.cc
index 9cf3e32..78e7857 100644
--- a/chrome/browser/sessions/tab_restore_service_helper.cc
+++ b/chrome/browser/sessions/tab_restore_service_helper.cc
@@ -165,11 +165,12 @@ const TabRestoreService::Entries& TabRestoreServiceHelper::entries() const {
}
void TabRestoreServiceHelper::RestoreMostRecentEntry(
- TabRestoreServiceDelegate* delegate) {
+ TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type) {
if (entries_.empty())
return;
- RestoreEntryById(delegate, entries_.front()->id, UNKNOWN);
+ RestoreEntryById(delegate, entries_.front()->id, host_desktop_type, UNKNOWN);
}
TabRestoreService::Tab* TabRestoreServiceHelper::RemoveTabEntryById(
@@ -190,6 +191,7 @@ TabRestoreService::Tab* TabRestoreServiceHelper::RemoveTabEntryById(
void TabRestoreServiceHelper::RestoreEntryById(
TabRestoreServiceDelegate* delegate,
SessionID::id_type id,
+ chrome::HostDesktopType host_desktop_type,
WindowOpenDisposition disposition) {
Entries::iterator entry_iterator = GetEntryIteratorById(id);
if (entry_iterator == entries_.end())
@@ -215,7 +217,7 @@ void TabRestoreServiceHelper::RestoreEntryById(
// new browser into which we restore the tabs.
if (entry->type == TabRestoreService::TAB) {
Tab* tab = static_cast<Tab*>(entry);
- delegate = RestoreTab(*tab, delegate, disposition);
+ delegate = RestoreTab(*tab, delegate, host_desktop_type, disposition);
delegate->ShowBrowserWindow();
} else if (entry->type == TabRestoreService::WINDOW) {
TabRestoreServiceDelegate* current_delegate = delegate;
@@ -225,7 +227,8 @@ void TabRestoreServiceHelper::RestoreEntryById(
// single tab within it. If the entry's ID matches the one to restore, then
// the entire window will be restored.
if (!restoring_tab_in_window) {
- delegate = TabRestoreServiceDelegate::Create(profile_, window->app_name);
+ delegate = TabRestoreServiceDelegate::Create(profile_, host_desktop_type,
+ window->app_name);
for (size_t tab_i = 0; tab_i < window->tabs.size(); ++tab_i) {
const Tab& tab = window->tabs[tab_i];
WebContents* restored_tab =
@@ -254,7 +257,7 @@ void TabRestoreServiceHelper::RestoreEntryById(
tab_i != window->tabs.end(); ++tab_i) {
const Tab& tab = *tab_i;
if (tab.id == id) {
- delegate = RestoreTab(tab, delegate, disposition);
+ delegate = RestoreTab(tab, delegate, host_desktop_type, disposition);
window->tabs.erase(tab_i);
// If restoring the tab leaves the window with nothing else, delete it
// as well.
@@ -421,6 +424,7 @@ void TabRestoreServiceHelper::PopulateTab(
TabRestoreServiceDelegate* TabRestoreServiceHelper::RestoreTab(
const Tab& tab,
TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type,
WindowOpenDisposition disposition) {
if (disposition == CURRENT_TAB && delegate) {
delegate->ReplaceRestoredTab(tab.navigations,
@@ -442,7 +446,8 @@ TabRestoreServiceDelegate* TabRestoreServiceHelper::RestoreTab(
if (delegate && disposition != NEW_WINDOW) {
tab_index = tab.tabstrip_index;
} else {
- delegate = TabRestoreServiceDelegate::Create(profile_, std::string());
+ delegate = TabRestoreServiceDelegate::Create(profile_, host_desktop_type,
+ std::string());
if (tab.has_browser())
UpdateTabBrowserIDs(tab.browser_id, delegate->GetSessionID().id());
}
diff --git a/chrome/browser/sessions/tab_restore_service_helper.h b/chrome/browser/sessions/tab_restore_service_helper.h
index 08b354e..4f8f1e0 100644
--- a/chrome/browser/sessions/tab_restore_service_helper.h
+++ b/chrome/browser/sessions/tab_restore_service_helper.h
@@ -13,6 +13,7 @@
#include "chrome/browser/sessions/session_id.h"
#include "chrome/browser/sessions/session_types.h"
#include "chrome/browser/sessions/tab_restore_service.h"
+#include "chrome/browser/ui/host_desktop.h"
class Profile;
class TabRestoreService;
@@ -78,10 +79,12 @@ class TabRestoreServiceHelper {
void BrowserClosed(TabRestoreServiceDelegate* delegate);
void ClearEntries();
const Entries& entries() const;
- void RestoreMostRecentEntry(TabRestoreServiceDelegate* delegate);
+ void RestoreMostRecentEntry(TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type);
Tab* RemoveTabEntryById(SessionID::id_type id);
void RestoreEntryById(TabRestoreServiceDelegate* delegate,
SessionID::id_type id,
+ chrome::HostDesktopType host_desktop_type,
WindowOpenDisposition disposition);
// Notifies observers the tabs have changed.
@@ -120,10 +123,14 @@ class TabRestoreServiceHelper {
// tab. If |delegate| is NULL, this creates a new window for the entry. This
// returns the TabRestoreServiceDelegate into which the tab was restored.
// |disposition| will be respected, but if it is UNKNOWN then the tab's
- // original attributes will be respected instead.
- TabRestoreServiceDelegate* RestoreTab(const Tab& tab,
- TabRestoreServiceDelegate* delegate,
- WindowOpenDisposition disposition);
+ // original attributes will be respected instead. If a new browser needs to be
+ // created for this tab, it will be created on the desktop specified by
+ // |host_desktop_type|.
+ TabRestoreServiceDelegate* RestoreTab(
+ const Tab& tab,
+ TabRestoreServiceDelegate* delegate,
+ chrome::HostDesktopType host_desktop_type,
+ WindowOpenDisposition disposition);
// Returns true if |tab| has more than one navigation. If |tab| has more
// than one navigation |tab->current_navigation_index| is constrained based