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) {
|
2017-03-15 12:56:06 +00:00
|
|
|
return new Win32Notification(delegate, this);
|
|
|
|
}
|
|
|
|
|
2017-04-03 08:38:21 +00:00
|
|
|
Win32Notification* NotificationPresenterWin7::GetNotificationObjectByRef(
|
2017-04-03 10:11:39 +00:00
|
|
|
const DesktopNotificationController::Notification& ref) {
|
2017-04-03 11:34:01 +00:00
|
|
|
for (auto n : this->notifications()) {
|
2017-03-15 12:56:06 +00:00
|
|
|
auto w32n = static_cast<Win32Notification*>(n);
|
2017-04-03 11:34:01 +00:00
|
|
|
if (w32n->GetRef() == ref)
|
2017-03-15 12:56:06 +00:00
|
|
|
return w32n;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-04-03 08:38:21 +00:00
|
|
|
Win32Notification* NotificationPresenterWin7::GetNotificationObjectByTag(
|
2017-04-03 10:11:39 +00:00
|
|
|
const std::string& tag) {
|
2017-04-03 11:34:01 +00:00
|
|
|
for (auto n : this->notifications()) {
|
2017-03-15 12:56:06 +00:00
|
|
|
auto w32n = static_cast<Win32Notification*>(n);
|
2017-04-03 11:34:01 +00:00
|
|
|
if (w32n->GetTag() == tag)
|
2017-03-15 12:56:06 +00:00
|
|
|
return w32n;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-04-03 08:38:21 +00:00
|
|
|
void NotificationPresenterWin7::OnNotificationClicked(
|
2017-04-03 10:11:39 +00:00
|
|
|
Notification& notification) {
|
2017-03-15 12:56:06 +00:00
|
|
|
auto n = GetNotificationObjectByRef(notification);
|
2017-04-03 11:34:01 +00:00
|
|
|
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) {
|
2017-03-15 12:56:06 +00:00
|
|
|
auto n = GetNotificationObjectByRef(notification);
|
2017-04-03 11:34:01 +00:00
|
|
|
if (n) n->NotificationDismissed();
|
2017-03-15 12:56:06 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 11:10:28 +00:00
|
|
|
} // namespace brightray
|