Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: chrome/browser/ui/cocoa/notifications/alert_notification_service.mm

Issue 2709213005: [Mac] Add XPC alerts to GetDisplayedNotifications (Closed)
Patch Set: Rebase after making the whole flow async in a different patch Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698