screenshot support

This commit is contained in:
Joao Moreno
2018-04-18 08:14:38 +02:00
parent 66581ee338
commit 713e5c13c8
5 changed files with 53 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ import { Emitter, toPromise } from 'vs/base/common/event';
// TODO@joao: bad layering!
import { KeybindingIO } from 'vs/workbench/services/keybinding/common/keybindingIO';
import { ScanCodeBinding } from 'vs/workbench/services/keybinding/common/scanCode';
import { NativeImage } from 'electron';
class WindowRouter implements IClientRouter {
@@ -63,6 +64,17 @@ export class Driver implements IDriver, IWindowDriverRegistry {
.filter(id => this.registeredWindowIds.has(id) && !this.reloadingWindowIds.has(id));
}
async capturePage(windowId: number): TPromise<string> {
await this.whenUnfrozen(windowId);
const window = this.windowsService.getWindowById(windowId);
const webContents = window.win.webContents;
const image = await new Promise<NativeImage>(c => webContents.capturePage(c));
const buffer = image.toPNG();
return buffer.toString('base64');
}
async reloadWindow(windowId: number): TPromise<void> {
await this.whenUnfrozen(windowId);