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

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

Issue 2753753005: [sync] WebContentsObserver based sessions notifications (Closed)
Patch Set: use base:MakeUnique, alphabetize 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
14 #include "components/keyed_service/core/keyed_service.h"
15 #include "components/sync/model/syncable_service.h"
16 #include "components/sync_sessions/local_session_event_router.h"
17
18 namespace content {
19 class WebContents;
20 } // namespace content
21
22 class Profile;
23
24 namespace sync_sessions {
25
26 class BrowserListRouterHelper;
27
28 // WebContentsObserver-based implementation of LocalSessionEventRouter. This
29 // 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 // WebContentsObservers, which are scoped to a single WebContents/tab.
32 class SyncSessionsWebContentsRouter : public LocalSessionEventRouter,
33 public KeyedService {
34 public:
35 explicit SyncSessionsWebContentsRouter(Profile* profile);
36
37 // Notify the router that the tab corresponding to |web_contents| has been
38 // modified in some way.
39 void NotifyTabModified(content::WebContents* web_contents);
40 // Inject a flare that can be used to start sync. See the comment for
41 // StartSyncFlare in syncable_service.h for more.
42 void InjectStartSyncFlare(syncer::SyncableService::StartSyncFlare flare);
43
44 // SessionsSyncManager::LocalEventRouter implementation.
45 void StartRoutingTo(LocalSessionEventHandler* handler) override;
46 void Stop() override;
47
48 // KeyedService implementation.
49 void Shutdown() override;
50
51 protected:
52 ~SyncSessionsWebContentsRouter() override;
53
54 private:
55 void OnFaviconsChanged(const std::set<GURL>& page_urls, const GURL& icon_url);
56
57 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&,
58 const GURL&)>::Subscription>
59 favicon_changed_subscription_;
60 syncer::SyncableService::StartSyncFlare flare_;
61 LocalSessionEventHandler* handler_ = nullptr;
62
63 #if !defined(OS_ANDROID)
64 std::unique_ptr<BrowserListRouterHelper> browser_list_helper_;
65 #endif // !defined(OS_ANDROID)
66
67 DISALLOW_COPY_AND_ASSIGN(SyncSessionsWebContentsRouter);
68 };
69
70 } // namespace sync_sessions
71
72 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSIONS_WEB_CONTENTS_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698