Skip to content

Commit

Permalink
Also allow clipboard-sanitized-write in webviews
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Jul 14, 2021
1 parent 1ac570e commit e6b29a1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,22 @@ export class CodeApplication extends Disposable {

const isUrlFromWebview = (requestingUrl: string | undefined) => requestingUrl?.startsWith(`${Schemas.vscodeWebview}://`);

const allowedPermissionsInWebview = new Set([
'clipboard-read',
'clipboard-sanitized-write',
]);

session.defaultSession.setPermissionRequestHandler((_webContents, permission /* 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal' */, callback, details) => {
if (isUrlFromWebview(details.requestingUrl)) {
return callback(permission === 'clipboard-read');
return callback(allowedPermissionsInWebview.has(permission));
}

return callback(false);
});

session.defaultSession.setPermissionCheckHandler((_webContents, permission /* 'media' */, _origin, details) => {
if (isUrlFromWebview(details.requestingUrl)) {
return permission === 'clipboard-read';
return allowedPermissionsInWebview.has(permission);
}

return false;
Expand Down

0 comments on commit e6b29a1

Please sign in to comment.