Add back support for reading from clipboard in webviews (#116597)

* Add back support for reading from clipboard in webviews

Fixes #115925

This was blocked by 7d5052f508.

* Gate permissions checks to webview frames
This commit is contained in:
Matt Bierner
2021-02-17 13:24:33 -08:00
committed by GitHub
parent 086112d496
commit 608e8791ff
4 changed files with 21 additions and 5 deletions

View File

@@ -225,11 +225,19 @@ export class CodeApplication extends Disposable {
this.nativeHostMainService?.openExternal(undefined, url);
});
session.defaultSession.setPermissionRequestHandler((webContents, permission /* 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal' */, callback) => {
const webviewFrameUrl = 'about:blank?webviewFrame';
session.defaultSession.setPermissionRequestHandler((_webContents, permission /* 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal' */, callback, details) => {
if (details.requestingUrl === webviewFrameUrl) {
return callback(permission === 'clipboard-read');
}
return callback(false);
});
session.defaultSession.setPermissionCheckHandler((webContents, permission /* 'media' */) => {
session.defaultSession.setPermissionCheckHandler((_webContents, permission /* 'media' */, _origin, details) => {
if (details.requestingUrl === webviewFrameUrl) {
return permission === 'clipboard-read';
}
return false;
});
});