cocoa_notification.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (c) 2015 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef SHELL_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
  5. #define SHELL_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
  6. #import <Foundation/Foundation.h>
  7. #include <map>
  8. #include <string>
  9. #include <vector>
  10. #include "base/logging.h"
  11. #include "base/mac/scoped_nsobject.h"
  12. #include "shell/browser/notifications/notification.h"
  13. namespace electron {
  14. class CocoaNotification : public Notification {
  15. public:
  16. CocoaNotification(NotificationDelegate* delegate,
  17. NotificationPresenter* presenter);
  18. ~CocoaNotification() override;
  19. // Notification:
  20. void Show(const NotificationOptions& options) override;
  21. void Dismiss() override;
  22. void NotificationDisplayed();
  23. void NotificationReplied(const std::string& reply);
  24. void NotificationActivated();
  25. void NotificationActivated(NSUserNotificationAction* action);
  26. void NotificationDismissed();
  27. NSUserNotification* notification() const { return notification_; }
  28. private:
  29. void LogAction(const char* action);
  30. base::scoped_nsobject<NSUserNotification> notification_;
  31. std::map<std::string, unsigned> additional_action_indices_;
  32. unsigned action_index_;
  33. DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
  34. };
  35. } // namespace electron
  36. #endif // SHELL_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_