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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 #else | 409 #else |
410 bool cancel_by_persistent_id = | 410 bool cancel_by_persistent_id = |
411 GetNotificationDisplayService(profile)->SupportsNotificationCenter(); | 411 GetNotificationDisplayService(profile)->SupportsNotificationCenter(); |
412 #endif | 412 #endif |
413 | 413 |
414 if (cancel_by_persistent_id) { | 414 if (cancel_by_persistent_id) { |
415 // TODO(peter): Remove this conversion when the notification ids are being | 415 // TODO(peter): Remove this conversion when the notification ids are being |
416 // generated by the caller of this method. | 416 // generated by the caller of this method. |
417 GetNotificationDisplayService(profile)->Close( | 417 GetNotificationDisplayService(profile)->Close( |
418 base::Int64ToString(persistent_notification_id)); | 418 base::Int64ToString(persistent_notification_id)); |
| 419 } else { |
| 420 auto iter = persistent_notifications_.find(persistent_notification_id); |
| 421 if (iter == persistent_notifications_.end()) |
| 422 return; |
| 423 GetNotificationDisplayService(profile)->Close(iter->second); |
419 } | 424 } |
420 | 425 |
421 auto iter = persistent_notifications_.find(persistent_notification_id); | 426 persistent_notifications_.erase(persistent_notification_id); |
422 if (iter == persistent_notifications_.end()) | |
423 return; | |
424 | |
425 GetNotificationDisplayService(profile)->Close(iter->second); | |
426 | |
427 persistent_notifications_.erase(iter); | |
428 } | 427 } |
429 | 428 |
430 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( | 429 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( |
431 BrowserContext* browser_context, | 430 BrowserContext* browser_context, |
432 std::set<std::string>* displayed_notifications) { | 431 std::set<std::string>* displayed_notifications) { |
433 DCHECK(displayed_notifications); | 432 DCHECK(displayed_notifications); |
434 | 433 |
435 Profile* profile = Profile::FromBrowserContext(browser_context); | 434 Profile* profile = Profile::FromBrowserContext(browser_context); |
436 if (!profile || profile->AsTestingProfile()) | 435 if (!profile || profile->AsTestingProfile()) |
437 return false; // Tests will not have a message center. | 436 return false; // Tests will not have a message center. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 } | 563 } |
565 #endif | 564 #endif |
566 | 565 |
567 return base::string16(); | 566 return base::string16(); |
568 } | 567 } |
569 | 568 |
570 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( | 569 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( |
571 NotificationDisplayService* display_service) { | 570 NotificationDisplayService* display_service) { |
572 test_display_service_ = display_service; | 571 test_display_service_ = display_service; |
573 } | 572 } |
OLD | NEW |