notification.cc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. Notification::Notification(NotificationDelegate* delegate,
  9. NotificationPresenter* presenter)
  10. : delegate_(delegate),
  11. presenter_(presenter),
  12. weak_factory_(this) {
  13. }
  14. Notification::~Notification() {
  15. if (delegate())
  16. delegate()->NotificationDestroyed();
  17. }
  18. void Notification::NotificationClicked() {
  19. if (delegate())
  20. delegate()->NotificationClick();
  21. Destroy();
  22. }
  23. void Notification::NotificationDismissed() {
  24. if (delegate())
  25. delegate()->NotificationClosed();
  26. Destroy();
  27. }
  28. void Notification::NotificationFailed() {
  29. if (delegate())
  30. delegate()->NotificationFailed();
  31. Destroy();
  32. }
  33. void Notification::Destroy() {
  34. presenter()->RemoveNotification(this);
  35. }
  36. } // namespace brightray