notification_presenter_win7.cc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "brightray/browser/win/notification_presenter_win7.h"
  2. #include <string>
  3. #include "brightray/browser/win/win32_notification.h"
  4. namespace brightray {
  5. brightray::Notification* NotificationPresenterWin7::CreateNotificationObject(
  6. NotificationDelegate* delegate) {
  7. return new Win32Notification(delegate, this);
  8. }
  9. Win32Notification* NotificationPresenterWin7::GetNotificationObjectByRef(
  10. const DesktopNotificationController::Notification& ref) {
  11. for (auto n : this->notifications()) {
  12. auto w32n = static_cast<Win32Notification*>(n);
  13. if (w32n->GetRef() == ref)
  14. return w32n;
  15. }
  16. return nullptr;
  17. }
  18. Win32Notification* NotificationPresenterWin7::GetNotificationObjectByTag(
  19. const std::string& tag) {
  20. for (auto n : this->notifications()) {
  21. auto w32n = static_cast<Win32Notification*>(n);
  22. if (w32n->GetTag() == tag)
  23. return w32n;
  24. }
  25. return nullptr;
  26. }
  27. void NotificationPresenterWin7::OnNotificationClicked(
  28. Notification& notification) {
  29. auto n = GetNotificationObjectByRef(notification);
  30. if (n)
  31. n->NotificationClicked();
  32. }
  33. void NotificationPresenterWin7::OnNotificationDismissed(
  34. Notification& notification) {
  35. auto n = GetNotificationObjectByRef(notification);
  36. if (n)
  37. n->NotificationDismissed();
  38. }
  39. } // namespace brightray