OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_ |
6 #define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_ | 6 #define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_ |
7 | 7 |
8 #include "base/callback_list.h" | 8 #include "base/callback_list.h" |
9 | 9 |
10 // Android has no BrowserList or TabStripModel, so we exclude code that refers | 10 // Android has no BrowserList or TabStripModel, so we exclude code that refers |
11 // to those two things. For non-android platforms, this code is used to | 11 // to those two things. For non-android platforms, this code is used to |
12 // ensure we are notified of tabs being added and moved between tab strips. | 12 // ensure we are notified of tabs being added and moved between tab strips. |
13 | 13 |
14 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
15 #include "components/sync/model/syncable_service.h" | 15 #include "components/sync/model/syncable_service.h" |
16 #include "components/sync_sessions/local_session_event_router.h" | 16 #include "components/sync_sessions/local_session_event_router.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class WebContents; | 19 class WebContents; |
20 } // namespace content | 20 } // namespace content |
21 | 21 |
22 class Profile; | 22 class Profile; |
23 | 23 |
24 namespace sync_sessions { | 24 namespace sync_sessions { |
25 | 25 |
26 class BrowserListRouterHelper; | 26 class BrowserListRouterHelper; |
27 class SyncSessionsClient; | |
27 | 28 |
28 // WebContentsObserver-based implementation of LocalSessionEventRouter. This | 29 // WebContentsObserver-based implementation of LocalSessionEventRouter. This |
29 // class is responsible for notifying Sessions Sync when local tabs are | 30 // class is responsible for notifying Sessions Sync when local tabs are |
30 // modified. It does this by forwarding the events pushed to it by individual | 31 // modified. It does this by forwarding the events pushed to it by individual |
31 // WebContentsObservers, which are scoped to a single WebContents/tab. | 32 // WebContentsObservers, which are scoped to a single WebContents/tab. |
32 class SyncSessionsWebContentsRouter : public LocalSessionEventRouter, | 33 class SyncSessionsWebContentsRouter : public LocalSessionEventRouter, |
33 public KeyedService { | 34 public KeyedService { |
34 public: | 35 public: |
35 explicit SyncSessionsWebContentsRouter(Profile* profile); | 36 explicit SyncSessionsWebContentsRouter(Profile* profile); |
36 | 37 |
37 // Notify the router that the tab corresponding to |web_contents| has been | 38 // Notify the router that the tab corresponding to |web_contents| has been |
38 // modified in some way. | 39 // modified in some way. |
39 void NotifyTabModified(content::WebContents* web_contents); | 40 void NotifyTabModified(content::WebContents* web_contents); |
40 // Inject a flare that can be used to start sync. See the comment for | 41 // Inject a flare that can be used to start sync. See the comment for |
41 // StartSyncFlare in syncable_service.h for more. | 42 // StartSyncFlare in syncable_service.h for more. |
42 void InjectStartSyncFlare(syncer::SyncableService::StartSyncFlare flare); | 43 void InjectStartSyncFlare(syncer::SyncableService::StartSyncFlare flare); |
44 void SetSyncSessionsClient(SyncSessionsClient* sessions_client) { | |
skym
2017/04/18 15:50:51
https://google.github.io/styleguide/cppguide.html#
Patrick Noland
2017/04/18 22:37:41
Acknowledged.
| |
45 sessions_client_ = sessions_client; | |
46 } | |
43 | 47 |
44 // SessionsSyncManager::LocalEventRouter implementation. | 48 // SessionsSyncManager::LocalEventRouter implementation. |
45 void StartRoutingTo(LocalSessionEventHandler* handler) override; | 49 void StartRoutingTo(LocalSessionEventHandler* handler) override; |
46 void Stop() override; | 50 void Stop() override; |
47 | 51 |
48 // KeyedService implementation. | 52 // KeyedService implementation. |
49 void Shutdown() override; | 53 void Shutdown() override; |
50 | 54 |
51 protected: | 55 protected: |
52 ~SyncSessionsWebContentsRouter() override; | 56 ~SyncSessionsWebContentsRouter() override; |
53 | 57 |
54 private: | 58 private: |
55 void OnFaviconsChanged(const std::set<GURL>& page_urls, const GURL& icon_url); | 59 void OnFaviconsChanged(const std::set<GURL>& page_urls, const GURL& icon_url); |
56 | 60 |
57 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&, | 61 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&, |
58 const GURL&)>::Subscription> | 62 const GURL&)>::Subscription> |
59 favicon_changed_subscription_; | 63 favicon_changed_subscription_; |
64 SyncSessionsClient* sessions_client_ = nullptr; | |
60 syncer::SyncableService::StartSyncFlare flare_; | 65 syncer::SyncableService::StartSyncFlare flare_; |
61 LocalSessionEventHandler* handler_ = nullptr; | 66 LocalSessionEventHandler* handler_ = nullptr; |
62 | 67 |
63 #if !defined(OS_ANDROID) | 68 #if !defined(OS_ANDROID) |
64 std::unique_ptr<BrowserListRouterHelper> browser_list_helper_; | 69 std::unique_ptr<BrowserListRouterHelper> browser_list_helper_; |
65 #endif // !defined(OS_ANDROID) | 70 #endif // !defined(OS_ANDROID) |
66 | 71 |
67 DISALLOW_COPY_AND_ASSIGN(SyncSessionsWebContentsRouter); | 72 DISALLOW_COPY_AND_ASSIGN(SyncSessionsWebContentsRouter); |
68 }; | 73 }; |
69 | 74 |
70 } // namespace sync_sessions | 75 } // namespace sync_sessions |
71 | 76 |
72 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_ | 77 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_ |
OLD | NEW |