提交 966aeb0c 编写于 作者: M Matt Bierner

Move useSameOriginForRoot into options

上级 d2d8e45c
......@@ -220,9 +220,9 @@ class WebviewEditor extends BaseWebviewEditor {
this.contextKey,
this.findInputFocusContextKey,
{
enableWrappedPostMessage: true
},
false);
enableWrappedPostMessage: true,
useSameOriginForRoot: false
});
this._webview.onDidClickLink(this.onDidClickLink, this, this._contentDisposables);
......
......@@ -421,7 +421,7 @@ export class ExtensionEditor extends BaseEditor {
.then<void>(body => {
const allowedBadgeProviders = this.extensionsWorkbenchService.allowedBadgeProviders;
const webViewOptions = allowedBadgeProviders.length > 0 ? { allowScripts: false, allowSvgs: false, svgWhiteList: allowedBadgeProviders } : {};
this.activeWebview = new Webview(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.themeService, this.environmentService, this.contextService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions, false);
this.activeWebview = new Webview(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.themeService, this.environmentService, this.contextService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions);
const removeLayoutParticipant = arrays.insert(this.layoutParticipants, this.activeWebview);
this.contentDisposables.push(toDisposable(removeLayoutParticipant));
this.activeWebview.contents = body;
......
......@@ -97,8 +97,10 @@ export class HtmlPreviewPart extends WebviewEditor {
this._contextViewService,
this.contextKey,
this.findInputFocusContextKey,
webviewOptions,
true);
{
...webviewOptions,
useSameOriginForRoot: true
});
if (this.input && this.input instanceof HtmlInput) {
const state = this.loadViewState(this.input.getResource());
......
......@@ -24,6 +24,7 @@ export interface WebviewOptions {
readonly allowSvgs?: boolean;
readonly svgWhiteList?: string[];
readonly enableWrappedPostMessage?: boolean;
readonly useSameOriginForRoot?: boolean;
}
export class Webview {
......@@ -44,8 +45,7 @@ export class Webview {
private readonly _contextViewService: IContextViewService,
private readonly _contextKey: IContextKey<boolean>,
private readonly _findInputContextKey: IContextKey<boolean>,
private _options: WebviewOptions,
useSameOriginForRoot: boolean
private _options: WebviewOptions
) {
this._webview = document.createElement('webview');
this._webview.setAttribute('partition', this._options.allowSvgs ? 'webview' : `webview${Date.now()}`);
......@@ -62,7 +62,7 @@ export class Webview {
this._webview.style.outline = '0';
this._webview.preload = require.toUrl('./webview-pre.js');
this._webview.src = useSameOriginForRoot ? require.toUrl('./webview.html') : 'data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Chtml%20lang%3D%22en%22%20style%3D%22width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3Chead%3E%0D%0A%09%3Ctitle%3EVirtual%20Document%3C%2Ftitle%3E%0D%0A%3C%2Fhead%3E%0D%0A%3Cbody%20style%3D%22margin%3A%200%3B%20overflow%3A%20hidden%3B%20width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E';
this._webview.src = this._options.useSameOriginForRoot ? require.toUrl('./webview.html') : 'data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Chtml%20lang%3D%22en%22%20style%3D%22width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3Chead%3E%0D%0A%09%3Ctitle%3EVirtual%20Document%3C%2Ftitle%3E%0D%0A%3C%2Fhead%3E%0D%0A%3Cbody%20style%3D%22margin%3A%200%3B%20overflow%3A%20hidden%3B%20width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E';
this._ready = new Promise<this>(resolve => {
const subscription = addDisposableListener(this._webview, 'ipc-message', (event) => {
......@@ -76,7 +76,7 @@ export class Webview {
});
});
if (!useSameOriginForRoot) {
if (!this._options.useSameOriginForRoot) {
let loaded = false;
this._disposables.push(addDisposableListener(this._webview, 'did-start-loading', () => {
if (loaded) {
......
......@@ -97,8 +97,7 @@ export class ReleaseNotesEditor extends WebviewEditor {
this._contextViewService,
this.contextKey,
this.findInputFocusContextKey,
{},
false);
{});
if (this.input && this.input instanceof ReleaseNotesInput) {
const state = this.loadViewState(this.input.version);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册