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

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

Issue 2709213005: [Mac] Add XPC alerts to GetDisplayedNotifications (Closed)
Patch Set: review Created 3 years, 8 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 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #import "base/mac/scoped_nsobject.h" 9 #import "base/mac/scoped_nsobject.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 - (void)closeAllNotifications { 108 - (void)closeAllNotifications {
109 DCHECK(didSetExceptionPort_); 109 DCHECK(didSetExceptionPort_);
110 110
111 [[NSUserNotificationCenter defaultUserNotificationCenter] 111 [[NSUserNotificationCenter defaultUserNotificationCenter]
112 removeAllDeliveredNotifications]; 112 removeAllDeliveredNotifications];
113 [transactionHandler_ closeTransactionIfNeeded]; 113 [transactionHandler_ closeTransactionIfNeeded];
114 } 114 }
115 115
116 - (void)getDisplayedAlertsForProfileId:(NSString*)profileId
117 andIncognito:(BOOL)incognito
118 withReply:(void (^)(NSArray*))reply {
119 NSUserNotificationCenter* notificationCenter =
120 [NSUserNotificationCenter defaultUserNotificationCenter];
121 NSMutableArray* notificationIds = [NSMutableArray
122 arrayWithCapacity:[[notificationCenter deliveredNotifications] count]];
123 for (NSUserNotification* toast in
124 [notificationCenter deliveredNotifications]) {
125 NSString* candidateProfileId = [toast.userInfo
126 objectForKey:notification_constants::kNotificationProfileId];
127 BOOL incognitoNotification = [[toast.userInfo
128 objectForKey:notification_constants::kNotificationIncognito] boolValue];
129 if ([candidateProfileId isEqualToString:profileId] &&
130 incognito == incognitoNotification) {
131 [notificationIds
132 addObject:[toast.userInfo
133 objectForKey:notification_constants::kNotificationId]];
134 }
135 }
136 reply(notificationIds);
137 }
138
116 @end 139 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698