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