electron/brightray/browser/mac/notification_center_delegate.mm

42 lines
1.2 KiB
Text
Raw Normal View History

2015-12-24 13:55:18 +00:00
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "brightray/browser/mac/notification_center_delegate.h"
2015-12-24 13:55:18 +00:00
#include "brightray/browser/mac/cocoa_notification.h"
#include "brightray/browser/mac/notification_presenter_mac.h"
2015-12-24 13:55:18 +00:00
@implementation NotificationCenterDelegate
- (instancetype)initWithPresenter:(brightray::NotificationPresenterMac*)presenter {
self = [super init];
if (!self)
return nil;
presenter_ = presenter;
return self;
}
2015-12-24 13:55:18 +00:00
- (void)userNotificationCenter:(NSUserNotificationCenter*)center
didDeliverNotification:(NSUserNotification*)notif {
auto notification = presenter_->GetNotification(notif);
2015-12-24 13:55:18 +00:00
if (notification)
notification->NotificationDisplayed();
2015-12-24 13:55:18 +00:00
}
- (void)userNotificationCenter:(NSUserNotificationCenter*)center
didActivateNotification:(NSUserNotification *)notif {
auto notification = presenter_->GetNotification(notif);
2015-12-24 13:55:18 +00:00
if (notification)
notification->NotificationClicked();
2015-12-24 13:55:18 +00:00
}
- (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center
shouldPresentNotification:(NSUserNotification*)notification {
// Display notifications even if the app is active.
return YES;
}
@end