Index: remoting/webapp/host_dispatcher.js |
diff --git a/remoting/webapp/host_dispatcher.js b/remoting/webapp/host_dispatcher.js |
index 7b81c0e71066fce7c31aa2bc698ce112b26b0e79..7e58501319c2f80fa71a8954d21ede18511a9858 100644 |
--- a/remoting/webapp/host_dispatcher.js |
+++ b/remoting/webapp/host_dispatcher.js |
@@ -43,24 +43,28 @@ remoting.HostDispatcher = function(createPluginCallback) { |
/** @type {Array.<function()>} */ |
this.pendingRequests_ = []; |
- /** @param {boolean} success */ |
- var onNativeMessagingInit = function(success) { |
- if (success) { |
- console.log('Native Messaging supported.'); |
- that.state_ = remoting.HostDispatcher.State.NATIVE_MESSAGING; |
- } else { |
- console.log('Native Messaging unsupported, falling back to NPAPI.'); |
- that.npapiHost_ = createPluginCallback(); |
- that.state_ = remoting.HostDispatcher.State.NPAPI; |
- } |
- // Send pending requests. |
+ function sendPendingRequests() { |
for (var i = 0; i < that.pendingRequests_.length; i++) { |
that.pendingRequests_[i](); |
} |
that.pendingRequests_ = null; |
- }; |
+ } |
+ |
+ function onNativeMessagingInit() { |
+ console.log('Native Messaging supported.'); |
+ that.state_ = remoting.HostDispatcher.State.NATIVE_MESSAGING; |
+ sendPendingRequests(); |
+ } |
+ |
+ function onNativeMessagingFailed(error) { |
+ console.log('Native Messaging unsupported, falling back to NPAPI.'); |
+ that.npapiHost_ = createPluginCallback(); |
+ that.state_ = remoting.HostDispatcher.State.NPAPI; |
+ sendPendingRequests(); |
+ } |
- this.nativeMessagingHost_.initialize(onNativeMessagingInit); |
+ this.nativeMessagingHost_.initialize(onNativeMessagingInit, |
+ onNativeMessagingFailed); |
}; |
/** @enum {number} */ |