| Index: remoting/webapp/host_controller.js
|
| diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
|
| index 9164d79e54d9a654a2c85ef44f039d0ef530b512..f8860c0e16605717b027ab18fe11ab481a4790b4 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);
|
| + }
|
| };
|
|
|
| /**
|
|
|