File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,11 @@ export class BrowserWindow extends Disposable {
141
141
// will trigger the `beforeunload`.
142
142
this . openerService . setDefaultExternalOpener ( {
143
143
openExternal : async ( href : string ) => {
144
+ if ( this . environmentService . options ?. externalURLOpener ) {
145
+ if ( await this . environmentService . options ?. externalURLOpener . openExternal ( href ) ) {
146
+ return true ;
147
+ }
148
+ }
144
149
145
150
// HTTP(s): open in new window and deal with potential popup blockers
146
151
if ( matchesScheme ( href , Schemas . http ) || matchesScheme ( href , Schemas . https ) ) {
Original file line number Diff line number Diff line change @@ -37,6 +37,21 @@ interface IExternalUriResolver {
37
37
( uri : URI ) : Promise < URI > ;
38
38
}
39
39
40
+ /**
41
+ * External URL opener
42
+ */
43
+ interface IExternalURLOpener {
44
+
45
+ /**
46
+ * Overrides the behavior when an external URL is about to be opened.
47
+ * Returning false means that the URL wasn't handled, and the default
48
+ * handling behavior should be used: `window.open(href, '_blank', 'noopener');`
49
+ *
50
+ * @returns true if URL was handled, false otherwise.
51
+ */
52
+ openExternal ( href : string ) : boolean | Promise < boolean > ;
53
+ }
54
+
40
55
interface ITunnelProvider {
41
56
42
57
/**
@@ -363,6 +378,11 @@ interface IWorkbenchConstructionOptions {
363
378
*/
364
379
readonly resolveExternalUri ?: IExternalUriResolver ;
365
380
381
+ /**
382
+ * Support for URL callbacks.
383
+ */
384
+ readonly externalURLOpener ?: IExternalURLOpener ;
385
+
366
386
/**
367
387
* A provider for supplying tunneling functionality,
368
388
* such as creating tunnels and showing candidate ports to forward.
@@ -742,6 +762,9 @@ export {
742
762
// External Uris
743
763
IExternalUriResolver ,
744
764
765
+ // External URL Opener
766
+ IExternalURLOpener ,
767
+
745
768
// Tunnel
746
769
ITunnelProvider ,
747
770
ITunnelFactory ,
You can’t perform that action at this time.
0 commit comments