diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 2e27a46af6b..0a7b895a2ea 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -962,9 +962,8 @@ ElectronBrowserClient::CreateDevToolsManagerDelegate() { } NotificationPresenter* ElectronBrowserClient::GetNotificationPresenter() { - if (!notification_presenter_) { - notification_presenter_.reset(NotificationPresenter::Create()); - } + if (!notification_presenter_) + notification_presenter_ = NotificationPresenter::Create(); return notification_presenter_.get(); } diff --git a/shell/browser/notifications/linux/notification_presenter_linux.cc b/shell/browser/notifications/linux/notification_presenter_linux.cc index adcdb5f8a3b..96b04604bed 100644 --- a/shell/browser/notifications/linux/notification_presenter_linux.cc +++ b/shell/browser/notifications/linux/notification_presenter_linux.cc @@ -10,10 +10,10 @@ namespace electron { // static -NotificationPresenter* NotificationPresenter::Create() { - if (!LibnotifyNotification::Initialize()) - return nullptr; - return new NotificationPresenterLinux; +std::unique_ptr NotificationPresenter::Create() { + if (LibnotifyNotification::Initialize()) + return std::make_unique(); + return {}; } NotificationPresenterLinux::NotificationPresenterLinux() = default; diff --git a/shell/browser/notifications/mac/notification_presenter_mac.mm b/shell/browser/notifications/mac/notification_presenter_mac.mm index 3d735916708..88877ae3fa8 100644 --- a/shell/browser/notifications/mac/notification_presenter_mac.mm +++ b/shell/browser/notifications/mac/notification_presenter_mac.mm @@ -12,8 +12,8 @@ namespace electron { // static -NotificationPresenter* NotificationPresenter::Create() { - return new NotificationPresenterMac; +std::unique_ptr NotificationPresenter::Create() { + return std::make_unique(); } CocoaNotification* NotificationPresenterMac::GetNotification( diff --git a/shell/browser/notifications/notification_presenter.h b/shell/browser/notifications/notification_presenter.h index b29dd2a4dc8..6058a82c6f4 100644 --- a/shell/browser/notifications/notification_presenter.h +++ b/shell/browser/notifications/notification_presenter.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_NOTIFICATIONS_NOTIFICATION_PRESENTER_H_ #define ELECTRON_SHELL_BROWSER_NOTIFICATIONS_NOTIFICATION_PRESENTER_H_ +#include #include #include @@ -17,7 +18,7 @@ class NotificationDelegate; class NotificationPresenter { public: - static NotificationPresenter* Create(); + static std::unique_ptr Create(); virtual ~NotificationPresenter(); diff --git a/shell/browser/notifications/win/notification_presenter_win.cc b/shell/browser/notifications/win/notification_presenter_win.cc index 407250614d3..965ef45c9b2 100644 --- a/shell/browser/notifications/win/notification_presenter_win.cc +++ b/shell/browser/notifications/win/notification_presenter_win.cc @@ -46,17 +46,17 @@ bool SaveIconToPath(const SkBitmap& bitmap, const base::FilePath& path) { } // namespace // static -NotificationPresenter* NotificationPresenter::Create() { +std::unique_ptr NotificationPresenter::Create() { if (!WindowsToastNotification::Initialize()) - return nullptr; + return {}; auto presenter = std::make_unique(); if (!presenter->Init()) - return nullptr; + return {}; if (IsDebuggingNotifications()) LOG(INFO) << "Successfully created Windows notifications presenter"; - return presenter.release(); + return presenter; } NotificationPresenterWin::NotificationPresenterWin() = default;