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/notifications/platform_notification_service_impl.h" | 5 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
26 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
27 #include "components/content_settings/core/browser/host_content_settings_map.h" | 27 #include "components/content_settings/core/browser/host_content_settings_map.h" |
28 #include "components/content_settings/core/common/content_settings.h" | 28 #include "components/content_settings/core/common/content_settings.h" |
29 #include "components/content_settings/core/common/content_settings_types.h" | 29 #include "components/content_settings/core/common/content_settings_types.h" |
30 #include "components/prefs/pref_service.h" | 30 #include "components/prefs/pref_service.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/desktop_notification_delegate.h" | 32 #include "content/public/browser/desktop_notification_delegate.h" |
33 #include "content/public/browser/notification_event_dispatcher.h" | 33 #include "content/public/browser/notification_event_dispatcher.h" |
34 #include "content/public/browser/notification_id_verifier.h" | |
34 #include "content/public/browser/permission_type.h" | 35 #include "content/public/browser/permission_type.h" |
35 #include "content/public/browser/user_metrics.h" | 36 #include "content/public/browser/user_metrics.h" |
36 #include "content/public/common/notification_resources.h" | 37 #include "content/public/common/notification_resources.h" |
37 #include "content/public/common/platform_notification_data.h" | 38 #include "content/public/common/platform_notification_data.h" |
38 #include "extensions/features/features.h" | 39 #include "extensions/features/features.h" |
39 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
40 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
41 #include "ui/message_center/notification.h" | 42 #include "ui/message_center/notification.h" |
42 #include "ui/message_center/notification_types.h" | 43 #include "ui/message_center/notification_types.h" |
43 #include "ui/message_center/notifier_settings.h" | 44 #include "ui/message_center/notifier_settings.h" |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 | 364 |
364 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( | 365 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( |
365 BrowserContext* browser_context, | 366 BrowserContext* browser_context, |
366 std::set<std::string>* displayed_notifications) { | 367 std::set<std::string>* displayed_notifications) { |
367 DCHECK(displayed_notifications); | 368 DCHECK(displayed_notifications); |
368 | 369 |
369 Profile* profile = Profile::FromBrowserContext(browser_context); | 370 Profile* profile = Profile::FromBrowserContext(browser_context); |
370 if (!profile || profile->AsTestingProfile()) | 371 if (!profile || profile->AsTestingProfile()) |
371 return false; // Tests will not have a message center. | 372 return false; // Tests will not have a message center. |
372 | 373 |
373 // TODO(peter): Filter for persistent notifications only. | 374 // Filter out non persistent notifications. |
374 return GetNotificationDisplayService(profile)->GetDisplayed( | 375 if (GetNotificationDisplayService(profile)->GetDisplayed( |
375 displayed_notifications); | 376 displayed_notifications)) { |
377 for (auto it = displayed_notifications->begin(); | |
378 it != displayed_notifications->end();) { | |
379 if (content::NotificationIdVerifier::IsNonPersistentNotification(*it)) { | |
380 it = displayed_notifications->erase(it); | |
381 } else { | |
382 ++it; | |
383 } | |
384 } | |
385 return true; | |
386 } | |
387 return false; | |
Peter Beverloo
2016/12/02 13:43:34
I think we should dismiss the previous TODO and ju
Miguel Garcia
2016/12/06 12:01:18
That's a good plan, I renamed the method in the pr
| |
376 } | 388 } |
377 | 389 |
378 void PlatformNotificationServiceImpl::OnClickEventDispatchComplete( | 390 void PlatformNotificationServiceImpl::OnClickEventDispatchComplete( |
379 content::PersistentNotificationStatus status) { | 391 content::PersistentNotificationStatus status) { |
380 UMA_HISTOGRAM_ENUMERATION( | 392 UMA_HISTOGRAM_ENUMERATION( |
381 "Notifications.PersistentWebNotificationClickResult", status, | 393 "Notifications.PersistentWebNotificationClickResult", status, |
382 content::PersistentNotificationStatus:: | 394 content::PersistentNotificationStatus:: |
383 PERSISTENT_NOTIFICATION_STATUS_MAX); | 395 PERSISTENT_NOTIFICATION_STATUS_MAX); |
384 #if BUILDFLAG(ENABLE_BACKGROUND) | 396 #if BUILDFLAG(ENABLE_BACKGROUND) |
385 DCHECK_GT(pending_click_dispatch_events_, 0); | 397 DCHECK_GT(pending_click_dispatch_events_, 0); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 } | 509 } |
498 #endif | 510 #endif |
499 | 511 |
500 return base::string16(); | 512 return base::string16(); |
501 } | 513 } |
502 | 514 |
503 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( | 515 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( |
504 NotificationDisplayService* display_service) { | 516 NotificationDisplayService* display_service) { |
505 test_display_service_ = display_service; | 517 test_display_service_ = display_service; |
506 } | 518 } |
OLD | NEW |