Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Side by Side Diff: components/sync_sessions/synced_tab_delegate.h

Issue 1408643002: [Sync] Componentize synced_tab_delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN, self review Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_TAB_DELEGATE_H__ 5 #ifndef COMPONENTS_SYNC_SESSIONS_SYNCED_TAB_DELEGATE_H__
6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_TAB_DELEGATE_H__ 6 #define COMPONENTS_SYNC_SESSIONS_SYNCED_TAB_DELEGATE_H__
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "components/sessions/core/serialized_navigation_entry.h"
12 #include "components/sessions/core/session_id.h" 13 #include "components/sessions/core/session_id.h"
13 #include "components/sync_driver/sessions/synced_window_delegates_getter.h" 14 #include "components/sync_driver/sessions/synced_window_delegates_getter.h"
15 #include "ui/base/page_transition_types.h"
skym 2015/10/16 16:55:47 Errr, what? I thought ui/ dependencies in componen
Nicolas Zea 2015/10/20 23:14:42 We can include ui/, just not content/ or chrome/
16 #include "url/gurl.h"
14 17
15 class Profile; 18 class Profile;
16 19
17 namespace content { 20 namespace sync_sessions {
18 class NavigationEntry; 21 class SyncSessionsClient;
19 class WebContents;
20 } 22 }
21 23
22 namespace browser_sync { 24 namespace browser_sync {
23 class SyncedWindowDelegate; 25 class SyncedWindowDelegate;
24 26
25 // A SyncedTabDelegate is used to insulate the sync code from depending 27 // A SyncedTabDelegate is used to insulate the sync code from depending
26 // directly on WebContents, NavigationController, and the extensions TabHelper. 28 // directly on WebContents, NavigationController, and the extensions TabHelper.
27 class SyncedTabDelegate { 29 class SyncedTabDelegate {
28 public: 30 public:
29 virtual ~SyncedTabDelegate(); 31 virtual ~SyncedTabDelegate();
30 32
31 // Methods from TabContents. 33 // Methods from TabContents.
32
33 virtual SessionID::id_type GetWindowId() const = 0; 34 virtual SessionID::id_type GetWindowId() const = 0;
34 virtual SessionID::id_type GetSessionId() const = 0; 35 virtual SessionID::id_type GetSessionId() const = 0;
35 virtual bool IsBeingDestroyed() const = 0; 36 virtual bool IsBeingDestroyed() const = 0;
36 virtual Profile* profile() const = 0;
37 37
38 // Method derived from extensions TabHelper. 38 // Method derived from extensions TabHelper.
39
40 virtual std::string GetExtensionAppId() const = 0; 39 virtual std::string GetExtensionAppId() const = 0;
41 40
42 // Methods from NavigationController. 41 // Methods from NavigationController.
43 virtual bool IsInitialBlankNavigation() const = 0; 42 virtual bool IsInitialBlankNavigation() const = 0;
44 virtual int GetCurrentEntryIndex() const = 0; 43 virtual int GetCurrentEntryIndex() const = 0;
45 virtual int GetEntryCount() const = 0; 44 virtual int GetEntryCount() const = 0;
46 virtual int GetPendingEntryIndex() const = 0; 45 virtual GURL GetVirtualURLAtIndex(int i) const = 0;
47 virtual content::NavigationEntry* GetPendingEntry() const = 0; 46 virtual GURL GetFaviconURLAtIndex(int i) const = 0;
48 virtual content::NavigationEntry* GetEntryAtIndex(int i) const = 0; 47 virtual ui::PageTransition GetTransitionAtIndex(int i) const = 0;
49 virtual content::NavigationEntry* GetActiveEntry() const = 0; 48 virtual void GetSerializedNavigationAtIndex(
50 49 int i,
51 // The idea here is that GetEntryAtIndex may not always return the pending 50 sessions::SerializedNavigationEntry* serialized_entry) const = 0;
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 51
57 // Supervised user related methods. 52 // Supervised user related methods.
58
59 virtual bool ProfileIsSupervised() const = 0; 53 virtual bool ProfileIsSupervised() const = 0;
60 virtual const std::vector<const content::NavigationEntry*>* 54 virtual const std::vector<const sessions::SerializedNavigationEntry*>*
61 GetBlockedNavigations() const = 0; 55 GetBlockedNavigations() const = 0;
62 56
63 virtual bool IsPinned() const = 0; 57 virtual bool IsPinned() const = 0;
64 virtual bool HasWebContents() const = 0; 58 virtual bool HasWebContents() const = 0;
blundell 2015/10/16 10:41:26 drive-by nit: This method should be renamed, assum
Nicolas Zea 2015/10/20 23:14:42 It is in fact still used (although this made me re
65 virtual content::WebContents* GetWebContents() const = 0;
66 59
67 // Session sync related methods. 60 // Session sync related methods.
68 virtual int GetSyncId() const = 0; 61 virtual int GetSyncId() const = 0;
69 virtual void SetSyncId(int sync_id) = 0; 62 virtual void SetSyncId(int sync_id) = 0;
70 63
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 64 // 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 65 // supervised user methods on this class are called. It must be set when
76 // the SyncTabDelegate is retrieved from WebContents via ImplFromWebContents. 66 // the SyncTabDelegate implementation is accessed from Sync.
77 void SetSyncedWindowGetter(scoped_ptr<SyncedWindowDelegatesGetter> getter); 67 void SetSyncedWindowGetter(scoped_ptr<SyncedWindowDelegatesGetter> getter);
78 68
79 // Returns the SyncedTabDelegate associated with WebContents. 69 // Get the synced window delegate for this tab.
80 static SyncedTabDelegate* ImplFromWebContents( 70 const SyncedWindowDelegate* GetSyncedWindowDelegate() const;
81 content::WebContents* web_contents);
82 71
83 protected: 72 protected:
84 SyncedTabDelegate(); 73 SyncedTabDelegate();
85 74
86 // Overridden by the tests to avoid interaction with static state.
87 virtual const SyncedWindowDelegate* GetSyncedWindowDelegate() const;
88
89 private: 75 private:
90 // A getter for accessing the associated SyncedWindowDelegate. 76 // A getter for accessing the associated SyncedWindowDelegate.
91 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_; 77 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_;
92 }; 78 };
93 79
94 } // namespace browser_sync 80 } // namespace browser_sync
95 81
96 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_TAB_DELEGATE_H__ 82 #endif // COMPONENTS_SYNC_SESSIONS_SYNCED_TAB_DELEGATE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698