Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Unified Diff: remoting/webapp/host_daemon_facade.js

Issue 396063003: Fix HostDaemonFacade to handle the case when NM host is not installed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/host_controller.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/host_daemon_facade.js
diff --git a/remoting/webapp/host_daemon_facade.js b/remoting/webapp/host_daemon_facade.js
index c21695d2082041ba355f3f518a36b52800722f0c..5b1567aaece2a4deb8b625df829a537c156b981b 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_);
}
});
}
« no previous file with comments | « remoting/webapp/host_controller.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698