electron/electron

[Feature Request]: (easy solution provided) WebContentsView should accept an existing webContents when creating

GramboStorm opened this issue · 1 comments

Preflight Checklist

Problem Description

In Branch 31.x.x, the SetWindowOpenHandler return value can include a function called createWindow. This allows us to create a new BrowserView or BrowserWindow instead of calling the default event did-create-window.

It is currently not possible to create a WebContentsView because it does not accept an existing webContents object in its options.
Due to this it is not possible to create a WebContentsView within the SetWindowOpenHandler,

Proposed Solution

To resolve this we can do the same as the BrowserWindow code does src\electron\shell\browser\api\electron_api_browser_window.cc
i.e.:

// Copy the webContents option to webPreferences.
  v8::Local<v8::Value> value;
  if (options.Get("webContents", &value)) {
    web_preferences.SetHidden("webContents", value);
  }

in src\electron\shell\browser\api\electron_api_web_contents_view.cc at line 157

This allows us to simply pass the options argument of createWindow straight into as follows: new WebContentsView(options)

Alternatives Considered

N/a

Additional Information

No response

OK - this is the same as: #42054