OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "chrome/browser/notifications/stub_alert_dispatcher_mac.h" |
| 6 |
| 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" |
| 9 |
| 10 @implementation StubAlertDispatcher { |
| 11 base::scoped_nsobject<NSMutableArray> alerts_; |
| 12 } |
| 13 |
| 14 - (instancetype)init { |
| 15 if ((self = [super init])) { |
| 16 alerts_.reset([[NSMutableArray alloc] init]); |
| 17 } |
| 18 return self; |
| 19 } |
| 20 |
| 21 - (void)dispatchNotification:(NSDictionary*)data { |
| 22 [alerts_ addObject:data]; |
| 23 } |
| 24 |
| 25 - (void)closeNotificationWithId:(NSString*)notificationId |
| 26 withProfileId:(NSString*)profileId { |
| 27 DCHECK(profileId); |
| 28 DCHECK(notificationId); |
| 29 for (NSDictionary* toast in alerts_.get()) { |
| 30 NSString* toastId = |
| 31 [toast objectForKey:notification_constants::kNotificationId]; |
| 32 NSString* persistentProfileId = |
| 33 [toast objectForKey:notification_constants::kNotificationProfileId]; |
| 34 if ([toastId isEqualToString:notificationId] && |
| 35 [persistentProfileId isEqualToString:profileId]) { |
| 36 [alerts_ removeObject:toast]; |
| 37 break; |
| 38 } |
| 39 } |
| 40 } |
| 41 |
| 42 - (void)closeAllNotifications { |
| 43 [alerts_ removeAllObjects]; |
| 44 } |
| 45 |
| 46 - (NSArray*)alerts { |
| 47 return [[alerts_ copy] autorelease]; |
| 48 } |
| 49 |
| 50 @end |
OLD | NEW |