2018-10-17 18:01:11 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "atom/browser/notifications/win/notification_presenter_win7.h"
|
2017-05-18 22:06:57 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2018-10-17 18:01:11 +00:00
|
|
|
#include "atom/browser/notifications/win/win32_notification.h"
|
2017-03-15 12:56:06 +00:00
|
|
|
|
2018-10-17 18:01:11 +00:00
|
|
|
namespace atom {
|
2017-03-15 12:56:06 +00:00
|
|
|
|
2018-10-17 18:01:11 +00:00
|
|
|
atom::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-06-21 23:45:45 +00:00
|
|
|
for (auto* n : this->notifications()) {
|
|
|
|
auto* w32n = static_cast<Win32Notification*>(n);
|
2018-04-18 01:56:12 +00:00
|
|
|
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-06-21 23:45:45 +00:00
|
|
|
for (auto* n : this->notifications()) {
|
|
|
|
auto* w32n = static_cast<Win32Notification*>(n);
|
2018-04-18 01:56:12 +00:00
|
|
|
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(
|
2018-10-17 18:01:11 +00:00
|
|
|
const Notification& notification) {
|
2018-06-21 23:45:45 +00:00
|
|
|
auto* n = GetNotificationObjectByRef(notification);
|
2018-04-18 01:56:12 +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(
|
2018-10-17 18:01:11 +00:00
|
|
|
const Notification& notification) {
|
2018-06-21 23:45:45 +00:00
|
|
|
auto* n = GetNotificationObjectByRef(notification);
|
2018-04-18 01:56:12 +00:00
|
|
|
if (n)
|
|
|
|
n->NotificationDismissed();
|
2017-03-15 12:56:06 +00:00
|
|
|
}
|
|
|
|
|
2018-10-17 18:01:11 +00:00
|
|
|
} // namespace atom
|