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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 | 372 |
373 Profile* profile = Profile::FromBrowserContext(browser_context); | 373 Profile* profile = Profile::FromBrowserContext(browser_context); |
374 DCHECK(profile); | 374 DCHECK(profile); |
375 | 375 |
376 closed_notifications_.insert(notification_id); | 376 closed_notifications_.insert(notification_id); |
377 | 377 |
378 GetNotificationDisplayService(profile)->Close(NotificationCommon::PERSISTENT, | 378 GetNotificationDisplayService(profile)->Close(NotificationCommon::PERSISTENT, |
379 notification_id); | 379 notification_id); |
380 } | 380 } |
381 | 381 |
382 bool PlatformNotificationServiceImpl::GetDisplayedNotifications( | 382 void PlatformNotificationServiceImpl::GetDisplayedNotifications( |
383 BrowserContext* browser_context, | 383 BrowserContext* browser_context, |
384 std::set<std::string>* displayed_notifications) { | 384 const NotificationResultCallback& callback) { |
385 DCHECK(displayed_notifications); | |
386 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 385 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
387 | 386 |
388 Profile* profile = Profile::FromBrowserContext(browser_context); | 387 Profile* profile = Profile::FromBrowserContext(browser_context); |
389 if (!profile || profile->AsTestingProfile()) | 388 // Tests will not have a message center. |
390 return false; // Tests will not have a message center. | 389 if (!profile || profile->AsTestingProfile()) { |
391 | 390 std::unique_ptr<std::set<std::string>> displayedNotifications = |
Peter Beverloo
2017/03/15 18:07:50
displayed_notifications or delete per the comment
Miguel Garcia
2017/03/16 14:57:42
Done.
| |
392 return GetNotificationDisplayService(profile)->GetDisplayed( | 391 base::MakeUnique<std::set<std::string>>(); |
393 displayed_notifications); | 392 content::BrowserThread::PostTask( |
393 content::BrowserThread::UI, FROM_HERE, | |
394 base::Bind(callback, base::Passed(&displayedNotifications), | |
395 false /* supports getting displayed notifications */)); | |
Peter Beverloo
2017/03/15 18:07:50
I'd just take the easy path here and use:
callb
Miguel Garcia
2017/03/16 14:57:42
Done.
| |
396 return; | |
397 } | |
398 GetNotificationDisplayService(profile)->GetDisplayed(callback); | |
394 } | 399 } |
395 | 400 |
396 void PlatformNotificationServiceImpl::OnClickEventDispatchComplete( | 401 void PlatformNotificationServiceImpl::OnClickEventDispatchComplete( |
397 content::PersistentNotificationStatus status) { | 402 content::PersistentNotificationStatus status) { |
398 UMA_HISTOGRAM_ENUMERATION( | 403 UMA_HISTOGRAM_ENUMERATION( |
399 "Notifications.PersistentWebNotificationClickResult", status, | 404 "Notifications.PersistentWebNotificationClickResult", status, |
400 content::PersistentNotificationStatus:: | 405 content::PersistentNotificationStatus:: |
401 PERSISTENT_NOTIFICATION_STATUS_MAX); | 406 PERSISTENT_NOTIFICATION_STATUS_MAX); |
402 #if BUILDFLAG(ENABLE_BACKGROUND) | 407 #if BUILDFLAG(ENABLE_BACKGROUND) |
403 DCHECK_GT(pending_click_dispatch_events_, 0); | 408 DCHECK_GT(pending_click_dispatch_events_, 0); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 } | 527 } |
523 #endif | 528 #endif |
524 | 529 |
525 return base::string16(); | 530 return base::string16(); |
526 } | 531 } |
527 | 532 |
528 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( | 533 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( |
529 NotificationDisplayService* display_service) { | 534 NotificationDisplayService* display_service) { |
530 test_display_service_ = display_service; | 535 test_display_service_ = display_service; |
531 } | 536 } |
OLD | NEW |