OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "chrome/browser/ui/cocoa/notifications/alert_notification_service.h" | 5 #import "chrome/browser/ui/cocoa/notifications/alert_notification_service.h" |
6 | 6 |
7 #import "base/mac/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
8 #import "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h" | 8 #import "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h" |
9 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" | 9 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" |
10 #import "chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h" | 10 #import "chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 - (void)closeAllNotifications { | 56 - (void)closeAllNotifications { |
57 [[NSUserNotificationCenter defaultUserNotificationCenter] | 57 [[NSUserNotificationCenter defaultUserNotificationCenter] |
58 removeAllDeliveredNotifications]; | 58 removeAllDeliveredNotifications]; |
59 [transactionHandler_ closeTransactionIfNeeded]; | 59 [transactionHandler_ closeTransactionIfNeeded]; |
60 } | 60 } |
61 | 61 |
| 62 - (void)getDisplayedAlertIds:(NSString*)profileId |
| 63 withReply:(void (^)(NSArray*))reply { |
| 64 NSUserNotificationCenter* notificationCenter = |
| 65 [NSUserNotificationCenter defaultUserNotificationCenter]; |
| 66 NSMutableArray* notificationIds = [NSMutableArray |
| 67 arrayWithCapacity:[[notificationCenter deliveredNotifications] count]]; |
| 68 for (NSUserNotification* toast in |
| 69 [notificationCenter deliveredNotifications]) { |
| 70 NSString* candidateProfileId = [toast.userInfo |
| 71 objectForKey:notification_constants::kNotificationProfileId]; |
| 72 if ([candidateProfileId isEqualToString:profileId]) { |
| 73 [notificationIds |
| 74 addObject:[toast.userInfo |
| 75 objectForKey:notification_constants::kNotificationId]]; |
| 76 } |
| 77 } |
| 78 reply(notificationIds); |
| 79 } |
| 80 |
62 @end | 81 @end |
OLD | NEW |