urls - add option to disable confirm dialog

This commit is contained in:
Benjamin Pasero
2019-10-02 14:38:31 +02:00
parent 57aea60efd
commit c5e2892b29
10 changed files with 48 additions and 29 deletions

View File

@@ -54,7 +54,7 @@ export class BrowserURLService extends AbstractURLService {
private registerListeners(): void {
if (this.provider) {
this._register(this.provider.onCallback(uri => this.open(uri)));
this._register(this.provider.onCallback(uri => this.open(uri, { trusted: true })));
}
}

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
import { IURLService, IURLHandler, IOpenURLOptions } from 'vs/platform/url/common/url';
import { URI, UriComponents } from 'vs/base/common/uri';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { URLHandlerChannel } from 'vs/platform/url/common/urlIpc';
@@ -15,6 +15,11 @@ import { IElectronEnvironmentService } from 'vs/workbench/services/electron/elec
import { createChannelSender } from 'vs/base/parts/ipc/node/ipc';
import { IElectronService } from 'vs/platform/electron/node/electron';
export interface IRelayOpenURLOptions extends IOpenURLOptions {
openToSide?: boolean;
openExternal?: boolean;
}
export class RelayURLService extends URLService implements IURLHandler {
private urlService: IURLService;
@@ -46,16 +51,16 @@ export class RelayURLService extends URLService implements IURLHandler {
return uri.with({ query });
}
async open(resource: URI, options?: { openToSide?: boolean, openExternal?: boolean }): Promise<boolean> {
async open(resource: URI, options?: IRelayOpenURLOptions): Promise<boolean> {
if (resource.scheme !== product.urlProtocol) {
return false;
}
return await this.urlService.open(resource);
return await this.urlService.open(resource, options);
}
async handleURL(uri: URI): Promise<boolean> {
const result = await super.open(uri);
async handleURL(uri: URI, options?: IOpenURLOptions): Promise<boolean> {
const result = await super.open(uri, options);
if (result) {
await this.electronService.focusWindow();