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

Side by Side Diff: remoting/webapp/app_remoting/js/app_remoting.js

Issue 1015553003: Added more typechecking functions and unit tests for existing code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/base.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * This class implements the functionality that is specific to application 7 * This class implements the functionality that is specific to application
8 * remoting ("AppRemoting" or AR). 8 * remoting ("AppRemoting" or AR).
9 */ 9 */
10 10
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 /** 308 /**
309 * @param {string} type The message type. 309 * @param {string} type The message type.
310 * @param {Object} message The parsed extension message data. 310 * @param {Object} message The parsed extension message data.
311 */ 311 */
312 remoting.AppRemoting.prototype.onExtensionMessage = function(type, message) { 312 remoting.AppRemoting.prototype.onExtensionMessage = function(type, message) {
313 switch (type) { 313 switch (type) {
314 314
315 case 'openURL': 315 case 'openURL':
316 // URL requests from the hosted app are untrusted, so disallow anything 316 // URL requests from the hosted app are untrusted, so disallow anything
317 // other than HTTP or HTTPS. 317 // other than HTTP or HTTPS.
318 var url = getStringAttr(message, 'url'); 318 var url = base.getStringAttr(message, 'url');
319 if (url.indexOf('http:') != 0 && url.indexOf('https:') != 0) { 319 if (url.indexOf('http:') != 0 && url.indexOf('https:') != 0) {
320 console.error('Bad URL: ' + url); 320 console.error('Bad URL: ' + url);
321 } else { 321 } else {
322 window.open(url); 322 window.open(url);
323 } 323 }
324 return true; 324 return true;
325 325
326 case 'onWindowRemoved': 326 case 'onWindowRemoved':
327 var id = getNumberAttr(message, 'id'); 327 var id = base.getNumberAttr(message, 'id');
328 this.windowActivationMenu_.remove(id); 328 this.windowActivationMenu_.remove(id);
329 return true; 329 return true;
330 330
331 case 'onWindowAdded': 331 case 'onWindowAdded':
332 var id = getNumberAttr(message, 'id'); 332 var id = base.getNumberAttr(message, 'id');
333 var title = getStringAttr(message, 'title'); 333 var title = base.getStringAttr(message, 'title');
334 this.windowActivationMenu_.add(id, title); 334 this.windowActivationMenu_.add(id, title);
335 return true; 335 return true;
336 336
337 case 'onAllWindowsMinimized': 337 case 'onAllWindowsMinimized':
338 chrome.app.window.current().minimize(); 338 chrome.app.window.current().minimize();
339 return true; 339 return true;
340 340
341 case 'setKeyboardLayouts': 341 case 'setKeyboardLayouts':
342 var supportedLayouts = getArrayAttr(message, 'supportedLayouts'); 342 var supportedLayouts = base.getArrayAttr(message, 'supportedLayouts');
343 var currentLayout = getStringAttr(message, 'currentLayout'); 343 var currentLayout = base.getStringAttr(message, 'currentLayout');
344 console.log('Current host keyboard layout: ' + currentLayout); 344 console.log('Current host keyboard layout: ' + currentLayout);
345 console.log('Supported host keyboard layouts: ' + supportedLayouts); 345 console.log('Supported host keyboard layouts: ' + supportedLayouts);
346 this.keyboardLayoutsMenu_.setLayouts(supportedLayouts, currentLayout); 346 this.keyboardLayoutsMenu_.setLayouts(supportedLayouts, currentLayout);
347 return true; 347 return true;
348 348
349 case 'pingResponse': 349 case 'pingResponse':
350 var then = getNumberAttr(message, 'timestamp'); 350 var then = base.getNumberAttr(message, 'timestamp');
351 var now = new Date().getTime(); 351 var now = new Date().getTime();
352 this.contextMenu_.updateConnectionRTT(now - then); 352 this.contextMenu_.updateConnectionRTT(now - then);
353 return true; 353 return true;
354 } 354 }
355 355
356 return false; 356 return false;
357 }; 357 };
358 358
359 /** 359 /**
360 * Called when an error needs to be displayed to the user. 360 * Called when an error needs to be displayed to the user.
361 * 361 *
362 * @param {!remoting.Error} error The error to be localized and displayed. 362 * @param {!remoting.Error} error The error to be localized and displayed.
363 * @return {void} Nothing. 363 * @return {void} Nothing.
364 */ 364 */
365 remoting.AppRemoting.prototype.handleError = function(error) { 365 remoting.AppRemoting.prototype.handleError = function(error) {
366 console.error('Connection failed: ' + error.toString()); 366 console.error('Connection failed: ' + error.toString());
367 remoting.LoadingWindow.close(); 367 remoting.LoadingWindow.close();
368 remoting.MessageWindow.showErrorMessage( 368 remoting.MessageWindow.showErrorMessage(
369 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), 369 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'),
370 chrome.i18n.getMessage(error.getTag())); 370 chrome.i18n.getMessage(error.getTag()));
371 }; 371 };
372 372
373 /** 373 /**
374 * Close the loading window before exiting. 374 * Close the loading window before exiting.
375 */ 375 */
376 remoting.AppRemoting.prototype.handleExit = function() { 376 remoting.AppRemoting.prototype.handleExit = function() {
377 remoting.LoadingWindow.close(); 377 remoting.LoadingWindow.close();
378 }; 378 };
OLDNEW
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/base.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698