Commit bc944cf3 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

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
parent e96fb154
...@@ -431,9 +431,13 @@ remoting.HostController.prototype.updatePin = function(newPin, onDone, ...@@ -431,9 +431,13 @@ remoting.HostController.prototype.updatePin = function(newPin, onDone,
* callback. * callback.
*/ */
remoting.HostController.prototype.getLocalHostState = function(onDone) { remoting.HostController.prototype.getLocalHostState = function(onDone) {
this.hostDaemonFacade_.getDaemonState(onDone, function(error) { /** @param {remoting.Error} error */
onDone(remoting.HostController.State.UNKNOWN); function onError(error) {
}); onDone((error == remoting.Error.MISSING_PLUGIN) ?
remoting.HostController.State.NOT_INSTALLED :
remoting.HostController.State.UNKNOWN);
}
this.hostDaemonFacade_.getDaemonState(onDone, onError);
}; };
/** /**
......
...@@ -43,6 +43,9 @@ remoting.HostDaemonFacade = function() { ...@@ -43,6 +43,9 @@ remoting.HostDaemonFacade = function() {
/** @private */ /** @private */
this.initializationFinished_ = false; this.initializationFinished_ = false;
/** @type {remoting.Error} @private */
this.error_ = remoting.Error.NONE;
try { try {
this.port_ = chrome.runtime.connectNative( this.port_ = chrome.runtime.connectNative(
'com.google.chrome.remote_desktop'); 'com.google.chrome.remote_desktop');
...@@ -80,10 +83,6 @@ remoting.HostDaemonFacade.PendingReply = function(type, onDone, onError) { ...@@ -80,10 +83,6 @@ remoting.HostDaemonFacade.PendingReply = function(type, onDone, onError) {
*/ */
remoting.HostDaemonFacade.prototype.onInitialized_ = function(success) { remoting.HostDaemonFacade.prototype.onInitialized_ = function(success) {
this.initializationFinished_ = true; this.initializationFinished_ = true;
if (!success) {
this.port_ = null;
}
var afterInitializationTasks = this.afterInitializationTasks_; var afterInitializationTasks = this.afterInitializationTasks_;
this.afterInitializationTasks_ = []; this.afterInitializationTasks_ = [];
for (var id in afterInitializationTasks) { for (var id in afterInitializationTasks) {
...@@ -128,7 +127,7 @@ remoting.HostDaemonFacade.prototype.hasFeature = function(feature, onDone) { ...@@ -128,7 +127,7 @@ remoting.HostDaemonFacade.prototype.hasFeature = function(feature, onDone) {
remoting.HostDaemonFacade.prototype.postMessage_ = remoting.HostDaemonFacade.prototype.postMessage_ =
function(message, onDone, onError) { function(message, onDone, onError) {
if (!this.port_) { if (!this.port_) {
onError(remoting.Error.UNEXPECTED); onError(this.error_);
return; return;
} }
var id = this.nextId_++; var id = this.nextId_++;
...@@ -280,13 +279,18 @@ remoting.HostDaemonFacade.prototype.handleIncomingMessage_ = ...@@ -280,13 +279,18 @@ remoting.HostDaemonFacade.prototype.handleIncomingMessage_ =
remoting.HostDaemonFacade.prototype.onDisconnect_ = function() { remoting.HostDaemonFacade.prototype.onDisconnect_ = function() {
console.error('Native Message port disconnected'); 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. // Notify the error-handlers of any requests that are still outstanding.
var pendingReplies = this.pendingReplies_; var pendingReplies = this.pendingReplies_;
this.pendingReplies_ = {}; this.pendingReplies_ = {};
for (var id in pendingReplies) { for (var id in pendingReplies) {
pendingReplies[/** @type {number} */(id)].onError( pendingReplies[/** @type {number} */(id)].onError(this.error_);
remoting.Error.UNEXPECTED);
} }
} }
...@@ -392,7 +396,7 @@ remoting.HostDaemonFacade.prototype.getDaemonVersion = ...@@ -392,7 +396,7 @@ remoting.HostDaemonFacade.prototype.getDaemonVersion =
if (success) { if (success) {
onDone(that.version_); onDone(that.version_);
} else { } else {
onError(remoting.Error.UNEXPECTED); onError(that.error_);
} }
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment