From f899d16a7902c50b5fa499ddebd43d4717664755 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Wed, 10 Aug 2016 14:13:32 -0500 Subject: [PATCH] Implements extension external installation for popup windows --- conference.js | 40 ++++++++++++++++++++++++++++++++++++++-- lang/main.json | 5 ++++- modules/UI/UI.js | 27 +++++++++++++++++++++++++++ service/UI/UIEvents.js | 12 +++++++++++- 4 files changed, 80 insertions(+), 4 deletions(-) diff --git a/conference.js b/conference.js index 7672c4d7b..42cab2c31 100644 --- a/conference.js +++ b/conference.js @@ -33,6 +33,11 @@ let room, connection, localAudio, localVideo, roomLocker; */ let connectionIsInterrupted = false; +/** + * Indicates whether extension external installation is in progress or not. + */ +let DSExternalInstallationInProgress = false; + import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/LargeVideo"; /** @@ -270,7 +275,9 @@ function createLocalTracks (options, checkForPermissionPrompt) { ? APP.settings.getMicDeviceId() : options.micDeviceId, // adds any ff fake device settings if any - firefox_fake_device: config.firefox_fake_device + firefox_fake_device: config.firefox_fake_device, + desktopSharingExtensionExternalInstallation: + options.desktopSharingExtensionExternalInstallation }, checkForPermissionPrompt) .catch(function (err) { console.error( @@ -878,9 +885,27 @@ export default { } this.videoSwitchInProgress = true; + let externalInstallation = false; if (shareScreen) { - createLocalTracks({ devices: ['desktop'] }).then(([stream]) => { + createLocalTracks({ + devices: ['desktop'], + desktopSharingExtensionExternalInstallation: { + interval: 500, + checkAgain: () => { + return DSExternalInstallationInProgress; + }, + listener: (url) => { + DSExternalInstallationInProgress = true; + externalInstallation = true; + APP.UI.showExtensionExternalInstallationDialog(url); + } + } + }).then(([stream]) => { + DSExternalInstallationInProgress = false; + // close external installation dialog on success. + if(externalInstallation) + $.prompt.close(); stream.on( TrackEvents.LOCAL_TRACK_STOPPED, () => { @@ -1134,6 +1159,17 @@ export default { APP.UI.updateDTMFSupport(isDTMFSupported); }); + APP.UI.addListener(UIEvents.EXTERNAL_INSTALLATION_CANCELED, () => { + // Wait a little bit more just to be sure that we won't miss the + // extension installation + setTimeout(() => DSExternalInstallationInProgress = false, 500); + }); + APP.UI.addListener(UIEvents.OPEN_EXTENSION_STORE, (url) => { + window.open( + url, "extension_store_window", + "resizable,scrollbars=yes,status=1"); + }); + APP.UI.addListener(UIEvents.ROOM_LOCK_CLICKED, () => { if (room.isModerator()) { let promise = roomLocker.isLocked diff --git a/lang/main.json b/lang/main.json index 9e8f9a551..d1a738014 100644 --- a/lang/main.json +++ b/lang/main.json @@ -263,7 +263,10 @@ "micUnknownError": "Cannot use microphone for a unknown reason.", "micPermissionDeniedError": "You have not granted permission to use your microphone. You can still join the conference but others won't hear you. Use the camera button in the address bar to fix this.", "micNotFoundError": "Requested microphone was not found.", - "micConstraintFailedError": "Yor microphone does not satisfy some of required constraints." + "micConstraintFailedError": "Yor microphone does not satisfy some of required constraints.", + "goToStore": "Go to the webstore", + "externalInstallationTitle": "Extension required", + "externalInstallationMsg": "You need to install our desktop sharing extension." }, "email": { diff --git a/modules/UI/UI.js b/modules/UI/UI.js index e717f72f3..6a570eeaf 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -1213,6 +1213,33 @@ UI.showExtensionRequiredDialog = function (url) { "dialog.firefoxExtensionPrompt", {url: url})); }; +/** + * Shows "Please go to chrome webstore to install the desktop sharing extension" + * 2 button dialog with buttons - cancel and go to web store. + * @param url {string} the url of the extension. + */ +UI.showExtensionExternalInstallationDialog = function (url) { + messageHandler.openTwoButtonDialog( + "dialog.externalInstallationTitle", + null, + "dialog.externalInstallationMsg", + null, + true, + "dialog.goToStore", + function(e,v,m,f){ + if (v) { + e.preventDefault(); + eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url); + } + }, + function () {}, + function () { + eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED); + } + ); +}; + + /** * Shows dialog with combined information about camera and microphone errors. * @param {JitsiTrackError} micError diff --git a/service/UI/UIEvents.js b/service/UI/UIEvents.js index 3d9c5f95c..cbd1bea6d 100644 --- a/service/UI/UIEvents.js +++ b/service/UI/UIEvents.js @@ -83,5 +83,15 @@ export default { LOCAL_FLIPX_CHANGED: "UI.local_flipx_changed", // An event which indicates that the resolution of a remote video has // changed. - RESOLUTION_CHANGED: "UI.resolution_changed" + RESOLUTION_CHANGED: "UI.resolution_changed", + /** + * Notifies that the button "Go to webstore" is pressed on the dialog for + * external extension installation. + */ + OPEN_EXTENSION_STORE: "UI.open_extension_store", + /** + * Notifies that the button "Cancel" is pressed on the dialog for + * external extension installation. + */ + EXTERNAL_INSTALLATION_CANCELED: "UI.external_installation_canceled" };