diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index c85d74e607a7..0a6addd43fd8 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -729,8 +729,8 @@ WebContents.prototype._init = function () { }; // Public APIs. -export function create (options = {}) { - return binding.create(options); +export function create (options = {}): Electron.WebContents { + return new (WebContents as any)(options); } export function fromId (id: string) { diff --git a/shell/browser/api/electron_api_browser_view.cc b/shell/browser/api/electron_api_browser_view.cc index b46bff87c5e3..23565cda13c1 100644 --- a/shell/browser/api/electron_api_browser_view.cc +++ b/shell/browser/api/electron_api_browser_view.cc @@ -79,7 +79,7 @@ BrowserView::BrowserView(gin::Arguments* args, options.Get(options::kWebPreferences, &web_preferences); web_preferences.Set("type", "browserView"); gin::Handle web_contents = - WebContents::Create(isolate, web_preferences); + WebContents::New(isolate, web_preferences); web_contents_.Reset(isolate, web_contents.ToV8()); api_web_contents_ = web_contents.get(); diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 3ff9cb16d709..e9289890f0e2 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -3727,7 +3727,7 @@ ElectronBrowserContext* WebContents::GetBrowserContext() const { } // static -gin::Handle WebContents::Create( +gin::Handle WebContents::New( v8::Isolate* isolate, const gin_helper::Dictionary& options) { gin::Handle handle = @@ -3736,13 +3736,6 @@ gin::Handle WebContents::Create( return handle; } -// static -gin::Handle WebContents::New( - v8::Isolate* isolate, - const gin_helper::Dictionary& options) { - return Create(isolate, options); -} - // static gin::Handle WebContents::CreateAndTake( v8::Isolate* isolate, @@ -3809,7 +3802,6 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); gin_helper::Dictionary dict(isolate, exports); dict.Set("WebContents", WebContents::GetConstructor(context)); - dict.SetMethod("create", &WebContents::Create); dict.SetMethod("fromId", &WebContents::FromID); dict.SetMethod("getAllWebContents", &GetAllWebContentsAsV8); } diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index e3cc2fb62a92..8923c5688983 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -111,8 +111,6 @@ class WebContents : public gin::Wrappable, }; // Create a new WebContents and return the V8 wrapper of it. - static gin::Handle Create(v8::Isolate* isolate, - const gin_helper::Dictionary& options); static gin::Handle New(v8::Isolate* isolate, const gin_helper::Dictionary& options); diff --git a/shell/browser/api/electron_api_web_contents_view.cc b/shell/browser/api/electron_api_web_contents_view.cc index c17f94e17fc1..7c213f078d1f 100644 --- a/shell/browser/api/electron_api_web_contents_view.cc +++ b/shell/browser/api/electron_api_web_contents_view.cc @@ -113,7 +113,7 @@ gin_helper::WrappableBase* WebContentsView::New( } } else { // Create one if not. - web_contents = WebContents::Create(args->isolate(), web_preferences); + web_contents = WebContents::New(args->isolate(), web_preferences); } // Constructor call. auto* view = new WebContentsView(args->isolate(), web_contents);