summaryrefslogtreecommitdiff
path: root/chromium/components/sync_sessions/synced_window_delegate.h
blob: af99cacf0fc7dc8c0065ff94421e1c8b316717c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 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.

#ifndef COMPONENTS_SYNC_SESSIONS_SYNCED_WINDOW_DELEGATE_H_
#define COMPONENTS_SYNC_SESSIONS_SYNCED_WINDOW_DELEGATE_H_

#include <set>

#include "components/sessions/core/session_id.h"

namespace sync_sessions {

class SyncedTabDelegate;

// A SyncedWindowDelegate is used to insulate the sync code from depending
// directly on Browser and BrowserList.
class SyncedWindowDelegate {
 public:
  // Methods originating from Browser.

  // Returns true iff this browser has a visible window representation
  // associated with it. Sometimes, if a window is being created/removed the
  // model object may exist without its UI counterpart.
  virtual bool HasWindow() const = 0;

  // see Browser::session_id
  virtual SessionID::id_type GetSessionId() const = 0;

  // see Browser::tab_count
  virtual int GetTabCount() const = 0;

  // see Browser::active_index
  virtual int GetActiveIndex() const = 0;

  // see Browser::is_app
  virtual bool IsApp() const = 0;

  // see Browser::is_type_tabbed
  virtual bool IsTypeTabbed() const = 0;

  // see Browser::is_type_popup
  virtual bool IsTypePopup() const = 0;

  // Methods derivated from Browser

  // Returns true iff the provided tab is currently "pinned" in the tab strip.
  virtual bool IsTabPinned(const SyncedTabDelegate* tab) const = 0;

  // see TabStripModel::GetWebContentsAt
  virtual SyncedTabDelegate* GetTabAt(int index) const = 0;

  // Return the tab id for the tab at |index|.
  virtual SessionID::id_type GetTabIdAt(int index) const = 0;

  // Return true if we are currently restoring sessions asynchronously.
  virtual bool IsSessionRestoreInProgress() const = 0;

  // Helper methods.

  // Return true if this window should be considered for syncing.
  virtual bool ShouldSync() const = 0;

 protected:
  virtual ~SyncedWindowDelegate() {}
};

}  // namespace sync_sessions

#endif  // COMPONENTS_SYNC_SESSIONS_SYNCED_WINDOW_DELEGATE_H_