1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_SYNC_SESSIONS2_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
6 #define CHROME_BROWSER_SYNC_SESSIONS2_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/sync/sessions2/sessions_sync_manager.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
19 namespace browser_sync
{
21 // A SessionsSyncManager::LocalEventRouter that drives session sync via
22 // the NotificationService.
23 class NotificationServiceSessionsRouter
24 : public LocalSessionEventRouter
,
25 public content::NotificationObserver
{
27 NotificationServiceSessionsRouter(
29 const syncer::SyncableService::StartSyncFlare
& flare
);
30 virtual ~NotificationServiceSessionsRouter();
32 // content::NotificationObserver implementation.
33 // BrowserSessionProvider -> sync API model change application.
34 virtual void Observe(int type
,
35 const content::NotificationSource
& source
,
36 const content::NotificationDetails
& details
) OVERRIDE
;
38 // SessionsSyncManager::LocalEventRouter implementation.
39 virtual void StartRoutingTo(LocalSessionEventHandler
* handler
) OVERRIDE
;
40 virtual void Stop() OVERRIDE
;
43 // Called when the URL visited in |web_contents| was blocked by the
44 // ManagedUserService. We forward this on to our handler_ via the
45 // normal OnLocalTabModified, but pass through here via a WeakPtr
46 // callback from ManagedUserService and to extract the tab delegate
48 void OnNavigationBlocked(content::WebContents
* web_contents
);
50 LocalSessionEventHandler
* handler_
;
51 content::NotificationRegistrar registrar_
;
52 Profile
* const profile_
;
53 syncer::SyncableService::StartSyncFlare flare_
;
54 base::WeakPtrFactory
<NotificationServiceSessionsRouter
> weak_ptr_factory_
;
56 DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter
);
59 } // namespace browser_sync
61 #endif // CHROME_BROWSER_SYNC_SESSIONS2_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_