mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 20:13:32 +01:00
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:
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user