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

Side by Side Diff: chrome/browser/sync/sessions/sync_sessions_web_contents_router.h

Issue 2753753005: [sync] WebContentsObserver based sessions notifications (Closed)
Patch Set: [sync] WebContentsObserver based sessions notifications Created 3 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_
6 #define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_
7
8 #include "base/callback_list.h"
9
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
12 // ensure we are notified of tabs being added and moved between tab strips.
13 #if !defined(OS_ANDROID)
Nicolas Zea 2017/03/16 19:57:43 is this pattern of using platform conditional code
Patrick Noland 2017/03/16 20:23:27 I've seen it done both ways(ifdefs and separate fi
Patrick Noland 2017/03/17 00:20:10 I've added a subclass that isolates the android in
14 #include "chrome/browser/ui/browser_list_observer.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
16 #endif // !defined(OS_ANDROID)
17
18 #include "components/keyed_service/core/keyed_service.h"
19 #include "components/sync/model/syncable_service.h"
20 #include "components/sync_sessions/local_session_event_router.h"
21
22 namespace content {
23 class WebContents;
24 } // namespace content
25
26 class Profile;
27
28 namespace sync_sessions {
29
30 // WebContentsObserver-based implementation of LocalSessionEventRouter. This
31 // class is responsible for notifying Sessions Sync when local tabs are
32 // modified. It does this by aggregating the events pushed to it by individual
Nicolas Zea 2017/03/16 19:57:43 it's not actually doing any aggregation right, jus
Patrick Noland 2017/03/16 20:23:27 Right, it's really just routing events from multip
33 // WebContentsObservers, which are scoped to a single WebContents/tab.
34 class SyncSessionsWebContentsRouter : public LocalSessionEventRouter,
35 public KeyedService
36 #if !defined(OS_ANDROID)
37 ,
38 public chrome::BrowserListObserver,
39 public TabStripModelObserver
40 #endif // !defined(OS_ANDROID)
41 {
42 public:
43 explicit SyncSessionsWebContentsRouter(Profile* profile);
44
45 // Notify the router that the tab corresponding to |web_contents| has been
46 // modified in some way.
47 void NotifyTabModified(content::WebContents* web_contents);
48 // Inject a flare that can be used to start sync. See the comment for
49 // StartSyncFlare in syncable_service.h for more.
50 void InjectStartSyncFlare(syncer::SyncableService::StartSyncFlare flare);
51
52 // SessionsSyncManager::LocalEventRouter implementation.
53 void StartRoutingTo(LocalSessionEventHandler* handler) override;
54 void Stop() override;
55
56 // KeyedService implementation.
57 void Shutdown() override;
58
59 protected:
60 ~SyncSessionsWebContentsRouter() override;
61
62 private:
63 #if !defined(OS_ANDROID)
64 // chrome::BrowserListObserver implementation.
65 void OnBrowserAdded(Browser* browser) override;
66 void OnBrowserRemoved(Browser* browser) override;
67 // TabStripModelObserver implementation.
68 void TabInsertedAt(TabStripModel* model,
69 content::WebContents* web_contents,
70 int index,
71 bool foreground) override;
72 #endif // !defined(OS_ANDROID)
73
74 void OnFaviconsChanged(const std::set<GURL>& page_urls, const GURL& icon_url);
75
76 LocalSessionEventHandler* handler_;
Nicolas Zea 2017/03/16 19:57:43 nit: may as well initialize this to nullptr here.
Patrick Noland 2017/03/17 00:20:10 Done.
77 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&,
78 const GURL&)>::Subscription>
79 favicon_changed_subscription_;
80 syncer::SyncableService::StartSyncFlare flare_;
81
82 DISALLOW_COPY_AND_ASSIGN(SyncSessionsWebContentsRouter);
83 };
84
85 } // namespace sync_sessions
86
87 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698