Adding toWebviewResource api

For #76489
This commit is contained in:
Matt Bierner
2019-07-03 19:14:19 -07:00
parent 3492642650
commit a558a9504a
20 changed files with 168 additions and 114 deletions

View File

@@ -23,7 +23,6 @@ import { ACTIVE_GROUP, IEditorService } from 'vs/workbench/services/editor/commo
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { extHostNamedCustomer } from '../common/extHostCustomers';
import { IProductService } from 'vs/platform/product/common/product';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
@extHostNamedCustomer(MainContext.MainThreadWebviews)
export class MainThreadWebviews extends Disposable implements MainThreadWebviewsShape {
@@ -51,11 +50,10 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
@IExtensionService extensionService: IExtensionService,
@IEditorGroupsService private readonly _editorGroupService: IEditorGroupsService,
@IEditorService private readonly _editorService: IEditorService,
@IWebviewEditorService private readonly _webviewService: IWebviewEditorService,
@IWebviewEditorService private readonly _webviewEditorService: IWebviewEditorService,
@IOpenerService private readonly _openerService: IOpenerService,
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@IProductService private readonly _productService: IProductService,
@IEnvironmentService private readonly _environmentService: IEnvironmentService,
) {
super();
@@ -65,7 +63,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
// This reviver's only job is to activate webview extensions
// This should trigger the real reviver to be registered from the extension host side.
this._register(_webviewService.registerReviver({
this._register(_webviewEditorService.registerReviver({
canRevive: (webview) => {
const viewType = webview.state.viewType;
if (viewType) {
@@ -97,7 +95,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
mainThreadShowOptions.group = viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn);
}
const webview = this._webviewService.createWebview(this.getInternalWebviewId(viewType), title, mainThreadShowOptions, reviveWebviewOptions(options), {
const webview = this._webviewEditorService.createWebview(this.getInternalWebviewId(viewType), title, mainThreadShowOptions, reviveWebviewOptions(options), {
location: URI.revive(extensionLocation),
id: extensionId
}, this.createWebviewEventDelegate(handle));
@@ -141,10 +139,6 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
webview.setOptions(reviveWebviewOptions(options as any /*todo@mat */));
}
async $getResourceRoot(_handle: WebviewPanelHandle): Promise<string> {
return this._environmentService.webviewResourceRoot;
}
public $reveal(handle: WebviewPanelHandle, showOptions: WebviewPanelShowOptions): void {
const webview = this.getWebview(handle);
if (webview.isDisposed()) {
@@ -153,7 +147,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
const targetGroup = this._editorGroupService.getGroup(viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn)) || this._editorGroupService.getGroup(webview.group || 0);
if (targetGroup) {
this._webviewService.revealWebview(webview, targetGroup, !!showOptions.preserveFocus);
this._webviewEditorService.revealWebview(webview, targetGroup, !!showOptions.preserveFocus);
}
}
@@ -182,7 +176,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
throw new Error(`Reviver for ${viewType} already registered`);
}
this._revivers.set(viewType, this._webviewService.registerReviver({
this._revivers.set(viewType, this._webviewEditorService.registerReviver({
canRevive: (webview) => {
return webview.state && webview.state.viewType === viewType;
},