Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
GramboStorm opened this issue May 16, 2024 · 1 comment

Comments

@GramboStorm
Copy link

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

@GramboStorm
Copy link
Author

OK - this is the same as: #42054

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant