-
Notifications
You must be signed in to change notification settings - Fork 15k
/
electron_api_notification.h
119 lines (98 loc) · 3.69 KB
/
electron_api_notification.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_API_ELECTRON_API_NOTIFICATION_H_
#define SHELL_BROWSER_API_ELECTRON_API_NOTIFICATION_H_
#include <memory>
#include <string>
#include <vector>
#include "base/strings/utf_string_conversions.h"
#include "gin/wrappable.h"
#include "shell/browser/event_emitter_mixin.h"
#include "shell/browser/notifications/notification.h"
#include "shell/browser/notifications/notification_delegate.h"
#include "shell/browser/notifications/notification_presenter.h"
#include "shell/common/gin_helper/cleaned_up_at_exit.h"
#include "shell/common/gin_helper/constructible.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "ui/gfx/image/image.h"
namespace gin {
class Arguments;
template <typename T>
class Handle;
} // namespace gin
namespace electron {
namespace api {
class Notification : public gin::Wrappable<Notification>,
public gin_helper::EventEmitterMixin<Notification>,
public gin_helper::Constructible<Notification>,
public gin_helper::CleanedUpAtExit,
public NotificationDelegate {
public:
static bool IsSupported();
// gin_helper::Constructible
static gin::Handle<Notification> New(gin_helper::ErrorThrower thrower,
gin::Arguments* args);
static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
v8::Isolate*,
v8::Local<v8::ObjectTemplate>);
// NotificationDelegate:
void NotificationAction(int index) override;
void NotificationClick() override;
void NotificationReplied(const std::string& reply) override;
void NotificationDisplayed() override;
void NotificationDestroyed() override;
void NotificationClosed() override;
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
protected:
explicit Notification(gin::Arguments* args);
~Notification() override;
void Show();
void Close();
// Prop Getters
base::string16 GetTitle() const;
base::string16 GetSubtitle() const;
base::string16 GetBody() const;
bool GetSilent() const;
bool GetHasReply() const;
base::string16 GetTimeoutType() const;
base::string16 GetReplyPlaceholder() const;
base::string16 GetUrgency() const;
base::string16 GetSound() const;
std::vector<electron::NotificationAction> GetActions() const;
base::string16 GetCloseButtonText() const;
// Prop Setters
void SetTitle(const base::string16& new_title);
void SetSubtitle(const base::string16& new_subtitle);
void SetBody(const base::string16& new_body);
void SetSilent(bool new_silent);
void SetHasReply(bool new_has_reply);
void SetUrgency(const base::string16& new_urgency);
void SetTimeoutType(const base::string16& new_timeout_type);
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
void SetSound(const base::string16& sound);
void SetActions(const std::vector<electron::NotificationAction>& actions);
void SetCloseButtonText(const base::string16& text);
private:
base::string16 title_;
base::string16 subtitle_;
base::string16 body_;
gfx::Image icon_;
base::string16 icon_path_;
bool has_icon_ = false;
bool silent_ = false;
bool has_reply_ = false;
base::string16 timeout_type_;
base::string16 reply_placeholder_;
base::string16 sound_;
base::string16 urgency_;
std::vector<electron::NotificationAction> actions_;
base::string16 close_button_text_;
electron::NotificationPresenter* presenter_;
base::WeakPtr<electron::Notification> notification_;
DISALLOW_COPY_AND_ASSIGN(Notification);
};
} // namespace api
} // namespace electron
#endif // SHELL_BROWSER_API_ELECTRON_API_NOTIFICATION_H_