diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-30 20:02:23 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-30 20:02:23 +0000 |
commit | 63157e7efd57c3b7bd89af64607eea1a8f460bb6 (patch) | |
tree | 6dffd9eeee4d2a09d91cab086e03f40981fd2cc9 /remoting/webapp/host_controller.js | |
parent | 2a5c8be4bd97e396000cfe767820c31da6ebbd84 (diff) | |
download | chromium_src-63157e7efd57c3b7bd89af64607eea1a8f460bb6.zip chromium_src-63157e7efd57c3b7bd89af64607eea1a8f460bb6.tar.gz chromium_src-63157e7efd57c3b7bd89af64607eea1a8f460bb6.tar.bz2 |
Implement hello exchange with Chromoting Native Messaging host
The webapp initializes Native Messaging, sends a 'hello'
message to the host and waits for a response. If this fails,
the webapp gets a disconnect notification on the port (if it
was successfully created) and falls back to using the NPAPI
plugin.
BUG=173509
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/13284002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp/host_controller.js')
-rw-r--r-- | remoting/webapp/host_controller.js | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js index c35d63c..fd54442 100644 --- a/remoting/webapp/host_controller.js +++ b/remoting/webapp/host_controller.js @@ -9,34 +9,46 @@ var remoting = remoting || {}; /** @constructor */ remoting.HostController = function() { + /** @type {remoting.HostController} */ + var that = this; + + /** @type {boolean} @private */ + this.pluginSupported_ = true; + /** @type {remoting.HostPlugin} @private */ - this.plugin_ = null; - if (remoting.HostNativeMessaging.isSupported()) { - this.plugin_ = new remoting.HostNativeMessaging(); - } else { - this.plugin_ = remoting.HostSession.createPlugin(); - /** @type {HTMLElement} @private */ - var container = document.getElementById('daemon-plugin-container'); - container.appendChild(this.plugin_); - } + this.plugin_ = new remoting.HostNativeMessaging(); - /** @param {string} version */ - var printVersion = function(version) { - if (version == '') { - console.log('Host not installed.'); + /** @param {boolean} success */ + var onNativeMessagingInit = function(success) { + if (success) { + console.log('Native Messaging supported.'); } else { - console.log('Host version: ' + version); + console.log('Native Messaging unsupported, falling back to NPAPI.'); + that.plugin_ = remoting.HostSession.createPlugin(); + /** @type {HTMLElement} @private */ + var container = document.getElementById('daemon-plugin-container'); + container.appendChild(that.plugin_); + } + + /** @param {string} version */ + var printVersion = function(version) { + if (version == '') { + console.log('Host not installed.'); + } else { + console.log('Host version: ' + version); + } + }; + that.pluginSupported_ = true; + try { + that.plugin_.getDaemonVersion(printVersion); + } catch (err) { + console.log('Host version not available.'); + that.pluginSupported_ = false; } - }; - /** @type {boolean} @private */ - this.pluginSupported_ = true; - try { - this.plugin_.getDaemonVersion(printVersion); - } catch (err) { - console.log('Host version not available.'); - this.pluginSupported_ = false; } -}; + + this.plugin_.initialize(onNativeMessagingInit); +} // Note that the values in the enums below are copied from // daemon_controller.h and must be kept in sync. |