UNPKG

2.23 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2018 TypeFox and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.HttpOpenHandler = void 0;
19const tslib_1 = require("tslib");
20const inversify_1 = require("inversify");
21const window_service_1 = require("./window/window-service");
22const external_uri_service_1 = require("./external-uri-service");
23let HttpOpenHandler = class HttpOpenHandler {
24 constructor() {
25 this.id = 'http';
26 }
27 canHandle(uri, options) {
28 return ((options && options.openExternal) || uri.scheme.startsWith('http') || uri.scheme.startsWith('mailto')) ? 500 : 0;
29 }
30 async open(uri) {
31 const resolvedUri = await this.externalUriService.resolve(uri);
32 return this.windowService.openNewWindow(resolvedUri.toString(true), { external: true });
33 }
34};
35(0, tslib_1.__decorate)([
36 (0, inversify_1.inject)(window_service_1.WindowService),
37 (0, tslib_1.__metadata)("design:type", Object)
38], HttpOpenHandler.prototype, "windowService", void 0);
39(0, tslib_1.__decorate)([
40 (0, inversify_1.inject)(external_uri_service_1.ExternalUriService),
41 (0, tslib_1.__metadata)("design:type", external_uri_service_1.ExternalUriService)
42], HttpOpenHandler.prototype, "externalUriService", void 0);
43HttpOpenHandler = (0, tslib_1.__decorate)([
44 (0, inversify_1.injectable)()
45], HttpOpenHandler);
46exports.HttpOpenHandler = HttpOpenHandler;
47//# sourceMappingURL=http-open-handler.js.map
\No newline at end of file