2017-04-23 12:16:19 +00:00
|
|
|
// 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 ATOM_BROWSER_API_ATOM_API_NOTIFICATION_H_
|
|
|
|
#define ATOM_BROWSER_API_ATOM_API_NOTIFICATION_H_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "atom/browser/api/trackable_object.h"
|
2017-04-23 22:14:35 +00:00
|
|
|
#include "base/strings/utf_string_conversions.h"
|
2017-05-29 11:18:18 +00:00
|
|
|
#include "brightray/browser/notification.h"
|
2017-05-30 09:06:51 +00:00
|
|
|
#include "brightray/browser/notification_delegate.h"
|
2017-05-29 11:18:18 +00:00
|
|
|
#include "brightray/browser/notification_presenter.h"
|
2017-04-23 12:16:19 +00:00
|
|
|
#include "native_mate/handle.h"
|
|
|
|
#include "ui/gfx/image/image.h"
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
|
|
|
class Notification : public mate::TrackableObject<Notification>,
|
2017-05-30 09:06:51 +00:00
|
|
|
public brightray::NotificationDelegate {
|
2017-04-23 12:16:19 +00:00
|
|
|
public:
|
|
|
|
static mate::WrappableBase* New(mate::Arguments* args);
|
2017-05-30 10:27:24 +00:00
|
|
|
static bool IsSupported();
|
2017-04-23 12:16:19 +00:00
|
|
|
|
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
|
|
|
|
2017-05-30 09:06:51 +00:00
|
|
|
// NotificationDelegate:
|
2017-06-23 10:39:42 +00:00
|
|
|
void NotificationAction(int index) override;
|
2017-05-30 09:06:51 +00:00
|
|
|
void NotificationClick() override;
|
2017-05-31 07:17:29 +00:00
|
|
|
void NotificationReplied(const std::string& reply) override;
|
2017-05-30 09:06:51 +00:00
|
|
|
void NotificationDisplayed() override;
|
|
|
|
void NotificationDestroyed() override;
|
|
|
|
void NotificationClosed() override;
|
2017-04-23 12:16:19 +00:00
|
|
|
|
|
|
|
protected:
|
2017-04-24 03:07:42 +00:00
|
|
|
Notification(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Object> wrapper,
|
|
|
|
mate::Arguments* args);
|
2017-04-23 12:16:19 +00:00
|
|
|
~Notification() override;
|
|
|
|
|
|
|
|
void Show();
|
2017-10-27 03:27:37 +00:00
|
|
|
void Close();
|
2017-04-23 12:16:19 +00:00
|
|
|
|
|
|
|
// Prop Getters
|
2017-06-30 14:04:59 +00:00
|
|
|
base::string16 GetTitle() const;
|
|
|
|
base::string16 GetSubtitle() const;
|
|
|
|
base::string16 GetBody() const;
|
|
|
|
bool GetSilent() const;
|
|
|
|
bool GetHasReply() const;
|
2018-01-22 18:48:12 +00:00
|
|
|
base::string16 GetReplyPlaceholder() const;
|
2017-08-21 20:53:50 +00:00
|
|
|
base::string16 GetSound() const;
|
2018-01-22 18:48:12 +00:00
|
|
|
std::vector<brightray::NotificationAction> GetActions() const;
|
2018-01-16 19:26:41 +00:00
|
|
|
base::string16 GetCloseButtonText() const;
|
2017-04-23 12:16:19 +00:00
|
|
|
|
|
|
|
// Prop Setters
|
2017-05-30 09:06:51 +00:00
|
|
|
void SetTitle(const base::string16& new_title);
|
2017-06-30 13:59:46 +00:00
|
|
|
void SetSubtitle(const base::string16& new_subtitle);
|
2017-05-30 09:06:51 +00:00
|
|
|
void SetBody(const base::string16& new_body);
|
2017-04-23 12:16:19 +00:00
|
|
|
void SetSilent(bool new_silent);
|
|
|
|
void SetHasReply(bool new_has_reply);
|
2018-01-22 18:48:12 +00:00
|
|
|
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
2017-08-21 20:53:50 +00:00
|
|
|
void SetSound(const base::string16& sound);
|
2018-01-22 18:48:12 +00:00
|
|
|
void SetActions(const std::vector<brightray::NotificationAction>& actions);
|
2018-01-16 19:26:41 +00:00
|
|
|
void SetCloseButtonText(const base::string16& text);
|
2017-04-23 12:16:19 +00:00
|
|
|
|
|
|
|
private:
|
2017-05-30 09:06:51 +00:00
|
|
|
base::string16 title_;
|
2017-06-30 13:59:46 +00:00
|
|
|
base::string16 subtitle_;
|
2017-05-30 09:06:51 +00:00
|
|
|
base::string16 body_;
|
2017-04-23 12:16:19 +00:00
|
|
|
gfx::Image icon_;
|
2017-05-30 09:06:51 +00:00
|
|
|
base::string16 icon_path_;
|
2017-04-23 12:16:19 +00:00
|
|
|
bool has_icon_ = false;
|
|
|
|
bool silent_ = false;
|
|
|
|
bool has_reply_ = false;
|
2018-01-22 18:48:12 +00:00
|
|
|
base::string16 reply_placeholder_;
|
2017-08-18 00:28:14 +00:00
|
|
|
base::string16 sound_;
|
2018-01-22 18:48:12 +00:00
|
|
|
std::vector<brightray::NotificationAction> actions_;
|
2018-01-16 19:26:41 +00:00
|
|
|
base::string16 close_button_text_;
|
2017-05-31 07:17:29 +00:00
|
|
|
|
2017-05-29 11:18:18 +00:00
|
|
|
brightray::NotificationPresenter* presenter_;
|
2017-04-23 12:16:19 +00:00
|
|
|
|
2017-05-30 09:06:51 +00:00
|
|
|
base::WeakPtr<brightray::Notification> notification_;
|
2017-04-23 12:16:19 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Notification);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_NOTIFICATION_H_
|