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" |
11 #include "chrome/browser/sync/glue/sync_start_util.h" | 11 #include "chrome/browser/sync/glue/sync_start_util.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" | 13 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" |
14 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" | 14 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" |
15 #include "chrome/common/features.h" | 15 #include "chrome/common/features.h" |
16 #include "components/history/core/browser/history_service.h" | 16 #include "components/history/core/browser/history_service.h" |
17 #include "components/sync_sessions/sync_sessions_client.h" | 17 #include "components/sync_sessions/sync_sessions_client.h" |
18 #include "components/sync_sessions/synced_tab_delegate.h" | 18 #include "components/sync_sessions/synced_tab_delegate.h" |
19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "extensions/features/features.h" |
25 | 26 |
26 #if BUILDFLAG(ANDROID_JAVA_UI) | 27 #if BUILDFLAG(ANDROID_JAVA_UI) |
27 #include "chrome/browser/android/tab_android.h" | 28 #include "chrome/browser/android/tab_android.h" |
28 #endif | 29 #endif |
29 | 30 |
30 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) | 31 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
31 #include "chrome/browser/supervised_user/supervised_user_service.h" | 32 #include "chrome/browser/supervised_user/supervised_user_service.h" |
32 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 33 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
33 #endif | 34 #endif |
34 | 35 |
35 #if defined(ENABLE_EXTENSIONS) | 36 #if BUILDFLAG(ENABLE_EXTENSIONS) |
36 #include "chrome/browser/extensions/tab_helper.h" | 37 #include "chrome/browser/extensions/tab_helper.h" |
37 #endif | 38 #endif |
38 | 39 |
39 using content::NavigationController; | 40 using content::NavigationController; |
40 using content::WebContents; | 41 using content::WebContents; |
41 | 42 |
42 namespace sync_sessions { | 43 namespace sync_sessions { |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
(...skipping 23 matching lines...) Expand all Loading... |
69 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, | 70 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, |
70 content::NotificationService::AllSources()); | 71 content::NotificationService::AllSources()); |
71 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 72 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
72 content::NotificationService::AllSources()); | 73 content::NotificationService::AllSources()); |
73 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, | 74 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, |
74 content::NotificationService::AllSources()); | 75 content::NotificationService::AllSources()); |
75 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, | 76 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, |
76 content::NotificationService::AllSources()); | 77 content::NotificationService::AllSources()); |
77 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 78 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
78 content::NotificationService::AllSources()); | 79 content::NotificationService::AllSources()); |
79 #if defined(ENABLE_EXTENSIONS) | 80 #if BUILDFLAG(ENABLE_EXTENSIONS) |
80 registrar_.Add(this, | 81 registrar_.Add(this, |
81 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, | 82 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, |
82 content::NotificationService::AllSources()); | 83 content::NotificationService::AllSources()); |
83 #endif | 84 #endif |
84 registrar_.Add(this, | 85 registrar_.Add(this, |
85 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 86 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
86 content::NotificationService::AllBrowserContextsAndSources()); | 87 content::NotificationService::AllBrowserContextsAndSources()); |
87 history::HistoryService* history_service = | 88 history::HistoryService* history_service = |
88 HistoryServiceFactory::GetForProfile(profile, | 89 HistoryServiceFactory::GetForProfile(profile, |
89 ServiceAccessType::EXPLICIT_ACCESS); | 90 ServiceAccessType::EXPLICIT_ACCESS); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 SyncedTabDelegate* tab = | 141 SyncedTabDelegate* tab = |
141 GetSyncedTabDelegateFromWebContents(web_contents); | 142 GetSyncedTabDelegateFromWebContents(web_contents); |
142 if (!tab) | 143 if (!tab) |
143 return; | 144 return; |
144 if (handler_) | 145 if (handler_) |
145 handler_->OnLocalTabModified(tab); | 146 handler_->OnLocalTabModified(tab); |
146 if (!tab->ShouldSync(sessions_client_)) | 147 if (!tab->ShouldSync(sessions_client_)) |
147 return; | 148 return; |
148 break; | 149 break; |
149 } | 150 } |
150 #if defined(ENABLE_EXTENSIONS) | 151 #if BUILDFLAG(ENABLE_EXTENSIONS) |
151 case chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: { | 152 case chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: { |
152 extensions::TabHelper* extension_tab_helper = | 153 extensions::TabHelper* extension_tab_helper = |
153 content::Source<extensions::TabHelper>(source).ptr(); | 154 content::Source<extensions::TabHelper>(source).ptr(); |
154 if (Profile::FromBrowserContext( | 155 if (Profile::FromBrowserContext( |
155 extension_tab_helper->web_contents()->GetBrowserContext()) != | 156 extension_tab_helper->web_contents()->GetBrowserContext()) != |
156 profile_) { | 157 profile_) { |
157 return; | 158 return; |
158 } | 159 } |
159 if (extension_tab_helper->extension_app()) { | 160 if (extension_tab_helper->extension_app()) { |
160 SyncedTabDelegate* tab = GetSyncedTabDelegateFromWebContents( | 161 SyncedTabDelegate* tab = GetSyncedTabDelegateFromWebContents( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 DCHECK(!handler_); | 205 DCHECK(!handler_); |
205 handler_ = handler; | 206 handler_ = handler; |
206 } | 207 } |
207 | 208 |
208 void NotificationServiceSessionsRouter::Stop() { | 209 void NotificationServiceSessionsRouter::Stop() { |
209 weak_ptr_factory_.InvalidateWeakPtrs(); | 210 weak_ptr_factory_.InvalidateWeakPtrs(); |
210 handler_ = nullptr; | 211 handler_ = nullptr; |
211 } | 212 } |
212 | 213 |
213 } // namespace sync_sessions | 214 } // namespace sync_sessions |
OLD | NEW |