e70ce89235
* chore: iwyu shell/browser/electron_pdf_document_helper_client.h * chore: iwyu shell/browser/hid/electron_hid_delegate.h * chore: iwyu content/public/browser/web_contents.h * chore: iwyu shell/browser/usb/electron_usb_delegate.h * chore: iwyu shell/browser/browser_observer.h * chore: iwyu shell/browser/bluetooth/electron_bluetooth_delegate.h * chore: iwyu shell/browser/serial/electron_serial_delegate.h * chore: iwyu shell/browser/api/frame_subscriber.h * chore: iwyu mojo/public/cpp/bindings/ * chore: iwyu components/ * chore: iwyu extensions/ * chore: iwyu shell/common/gin_helper/ * chore: iwyu v8/ * chore: iwyu base/containers/linked_list.h * chore: iwyu shell/browser/native_window.h * chore: iwyu shell/browser/api/electron_api_base_window.h * chore: iwyu shell/common/node_includes.h * chore: iwyu gin/handle.h * chore: iwyu base/functional/callback.h * chore: iwyu ui/gfx/ * chore: iwyu content/public/browser/render_frame_host.h * fix: mac * fix: mac * fix: win * chore: iwyu base/files/file_path.h * chore: iwyu base/unguessable_token.h * chore: iwyu ui/display/screen.h * chore: iwyu chrome/browser/predictors/preconnect_manager.h * chore: iwyu base/observer_list_types.h * chore: iwyu content/public/browser/web_contents.h * chore: iwyu chrome/browser/devtools/devtools_eye_dropper.h * chore: iwyu shell/browser/ui/inspectable_web_contents.h * chore: iwyu content/public/browser/keyboard_event_processing_result.h * chore: iwyu net/cookies/canonical_cookie.h * chore: iwyu net/base/address_list.h * chore: iwyu net/cert/x509_certificate.h * chore: iwyu net/cookies/cookie_change_dispatcher.h * chore: iwyu net/dns/public/host_resolver_results.h * fix: mac * Revert "chore: iwyu net/cert/x509_certificate.h" This reverts commit 002896f71146e90f1e29e090a1d6eede48cee11e.
125 lines
4.3 KiB
C++
125 lines
4.3 KiB
C++
// 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 ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NOTIFICATION_H_
|
|
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NOTIFICATION_H_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "base/memory/raw_ptr.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 "ui/gfx/image/image.h"
|
|
|
|
namespace gin {
|
|
class Arguments;
|
|
template <typename T>
|
|
class Handle;
|
|
} // namespace gin
|
|
|
|
namespace gin_helper {
|
|
class ErrorThrower;
|
|
} // namespace gin_helper
|
|
|
|
namespace electron::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 void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>);
|
|
static const char* GetClassName() { return "Notification"; }
|
|
|
|
// 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;
|
|
void NotificationFailed(const std::string& error) override;
|
|
|
|
// gin::Wrappable
|
|
static gin::WrapperInfo kWrapperInfo;
|
|
const char* GetTypeName() override;
|
|
|
|
// disable copy
|
|
Notification(const Notification&) = delete;
|
|
Notification& operator=(const Notification&) = delete;
|
|
|
|
protected:
|
|
explicit Notification(gin::Arguments* args);
|
|
~Notification() override;
|
|
|
|
void Show();
|
|
void Close();
|
|
|
|
// Prop Getters
|
|
const std::u16string& title() const { return title_; }
|
|
const std::u16string& subtitle() const { return subtitle_; }
|
|
const std::u16string& body() const { return body_; }
|
|
bool is_silent() const { return silent_; }
|
|
bool has_reply() const { return has_reply_; }
|
|
const std::u16string& timeout_type() const { return timeout_type_; }
|
|
const std::u16string& reply_placeholder() const { return reply_placeholder_; }
|
|
const std::u16string& urgency() const { return urgency_; }
|
|
const std::u16string& sound() const { return sound_; }
|
|
const std::vector<electron::NotificationAction>& actions() const {
|
|
return actions_;
|
|
}
|
|
const std::u16string& close_button_text() const { return close_button_text_; }
|
|
const std::u16string& toast_xml() const { return toast_xml_; }
|
|
|
|
// Prop Setters
|
|
void SetTitle(const std::u16string& new_title);
|
|
void SetSubtitle(const std::u16string& new_subtitle);
|
|
void SetBody(const std::u16string& new_body);
|
|
void SetSilent(bool new_silent);
|
|
void SetHasReply(bool new_has_reply);
|
|
void SetUrgency(const std::u16string& new_urgency);
|
|
void SetTimeoutType(const std::u16string& new_timeout_type);
|
|
void SetReplyPlaceholder(const std::u16string& new_placeholder);
|
|
void SetSound(const std::u16string& sound);
|
|
void SetActions(const std::vector<electron::NotificationAction>& actions);
|
|
void SetCloseButtonText(const std::u16string& text);
|
|
void SetToastXml(const std::u16string& new_toast_xml);
|
|
|
|
private:
|
|
std::u16string title_;
|
|
std::u16string subtitle_;
|
|
std::u16string body_;
|
|
gfx::Image icon_;
|
|
std::u16string icon_path_;
|
|
bool has_icon_ = false;
|
|
bool silent_ = false;
|
|
bool has_reply_ = false;
|
|
std::u16string timeout_type_;
|
|
std::u16string reply_placeholder_;
|
|
std::u16string sound_;
|
|
std::u16string urgency_;
|
|
std::vector<electron::NotificationAction> actions_;
|
|
std::u16string close_button_text_;
|
|
std::u16string toast_xml_;
|
|
|
|
raw_ptr<electron::NotificationPresenter> presenter_;
|
|
|
|
base::WeakPtr<electron::Notification> notification_;
|
|
};
|
|
|
|
} // namespace electron::api
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NOTIFICATION_H_
|