1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_DELEGATE_H_
6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_DELEGATE_H_
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/host_desktop.h"
13 #include "components/sessions/session_id.h"
18 class NavigationController
;
19 class SessionStorageNamespace
;
24 class SerializedNavigationEntry
;
27 // Objects implement this interface to provide necessary functionality for
28 // TabRestoreService to operate. These methods are mostly copies of existing
30 class TabRestoreServiceDelegate
{
32 // see BrowserWindow::Show()
33 virtual void ShowBrowserWindow() = 0;
35 // see Browser::session_id()
36 virtual const SessionID
& GetSessionID() const = 0;
38 // see Browser::tab_count()
39 virtual int GetTabCount() const = 0;
41 // see Browser::active_index()
42 virtual int GetSelectedIndex() const = 0;
44 // see Browser::app_name()
45 virtual std::string
GetAppName() const = 0;
47 // see Browser methods with the same names
48 virtual content::WebContents
* GetWebContentsAt(int index
) const = 0;
49 virtual content::WebContents
* GetActiveWebContents() const = 0;
50 virtual bool IsTabPinned(int index
) const = 0;
51 virtual content::WebContents
* AddRestoredTab(
52 const std::vector
<sessions::SerializedNavigationEntry
>& navigations
,
54 int selected_navigation
,
55 const std::string
& extension_app_id
,
58 bool from_last_session
,
59 content::SessionStorageNamespace
* storage_namespace
,
60 const std::string
& user_agent_override
) = 0;
61 virtual content::WebContents
* ReplaceRestoredTab(
62 const std::vector
<sessions::SerializedNavigationEntry
>& navigations
,
63 int selected_navigation
,
64 bool from_last_session
,
65 const std::string
& extension_app_id
,
66 content::SessionStorageNamespace
* session_storage_namespace
,
67 const std::string
& user_agent_override
) = 0;
68 virtual void CloseTab() = 0;
70 // see Browser::Create
71 static TabRestoreServiceDelegate
* Create(
73 chrome::HostDesktopType host_desktop_type
,
74 const std::string
& app_name
);
76 // see browser::FindBrowserForWebContents
77 static TabRestoreServiceDelegate
* FindDelegateForWebContents(
78 const content::WebContents
* contents
);
80 // see chrome::FindBrowserWithID
81 // Returns the TabRestoreServiceDelegate of the Browser with |desired_id| if
82 // such a Browser exists and is on the desktop defined by |host_desktop_type|.
83 static TabRestoreServiceDelegate
* FindDelegateWithID(
84 SessionID::id_type desired_id
,
85 chrome::HostDesktopType host_desktop_type
);
88 virtual ~TabRestoreServiceDelegate() {}
91 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_DELEGATE_H_