chore: bump chromium to f755b70e34659441e72c1a928a406 (master) (#21000)
This commit is contained in:
parent
a5c9bd53e0
commit
49b47ee4ed
181 changed files with 1117 additions and 1786 deletions
|
@ -20,9 +20,6 @@
|
|||
#include "shell/browser/notifications/win/win32_desktop_notifications/common.h"
|
||||
#include "shell/browser/notifications/win/win32_desktop_notifications/toast.h"
|
||||
|
||||
using std::make_shared;
|
||||
using std::shared_ptr;
|
||||
|
||||
namespace electron {
|
||||
|
||||
HBITMAP CopyBitmap(HBITMAP bitmap) {
|
||||
|
@ -281,8 +278,8 @@ DesktopNotificationController::Notification
|
|||
DesktopNotificationController::AddNotification(std::wstring caption,
|
||||
std::wstring body_text,
|
||||
HBITMAP image) {
|
||||
NotificationLink data(this);
|
||||
|
||||
auto data = std::make_shared<NotificationData>();
|
||||
data->controller = this;
|
||||
data->caption = move(caption);
|
||||
data->body_text = move(body_text);
|
||||
data->image = CopyBitmap(image);
|
||||
|
@ -298,6 +295,7 @@ void DesktopNotificationController::CloseNotification(
|
|||
// Remove it from the queue
|
||||
auto it = find(queue_.begin(), queue_.end(), notification.data_);
|
||||
if (it != queue_.end()) {
|
||||
(*it)->controller = nullptr;
|
||||
queue_.erase(it);
|
||||
this->OnNotificationClosed(notification);
|
||||
return;
|
||||
|
@ -318,7 +316,8 @@ void DesktopNotificationController::CheckQueue() {
|
|||
}
|
||||
}
|
||||
|
||||
void DesktopNotificationController::CreateToast(NotificationLink&& data) {
|
||||
void DesktopNotificationController::CreateToast(
|
||||
std::shared_ptr<NotificationData>&& data) {
|
||||
auto* hinstance = RegisterWndClasses();
|
||||
auto* hwnd = Toast::Create(hinstance, data);
|
||||
if (hwnd) {
|
||||
|
@ -333,7 +332,7 @@ void DesktopNotificationController::CreateToast(NotificationLink&& data) {
|
|||
scr.Y(toast_margin_);
|
||||
}
|
||||
|
||||
instances_.push_back({hwnd, move(data)});
|
||||
instances_.push_back({hwnd, std::move(data)});
|
||||
|
||||
if (!hwnd_controller_) {
|
||||
// NOTE: We cannot use a message-only window because we need to
|
||||
|
@ -377,7 +376,7 @@ DesktopNotificationController::Notification::Notification(
|
|||
const DesktopNotificationController::Notification&) = default;
|
||||
|
||||
DesktopNotificationController::Notification::Notification(
|
||||
const shared_ptr<NotificationData>& data)
|
||||
const std::shared_ptr<NotificationData>& data)
|
||||
: data_(data) {
|
||||
DCHECK(data != nullptr);
|
||||
}
|
||||
|
@ -424,16 +423,14 @@ void DesktopNotificationController::Notification::Set(std::wstring caption,
|
|||
data_->controller->StartAnimation();
|
||||
}
|
||||
|
||||
DesktopNotificationController::NotificationLink::NotificationLink(
|
||||
DesktopNotificationController* controller)
|
||||
: shared_ptr(make_shared<NotificationData>()) {
|
||||
get()->controller = controller;
|
||||
}
|
||||
|
||||
DesktopNotificationController::NotificationLink::~NotificationLink() {
|
||||
auto* p = get();
|
||||
if (p)
|
||||
p->controller = nullptr;
|
||||
DesktopNotificationController::ToastInstance::ToastInstance(
|
||||
HWND hwnd,
|
||||
std::shared_ptr<NotificationData> data) {
|
||||
this->hwnd = hwnd;
|
||||
this->data = std::move(data);
|
||||
}
|
||||
DesktopNotificationController::ToastInstance::~ToastInstance() = default;
|
||||
DesktopNotificationController::ToastInstance::ToastInstance(ToastInstance&&) =
|
||||
default;
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -28,39 +28,35 @@ class DesktopNotificationController {
|
|||
|
||||
// Event handlers -- override to receive the events
|
||||
private:
|
||||
class Toast;
|
||||
DesktopNotificationController(const DesktopNotificationController&) = delete;
|
||||
|
||||
struct ToastInstance {
|
||||
ToastInstance(HWND, std::shared_ptr<NotificationData>);
|
||||
~ToastInstance();
|
||||
ToastInstance(ToastInstance&&);
|
||||
ToastInstance(const ToastInstance&) = delete;
|
||||
ToastInstance& operator=(ToastInstance&&) = default;
|
||||
|
||||
HWND hwnd;
|
||||
std::shared_ptr<NotificationData> data;
|
||||
};
|
||||
|
||||
virtual void OnNotificationClosed(const Notification& notification) {}
|
||||
virtual void OnNotificationClicked(const Notification& notification) {}
|
||||
virtual void OnNotificationDismissed(const Notification& notification) {}
|
||||
|
||||
private:
|
||||
static HINSTANCE RegisterWndClasses();
|
||||
void StartAnimation();
|
||||
HFONT GetCaptionFont();
|
||||
HFONT GetBodyFont();
|
||||
|
||||
private:
|
||||
enum TimerID { TimerID_Animate = 1 };
|
||||
|
||||
static constexpr int toast_margin_ = 20;
|
||||
|
||||
// Wrapper around `NotificationData` which makes sure that
|
||||
// the `controller` member is cleared when the controller object
|
||||
// stops tracking the notification
|
||||
struct NotificationLink : std::shared_ptr<NotificationData> {
|
||||
explicit NotificationLink(DesktopNotificationController* controller);
|
||||
~NotificationLink();
|
||||
|
||||
NotificationLink(NotificationLink&&) = default;
|
||||
NotificationLink(const NotificationLink&) = delete;
|
||||
NotificationLink& operator=(NotificationLink&&) = default;
|
||||
};
|
||||
|
||||
struct ToastInstance {
|
||||
HWND hwnd;
|
||||
NotificationLink data;
|
||||
};
|
||||
|
||||
class Toast;
|
||||
void InitializeFonts();
|
||||
void ClearAssets();
|
||||
void AnimateAll();
|
||||
void CheckQueue();
|
||||
void CreateToast(std::shared_ptr<NotificationData>&& data);
|
||||
HWND GetToast(const NotificationData* data) const;
|
||||
void DestroyToast(ToastInstance* inst);
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd,
|
||||
UINT message,
|
||||
|
@ -71,23 +67,13 @@ class DesktopNotificationController {
|
|||
GetWindowLongPtr(hwnd, 0));
|
||||
}
|
||||
|
||||
DesktopNotificationController(const DesktopNotificationController&) = delete;
|
||||
|
||||
void InitializeFonts();
|
||||
void ClearAssets();
|
||||
void AnimateAll();
|
||||
void CheckQueue();
|
||||
void CreateToast(NotificationLink&& data);
|
||||
HWND GetToast(const NotificationData* data) const;
|
||||
void DestroyToast(ToastInstance* inst);
|
||||
|
||||
private:
|
||||
static constexpr int toast_margin_ = 20;
|
||||
static const TCHAR class_name_[];
|
||||
|
||||
enum TimerID { TimerID_Animate = 1 };
|
||||
HWND hwnd_controller_ = NULL;
|
||||
HFONT caption_font_ = NULL, body_font_ = NULL;
|
||||
std::vector<ToastInstance> instances_;
|
||||
std::deque<NotificationLink> queue_;
|
||||
std::deque<std::shared_ptr<NotificationData>> queue_;
|
||||
bool is_animating_ = false;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue