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

Side by Side Diff: chrome/browser/sync/sessions/notification_service_sessions_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 2014 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_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
6 #define CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
7
8 #include <memory>
9 #include <set>
10
11 #include "base/callback_list.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "components/sync_sessions/sessions_sync_manager.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17
18 class GURL;
19 class Profile;
20
21 namespace content {
22 class WebContents;
23 }
24
25 namespace sync_sessions {
26
27 class SyncSessionsClient;
28
29 // A SessionsSyncManager::LocalEventRouter that drives session sync via
30 // the NotificationService.
31 class NotificationServiceSessionsRouter
32 : public LocalSessionEventRouter,
33 public content::NotificationObserver {
34 public:
35 NotificationServiceSessionsRouter(
36 Profile* profile,
37 SyncSessionsClient* sessions_client_,
38 const syncer::SyncableService::StartSyncFlare& flare);
39 ~NotificationServiceSessionsRouter() override;
40
41 // content::NotificationObserver implementation.
42 // BrowserSessionProvider -> sync API model change application.
43 void Observe(int type,
44 const content::NotificationSource& source,
45 const content::NotificationDetails& details) override;
46
47 // SessionsSyncManager::LocalEventRouter implementation.
48 void StartRoutingTo(LocalSessionEventHandler* handler) override;
49 void Stop() override;
50
51 private:
52 // Called when the URL visited in |web_contents| was blocked by the
53 // SupervisedUserService. We forward this on to our handler_ via the
54 // normal OnLocalTabModified, but pass through here via a WeakPtr
55 // callback from SupervisedUserService and to extract the tab delegate
56 // from WebContents.
57 void OnNavigationBlocked(content::WebContents* web_contents);
58
59 // Called when the favicons for the given page URLs
60 // (e.g. http://www.google.com) and the given icon URL (e.g.
61 // http://www.google.com/favicon.ico) have changed. It is valid to call
62 // OnFaviconsChanged() with non-empty |page_urls| and an empty |icon_url|
63 // and vice versa.
64 void OnFaviconsChanged(const std::set<GURL>& page_urls,
65 const GURL& icon_url);
66
67 LocalSessionEventHandler* handler_;
68 content::NotificationRegistrar registrar_;
69 Profile* const profile_;
70 SyncSessionsClient* const sessions_client_;
71 syncer::SyncableService::StartSyncFlare flare_;
72
73 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&,
74 const GURL&)>::Subscription>
75 favicon_changed_subscription_;
76
77 base::WeakPtrFactory<NotificationServiceSessionsRouter> weak_ptr_factory_;
78
79 DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter);
80 };
81
82 } // namespace sync_sessions
83
84 #endif // CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698