From e0bfdcd9f86d33b3f77a28e9cbc05287c72ab461 Mon Sep 17 00:00:00 2001 From: bingenito Date: Tue, 8 May 2018 15:54:58 -0400 Subject: [PATCH] Allow override of default behavior of registring W3C notification api with options to resolveContainer --- src/Electron/electron.ts | 16 ++++++++++++---- src/OpenFin/openfin.ts | 12 ++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Electron/electron.ts b/src/Electron/electron.ts index dea38d96..22ce1968 100644 --- a/src/Electron/electron.ts +++ b/src/Electron/electron.ts @@ -17,7 +17,7 @@ ContainerRegistry.registerContainer("Electron", { return false; } }, - create: () => new ElectronContainer() + create: (options) => new ElectronContainer(null, null, null, options) }); class InternalMessageType { @@ -255,7 +255,7 @@ export class ElectronContainer extends WebContainerBase { public windowOptionsMap: PropertyMap = ElectronContainer.windowOptionsMap; - public constructor(electron?: any, ipc?: NodeJS.EventEmitter | any, win?: any) { + public constructor(electron?: any, ipc?: NodeJS.EventEmitter | any, win?: any, options?: any) { super(win); this.hostType = "Electron"; @@ -286,12 +286,20 @@ export class ElectronContainer extends WebContainerBase { console.error(e); } - this.registerNotificationsApi(); + let replaceNotificationApi = ElectronContainer.replaceNotificationApi; + if (options && typeof options.replaceNotificationApi !== "undefined") { + replaceNotificationApi = options.replaceNotificationApi; + } + + if (replaceNotificationApi) { + this.registerNotificationsApi(); + } + this.screen = new ElectronDisplayManager(this.electron); } protected registerNotificationsApi() { - if (ElectronContainer.replaceNotificationApi && typeof this.globalWindow !== "undefined" && this.globalWindow) { + if (typeof this.globalWindow !== "undefined" && this.globalWindow) { // Define owningContainer for closure to inner class const owningContainer: ElectronContainer = this; // tslint:disable-line diff --git a/src/OpenFin/openfin.ts b/src/OpenFin/openfin.ts index c73ef057..880b431d 100644 --- a/src/OpenFin/openfin.ts +++ b/src/OpenFin/openfin.ts @@ -327,13 +327,21 @@ export class OpenFinContainer extends WebContainerBase { } this.ipc = new OpenFinMessageBus(this.desktop.InterApplicationBus, (this.desktop.Application.getCurrent()).uuid); - this.registerNotificationsApi(); + + let replaceNotificationApi = OpenFinContainer.replaceNotificationApi; + if (options && typeof options.replaceNotificationApi !== "undefined") { + replaceNotificationApi = options.replaceNotificationApi; + } + + if (replaceNotificationApi) { + this.registerNotificationsApi(); + } this.screen = new OpenFinDisplayManager(this.desktop); } protected registerNotificationsApi() { - if (OpenFinContainer.replaceNotificationApi && typeof this.globalWindow !== "undefined" && this.globalWindow) { + if (typeof this.globalWindow !== "undefined" && this.globalWindow) { // Define owningContainer for closure to inner class const owningContainer: OpenFinContainer = this; // tslint:disable-line