| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 - (void)closeAllNotifications { | 78 - (void)closeAllNotifications { |
| 79 DCHECK(didSetExceptionPort_); | 79 DCHECK(didSetExceptionPort_); |
| 80 | 80 |
| 81 [[NSUserNotificationCenter defaultUserNotificationCenter] | 81 [[NSUserNotificationCenter defaultUserNotificationCenter] |
| 82 removeAllDeliveredNotifications]; | 82 removeAllDeliveredNotifications]; |
| 83 [transactionHandler_ closeTransactionIfNeeded]; | 83 [transactionHandler_ closeTransactionIfNeeded]; |
| 84 } | 84 } |
| 85 | 85 |
| 86 - (void)getDisplayedAlertsForProfileId:(NSString*)profileId |
| 87 withReply:(void (^)(NSArray*))reply { |
| 88 NSUserNotificationCenter* notificationCenter = |
| 89 [NSUserNotificationCenter defaultUserNotificationCenter]; |
| 90 NSMutableArray* notificationIds = [NSMutableArray |
| 91 arrayWithCapacity:[[notificationCenter deliveredNotifications] count]]; |
| 92 for (NSUserNotification* toast in |
| 93 [notificationCenter deliveredNotifications]) { |
| 94 NSString* candidateProfileId = [toast.userInfo |
| 95 objectForKey:notification_constants::kNotificationProfileId]; |
| 96 if ([candidateProfileId isEqualToString:profileId]) { |
| 97 [notificationIds |
| 98 addObject:[toast.userInfo |
| 99 objectForKey:notification_constants::kNotificationId]]; |
| 100 } |
| 101 } |
| 102 reply(notificationIds); |
| 103 } |
| 104 |
| 86 @end | 105 @end |
| OLD | NEW |