summaryrefslogtreecommitdiffstats
path: root/remoting/webapp
diff options
context:
space:
mode:
authorweitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 20:08:06 +0000
committerweitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 20:08:06 +0000
commit33270c734fac44abdd7160c6ee1f955d43541adf (patch)
tree87090fe538f3eabd7c32f3b0a7496443ce53da04 /remoting/webapp
parent660b663d377737875118f78a0dfdf59ba580019e (diff)
downloadchromium_src-33270c734fac44abdd7160c6ee1f955d43541adf.zip
chromium_src-33270c734fac44abdd7160c6ee1f955d43541adf.tar.gz
chromium_src-33270c734fac44abdd7160c6ee1f955d43541adf.tar.bz2
Automatic host installation for IT2Me on Windows.
With this change, the webapp will install the host component (if it is not installed) on Windows when the user tries to share an IT2Me session. Also HostInstallDialog (instead of HostSetupDialog) now displays the installation progress dialog so it can be shared by both IT2Me and Me2Me. The code around HostDispatcher and HostIt2MeDispatcher is still a bit ugly but it should look better after the removal of the NPAPI dispatching logic, which comes next. BUG=134215 Review URL: https://codereview.chromium.org/291133004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272294 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r--remoting/webapp/host_controller.js7
-rw-r--r--remoting/webapp/host_dispatcher.js11
-rw-r--r--remoting/webapp/host_install_dialog.js19
-rw-r--r--remoting/webapp/host_it2me_dispatcher.js16
-rw-r--r--remoting/webapp/host_screen.js47
-rw-r--r--remoting/webapp/host_setup_dialog.js32
-rw-r--r--remoting/webapp/ui_mode.js9
7 files changed, 91 insertions, 50 deletions
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
index 056cdd9..70cf69e 100644
--- a/remoting/webapp/host_controller.js
+++ b/remoting/webapp/host_controller.js
@@ -12,6 +12,13 @@ remoting.HostController = function() {
this.hostDispatcher_ = this.createDispatcher_();
};
+/**
+ * @return {remoting.HostDispatcher}
+ */
+remoting.HostController.prototype.getDispatcher = function() {
+ return this.hostDispatcher_;
+};
+
// Note that the values in the enums below are copied from
// daemon_controller.h and must be kept in sync.
/** @enum {number} */
diff --git a/remoting/webapp/host_dispatcher.js b/remoting/webapp/host_dispatcher.js
index a5ea504..0aa76b6 100644
--- a/remoting/webapp/host_dispatcher.js
+++ b/remoting/webapp/host_dispatcher.js
@@ -87,6 +87,13 @@ remoting.HostDispatcher.prototype.tryToInitialize_ = function() {
};
/**
+ * @return {remoting.HostPlugin}
+ */
+remoting.HostDispatcher.prototype.getNpapiHost = function() {
+ return this.npapiHost_;
+}
+
+/**
* @param {remoting.HostController.Feature} feature The feature to test for.
* @param {function(boolean):void} onDone
* @return {void}
@@ -327,8 +334,8 @@ remoting.HostDispatcher.prototype.getUsageStatsConsent =
};
/**
- * This function installs the chromoting host using the NPAPI plugin and should
- * only be called on Windows.
+ * This function installs the host using the NPAPI plugin and should only be
+ * called on Windows.
*
* @param {function(remoting.HostController.AsyncResult):void} onDone
* @param {function(remoting.Error):void} onError
diff --git a/remoting/webapp/host_install_dialog.js b/remoting/webapp/host_install_dialog.js
index 71bf84d..448b2d7 100644
--- a/remoting/webapp/host_install_dialog.js
+++ b/remoting/webapp/host_install_dialog.js
@@ -49,8 +49,7 @@ remoting.HostInstallDialog.hostDownloadUrls = {
/**
* Starts downloading host components and shows installation prompt.
*
- * @param {remoting.HostController} hostController Used to install the host on
- * Windows.
+ * @param {remoting.HostPlugin} hostPlugin Used to install the host on Windows.
* @param {function(remoting.HostController.AsyncResult):void} onDone Callback
* called when user clicks Ok, presumably after installing the host. The
* handler must verify that the host has been installed and call tryAgain()
@@ -60,14 +59,24 @@ remoting.HostInstallDialog.hostDownloadUrls = {
* @return {void}
*/
remoting.HostInstallDialog.prototype.show = function(
- hostController, onDone, onError) {
+ hostPlugin, onDone, onError) {
// On Windows, host installation is automatic (handled by the NPAPI plugin)
// and we don't show the dialog. On Mac and Linux, we show the dialog and the
// user is expected to manually install the host before clicking OK.
// TODO (weitaosu): Make host installation automatic for IT2Me (like Me2Me) on
// Windows. Currently hostController is always null for IT2Me.
- if (navigator.platform == 'Win32' && hostController != null) {
- hostController.installHost(onDone, onError);
+ if (navigator.platform == 'Win32' && hostPlugin != null) {
+ // Currently we show two dialogs (each with a UAC prompt) when a user
+ // enables the host for the first time, one for installing the host (by the
+ // plugin) and the other for starting the host (by the native messaging
+ // host). We'd like to reduce it to one but don't have a good solution
+ // right now.
+ // We also show the same message on the two dialogs because. We don't want
+ // to confuse the user by saying "Installing Remote Desktop" because in
+ // their mind "Remote Desktop" (the webapp) has already been installed.
+ remoting.showSetupProcessingMessage(/*i18n-content*/'HOST_SETUP_STARTING');
+
+ hostPlugin.installHost(onDone);
} else {
this.continueInstallButton_.addEventListener(
'click', this.onOkClickedHandler_, false);
diff --git a/remoting/webapp/host_it2me_dispatcher.js b/remoting/webapp/host_it2me_dispatcher.js
index f2a7e90..3c2fce7 100644
--- a/remoting/webapp/host_it2me_dispatcher.js
+++ b/remoting/webapp/host_it2me_dispatcher.js
@@ -56,6 +56,8 @@ remoting.HostIt2MeDispatcher.prototype.initialize =
function onNativeMessagingStarted() {
console.log('Native Messaging supported.');
+
+ that.npapiHost_ = null;
onDispatcherInitialized();
}
@@ -90,6 +92,20 @@ remoting.HostIt2MeDispatcher.prototype.onNativeMessagingError_ =
}
/**
+ * @return {boolean}
+ */
+remoting.HostIt2MeDispatcher.prototype.usingNpapi = function() {
+ return this.npapiHost_ != null;
+}
+
+/**
+ * @return {remoting.HostPlugin}
+ */
+remoting.HostIt2MeDispatcher.prototype.getNpapiHost = function() {
+ return this.npapiHost_;
+}
+
+/**
* @param {string} email The user's email address.
* @param {string} authServiceWithToken Concatenation of the auth service
* (e.g. oauth2) and the access token.
diff --git a/remoting/webapp/host_screen.js b/remoting/webapp/host_screen.js
index 45e9975..71446ae 100644
--- a/remoting/webapp/host_screen.js
+++ b/remoting/webapp/host_screen.js
@@ -38,15 +38,37 @@ remoting.tryShare = function() {
onDispatcherInitializationFailed);
}
- /** @return {remoting.HostPlugin} */
+ /** @return {remoting.HostPlugin} */
var createPluginForIt2Me = function() {
return remoting.createNpapiPlugin(
document.getElementById('host-plugin-container'));
}
+ /** @param {remoting.HostController.AsyncResult} asyncResult */
+ var onHostInstalled = function(asyncResult) {
+ if (asyncResult == remoting.HostController.AsyncResult.OK) {
+ tryInitializeDispatcher();
+ } else if (asyncResult == remoting.HostController.AsyncResult.CANCELLED) {
+ onInstallError(remoting.Error.CANCELLED);
+ } else {
+ onInstallError(remoting.Error.UNEXPECTED);
+ }
+ };
+
var onDispatcherInitialized = function () {
- remoting.startHostUsingDispatcher_(hostDispatcher);
- }
+ if (hostDispatcher.usingNpapi()) {
+ hostInstallDialog = new remoting.HostInstallDialog();
+ if (navigator.platform == 'Win32') {
+ hostInstallDialog.show(
+ hostDispatcher.getNpapiHost(), onHostInstalled, onInstallError);
+ } else {
+ hostInstallDialog.show(null, onHostInstalled, onInstallError);
+ }
+ } else {
+ // Host alrady installed.
+ remoting.startHostUsingDispatcher_(hostDispatcher);
+ }
+ };
/** @param {remoting.Error} error */
var onDispatcherInitializationFailed = function(error) {
@@ -55,29 +77,20 @@ remoting.tryShare = function() {
return;
}
- // If we failed to initialize dispatcher then prompt the user to install the
- // host.
+ // If we failed to initialize the dispatcher then prompt the user to install
+ // the host manually.
if (hostInstallDialog == null) {
- var onDone = function(asyncResult) {
- // TODO (weitaosu): Ignore asyncResult for now because it is not set
- // during manual host installation. We should fix it after switching
- // to automatic host installation on Windows.
- tryInitializeDispatcher();
- };
-
hostInstallDialog = new remoting.HostInstallDialog();
(/** @type {remoting.HostInstallDialog} */ hostInstallDialog).show(
- null,
- onDone,
- onInstallPromptError);
+ null, onHostInstalled, onInstallError);
} else {
(/** @type {remoting.HostInstallDialog} */ hostInstallDialog).tryAgain();
}
- }
+ };
/** @param {remoting.Error} error */
- var onInstallPromptError = function(error) {
+ var onInstallError = function(error) {
if (error == remoting.Error.CANCELLED) {
remoting.setMode(remoting.AppMode.HOME);
} else {
diff --git a/remoting/webapp/host_setup_dialog.js b/remoting/webapp/host_setup_dialog.js
index 13717a2..bf950ba 100644
--- a/remoting/webapp/host_setup_dialog.js
+++ b/remoting/webapp/host_setup_dialog.js
@@ -273,16 +273,6 @@ remoting.HostSetupDialog.prototype.startNewFlow_ = function(sequence) {
};
/**
- * @param {string} tag
- * @private
- */
-remoting.HostSetupDialog.prototype.showProcessingMessage_ = function(tag) {
- var messageDiv = document.getElementById('host-setup-processing-message');
- l10n.localizeElementFromTag(messageDiv, tag);
- remoting.setMode(remoting.AppMode.HOST_SETUP_PROCESSING);
-}
-
-/**
* Updates current UI mode according to the current state of the setup
* flow and start the action corresponding to the current step (if
* any).
@@ -319,13 +309,14 @@ remoting.HostSetupDialog.prototype.updateState_ = function() {
} else if (state == remoting.HostSetupFlow.State.INSTALL_HOST) {
this.installHost_();
} else if (state == remoting.HostSetupFlow.State.STARTING_HOST) {
- this.showProcessingMessage_(/*i18n-content*/'HOST_SETUP_STARTING');
+ remoting.showSetupProcessingMessage(/*i18n-content*/'HOST_SETUP_STARTING');
this.startHost_();
} else if (state == remoting.HostSetupFlow.State.UPDATING_PIN) {
- this.showProcessingMessage_(/*i18n-content*/'HOST_SETUP_UPDATING_PIN');
+ remoting.showSetupProcessingMessage(
+ /*i18n-content*/'HOST_SETUP_UPDATING_PIN');
this.updatePin_();
} else if (state == remoting.HostSetupFlow.State.STOPPING_HOST) {
- this.showProcessingMessage_(/*i18n-content*/'HOST_SETUP_STOPPING');
+ remoting.showSetupProcessingMessage(/*i18n-content*/'HOST_SETUP_STOPPING');
this.stopHost_();
} else if (state == remoting.HostSetupFlow.State.HOST_STARTED) {
// TODO(jamiewalch): Only display the second string if the computer's power
@@ -396,21 +387,10 @@ remoting.HostSetupDialog.prototype.installHost_ = function() {
}
};
- if (navigator.platform == 'Win32') {
- // Currently we show two dialogs (each with a UAC prompt) when a user
- // enables the host for the first time, one for installing the host (by the
- // plugin) and the other for starting the host (by the native messaging
- // host). We'd like to reduce it to one but don't have a good solution
- // right now.
- // We also show the same message on the two dialogs because. We don't want
- // to confuse the user by saying "Installing Remote Desktop" because in
- // their mind "Remote Deskto" (the webapp) has already been installed.
- that.showProcessingMessage_(/*i18n-content*/'HOST_SETUP_STARTING');
- }
-
/** @type {remoting.HostInstallDialog} */
var hostInstallDialog = new remoting.HostInstallDialog();
- hostInstallDialog.show(this.hostController_, onDone, onError);
+ hostInstallDialog.show(
+ this.hostController_.getDispatcher().getNpapiHost(), onDone, onError);
}
/**
diff --git a/remoting/webapp/ui_mode.js b/remoting/webapp/ui_mode.js
index e9d8474..16e5e53 100644
--- a/remoting/webapp/ui_mode.js
+++ b/remoting/webapp/ui_mode.js
@@ -276,3 +276,12 @@ function confineOrRestoreFocus_(mutations) {
}
}
}
+
+/**
+ * @param {string} tag
+ */
+remoting.showSetupProcessingMessage = function(tag) {
+ var messageDiv = document.getElementById('host-setup-processing-message');
+ l10n.localizeElementFromTag(messageDiv, tag);
+ remoting.setMode(remoting.AppMode.HOST_SETUP_PROCESSING);
+}