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

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

Issue 2047643003: DO NOT SUBMIT. Implement an XPCService for notifications. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge to use AlertNotificationService Created 4 years, 5 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
(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 <AppKit/AppKit.h>
6 #import <Foundation/Foundation.h>
7
8 #import "chrome/browser/ui/cocoa/notifications/notification_service_delegate.h"
9
10 #include "base/mac/scoped_nsobject.h"
11 #import "chrome/browser/ui/cocoa/notifications/alert_notification_service.h"
12 #import "chrome/browser/ui/cocoa/notifications/notification_delivery.h"
13 #import "chrome/browser/ui/cocoa/notifications/notification_response_builder_mac .h"
14
15 @class NSUserNotification;
16 @class NSUserNotificationCenter;
17
18 @implementation ServiceDelegate
19
20 @synthesize connection = _connection;
21
22 - (instancetype)init {
23 if (self = [super init]) {
24 [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
25 }
26 return self;
27 }
28
29 - (BOOL)listener:(NSXPCListener*)listener
30 shouldAcceptNewConnection:(NSXPCConnection*)newConnection {
31 newConnection.exportedInterface =
32 [NSXPCInterface interfaceWithProtocol:@protocol(NotificationDelivery)];
33 [newConnection.exportedInterface
34 setClasses:[NSSet setWithObjects:[NSDictionary class], [NSImage class],
35 [NSNumber class], [NSString class],
36 nil]
37 forSelector:@selector(deliverNotification:)
38 argumentIndex:0
39 ofReply:NO];
40
41 base::scoped_nsobject<AlertNotificationService> object(
42 [[AlertNotificationService alloc] init]);
43 newConnection.exportedObject = object.get();
44 newConnection.remoteObjectInterface =
45 [NSXPCInterface interfaceWithProtocol:@protocol(NotificationReply)];
46 _connection = newConnection;
47 [newConnection resume];
48
49 return YES;
50 }
51
52 // NSUserNotification center delegate
53 - (void)userNotificationCenter:(NSUserNotificationCenter*)center
54 didActivateNotification:(NSUserNotification*)notification {
55 NSDictionary* response =
56 [NotificationResponseBuilder buildDictionary:notification];
57 [[_connection remoteObjectProxy] notificationClick:response];
58 }
59
60 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698