1// Copyright (c) 2011 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.
4
5#ifndef CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_DELEGATE_H_
6#define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_DELEGATE_H_
7
8#include <string>
9#include <vector>
10
11#include "chrome/browser/sessions/session_id.h"
12
13class Profile;
14class SessionStorageNamespace;
15class TabContents;
16class TabNavigation;
17
18// Objects implement this interface to provide necessary functionality for
19// TabRestoreService to operate. These methods are mostly copies of existing
20// Browser methods.
21class TabRestoreServiceDelegate {
22 public:
23  // see BrowserWindow::Show()
24  virtual void ShowBrowserWindow() = 0;
25
26  // see Browser::session_id()
27  virtual const SessionID& GetSessionID() const = 0;
28
29  // see Browser::tab_count()
30  virtual int GetTabCount() const = 0;
31
32  // see Browser::active_index()
33  virtual int GetSelectedIndex() const = 0;
34
35  // see Browser methods with the same names
36  virtual TabContents* GetTabContentsAt(int index) const = 0;
37  virtual TabContents* GetSelectedTabContents() const = 0;
38  virtual bool IsTabPinned(int index) const = 0;
39  virtual TabContents* AddRestoredTab(
40      const std::vector<TabNavigation>& navigations,
41      int tab_index,
42      int selected_navigation,
43      const std::string& extension_app_id,
44      bool select,
45      bool pin,
46      bool from_last_session,
47      SessionStorageNamespace* storage_namespace) = 0;
48  virtual void ReplaceRestoredTab(
49      const std::vector<TabNavigation>& navigations,
50      int selected_navigation,
51      bool from_last_session,
52      const std::string& extension_app_id,
53      SessionStorageNamespace* session_storage_namespace) = 0;
54  virtual void CloseTab() = 0;
55
56  // see Browser::Create
57  static TabRestoreServiceDelegate* Create(Profile* profile);
58
59  // see BrowserList::GetBrowserForController
60  static TabRestoreServiceDelegate* FindDelegateForController(
61      const NavigationController* controller,
62      int* index);
63
64  // see BrowserList::FindBrowserWithID
65  static TabRestoreServiceDelegate* FindDelegateWithID(
66      SessionID::id_type desired_id);
67
68 protected:
69  virtual ~TabRestoreServiceDelegate() {}
70};
71
72#endif  // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_DELEGATE_H_
73