sandbox/features.gni
[chromium-dfly.git] / components / sync_sessions / synced_tab_delegate.h
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.
4
5 #ifndef COMPONENTS_SYNC_SESSIONS_SYNCED_TAB_DELEGATE_H__
6 #define COMPONENTS_SYNC_SESSIONS_SYNCED_TAB_DELEGATE_H__
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "components/sessions/core/serialized_navigation_entry.h"
13 #include "components/sessions/core/session_id.h"
14 #include "ui/base/page_transition_types.h"
15 #include "url/gurl.h"
16
17 namespace sync_sessions {
18 class SyncSessionsClient;
19 }
20
21 namespace sync_sessions {
22
23 // A SyncedTabDelegate is used to insulate the sync code from depending
24 // directly on WebContents, NavigationController, and the extensions TabHelper.
25 class SyncedTabDelegate {
26  public:
27   virtual ~SyncedTabDelegate();
28
29   // Methods from TabContents.
30   virtual SessionID GetWindowId() const = 0;
31   // Tab identifier: two tabs with the same ID (even across browser restarts)
32   // will be considered identical. Tab/session restore may or may not be able
33   // to restore this value, which means the opposite is not true: having
34   // distinct IDs does not imply they are distinct tabs.
35   virtual SessionID GetSessionId() const = 0;
36   virtual bool IsBeingDestroyed() const = 0;
37
38   // Method derived from extensions TabHelper.
39   virtual std::string GetExtensionAppId() const = 0;
40
41   // Methods from NavigationController.
42   virtual bool IsInitialBlankNavigation() const = 0;
43   virtual int GetCurrentEntryIndex() const = 0;
44   virtual int GetEntryCount() const = 0;
45   virtual GURL GetVirtualURLAtIndex(int i) const = 0;
46   virtual GURL GetFaviconURLAtIndex(int i) const = 0;
47   virtual ui::PageTransition GetTransitionAtIndex(int i) const = 0;
48   virtual std::string GetPageLanguageAtIndex(int i) const = 0;
49   virtual void GetSerializedNavigationAtIndex(
50       int i,
51       sessions::SerializedNavigationEntry* serialized_entry) const = 0;
52
53   // Supervised user related methods.
54   virtual bool ProfileIsSupervised() const = 0;
55   virtual const std::vector<
56       std::unique_ptr<const sessions::SerializedNavigationEntry>>*
57   GetBlockedNavigations() const = 0;
58
59   // Session sync related methods.
60   virtual bool ShouldSync(SyncSessionsClient* sessions_client) = 0;
61
62   // Whether this tab is a placeholder tab. On some platforms, tabs can be
63   // restored without bringing all their state into memory, and are just
64   // restored as a placeholder. In that case, the previous synced data from that
65   // tab should be preserved.
66   virtual bool IsPlaceholderTab() const = 0;
67
68   // Task IDs represent navigations and relationships between navigations. -1
69   // indicates the Task ID is unknown. A Navigation ID is a Unique ID and
70   // is stored on a NavigationEntry and SerialiedNavigationEntry.
71   virtual int64_t GetTaskIdForNavigationId(int nav_id) const = 0;
72   virtual int64_t GetParentTaskIdForNavigationId(int nav_id) const = 0;
73   virtual int64_t GetRootTaskIdForNavigationId(int nav_id) const = 0;
74
75  protected:
76   SyncedTabDelegate();
77 };
78
79 }  // namespace sync_sessions
80
81 #endif  // COMPONENTS_SYNC_SESSIONS_SYNCED_TAB_DELEGATE_H__