refactor: consolidate WebContents::{Create,New} (#26521)
This commit is contained in:
parent
a303813d15
commit
92643a5a1c
5 changed files with 5 additions and 15 deletions
|
@ -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) {
|
||||
|
|
|
@ -79,7 +79,7 @@ BrowserView::BrowserView(gin::Arguments* args,
|
|||
options.Get(options::kWebPreferences, &web_preferences);
|
||||
web_preferences.Set("type", "browserView");
|
||||
gin::Handle<class WebContents> 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();
|
||||
|
|
|
@ -3727,7 +3727,7 @@ ElectronBrowserContext* WebContents::GetBrowserContext() const {
|
|||
}
|
||||
|
||||
// static
|
||||
gin::Handle<WebContents> WebContents::Create(
|
||||
gin::Handle<WebContents> WebContents::New(
|
||||
v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options) {
|
||||
gin::Handle<WebContents> handle =
|
||||
|
@ -3736,13 +3736,6 @@ gin::Handle<WebContents> WebContents::Create(
|
|||
return handle;
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<WebContents> WebContents::New(
|
||||
v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options) {
|
||||
return Create(isolate, options);
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<WebContents> WebContents::CreateAndTake(
|
||||
v8::Isolate* isolate,
|
||||
|
@ -3809,7 +3802,6 @@ void Initialize(v8::Local<v8::Object> 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);
|
||||
}
|
||||
|
|
|
@ -111,8 +111,6 @@ class WebContents : public gin::Wrappable<WebContents>,
|
|||
};
|
||||
|
||||
// Create a new WebContents and return the V8 wrapper of it.
|
||||
static gin::Handle<WebContents> Create(v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options);
|
||||
static gin::Handle<WebContents> New(v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue