Coding style fixes
This commit is contained in:
parent
227a2bd5dc
commit
5fa2831756
7 changed files with 23 additions and 33 deletions
|
@ -4,24 +4,16 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_notification.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/browser_client.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "ui/gfx/codec/png_codec.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -33,6 +25,8 @@ Notification::Notification(v8::Isolate* isolate,
|
|||
mate::Arguments* args) {
|
||||
InitWith(isolate, wrapper);
|
||||
|
||||
presenter_ = brightray::BrowserClient::Get()->GetNotificationPresenter();
|
||||
|
||||
mate::Dictionary opts;
|
||||
if (args->GetNext(&opts)) {
|
||||
opts.Get("title", &title_);
|
||||
|
@ -45,10 +39,10 @@ Notification::Notification(v8::Isolate* isolate,
|
|||
opts.Get("replyPlaceholder", &reply_placeholder_);
|
||||
opts.Get("hasReply", &has_reply_);
|
||||
}
|
||||
OnInitialProps();
|
||||
}
|
||||
|
||||
Notification::~Notification() {
|
||||
if (notification_)
|
||||
notification_->set_delegate(nullptr);
|
||||
}
|
||||
|
||||
|
@ -65,15 +59,19 @@ mate::WrappableBase* Notification::New(mate::Arguments* args) {
|
|||
base::string16 Notification::GetTitle() {
|
||||
return title_;
|
||||
}
|
||||
|
||||
base::string16 Notification::GetBody() {
|
||||
return body_;
|
||||
}
|
||||
|
||||
bool Notification::GetSilent() {
|
||||
return silent_;
|
||||
}
|
||||
|
||||
base::string16 Notification::GetReplyPlaceholder() {
|
||||
return reply_placeholder_;
|
||||
}
|
||||
|
||||
bool Notification::GetHasReply() {
|
||||
return has_reply_;
|
||||
}
|
||||
|
@ -82,15 +80,19 @@ bool Notification::GetHasReply() {
|
|||
void Notification::SetTitle(const base::string16& new_title) {
|
||||
title_ = new_title;
|
||||
}
|
||||
|
||||
void Notification::SetBody(const base::string16& new_body) {
|
||||
body_ = new_body;
|
||||
}
|
||||
|
||||
void Notification::SetSilent(bool new_silent) {
|
||||
silent_ = new_silent;
|
||||
}
|
||||
|
||||
void Notification::SetReplyPlaceholder(const base::string16& new_placeholder) {
|
||||
reply_placeholder_ = new_placeholder;
|
||||
}
|
||||
|
||||
void Notification::SetHasReply(bool new_has_reply) {
|
||||
has_reply_ = new_has_reply;
|
||||
}
|
||||
|
@ -99,7 +101,7 @@ void Notification::NotificationClick() {
|
|||
Emit("click");
|
||||
}
|
||||
|
||||
void Notification::NotificationReplied(const std::string reply) {
|
||||
void Notification::NotificationReplied(const std::string& reply) {
|
||||
Emit("reply", reply);
|
||||
}
|
||||
|
||||
|
@ -111,7 +113,8 @@ void Notification::NotificationDestroyed() {
|
|||
Emit("close");
|
||||
}
|
||||
|
||||
void Notification::NotificationClosed() {}
|
||||
void Notification::NotificationClosed() {
|
||||
}
|
||||
|
||||
// Showing notifications
|
||||
void Notification::Show() {
|
||||
|
@ -124,14 +127,6 @@ void Notification::Show() {
|
|||
}
|
||||
}
|
||||
|
||||
bool initialized_ = false;
|
||||
void Notification::OnInitialProps() {
|
||||
if (!initialized_) {
|
||||
presenter_ = brightray::BrowserClient::Get()->GetNotificationPresenter();
|
||||
initialized_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Notification::IsSupported() {
|
||||
return !!brightray::BrowserClient::Get()->GetNotificationPresenter();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
|
||||
// NotificationDelegate:
|
||||
void NotificationClick() override;
|
||||
void NotificationReplied(const std::string reply) override;
|
||||
void NotificationReplied(const std::string& reply) override;
|
||||
void NotificationDisplayed() override;
|
||||
void NotificationDestroyed() override;
|
||||
void NotificationClosed() override;
|
||||
|
@ -43,7 +43,6 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
mate::Arguments* args);
|
||||
~Notification() override;
|
||||
|
||||
void OnInitialProps();
|
||||
void Show();
|
||||
|
||||
// Prop Getters
|
||||
|
@ -69,6 +68,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
bool silent_ = false;
|
||||
base::string16 reply_placeholder_;
|
||||
bool has_reply_ = false;
|
||||
|
||||
brightray::NotificationPresenter* presenter_;
|
||||
|
||||
base::WeakPtr<brightray::Notification> notification_;
|
||||
|
|
|
@ -32,7 +32,7 @@ class CocoaNotification : public Notification {
|
|||
void Dismiss() override;
|
||||
|
||||
void NotificationDisplayed();
|
||||
void NotificationReplied(const std::string reply);
|
||||
void NotificationReplied(const std::string& reply);
|
||||
|
||||
NSUserNotification* notification() const { return notification_; }
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ void CocoaNotification::NotificationDisplayed() {
|
|||
delegate()->NotificationDisplayed();
|
||||
}
|
||||
|
||||
void CocoaNotification::NotificationReplied(const std::string reply) {
|
||||
void CocoaNotification::NotificationReplied(const std::string& reply) {
|
||||
if (delegate())
|
||||
delegate()->NotificationReplied(reply);
|
||||
}
|
||||
|
|
|
@ -21,10 +21,6 @@ Notification::~Notification() {
|
|||
delegate()->NotificationDestroyed();
|
||||
}
|
||||
|
||||
void Notification::set_delegate(NotificationDelegate* delegate) {
|
||||
delegate_ = delegate;
|
||||
}
|
||||
|
||||
void Notification::NotificationClicked() {
|
||||
if (delegate())
|
||||
delegate()->NotificationClick();
|
||||
|
|
|
@ -20,6 +20,8 @@ class NotificationPresenter;
|
|||
|
||||
class Notification {
|
||||
public:
|
||||
virtual ~Notification();
|
||||
|
||||
// Shows the notification.
|
||||
virtual void Show(const base::string16& title,
|
||||
const base::string16& msg,
|
||||
|
@ -45,6 +47,7 @@ class Notification {
|
|||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
void set_delegate(NotificationDelegate* delegate) { delegate_ = delegate; }
|
||||
NotificationDelegate* delegate() const { return delegate_; }
|
||||
NotificationPresenter* presenter() const { return presenter_; }
|
||||
|
||||
|
@ -52,10 +55,6 @@ class Notification {
|
|||
Notification(NotificationDelegate* delegate,
|
||||
NotificationPresenter* presenter);
|
||||
|
||||
public:
|
||||
virtual ~Notification();
|
||||
void set_delegate(NotificationDelegate* delegate);
|
||||
|
||||
private:
|
||||
NotificationDelegate* delegate_;
|
||||
NotificationPresenter* presenter_;
|
||||
|
|
|
@ -20,7 +20,7 @@ class NotificationDelegate : public content::DesktopNotificationDelegate {
|
|||
virtual void NotificationFailed() {}
|
||||
|
||||
// Notification was replied to
|
||||
virtual void NotificationReplied(const std::string reply) {}
|
||||
virtual void NotificationReplied(const std::string& reply) {}
|
||||
};
|
||||
|
||||
} // namespace brightray
|
||||
|
|
Loading…
Reference in a new issue