OLD | NEW |
| (Empty) |
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 CHROME_BROWSER_SYNC_GLUE_SYNCED_TAB_DELEGATE_H__ | |
6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_TAB_DELEGATE_H__ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "components/sessions/core/session_id.h" | |
13 #include "components/sync_driver/sessions/synced_window_delegates_getter.h" | |
14 | |
15 class Profile; | |
16 | |
17 namespace content { | |
18 class NavigationEntry; | |
19 class WebContents; | |
20 } | |
21 | |
22 namespace browser_sync { | |
23 class SyncedWindowDelegate; | |
24 | |
25 // A SyncedTabDelegate is used to insulate the sync code from depending | |
26 // directly on WebContents, NavigationController, and the extensions TabHelper. | |
27 class SyncedTabDelegate { | |
28 public: | |
29 virtual ~SyncedTabDelegate(); | |
30 | |
31 // Methods from TabContents. | |
32 | |
33 virtual SessionID::id_type GetWindowId() const = 0; | |
34 virtual SessionID::id_type GetSessionId() const = 0; | |
35 virtual bool IsBeingDestroyed() const = 0; | |
36 virtual Profile* profile() const = 0; | |
37 | |
38 // Method derived from extensions TabHelper. | |
39 | |
40 virtual std::string GetExtensionAppId() const = 0; | |
41 | |
42 // Methods from NavigationController. | |
43 virtual bool IsInitialBlankNavigation() const = 0; | |
44 virtual int GetCurrentEntryIndex() const = 0; | |
45 virtual int GetEntryCount() const = 0; | |
46 virtual int GetPendingEntryIndex() const = 0; | |
47 virtual content::NavigationEntry* GetPendingEntry() const = 0; | |
48 virtual content::NavigationEntry* GetEntryAtIndex(int i) const = 0; | |
49 virtual content::NavigationEntry* GetActiveEntry() const = 0; | |
50 | |
51 // The idea here is that GetEntryAtIndex may not always return the pending | |
52 // entry when asked for the entry at the pending index. These convinience | |
53 // methods will check for this case and then call the correct entry accessor. | |
54 content::NavigationEntry* GetCurrentEntryMaybePending() const; | |
55 content::NavigationEntry* GetEntryAtIndexMaybePending(int i) const; | |
56 | |
57 // Supervised user related methods. | |
58 | |
59 virtual bool ProfileIsSupervised() const = 0; | |
60 virtual const std::vector<const content::NavigationEntry*>* | |
61 GetBlockedNavigations() const = 0; | |
62 | |
63 virtual bool IsPinned() const = 0; | |
64 virtual bool HasWebContents() const = 0; | |
65 virtual content::WebContents* GetWebContents() const = 0; | |
66 | |
67 // Session sync related methods. | |
68 virtual int GetSyncId() const = 0; | |
69 virtual void SetSyncId(int sync_id) = 0; | |
70 | |
71 // Returns true if this tab should be synchronized. | |
72 bool ShouldSync() const; | |
73 | |
74 // Sets the window getter. This must be called before any of the sync or | |
75 // supervised user methods on this class are called. It is currently set when | |
76 // the SyncTabDelegate is retrieved from WebContents via ImplFromWebContents. | |
77 void SetSyncedWindowGetter(scoped_ptr<SyncedWindowDelegatesGetter> getter); | |
78 | |
79 // Returns the SyncedTabDelegate associated with WebContents. | |
80 static SyncedTabDelegate* ImplFromWebContents( | |
81 content::WebContents* web_contents); | |
82 | |
83 protected: | |
84 SyncedTabDelegate(); | |
85 | |
86 // Overridden by the tests to avoid interaction with static state. | |
87 virtual const SyncedWindowDelegate* GetSyncedWindowDelegate() const; | |
88 | |
89 private: | |
90 // A getter for accessing the associated SyncedWindowDelegate. | |
91 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_; | |
92 }; | |
93 | |
94 } // namespace browser_sync | |
95 | |
96 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_TAB_DELEGATE_H__ | |
OLD | NEW |