2017-05-18 15:58:12 -07:00
|
|
|
#include "brightray/browser/win/notification_presenter_win7.h"
|
2017-05-18 15:06:57 -07:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2017-05-18 15:58:12 -07:00
|
|
|
#include "brightray/browser/win/win32_notification.h"
|
2017-03-15 13:56:06 +01:00
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
2017-04-03 10:38:21 +02:00
|
|
|
brightray::Notification* NotificationPresenterWin7::CreateNotificationObject(
|
2017-04-03 12:11:39 +02:00
|
|
|
NotificationDelegate* delegate) {
|
2018-04-17 21:56:12 -04:00
|
|
|
return new Win32Notification(delegate, this);
|
2017-03-15 13:56:06 +01:00
|
|
|
}
|
|
|
|
|
2017-04-03 10:38:21 +02:00
|
|
|
Win32Notification* NotificationPresenterWin7::GetNotificationObjectByRef(
|
2017-04-03 12:11:39 +02:00
|
|
|
const DesktopNotificationController::Notification& ref) {
|
2018-04-17 21:56:12 -04:00
|
|
|
for (auto n : this->notifications()) {
|
|
|
|
auto w32n = static_cast<Win32Notification*>(n);
|
|
|
|
if (w32n->GetRef() == ref)
|
|
|
|
return w32n;
|
|
|
|
}
|
2017-03-15 13:56:06 +01:00
|
|
|
|
2018-04-17 21:56:12 -04:00
|
|
|
return nullptr;
|
2017-03-15 13:56:06 +01:00
|
|
|
}
|
|
|
|
|
2017-04-03 10:38:21 +02:00
|
|
|
Win32Notification* NotificationPresenterWin7::GetNotificationObjectByTag(
|
2017-04-03 12:11:39 +02:00
|
|
|
const std::string& tag) {
|
2018-04-17 21:56:12 -04:00
|
|
|
for (auto n : this->notifications()) {
|
|
|
|
auto w32n = static_cast<Win32Notification*>(n);
|
|
|
|
if (w32n->GetTag() == tag)
|
|
|
|
return w32n;
|
|
|
|
}
|
2017-03-15 13:56:06 +01:00
|
|
|
|
2018-04-17 21:56:12 -04:00
|
|
|
return nullptr;
|
2017-03-15 13:56:06 +01:00
|
|
|
}
|
|
|
|
|
2017-04-03 10:38:21 +02:00
|
|
|
void NotificationPresenterWin7::OnNotificationClicked(
|
2017-04-03 12:11:39 +02:00
|
|
|
Notification& notification) {
|
2018-04-17 21:56:12 -04:00
|
|
|
auto n = GetNotificationObjectByRef(notification);
|
|
|
|
if (n)
|
|
|
|
n->NotificationClicked();
|
2017-03-15 13:56:06 +01:00
|
|
|
}
|
|
|
|
|
2017-04-03 10:38:21 +02:00
|
|
|
void NotificationPresenterWin7::OnNotificationDismissed(
|
2017-04-03 12:11:39 +02:00
|
|
|
Notification& notification) {
|
2018-04-17 21:56:12 -04:00
|
|
|
auto n = GetNotificationObjectByRef(notification);
|
|
|
|
if (n)
|
|
|
|
n->NotificationDismissed();
|
2017-03-15 13:56:06 +01:00
|
|
|
}
|
|
|
|
|
2018-04-17 21:56:12 -04:00
|
|
|
} // namespace brightray
|