feat: replace BrowserView with WebContentsView (#35658)

This commit is contained in:
Jeremy Rose 2023-12-13 13:01:03 -08:00 committed by GitHub
parent a94fb2cb5d
commit 15c6014324
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
76 changed files with 2987 additions and 1531 deletions

View file

@ -592,6 +592,16 @@ WebContents.prototype._init = function () {
}
});
this.on('-before-unload-fired' as any, function (this: Electron.WebContents, event: Electron.Event, proceed: boolean) {
const type = this.getType();
// These are the "interactive" types, i.e. ones a user might be looking at.
// All other types should ignore the "proceed" signal and unload
// regardless.
if (type === 'window' || type === 'offscreen' || type === 'browserView') {
if (!proceed) { return event.preventDefault(); }
}
});
// The devtools requests the webContents to reload.
this.on('devtools-reload-page', function (this: Electron.WebContents) {
this.reload();
@ -776,7 +786,7 @@ WebContents.prototype._init = function () {
const promise = parent && !prefs.offscreen ? dialog.showMessageBox(parent, options) : dialog.showMessageBox(options);
try {
const result = await promise;
if (abortController.signal.aborted) return;
if (abortController.signal.aborted || this.isDestroyed()) return;
if (result.checkboxChecked) originCounts.set(origin, -1);
return callback(result.response === 0, '');
} finally {