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 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" | 5 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 32 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
33 #endif | 33 #endif |
34 | 34 |
35 #if defined(ENABLE_EXTENSIONS) | 35 #if defined(ENABLE_EXTENSIONS) |
36 #include "chrome/browser/extensions/tab_helper.h" | 36 #include "chrome/browser/extensions/tab_helper.h" |
37 #endif | 37 #endif |
38 | 38 |
39 using content::NavigationController; | 39 using content::NavigationController; |
40 using content::WebContents; | 40 using content::WebContents; |
41 | 41 |
42 namespace browser_sync { | 42 namespace sync_sessions { |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 SyncedTabDelegate* GetSyncedTabDelegateFromWebContents( | 46 SyncedTabDelegate* GetSyncedTabDelegateFromWebContents( |
47 content::WebContents* web_contents) { | 47 content::WebContents* web_contents) { |
48 #if BUILDFLAG(ANDROID_JAVA_UI) | 48 #if BUILDFLAG(ANDROID_JAVA_UI) |
49 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | 49 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
50 return tab ? tab->GetSyncedTabDelegate() : nullptr; | 50 return tab ? tab->GetSyncedTabDelegate() : nullptr; |
51 #else | 51 #else |
52 SyncedTabDelegate* delegate = | 52 SyncedTabDelegate* delegate = |
53 TabContentsSyncedTabDelegate::FromWebContents(web_contents); | 53 TabContentsSyncedTabDelegate::FromWebContents(web_contents); |
54 return delegate; | 54 return delegate; |
55 #endif | 55 #endif |
56 } | 56 } |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
60 NotificationServiceSessionsRouter::NotificationServiceSessionsRouter( | 60 NotificationServiceSessionsRouter::NotificationServiceSessionsRouter( |
61 Profile* profile, | 61 Profile* profile, |
62 sync_sessions::SyncSessionsClient* sessions_client, | 62 SyncSessionsClient* sessions_client, |
63 const syncer::SyncableService::StartSyncFlare& flare) | 63 const syncer::SyncableService::StartSyncFlare& flare) |
64 : handler_(NULL), | 64 : handler_(NULL), |
65 profile_(profile), | 65 profile_(profile), |
66 sessions_client_(sessions_client), | 66 sessions_client_(sessions_client), |
67 flare_(flare), | 67 flare_(flare), |
68 weak_ptr_factory_(this) { | 68 weak_ptr_factory_(this) { |
69 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, | 69 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, |
70 content::NotificationService::AllSources()); | 70 content::NotificationService::AllSources()); |
71 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 71 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
72 content::NotificationService::AllSources()); | 72 content::NotificationService::AllSources()); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 LocalSessionEventHandler* handler) { | 203 LocalSessionEventHandler* handler) { |
204 DCHECK(!handler_); | 204 DCHECK(!handler_); |
205 handler_ = handler; | 205 handler_ = handler; |
206 } | 206 } |
207 | 207 |
208 void NotificationServiceSessionsRouter::Stop() { | 208 void NotificationServiceSessionsRouter::Stop() { |
209 weak_ptr_factory_.InvalidateWeakPtrs(); | 209 weak_ptr_factory_.InvalidateWeakPtrs(); |
210 handler_ = NULL; | 210 handler_ = NULL; |
211 } | 211 } |
212 | 212 |
213 } // namespace browser_sync | 213 } // namespace sync_sessions |
OLD | NEW |