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..8017e0d4632f63a0f86c574cc4206c549c173487 100644 |
--- a/remoting/webapp/crd/js/host_controller.js |
+++ b/remoting/webapp/crd/js/host_controller.js |
@@ -9,7 +9,23 @@ 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) |
+ .catch(function() { |
+ console.log('Host version not available.'); |
+ }); |
}; |
// The values in the enums below are duplicated in daemon_controller.h except |
@@ -56,30 +72,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 +411,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 |