diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 00:37:21 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 00:37:21 +0000 |
commit | 2febe2d379df617daa59950de45105700d8a6518 (patch) | |
tree | 42096318a56e9c25752ed67cc0559338ebf636a0 /remoting/webapp/host_controller.js | |
parent | ceefd7fdfd72ac1d845a053391601302af4d1f4d (diff) | |
download | chromium_src-2febe2d379df617daa59950de45105700d8a6518.zip chromium_src-2febe2d379df617daa59950de45105700d8a6518.tar.gz chromium_src-2febe2d379df617daa59950de45105700d8a6518.tar.bz2 |
Remove remoting.HostController.state()
In future, when we remove NPAPI we'll be getting host state asynchronously.
This change removes state() method from HostController class. Now the
getLocalHostStateAndId() should be used to get host state. There is still
isInstalled() used by the HostSetupDialog, but it the future it will need
to be removed as well.
Review URL: https://codereview.chromium.org/11418207
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170106 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp/host_controller.js')
-rw-r--r-- | remoting/webapp/host_controller.js | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js index 0dfabdb..53e332e 100644 --- a/remoting/webapp/host_controller.js +++ b/remoting/webapp/host_controller.js @@ -53,17 +53,21 @@ remoting.HostController.AsyncResult = { FAILED_DIRECTORY: 3 }; -/** @return {remoting.HostController.State} The current state of the daemon. */ -remoting.HostController.prototype.state = function() { - var result = this.plugin_.daemonState; - if (typeof(result) == 'undefined') { - // If the plug-in can't be instantiated, for example on ChromeOS, then - // return something sensible. - return remoting.HostController.State.NOT_IMPLEMENTED; - } else { - return result; - } -}; +/** + * Checks if the host is installed on the local computer. + * + * TODO(sergeyu): Make this method asynchronous or just remove it and use + * getLocalHostStateAndId() instead. + * + * @return {boolean} True if the host is installed. + */ +remoting.HostController.prototype.isInstalled = function() { + var state = this.plugin_.daemonState; + return typeof(state) != 'undefined' && + state != remoting.HostController.State.NOT_INSTALLED && + state != remoting.HostController.State.INSTALLING; +} + /** * @param {function(boolean, boolean, boolean):void} callback Callback to be @@ -269,9 +273,10 @@ remoting.HostController.prototype.updatePin = function(newPin, callback) { * Update the internal state so that the local host can be correctly filtered * out of the host list. * - * @param {function(string?):void} onDone Completion callback. + * @param {function(remoting.HostController.State, string?):void} onDone + * Completion callback. */ -remoting.HostController.prototype.getLocalHostId = function(onDone) { +remoting.HostController.prototype.getLocalHostStateAndId = function(onDone) { /** @type {remoting.HostController} */ var that = this; /** @param {string} configStr */ @@ -279,15 +284,23 @@ remoting.HostController.prototype.getLocalHostId = function(onDone) { var config = parseHostConfig_(configStr); if (config) { that.localHostId_ = config['host_id']; - onDone(that.localHostId_); } else { - onDone(null); + that.localHostId_ = null; } + + var state = that.plugin_.daemonState; + if (typeof(state) == 'undefined') { + // If the plug-in can't be instantiated, for example on ChromeOS, then + // return something sensible. + state = remoting.HostController.State.NOT_IMPLEMENTED; + } + + onDone(state, that.localHostId_); }; try { this.plugin_.getDaemonConfig(onConfig); } catch (err) { - onDone(null); + onDone(remoting.HostController.State.NOT_IMPLEMENTED, null); } }; |