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"
|
|
|
|
#include "atom/browser/ui/notification_observer.h"
|
2017-04-23 22:14:35 +00:00
|
|
|
#include "base/strings/utf_string_conversions.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>,
|
|
|
|
public NotifictionObserver {
|
|
|
|
public:
|
|
|
|
static mate::WrappableBase* New(mate::Arguments* args);
|
|
|
|
static bool HasID(int id);
|
|
|
|
static Notification* FromID(int id);
|
|
|
|
|
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
|
|
|
|
|
|
|
// NotificationObserver:
|
|
|
|
void OnClicked() override;
|
|
|
|
void OnReplied(std::string reply) override;
|
|
|
|
void OnShown() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Notification(v8::Isolate* isolate, v8::Local<v8::Object> wrapper, mate::Arguments* args);
|
|
|
|
~Notification() override;
|
|
|
|
|
|
|
|
void OnInitialProps();
|
|
|
|
void Show();
|
|
|
|
|
|
|
|
// Prop Getters
|
|
|
|
int GetID();
|
2017-04-23 14:18:31 +00:00
|
|
|
base::string16 GetTitle();
|
|
|
|
base::string16 GetBody();
|
2017-04-23 12:16:19 +00:00
|
|
|
bool GetSilent();
|
2017-04-23 14:18:31 +00:00
|
|
|
base::string16 GetReplyPlaceholder();
|
2017-04-23 12:16:19 +00:00
|
|
|
bool GetHasReply();
|
|
|
|
|
|
|
|
// Prop Setters
|
2017-04-23 14:18:31 +00:00
|
|
|
void SetTitle(base::string16 new_title);
|
|
|
|
void SetBody(base::string16 new_body);
|
2017-04-23 12:16:19 +00:00
|
|
|
void SetSilent(bool new_silent);
|
2017-04-23 14:18:31 +00:00
|
|
|
void SetReplyPlaceholder(base::string16 new_reply_placeholder);
|
2017-04-23 12:16:19 +00:00
|
|
|
void SetHasReply(bool new_has_reply);
|
|
|
|
|
|
|
|
void NotifyPropsUpdated();
|
|
|
|
|
|
|
|
private:
|
2017-04-23 22:14:35 +00:00
|
|
|
base::string16 title_ = base::UTF8ToUTF16("");
|
|
|
|
base::string16 body_ = base::UTF8ToUTF16("");
|
2017-04-23 12:16:19 +00:00
|
|
|
gfx::Image icon_;
|
2017-04-23 22:14:35 +00:00
|
|
|
base::string16 icon_path_ = base::UTF8ToUTF16("");
|
2017-04-23 12:16:19 +00:00
|
|
|
bool has_icon_ = false;
|
|
|
|
bool silent_ = false;
|
2017-04-23 22:14:35 +00:00
|
|
|
base::string16 reply_placeholder_ = base::UTF8ToUTF16("");
|
2017-04-23 12:16:19 +00:00
|
|
|
bool has_reply_ = false;
|
|
|
|
|
|
|
|
int id_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Notification);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_NOTIFICATION_H_
|