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