OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/push_messaging/push_messaging_notification_manager.h" | 5 #include "chrome/browser/push_messaging/push_messaging_notification_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <bitset> | 9 #include <bitset> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "content/public/common/notification_resources.h" | 30 #include "content/public/common/notification_resources.h" |
31 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 31 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
33 #include "url/gurl.h" | 33 #include "url/gurl.h" |
34 | 34 |
35 #if BUILDFLAG(ANDROID_JAVA_UI) | 35 #if BUILDFLAG(ANDROID_JAVA_UI) |
36 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 36 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
37 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 37 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
38 #else | 38 #else |
39 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
40 #include "chrome/browser/ui/browser_iterator.h" | 40 #include "chrome/browser/ui/browser_list.h" |
41 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
42 #endif | 42 #endif |
43 | 43 |
44 using content::BrowserThread; | 44 using content::BrowserThread; |
45 using content::NotificationDatabaseData; | 45 using content::NotificationDatabaseData; |
46 using content::NotificationResources; | 46 using content::NotificationResources; |
47 using content::PlatformNotificationContext; | 47 using content::PlatformNotificationContext; |
48 using content::PlatformNotificationData; | 48 using content::PlatformNotificationData; |
49 using content::PushMessagingService; | 49 using content::PushMessagingService; |
50 using content::ServiceWorkerContext; | 50 using content::ServiceWorkerContext; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 int notification_count = success ? data.size() : 0; | 146 int notification_count = success ? data.size() : 0; |
147 bool notification_shown = notification_count > 0; | 147 bool notification_shown = notification_count > 0; |
148 bool notification_needed = true; | 148 bool notification_needed = true; |
149 | 149 |
150 // Sites with a currently visible tab don't need to show notifications. | 150 // Sites with a currently visible tab don't need to show notifications. |
151 #if BUILDFLAG(ANDROID_JAVA_UI) | 151 #if BUILDFLAG(ANDROID_JAVA_UI) |
152 for (auto it = TabModelList::begin(); it != TabModelList::end(); ++it) { | 152 for (auto it = TabModelList::begin(); it != TabModelList::end(); ++it) { |
153 Profile* profile = (*it)->GetProfile(); | 153 Profile* profile = (*it)->GetProfile(); |
154 WebContents* active_web_contents = (*it)->GetActiveWebContents(); | 154 WebContents* active_web_contents = (*it)->GetActiveWebContents(); |
155 #else | 155 #else |
156 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 156 for (auto* browser : *BrowserList::GetInstance()) { |
157 Profile* profile = it->profile(); | 157 Profile* profile = browser->profile(); |
158 WebContents* active_web_contents = | 158 WebContents* active_web_contents = |
159 it->tab_strip_model()->GetActiveWebContents(); | 159 browser->tab_strip_model()->GetActiveWebContents(); |
160 #endif | 160 #endif |
161 if (IsTabVisible(profile, active_web_contents, origin)) { | 161 if (IsTabVisible(profile, active_web_contents, origin)) { |
162 notification_needed = false; | 162 notification_needed = false; |
163 break; | 163 break; |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 // If more than one notification is showing for this Service Worker, close | 167 // If more than one notification is showing for this Service Worker, close |
168 // the default notification if it happens to be part of this group. | 168 // the default notification if it happens to be part of this group. |
169 if (notification_count >= 2) { | 169 if (notification_count >= 2) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 message_handled_closure.Run(); | 334 message_handled_closure.Run(); |
335 return; | 335 return; |
336 } | 336 } |
337 | 337 |
338 PlatformNotificationServiceImpl::GetInstance()->DisplayPersistentNotification( | 338 PlatformNotificationServiceImpl::GetInstance()->DisplayPersistentNotification( |
339 profile_, persistent_notification_id, origin, notification_data, | 339 profile_, persistent_notification_id, origin, notification_data, |
340 NotificationResources()); | 340 NotificationResources()); |
341 | 341 |
342 message_handled_closure.Run(); | 342 message_handled_closure.Run(); |
343 } | 343 } |
OLD | NEW |