summaryrefslogtreecommitdiffstats
path: root/remoting/webapp
diff options
context:
space:
mode:
authorweitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-15 00:41:06 +0000
committerweitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-15 00:41:06 +0000
commit174963675bf92d06bf24b251efa46ddee3475b8e (patch)
treee0d86e9a192f05155461a7d0c1c774208508426a /remoting/webapp
parentcc239fd0d40bf199ac5332f4ee4180c87a4ce85e (diff)
downloadchromium_src-174963675bf92d06bf24b251efa46ddee3475b8e.zip
chromium_src-174963675bf92d06bf24b251efa46ddee3475b8e.tar.gz
chromium_src-174963675bf92d06bf24b251efa46ddee3475b8e.tar.bz2
On Windows, install the chromoting host component via a separate NPAPI call. This sets us up for:
1. installation of the host component using the Omaha native messaging API when it's ready 2. removal of the NPAPI plugin. BUG=134215 Review URL: https://codereview.chromium.org/232223003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r--remoting/webapp/host_controller.js85
-rw-r--r--remoting/webapp/host_dispatcher.js33
-rw-r--r--remoting/webapp/host_setup_dialog.js4
-rw-r--r--remoting/webapp/js_proto/remoting_proto.js5
-rw-r--r--remoting/webapp/remoting.js7
5 files changed, 106 insertions, 28 deletions
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
index 9164d79..f8860c0 100644
--- a/remoting/webapp/host_controller.js
+++ b/remoting/webapp/host_controller.js
@@ -9,28 +9,7 @@ var remoting = remoting || {};
/** @constructor */
remoting.HostController = function() {
- /** @return {remoting.HostPlugin} */
- var createPluginForMe2Me = function() {
- /** @type {HTMLElement} @private */
- var container = document.getElementById('daemon-plugin-container');
- return remoting.createNpapiPlugin(container);
- };
-
- /** @type {remoting.HostDispatcher} @private */
- this.hostDispatcher_ = new remoting.HostDispatcher(createPluginForMe2Me);
-
- /** @param {string} version */
- var printVersion = function(version) {
- if (version == '') {
- console.log('Host not installed.');
- } else {
- console.log('Host version: ' + version);
- }
- };
-
- this.hostDispatcher_.getDaemonVersion(printVersion, function() {
- console.log('Host version not available.');
- });
+ this.hostDispatcher_ = this.createDispatcher_();
};
// Note that the values in the enums below are copied from
@@ -78,6 +57,37 @@ remoting.HostController.AsyncResult.fromString = function(result) {
}
/**
+ * @return {remoting.HostDispatcher}
+ * @private
+ */
+remoting.HostController.prototype.createDispatcher_ = function() {
+ /** @return {remoting.HostPlugin} */
+ var createPluginForMe2Me = function() {
+ /** @type {HTMLElement} @private */
+ var container = document.getElementById('daemon-plugin-container');
+ return remoting.createNpapiPlugin(container);
+ };
+
+ /** @type {remoting.HostDispatcher} @private */
+ var hostDispatcher = new remoting.HostDispatcher(createPluginForMe2Me);
+
+ /** @param {string} version */
+ var printVersion = function(version) {
+ if (version == '') {
+ console.log('Host not installed.');
+ } else {
+ console.log('Host version: ' + version);
+ }
+ };
+
+ hostDispatcher.getDaemonVersion(printVersion, function() {
+ console.log('Host version not available.');
+ });
+
+ return hostDispatcher;
+};
+
+/**
* Set of features for which hasFeature() can be used to test.
*
* @enum {string}
@@ -109,6 +119,15 @@ remoting.HostController.prototype.getConsent = function(onDone, onError) {
};
/**
+ * @param {function(remoting.HostController.AsyncResult):void} onDone
+ * @param {function(remoting.Error):void} onError
+ * @return {void}
+ */
+remoting.HostController.prototype.installHost = function(onDone, onError) {
+ this.hostDispatcher_.installHost(onDone, onError);
+};
+
+/**
* Registers and starts the host.
*
* @param {string} hostPin Host PIN.
@@ -325,7 +344,27 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
onError);
}
- this.hostDispatcher_.getHostName(startWithHostname, onError);
+ /** @param {remoting.HostController.AsyncResult} asyncResult */
+ var onHostInstalled = function(asyncResult) {
+ if (asyncResult == remoting.HostController.AsyncResult.OK) {
+ // Now that the host is installed, we need to get a new dispatcher that
+ // dispatches to the NM host instead of the NPAPI plugin.
+ console.log('Recreating the host dispatcher.');
+ that.hostDispatcher_ = that.createDispatcher_();
+ that.hostDispatcher_.getHostName(startWithHostname, onError);
+ } else if (asyncResult == remoting.HostController.AsyncResult.CANCELLED) {
+ onError(remoting.Error.CANCELLED);
+ } else {
+ onError(remoting.Error.UNEXPECTED);
+ }
+ }
+
+ // Perform the installation step here on Windows.
+ if (navigator.platform == 'Win32') {
+ this.installHost(onHostInstalled, onError);
+ } else {
+ this.hostDispatcher_.getHostName(startWithHostname, onError);
+ }
};
/**
diff --git a/remoting/webapp/host_dispatcher.js b/remoting/webapp/host_dispatcher.js
index 5dd3bc9..a156697 100644
--- a/remoting/webapp/host_dispatcher.js
+++ b/remoting/webapp/host_dispatcher.js
@@ -34,12 +34,13 @@ remoting.HostDispatcher = function(createPluginCallback) {
/** @type {remoting.HostPlugin} @private */
this.npapiHost_ = null;
- /** @type {remoting.HostDispatcher.State} */
+ /** @type {remoting.HostDispatcher.State} @private */
this.state_ = remoting.HostDispatcher.State.UNKNOWN;
- /** @type {Array.<function()>} */
+ /** @type {Array.<function()>} @private */
this.pendingRequests_ = [];
+ /** @type {function():remoting.HostPlugin} @private */
this.createPluginCallback_ = createPluginCallback;
this.tryToInitialize_();
@@ -326,6 +327,34 @@ remoting.HostDispatcher.prototype.getUsageStatsConsent =
};
/**
+ * @param {function(remoting.HostController.AsyncResult):void} onDone
+ * @param {function(remoting.Error):void} onError
+ * @return {void}
+ */
+remoting.HostDispatcher.prototype.installHost = function(onDone, onError) {
+ switch (this.state_) {
+ case remoting.HostDispatcher.State.UNKNOWN:
+ this.pendingRequests_.push(
+ this.startDaemon.bind(this, config, consent, onDone, onError));
+ break;
+ case remoting.HostDispatcher.State.NATIVE_MESSAGING:
+ // Host already installed, no action needed.
+ onDone(remoting.HostController.AsyncResult.OK);
+ break;
+ case remoting.HostDispatcher.State.NPAPI:
+ try {
+ this.npapiHost_.installHost(onDone);
+ } catch (err) {
+ onError(remoting.Error.MISSING_PLUGIN);
+ }
+ break;
+ case remoting.HostDispatcher.State.NOT_INSTALLED:
+ onError(remoting.Error.MISSING_PLUGIN);
+ break;
+ }
+};
+
+/**
* @param {Object} config
* @param {boolean} consent
* @param {function(remoting.HostController.AsyncResult):void} onDone
diff --git a/remoting/webapp/host_setup_dialog.js b/remoting/webapp/host_setup_dialog.js
index 800770b..f8c12bf 100644
--- a/remoting/webapp/host_setup_dialog.js
+++ b/remoting/webapp/host_setup_dialog.js
@@ -372,7 +372,9 @@ remoting.HostSetupDialog.prototype.installHost_ = function() {
var installed =
state != remoting.HostController.State.NOT_INSTALLED &&
state != remoting.HostController.State.INSTALLING;
- if (installed) {
+
+ // On Windows we perform the host installation after showing the pin form.
+ if (installed || navigator.platform == 'Win32') {
that.flow_.switchToNextStep();
that.updateState_();
} else {
diff --git a/remoting/webapp/js_proto/remoting_proto.js b/remoting/webapp/js_proto/remoting_proto.js
index 52252e1..8b5321e 100644
--- a/remoting/webapp/js_proto/remoting_proto.js
+++ b/remoting/webapp/js_proto/remoting_proto.js
@@ -97,6 +97,11 @@ remoting.HostPlugin.prototype.getDaemonVersion = function(callback) {};
* @return {void} Nothing. */
remoting.HostPlugin.prototype.getUsageStatsConsent = function(callback) {};
+/** @param {function(remoting.HostController.AsyncResult):void} callback
+ * Callback to be called when finished.
+ * @return {void} Nothing. */
+remoting.HostPlugin.prototype.installHost = function(callback) {};
+
/** @param {string} config Host configuration.
* @param {function(remoting.HostController.AsyncResult):void} callback
* Callback to be called when finished.
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index 9e15be8..b59ec6e 100644
--- a/remoting/webapp/remoting.js
+++ b/remoting/webapp/remoting.js
@@ -185,8 +185,11 @@ remoting.createNpapiPlugin = function(container) {
remoting.isMe2MeInstallable = function() {
/** @type {string} */
var platform = navigator.platform;
- // Chromoting host is not installable on ChromeOS and any linux distro other
- // than Ubuntu.
+ // The chromoting host is currently not installable on ChromeOS.
+ // For Linux, we have a install package for Ubuntu but not other distros.
+ // Since we cannot tell from javascript alone the Linux distro the client is
+ // on, we don't show the daemon-control UI for Linux unless the host is
+ // installed.
return platform == 'Win32' || platform == 'MacIntel';
}