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

Side by Side Diff: remoting/webapp/crd/js/it2me_helpee_channel.js

Issue 803653004: Update Chromoting to use /third_party/closure_compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Define Entry for browser_tests Created 5 years, 11 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
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 * It2MeHelpeeChannel relays messages between the Hangouts web page (Hangouts) 8 * It2MeHelpeeChannel relays messages between the Hangouts web page (Hangouts)
9 * and the It2Me Native Messaging Host (It2MeHost) for the helpee (the Hangouts 9 * and the It2Me Native Messaging Host (It2MeHost) for the helpee (the Hangouts
10 * participant who is receiving remoting assistance). 10 * participant who is receiving remoting assistance).
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 this.handleDownloadHost_(message); 181 this.handleDownloadHost_(message);
182 return true; 182 return true;
183 case MessageTypes.CONNECT: 183 case MessageTypes.CONNECT:
184 this.handleConnect_(message); 184 this.handleConnect_(message);
185 return true; 185 return true;
186 case MessageTypes.DISCONNECT: 186 case MessageTypes.DISCONNECT:
187 this.dispose(); 187 this.dispose();
188 return true; 188 return true;
189 } 189 }
190 throw new Error('Unsupported message method=' + message.method); 190 throw new Error('Unsupported message method=' + message.method);
191 } catch(e) { 191 } catch(/** @type {Error} */ error) {
192 var error = /** @type {Error} */ e;
193 this.sendErrorResponse_(message, error.message); 192 this.sendErrorResponse_(message, error.message);
194 } 193 }
195 return false; 194 return false;
196 }; 195 };
197 196
198 /** 197 /**
199 * Queries the |hostInstaller| for the installation status. 198 * Queries the |hostInstaller| for the installation status.
200 * 199 *
201 * @param {{method:string, data:Object.<string,*>}} message 200 * @param {{method:string, data:Object.<string,*>}} message
202 * @private 201 * @private
203 */ 202 */
204 remoting.It2MeHelpeeChannel.prototype.handleIsHostInstalled_ = 203 remoting.It2MeHelpeeChannel.prototype.handleIsHostInstalled_ =
205 function(message) { 204 function(message) {
206 /** @type {remoting.It2MeHelpeeChannel} */ 205 /** @type {remoting.It2MeHelpeeChannel} */
207 var that = this; 206 var that = this;
208 207
209 /** @param {boolean} installed */ 208 /** @param {boolean} installed */
210 function sendResponse(installed) { 209 function sendResponse(installed) {
211 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes; 210 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
212 that.hangoutPort_.postMessage({ 211 that.hangoutPort_.postMessage({
213 method: MessageTypes.IS_HOST_INSTALLED_RESPONSE, 212 method: MessageTypes.IS_HOST_INSTALLED_RESPONSE,
214 result: installed 213 result: installed
215 }); 214 });
216 } 215 }
217 216
218 this.hostInstaller_.isInstalled().then( 217 this.hostInstaller_.isInstalled().then(
219 sendResponse, 218 sendResponse,
220 this.sendErrorResponse_.bind(this, message) 219 /** @type {function(*):void} */(this.sendErrorResponse_.bind(this, message))
221 ); 220 );
222 }; 221 };
223 222
224 /** 223 /**
225 * @param {{method:string, data:Object.<string,*>}} message 224 * @param {{method:string, data:Object.<string,*>}} message
226 * @private 225 * @private
227 */ 226 */
228 remoting.It2MeHelpeeChannel.prototype.handleDownloadHost_ = function(message) { 227 remoting.It2MeHelpeeChannel.prototype.handleDownloadHost_ = function(message) {
229 try { 228 try {
230 this.hostInstaller_.download(); 229 this.hostInstaller_.download();
231 } catch (e) { 230 } catch (/** @type {*} */ e) {
232 var error = /** @type {Error} */ e; 231 var error = /** @type {Error} */ (e);
233 this.sendErrorResponse_(message, error.message); 232 this.sendErrorResponse_(message, error.message);
234 } 233 }
235 }; 234 };
236 235
237 /** 236 /**
238 * Disconnect the session if the |hangoutPort| gets disconnected. 237 * Disconnect the session if the |hangoutPort| gets disconnected.
239 * @private 238 * @private
240 */ 239 */
241 remoting.It2MeHelpeeChannel.prototype.onHangoutDisconnect_ = function() { 240 remoting.It2MeHelpeeChannel.prototype.onHangoutDisconnect_ = function() {
242 this.dispose(); 241 this.dispose();
(...skipping 15 matching lines...) Expand all
258 257
259 if (this.hostState_ !== remoting.HostSession.State.UNKNOWN) { 258 if (this.hostState_ !== remoting.HostSession.State.UNKNOWN) {
260 throw new Error('An existing connection is in progress.'); 259 throw new Error('An existing connection is in progress.');
261 } 260 }
262 261
263 this.showConfirmDialog_().then( 262 this.showConfirmDialog_().then(
264 this.initializeHost_.bind(this) 263 this.initializeHost_.bind(this)
265 ).then( 264 ).then(
266 this.fetchOAuthToken_.bind(this) 265 this.fetchOAuthToken_.bind(this)
267 ).then( 266 ).then(
268 this.connectToHost_.bind(this, email), 267 /** @type {function(*):void} */(this.connectToHost_.bind(this, email)),
269 this.sendErrorResponse_.bind(this, message) 268 /** @type {function(*):void} */(this.sendErrorResponse_.bind(this, message))
270 ); 269 );
271 }; 270 };
272 271
273 /** 272 /**
274 * Prompts the user before starting the It2Me Native Messaging Host. This 273 * Prompts the user before starting the It2Me Native Messaging Host. This
275 * ensures that even if Hangouts is compromised, an attacker cannot start the 274 * ensures that even if Hangouts is compromised, an attacker cannot start the
276 * host without explicit user confirmation. 275 * host without explicit user confirmation.
277 * 276 *
278 * @return {Promise} A promise that resolves to a boolean value, indicating 277 * @return {Promise} A promise that resolves to a boolean value, indicating
279 * whether the user accepts the remote assistance or not. 278 * whether the user accepts the remote assistance or not.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 '<li>' + base.escapeHTML(message2) + '</li>' + 327 '<li>' + base.escapeHTML(message2) + '</li>' +
329 '</ul>'; 328 '</ul>';
330 /** 329 /**
331 * @param {function(*=):void} resolve 330 * @param {function(*=):void} resolve
332 * @param {function(*=):void} reject 331 * @param {function(*=):void} reject
333 */ 332 */
334 return new Promise(function(resolve, reject) { 333 return new Promise(function(resolve, reject) {
335 /** @param {number} result */ 334 /** @param {number} result */
336 function confirmDialogCallback(result) { 335 function confirmDialogCallback(result) {
337 if (result === 1) { 336 if (result === 1) {
338 resolve(); 337 resolve(true);
339 } else { 338 } else {
340 reject(new Error(remoting.Error.CANCELLED)); 339 reject(new Error(remoting.Error.CANCELLED));
341 } 340 }
342 } 341 }
343 remoting.MessageWindow.showConfirmWindow( 342 remoting.MessageWindow.showConfirmWindow(
344 '', // Empty string to use the package name as the dialog title. 343 '', // Empty string to use the package name as the dialog title.
345 message, 344 message,
346 l10n.getTranslationOrError( 345 l10n.getTranslationOrError(
347 /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_ACCEPT'), 346 /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_ACCEPT'),
348 l10n.getTranslationOrError( 347 l10n.getTranslationOrError(
(...skipping 10 matching lines...) Expand all
359 remoting.It2MeHelpeeChannel.prototype.initializeHost_ = function() { 358 remoting.It2MeHelpeeChannel.prototype.initializeHost_ = function() {
360 /** @type {remoting.It2MeHostFacade} */ 359 /** @type {remoting.It2MeHostFacade} */
361 var host = this.host_; 360 var host = this.host_;
362 361
363 /** 362 /**
364 * @param {function(*=):void} resolve 363 * @param {function(*=):void} resolve
365 * @param {function(*=):void} reject 364 * @param {function(*=):void} reject
366 */ 365 */
367 return new Promise(function(resolve, reject) { 366 return new Promise(function(resolve, reject) {
368 if (host.initialized()) { 367 if (host.initialized()) {
369 resolve(); 368 resolve(true);
370 } else { 369 } else {
371 host.initialize(resolve, reject); 370 host.initialize(/** @type {function(*=):void} */ (resolve),
371 /** @type {function(*=):void} */ (reject));
372 } 372 }
373 }); 373 });
374 }; 374 };
375 375
376 /** 376 /**
377 * @return {Promise} Promise that resolves with the OAuth token as the value. 377 * @return {Promise} Promise that resolves with the OAuth token as the value.
378 */ 378 */
379 remoting.It2MeHelpeeChannel.prototype.fetchOAuthToken_ = function() { 379 remoting.It2MeHelpeeChannel.prototype.fetchOAuthToken_ = function() {
380 if (base.isAppsV2()) { 380 if (base.isAppsV2()) {
381 /** 381 /**
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 console.error('Error responding to message method:' + 489 console.error('Error responding to message method:' +
490 (incomingMessage ? incomingMessage.method : 'null') + 490 (incomingMessage ? incomingMessage.method : 'null') +
491 ' error:' + error); 491 ' error:' + error);
492 this.hangoutPort_.postMessage({ 492 this.hangoutPort_.postMessage({
493 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.ERROR, 493 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.ERROR,
494 message: error, 494 message: error,
495 request: incomingMessage 495 request: incomingMessage
496 }); 496 });
497 }; 497 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698