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

Side by Side Diff: chrome/browser/notifications/stub_alert_dispatcher_mac.mm

Issue 2479143003: Add tests for the XPC client. (Closed)
Patch Set: review Created 4 years, 1 month 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
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698