diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index 1882c211fe82..ab2214bfa694 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -96,8 +96,8 @@ BaseWindow::BaseWindow(v8::Isolate* isolate, } // Creates NativeWindow. - window_.reset(NativeWindow::Create( - options, parent.IsEmpty() ? nullptr : parent->window_.get())); + window_ = NativeWindow::Create( + options, parent.IsEmpty() ? nullptr : parent->window_.get()); window_->AddObserver(this); SetContentView(View::Create(isolate)); diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index c563fac6fed4..43ff73e774c0 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -72,8 +72,9 @@ class NativeWindow : public base::SupportsUserData, // Create window with existing WebContents, the caller is responsible for // managing the window's live. - static NativeWindow* Create(const gin_helper::Dictionary& options, - NativeWindow* parent = nullptr); + static std::unique_ptr Create( + const gin_helper::Dictionary& options, + NativeWindow* parent = nullptr); void InitFromOptions(const gin_helper::Dictionary& options); diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 774c2d8f2be4..a7ec8a2bfef3 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1805,9 +1805,10 @@ std::optional NativeWindowMac::GetWindowControlsOverlayRect() { } // static -NativeWindow* NativeWindow::Create(const gin_helper::Dictionary& options, - NativeWindow* parent) { - return new NativeWindowMac(options, parent); +std::unique_ptr NativeWindow::Create( + const gin_helper::Dictionary& options, + NativeWindow* parent) { + return std::make_unique(options, parent); } } // namespace electron diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 8428c1013d09..e74bc7ec0c66 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -1787,9 +1787,10 @@ void NativeWindowViews::MoveBehindTaskBarIfNeeded() { } // static -NativeWindow* NativeWindow::Create(const gin_helper::Dictionary& options, - NativeWindow* parent) { - return new NativeWindowViews(options, parent); +std::unique_ptr NativeWindow::Create( + const gin_helper::Dictionary& options, + NativeWindow* parent) { + return std::make_unique(options, parent); } } // namespace electron