diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index 91030ed491..f67923ef1a 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -98,8 +98,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 d387c8f793..a821fde6cc 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -71,8 +71,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 625ffcf612..6ac5805750 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1814,9 +1814,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 5a0fb64834..91745ce91b 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -1789,9 +1789,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