Chromium Code Reviews| Index: remoting/webapp/crd/js/host_controller.js |
| diff --git a/remoting/webapp/crd/js/host_controller.js b/remoting/webapp/crd/js/host_controller.js |
| index 9ef8278a6118fb51de01bbaae770e15a5067cac2..e01a7bf2f7b4a8f367f36539bd2ad1fa09ba1a54 100644 |
| --- a/remoting/webapp/crd/js/host_controller.js |
| +++ b/remoting/webapp/crd/js/host_controller.js |
| @@ -9,7 +9,21 @@ var remoting = remoting || {}; |
| /** @constructor */ |
| remoting.HostController = function() { |
| - this.hostDaemonFacade_ = this.createDaemonFacade_(); |
| + /** @type {remoting.HostDaemonFacade} @private */ |
| + this.hostDaemonFacade_ = new remoting.HostDaemonFacade(); |
| + |
| + /** @param {string} version */ |
| + var printVersion = function(version) { |
| + if (version == '') { |
| + console.log('Host not installed.'); |
| + } else { |
| + console.log('Host version: ' + version); |
| + } |
| + }; |
| + |
| + this.getLocalHostVersion().then(printVersion, function() { |
|
kelvinp
2015/06/10 18:00:45
Nit: Use .catch for error handling for readability
Jamie
2015/06/10 18:14:44
Done.
|
| + console.log('Host version not available.'); |
| + }); |
| }; |
| // The values in the enums below are duplicated in daemon_controller.h except |
| @@ -56,30 +70,6 @@ remoting.HostController.AsyncResult.fromString = function(result) { |
| } |
| /** |
| - * @return {remoting.HostDaemonFacade} |
| - * @private |
| - */ |
| -remoting.HostController.prototype.createDaemonFacade_ = function() { |
| - /** @type {remoting.HostDaemonFacade} @private */ |
| - var hostDaemonFacade = new remoting.HostDaemonFacade(); |
| - |
| - /** @param {string} version */ |
| - var printVersion = function(version) { |
| - if (version == '') { |
| - console.log('Host not installed.'); |
| - } else { |
| - console.log('Host version: ' + version); |
| - } |
| - }; |
| - |
| - hostDaemonFacade.getDaemonVersion().then(printVersion, function() { |
| - console.log('Host version not available.'); |
| - }); |
| - |
| - return hostDaemonFacade; |
| -}; |
| - |
| -/** |
| * Set of features for which hasFeature() can be used to test. |
| * |
| * @enum {string} |
| @@ -419,6 +409,14 @@ remoting.HostController.prototype.getLocalHostId = function(onDone) { |
| }; |
| /** |
| + * @return {Promise<string>} Promise that resolves with the host version, if |
| + * installed, or rejects otherwise. |
| + */ |
| +remoting.HostController.prototype.getLocalHostVersion = function() { |
| + return this.hostDaemonFacade_.getDaemonVersion(); |
| +}; |
| + |
| +/** |
| * Fetch the list of paired clients for this host. |
| * |
| * @param {function(Array<remoting.PairedClient>):void} onDone |