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

Side by Side Diff: remoting/webapp/background/it2me_helper_channel.js

Issue 473073002: Move hello message from It2MeService to It2MeChannel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 7 *
8 * It2MeHelperChannel relays messages between Hangouts and Chrome Remote Desktop 8 * It2MeHelperChannel relays messages between Hangouts and Chrome Remote Desktop
9 * (webapp) for the helper (the Hangouts participant who is giving remote 9 * (webapp) for the helper (the Hangouts participant who is giving remote
10 * assistance). 10 * assistance).
11 * 11 *
12 * It runs in the background page and contains two chrome.runtime.Port objects, 12 * It runs in the background page and contains two chrome.runtime.Port objects,
13 * respresenting connections to the webapp and hangout, respectively. 13 * representing connections to the webapp and hangout, respectively.
14 * 14 *
15 * Connection is always initiated from Hangouts. 15 * Connection is always initiated from Hangouts by calling
16 * var port = chrome.runtime.connect({name:'it2me.helper.hangout'}, extId).
17 * port.postMessage('hello')
18 * If the webapp is not installed, |port.onDisconnect| will fire.
19 * If the webapp is installed, Hangouts will receive a hello response with the
20 * list of supported features.
16 * 21 *
17 * Hangout It2MeHelperChannel Chrome Remote Desktop 22 * Hangout It2MeHelperChannel Chrome Remote Desktop
18 * |-----runtime.connect() ------>| | 23 * |-----runtime.connect() ------>| |
19 * |------connect message-------->| | 24 * |--------hello message-------->| |
25 * | |<-----helloResponse message-----|
26 * |-------connect message------->| |
20 * | |-------appLauncher.launch()---->| 27 * | |-------appLauncher.launch()---->|
21 * | |<------runtime.connect()------- | 28 * | |<------runtime.connect()------- |
22 * | |<-----sessionStateChanged------ | 29 * | |<-----sessionStateChanged------ |
23 * |<----sessionStateChanged------| | 30 * |<----sessionStateChanged------| |
24 * 31 *
25 * Disconnection can be initiated from either side: 32 * Disconnection can be initiated from either side:
26 * 1. In the normal flow initiated from hangout 33 * 1. In the normal flow initiated from hangout
27 * Hangout It2MeHelperChannel Chrome Remote Desktop 34 * Hangout It2MeHelperChannel Chrome Remote Desktop
28 * |-----disconnect message------>| | 35 * |-----disconnect message------>| |
29 * |<-sessionStateChanged(CLOSED)-| | 36 * |<-sessionStateChanged(CLOSED)-| |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 110
104 this.onWebappMessageRef_ = this.onWebappMessage_.bind(this); 111 this.onWebappMessageRef_ = this.onWebappMessage_.bind(this);
105 this.onWebappDisconnectRef_ = this.onWebappDisconnect_.bind(this); 112 this.onWebappDisconnectRef_ = this.onWebappDisconnect_.bind(this);
106 this.onHangoutMessageRef_ = this.onHangoutMessage_.bind(this); 113 this.onHangoutMessageRef_ = this.onHangoutMessage_.bind(this);
107 this.onHangoutDisconnectRef_ = this.onHangoutDisconnect_.bind(this); 114 this.onHangoutDisconnectRef_ = this.onHangoutDisconnect_.bind(this);
108 }; 115 };
109 116
110 /** @enum {string} */ 117 /** @enum {string} */
111 remoting.It2MeHelperChannel.HangoutMessageTypes = { 118 remoting.It2MeHelperChannel.HangoutMessageTypes = {
112 CONNECT: 'connect', 119 CONNECT: 'connect',
113 DISCONNECT: 'disconnect' 120 DISCONNECT: 'disconnect',
121 HELLO: 'hello'
114 }; 122 };
115 123
116 /** @enum {string} */ 124 /** @enum {string} */
117 remoting.It2MeHelperChannel.WebappMessageTypes = { 125 remoting.It2MeHelperChannel.WebappMessageTypes = {
118 SESSION_STATE_CHANGED: 'sessionStateChanged' 126 SESSION_STATE_CHANGED: 'sessionStateChanged'
119 }; 127 };
120 128
121 remoting.It2MeHelperChannel.prototype.init = function() { 129 remoting.It2MeHelperChannel.prototype.init = function() {
122 this.hangoutPort_.onMessage.addListener(this.onHangoutMessageRef_); 130 this.hangoutPort_.onMessage.addListener(this.onHangoutMessageRef_);
123 this.hangoutPort_.onDisconnect.addListener(this.onHangoutDisconnectRef_); 131 this.hangoutPort_.onDisconnect.addListener(this.onHangoutDisconnectRef_);
(...skipping 12 matching lines...) Expand all
136 remoting.It2MeHelperChannel.prototype.onHangoutMessage_ = function(message) { 144 remoting.It2MeHelperChannel.prototype.onHangoutMessage_ = function(message) {
137 try { 145 try {
138 var MessageTypes = remoting.It2MeHelperChannel.HangoutMessageTypes; 146 var MessageTypes = remoting.It2MeHelperChannel.HangoutMessageTypes;
139 switch (message.method) { 147 switch (message.method) {
140 case MessageTypes.CONNECT: 148 case MessageTypes.CONNECT:
141 this.launchWebapp_(message); 149 this.launchWebapp_(message);
142 return true; 150 return true;
143 case MessageTypes.DISCONNECT: 151 case MessageTypes.DISCONNECT:
144 this.closeWebapp_(message); 152 this.closeWebapp_(message);
145 return true; 153 return true;
154 case MessageTypes.HELLO:
155 this.hangoutPort_.postMessage({
156 method: message.method + 'Response',
Jamie 2014/08/15 19:11:46 I think that helloResponse would be better declare
kelvinp 2014/08/15 21:28:32 Done.
157 supportedFeatures:
158 base.values(remoting.It2MeHelperChannel.HangoutMessageTypes)
Jamie 2014/08/15 19:11:46 I don't think that requiring a 1-1 mapping of feat
kelvinp 2014/08/15 21:28:32 Done.
159 });
160 return true;
146 } 161 }
147 } catch(e) { 162 } catch(e) {
148 var error = /** @type {Error} */ e; 163 var error = /** @type {Error} */ e;
149 console.error(error); 164 console.error(error);
150 this.hangoutPort_.postMessage({ 165 this.hangoutPort_.postMessage({
151 method: message.method + 'Response', 166 method: message.method + 'Response',
152 error: error.message 167 error: error.message
153 }); 168 });
154 } 169 }
155 return false; 170 return false;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 this.hangoutPort_.onDisconnect.removeListener(this.onHangoutDisconnectRef_); 296 this.hangoutPort_.onDisconnect.removeListener(this.onHangoutDisconnectRef_);
282 this.hangoutPort_.disconnect(); 297 this.hangoutPort_.disconnect();
283 this.hangoutPort_ = null; 298 this.hangoutPort_ = null;
284 } 299 }
285 300
286 if (this.onDisconnectCallback_) { 301 if (this.onDisconnectCallback_) {
287 this.onDisconnectCallback_(this); 302 this.onDisconnectCallback_(this);
288 this.onDisconnectCallback_ = null; 303 this.onDisconnectCallback_ = null;
289 } 304 }
290 }; 305 };
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/background/it2me_service.js » ('j') | remoting/webapp/background/it2me_service.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698