| OLD | NEW |
| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 * @param {Object} message The parsed extension message data. | 281 * @param {Object} message The parsed extension message data. |
| 282 * @return {boolean} True if the extension message was recognized. | 282 * @return {boolean} True if the extension message was recognized. |
| 283 */ | 283 */ |
| 284 remoting.AppRemoting.prototype.handleExtensionMessage = function( | 284 remoting.AppRemoting.prototype.handleExtensionMessage = function( |
| 285 type, message) { | 285 type, message) { |
| 286 switch (type) { | 286 switch (type) { |
| 287 | 287 |
| 288 case 'openURL': | 288 case 'openURL': |
| 289 // URL requests from the hosted app are untrusted, so disallow anything | 289 // URL requests from the hosted app are untrusted, so disallow anything |
| 290 // other than HTTP or HTTPS. | 290 // other than HTTP or HTTPS. |
| 291 var url = getStringAttr(message, 'url'); | 291 var url = base.getStringAttr(message, 'url'); |
| 292 if (url.indexOf('http:') != 0 && url.indexOf('https:') != 0) { | 292 if (url.indexOf('http:') != 0 && url.indexOf('https:') != 0) { |
| 293 console.error('Bad URL: ' + url); | 293 console.error('Bad URL: ' + url); |
| 294 } else { | 294 } else { |
| 295 window.open(url); | 295 window.open(url); |
| 296 } | 296 } |
| 297 return true; | 297 return true; |
| 298 | 298 |
| 299 case 'onWindowRemoved': | 299 case 'onWindowRemoved': |
| 300 var id = getNumberAttr(message, 'id'); | 300 var id = base.getNumberAttr(message, 'id'); |
| 301 this.windowActivationMenu_.remove(id); | 301 this.windowActivationMenu_.remove(id); |
| 302 return true; | 302 return true; |
| 303 | 303 |
| 304 case 'onWindowAdded': | 304 case 'onWindowAdded': |
| 305 var id = getNumberAttr(message, 'id'); | 305 var id = base.getNumberAttr(message, 'id'); |
| 306 var title = getStringAttr(message, 'title'); | 306 var title = base.getStringAttr(message, 'title'); |
| 307 this.windowActivationMenu_.add(id, title); | 307 this.windowActivationMenu_.add(id, title); |
| 308 return true; | 308 return true; |
| 309 | 309 |
| 310 case 'onAllWindowsMinimized': | 310 case 'onAllWindowsMinimized': |
| 311 chrome.app.window.current().minimize(); | 311 chrome.app.window.current().minimize(); |
| 312 return true; | 312 return true; |
| 313 | 313 |
| 314 case 'setKeyboardLayouts': | 314 case 'setKeyboardLayouts': |
| 315 var supportedLayouts = getArrayAttr(message, 'supportedLayouts'); | 315 var supportedLayouts = base.getArrayAttr(message, 'supportedLayouts'); |
| 316 var currentLayout = getStringAttr(message, 'currentLayout'); | 316 var currentLayout = base.getStringAttr(message, 'currentLayout'); |
| 317 console.log('Current host keyboard layout: ' + currentLayout); | 317 console.log('Current host keyboard layout: ' + currentLayout); |
| 318 console.log('Supported host keyboard layouts: ' + supportedLayouts); | 318 console.log('Supported host keyboard layouts: ' + supportedLayouts); |
| 319 this.keyboardLayoutsMenu_.setLayouts(supportedLayouts, currentLayout); | 319 this.keyboardLayoutsMenu_.setLayouts(supportedLayouts, currentLayout); |
| 320 return true; | 320 return true; |
| 321 | 321 |
| 322 case 'pingResponse': | 322 case 'pingResponse': |
| 323 var then = getNumberAttr(message, 'timestamp'); | 323 var then = base.getNumberAttr(message, 'timestamp'); |
| 324 var now = new Date().getTime(); | 324 var now = new Date().getTime(); |
| 325 this.contextMenu_.updateConnectionRTT(now - then); | 325 this.contextMenu_.updateConnectionRTT(now - then); |
| 326 return true; | 326 return true; |
| 327 } | 327 } |
| 328 | 328 |
| 329 return false; | 329 return false; |
| 330 }; | 330 }; |
| 331 | 331 |
| 332 /** | 332 /** |
| 333 * Called when an error needs to be displayed to the user. | 333 * Called when an error needs to be displayed to the user. |
| 334 * | 334 * |
| 335 * @param {!remoting.Error} error The error to be localized and displayed. | 335 * @param {!remoting.Error} error The error to be localized and displayed. |
| 336 * @return {void} Nothing. | 336 * @return {void} Nothing. |
| 337 */ | 337 */ |
| 338 remoting.AppRemoting.prototype.handleError = function(error) { | 338 remoting.AppRemoting.prototype.handleError = function(error) { |
| 339 console.error('Connection failed: ' + error.toString()); | 339 console.error('Connection failed: ' + error.toString()); |
| 340 remoting.LoadingWindow.close(); | 340 remoting.LoadingWindow.close(); |
| 341 remoting.MessageWindow.showErrorMessage( | 341 remoting.MessageWindow.showErrorMessage( |
| 342 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), | 342 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), |
| 343 chrome.i18n.getMessage(error.getTag())); | 343 chrome.i18n.getMessage(error.getTag())); |
| 344 }; | 344 }; |
| 345 | 345 |
| 346 /** | 346 /** |
| 347 * Close the loading window before exiting. | 347 * Close the loading window before exiting. |
| 348 */ | 348 */ |
| 349 remoting.AppRemoting.prototype.handleExit = function() { | 349 remoting.AppRemoting.prototype.handleExit = function() { |
| 350 remoting.LoadingWindow.close(); | 350 remoting.LoadingWindow.close(); |
| 351 }; | 351 }; |
| OLD | NEW |