diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-17 00:38:22 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-17 00:38:22 +0000 |
commit | bc944cf3eac91612afc29cc8d4b4c61471827358 (patch) | |
tree | 3ad94f2d43a22baaa8e2f9f096bee515fddab614 | |
parent | e96fb154e05d5f6a87afcf612e07a9d224782af3 (diff) | |
download | chromium_src-bc944cf3eac91612afc29cc8d4b4c61471827358.zip chromium_src-bc944cf3eac91612afc29cc8d4b4c61471827358.tar.gz chromium_src-bc944cf3eac91612afc29cc8d4b4c61471827358.tar.bz2 |
Fix HostDaemonFacade to handle the case when NM host is not installed.
BUG=393388
R=jamiewalch@chromium.org
Review URL: https://codereview.chromium.org/396063003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283595 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/webapp/host_controller.js | 10 | ||||
-rw-r--r-- | remoting/webapp/host_daemon_facade.js | 22 |
2 files changed, 20 insertions, 12 deletions
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js index dfcfcf6..34278ac 100644 --- a/remoting/webapp/host_controller.js +++ b/remoting/webapp/host_controller.js @@ -431,9 +431,13 @@ remoting.HostController.prototype.updatePin = function(newPin, onDone, * callback. */ remoting.HostController.prototype.getLocalHostState = function(onDone) { - this.hostDaemonFacade_.getDaemonState(onDone, function(error) { - onDone(remoting.HostController.State.UNKNOWN); - }); + /** @param {remoting.Error} error */ + function onError(error) { + onDone((error == remoting.Error.MISSING_PLUGIN) ? + remoting.HostController.State.NOT_INSTALLED : + remoting.HostController.State.UNKNOWN); + } + this.hostDaemonFacade_.getDaemonState(onDone, onError); }; /** diff --git a/remoting/webapp/host_daemon_facade.js b/remoting/webapp/host_daemon_facade.js index c21695d..5b1567a 100644 --- a/remoting/webapp/host_daemon_facade.js +++ b/remoting/webapp/host_daemon_facade.js @@ -43,6 +43,9 @@ remoting.HostDaemonFacade = function() { /** @private */ this.initializationFinished_ = false; + /** @type {remoting.Error} @private */ + this.error_ = remoting.Error.NONE; + try { this.port_ = chrome.runtime.connectNative( 'com.google.chrome.remote_desktop'); @@ -80,10 +83,6 @@ remoting.HostDaemonFacade.PendingReply = function(type, onDone, onError) { */ remoting.HostDaemonFacade.prototype.onInitialized_ = function(success) { this.initializationFinished_ = true; - if (!success) { - this.port_ = null; - } - var afterInitializationTasks = this.afterInitializationTasks_; this.afterInitializationTasks_ = []; for (var id in afterInitializationTasks) { @@ -128,7 +127,7 @@ remoting.HostDaemonFacade.prototype.hasFeature = function(feature, onDone) { remoting.HostDaemonFacade.prototype.postMessage_ = function(message, onDone, onError) { if (!this.port_) { - onError(remoting.Error.UNEXPECTED); + onError(this.error_); return; } var id = this.nextId_++; @@ -280,13 +279,18 @@ remoting.HostDaemonFacade.prototype.handleIncomingMessage_ = remoting.HostDaemonFacade.prototype.onDisconnect_ = function() { console.error('Native Message port disconnected'); + this.port_ = null; + + // If initialization hasn't finished then assume that the port was + // disconnected because Native Messaging host is not installed. + this.error_ = this.initializationFinished_ ? remoting.Error.UNEXPECTED : + remoting.Error.MISSING_PLUGIN; + // Notify the error-handlers of any requests that are still outstanding. var pendingReplies = this.pendingReplies_; this.pendingReplies_ = {}; - for (var id in pendingReplies) { - pendingReplies[/** @type {number} */(id)].onError( - remoting.Error.UNEXPECTED); + pendingReplies[/** @type {number} */(id)].onError(this.error_); } } @@ -392,7 +396,7 @@ remoting.HostDaemonFacade.prototype.getDaemonVersion = if (success) { onDone(that.version_); } else { - onError(remoting.Error.UNEXPECTED); + onError(that.error_); } }); } |