2015-12-24 19:16:07 -07: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.
|
|
|
|
|
2019-06-19 14:46:59 -06:00
|
|
|
#include "shell/browser/notifications/notification.h"
|
2015-12-24 19:16:07 -07:00
|
|
|
|
2019-06-19 14:46:59 -06:00
|
|
|
#include "shell/browser/notifications/notification_delegate.h"
|
|
|
|
#include "shell/browser/notifications/notification_presenter.h"
|
2015-12-24 19:16:07 -07:00
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
namespace electron {
|
2015-12-24 19:16:07 -07:00
|
|
|
|
2018-04-17 17:37:22 -06:00
|
|
|
NotificationOptions::NotificationOptions() = default;
|
|
|
|
NotificationOptions::~NotificationOptions() = default;
|
|
|
|
|
2015-12-24 19:16:07 -07:00
|
|
|
Notification::Notification(NotificationDelegate* delegate,
|
|
|
|
NotificationPresenter* presenter)
|
2021-01-26 11:16:21 -07:00
|
|
|
: delegate_(delegate), presenter_(presenter) {}
|
2015-12-24 19:16:07 -07:00
|
|
|
|
|
|
|
Notification::~Notification() {
|
2017-05-30 03:06:51 -06:00
|
|
|
if (delegate())
|
|
|
|
delegate()->NotificationDestroyed();
|
|
|
|
}
|
|
|
|
|
2020-09-01 19:02:47 -06:00
|
|
|
void Notification::NotificationClicked() {
|
2017-05-30 03:06:51 -06:00
|
|
|
if (delegate())
|
|
|
|
delegate()->NotificationClick();
|
2020-09-01 19:02:47 -06:00
|
|
|
Destroy();
|
2016-04-15 01:14:13 -06:00
|
|
|
}
|
|
|
|
|
2023-10-17 17:33:00 -06:00
|
|
|
void Notification::NotificationDismissed(bool should_destroy) {
|
2017-05-30 03:06:51 -06:00
|
|
|
if (delegate())
|
|
|
|
delegate()->NotificationClosed();
|
2023-10-17 17:33:00 -06:00
|
|
|
|
|
|
|
set_is_dismissed(true);
|
|
|
|
|
|
|
|
if (should_destroy)
|
|
|
|
Destroy();
|
2016-04-15 01:14:13 -06:00
|
|
|
}
|
|
|
|
|
2020-09-29 13:20:10 -06:00
|
|
|
void Notification::NotificationFailed(const std::string& error) {
|
2017-05-30 03:06:51 -06:00
|
|
|
if (delegate())
|
2020-09-29 13:20:10 -06:00
|
|
|
delegate()->NotificationFailed(error);
|
2016-04-15 01:14:13 -06:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2023-10-17 17:33:00 -06:00
|
|
|
void Notification::Remove() {}
|
|
|
|
|
2015-12-24 19:16:07 -07:00
|
|
|
void Notification::Destroy() {
|
|
|
|
presenter()->RemoveNotification(this);
|
|
|
|
}
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
} // namespace electron
|