notification.cc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include "brightray/browser/notification.h"
  5. #include "brightray/browser/notification_delegate.h"
  6. #include "brightray/browser/notification_presenter.h"
  7. namespace brightray {
  8. NotificationOptions::NotificationOptions() = default;
  9. NotificationOptions::~NotificationOptions() = default;
  10. Notification::Notification(NotificationDelegate* delegate,
  11. NotificationPresenter* presenter)
  12. : delegate_(delegate), presenter_(presenter), weak_factory_(this) {}
  13. Notification::~Notification() {
  14. if (delegate())
  15. delegate()->NotificationDestroyed();
  16. }
  17. void Notification::NotificationClicked() {
  18. if (delegate())
  19. delegate()->NotificationClick();
  20. Destroy();
  21. }
  22. void Notification::NotificationDismissed() {
  23. if (delegate())
  24. delegate()->NotificationClosed();
  25. Destroy();
  26. }
  27. void Notification::NotificationFailed() {
  28. if (delegate())
  29. delegate()->NotificationFailed();
  30. Destroy();
  31. }
  32. void Notification::Destroy() {
  33. presenter()->RemoveNotification(this);
  34. }
  35. } // namespace brightray