Index: remoting/webapp/background/it2me_helper_channel.js |
diff --git a/remoting/webapp/background/it2me_helper_channel.js b/remoting/webapp/background/it2me_helper_channel.js |
index e25c443b6a64cd848bd595b91dbae9ecce908b84..e039783273b6c462e57bc24fde01b1cc0f73b481 100644 |
--- a/remoting/webapp/background/it2me_helper_channel.js |
+++ b/remoting/webapp/background/it2me_helper_channel.js |
@@ -10,13 +10,20 @@ |
* assistance). |
* |
* It runs in the background page and contains two chrome.runtime.Port objects, |
- * respresenting connections to the webapp and hangout, respectively. |
+ * representing connections to the webapp and hangout, respectively. |
* |
- * Connection is always initiated from Hangouts. |
+ * Connection is always initiated from Hangouts by calling |
+ * var port = chrome.runtime.connect({name:'it2me.helper.hangout'}, extId). |
+ * port.postMessage('hello') |
+ * If the webapp is not installed, |port.onDisconnect| will fire. |
+ * If the webapp is installed, Hangouts will receive a hello response with the |
+ * list of supported features. |
* |
* Hangout It2MeHelperChannel Chrome Remote Desktop |
* |-----runtime.connect() ------>| | |
- * |------connect message-------->| | |
+ * |--------hello message-------->| | |
+ * | |<-----helloResponse message-----| |
+ * |-------connect message------->| | |
* | |-------appLauncher.launch()---->| |
* | |<------runtime.connect()------- | |
* | |<-----sessionStateChanged------ | |
@@ -109,11 +116,18 @@ remoting.It2MeHelperChannel = |
/** @enum {string} */ |
remoting.It2MeHelperChannel.HangoutMessageTypes = { |
+ HELLO: 'hello', |
+ HELLO_RESPONSE: 'helloResponse', |
CONNECT: 'connect', |
DISCONNECT: 'disconnect' |
}; |
/** @enum {string} */ |
+remoting.It2MeHelperChannel.Features = { |
+ REMOTE_ASSISTANCE: 'remoteAssistance' |
+}; |
+ |
+/** @enum {string} */ |
remoting.It2MeHelperChannel.WebappMessageTypes = { |
SESSION_STATE_CHANGED: 'sessionStateChanged' |
}; |
@@ -143,7 +157,14 @@ remoting.It2MeHelperChannel.prototype.onHangoutMessage_ = function(message) { |
case MessageTypes.DISCONNECT: |
this.closeWebapp_(message); |
return true; |
+ case MessageTypes.HELLO: |
+ this.hangoutPort_.postMessage({ |
+ method: MessageTypes.HELLO_RESPONSE, |
+ supportedFeatures: base.values(remoting.It2MeHelperChannel.Features) |
+ }); |
+ return true; |
} |
+ throw new Error('Unknown message method=' + message.method); |
} catch(e) { |
var error = /** @type {Error} */ e; |
console.error(error); |