Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
| 8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * @param {Array.<remoting.HostSetupFlow.State>} sequence Sequence of | 11 * @param {Array.<remoting.HostSetupFlow.State>} sequence Sequence of |
| 12 * steps for the flow. | 12 * steps for the flow. |
| 13 * @constructor | 13 * @constructor |
| 14 */ | 14 */ |
| 15 remoting.HostSetupFlow = function(sequence) { | 15 remoting.HostSetupFlow = function(sequence) { |
| 16 this.sequence_ = sequence; | 16 this.sequence_ = sequence; |
| 17 this.currentStep_ = 0; | 17 this.currentStep_ = 0; |
| 18 this.state_ = sequence[0]; | 18 this.state_ = sequence[0]; |
| 19 this.pin = ''; | 19 this.pin = ''; |
| 20 this.consent = false; | 20 this.consent = false; |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 /** @enum {number} */ | 23 /** @enum {number} */ |
| 24 remoting.HostSetupFlow.State = { | 24 remoting.HostSetupFlow.State = { |
| 25 NONE: 0, | 25 NONE: 0, |
| 26 | 26 |
| 27 // Dialog states. | 27 // Dialog states. |
| 28 ASK_PIN: 1, | 28 ASK_PIN: 1, |
| 29 | 29 |
| 30 // Used on Mac OS X to prompt the user to manually install a .dmg package. | 30 // Prompts the user to install the host package. |
| 31 INSTALL_HOST: 2, | 31 INSTALL_HOST: 2, |
| 32 | 32 |
| 33 // Processing states. | 33 // Processing states. |
| 34 STARTING_HOST: 3, | 34 STARTING_HOST: 3, |
| 35 UPDATING_PIN: 4, | 35 UPDATING_PIN: 4, |
| 36 STOPPING_HOST: 5, | 36 STOPPING_HOST: 5, |
| 37 | 37 |
| 38 // Done states. | 38 // Done states. |
| 39 HOST_STARTED: 6, | 39 HOST_STARTED: 6, |
| 40 UPDATED_PIN: 7, | 40 UPDATED_PIN: 7, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 | 224 |
| 225 var flow = [ | 225 var flow = [ |
| 226 remoting.HostSetupFlow.State.ASK_PIN, | 226 remoting.HostSetupFlow.State.ASK_PIN, |
| 227 remoting.HostSetupFlow.State.STARTING_HOST, | 227 remoting.HostSetupFlow.State.STARTING_HOST, |
| 228 remoting.HostSetupFlow.State.HOST_STARTED]; | 228 remoting.HostSetupFlow.State.HOST_STARTED]; |
| 229 | 229 |
| 230 var installed = | 230 var installed = |
| 231 state != remoting.HostController.State.NOT_INSTALLED && | 231 state != remoting.HostController.State.NOT_INSTALLED && |
| 232 state != remoting.HostController.State.INSTALLING; | 232 state != remoting.HostController.State.INSTALLING; |
| 233 | 233 |
| 234 if (navigator.platform.indexOf('Mac') != -1 && !installed) { | 234 if (!installed) |
| 235 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST); | 235 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST); |
| 236 } | |
| 237 | 236 |
| 238 this.startNewFlow_(flow); | 237 this.startNewFlow_(flow); |
| 239 }; | 238 }; |
| 240 | 239 |
| 241 /** | 240 /** |
| 242 * Show the dialog in order to change the PIN associated with a running daemon. | 241 * Show the dialog in order to change the PIN associated with a running daemon. |
| 243 * | 242 * |
| 244 * @return {void} Nothing. | 243 * @return {void} Nothing. |
| 245 */ | 244 */ |
| 246 remoting.HostSetupDialog.prototype.showForPin = function() { | 245 remoting.HostSetupDialog.prototype.showForPin = function() { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 remoting.setMode(remoting.AppMode.HOST_SETUP_ERROR); | 317 remoting.setMode(remoting.AppMode.HOST_SETUP_ERROR); |
| 319 } | 318 } |
| 320 | 319 |
| 321 var state = this.flow_.getState(); | 320 var state = this.flow_.getState(); |
| 322 if (state == remoting.HostSetupFlow.State.NONE) { | 321 if (state == remoting.HostSetupFlow.State.NONE) { |
| 323 this.hide(); | 322 this.hide(); |
| 324 } else if (state == remoting.HostSetupFlow.State.ASK_PIN) { | 323 } else if (state == remoting.HostSetupFlow.State.ASK_PIN) { |
| 325 remoting.setMode(remoting.AppMode.HOST_SETUP_ASK_PIN); | 324 remoting.setMode(remoting.AppMode.HOST_SETUP_ASK_PIN); |
| 326 } else if (state == remoting.HostSetupFlow.State.INSTALL_HOST) { | 325 } else if (state == remoting.HostSetupFlow.State.INSTALL_HOST) { |
| 327 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); | 326 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); |
| 328 window.location = | 327 this.installHost_(); |
| 329 'https://dl.google.com/chrome-remote-desktop/chromeremotedesktop.dmg'; | |
| 330 } else if (state == remoting.HostSetupFlow.State.STARTING_HOST) { | 328 } else if (state == remoting.HostSetupFlow.State.STARTING_HOST) { |
| 331 showProcessingMessage(/*i18n-content*/'HOST_SETUP_STARTING'); | 329 showProcessingMessage(/*i18n-content*/'HOST_SETUP_STARTING'); |
| 332 this.startHost_(); | 330 this.startHost_(); |
| 333 } else if (state == remoting.HostSetupFlow.State.UPDATING_PIN) { | 331 } else if (state == remoting.HostSetupFlow.State.UPDATING_PIN) { |
| 334 showProcessingMessage(/*i18n-content*/'HOST_SETUP_UPDATING_PIN'); | 332 showProcessingMessage(/*i18n-content*/'HOST_SETUP_UPDATING_PIN'); |
| 335 this.updatePin_(); | 333 this.updatePin_(); |
| 336 } else if (state == remoting.HostSetupFlow.State.STOPPING_HOST) { | 334 } else if (state == remoting.HostSetupFlow.State.STOPPING_HOST) { |
| 337 showProcessingMessage(/*i18n-content*/'HOST_SETUP_STOPPING'); | 335 showProcessingMessage(/*i18n-content*/'HOST_SETUP_STOPPING'); |
| 338 this.stopHost_(); | 336 this.stopHost_(); |
| 339 } else if (state == remoting.HostSetupFlow.State.HOST_STARTED) { | 337 } else if (state == remoting.HostSetupFlow.State.HOST_STARTED) { |
| 340 // TODO(jamiewalch): Only display the second string if the computer's power | 338 // TODO(jamiewalch): Only display the second string if the computer's power |
| 341 // management settings indicate that it's necessary. | 339 // management settings indicate that it's necessary. |
| 342 showDoneMessage(/*i18n-content*/'HOST_SETUP_STARTED', | 340 showDoneMessage(/*i18n-content*/'HOST_SETUP_STARTED', |
| 343 /*i18n-content*/'HOST_SETUP_STARTED_DISABLE_SLEEP'); | 341 /*i18n-content*/'HOST_SETUP_STARTED_DISABLE_SLEEP'); |
| 344 } else if (state == remoting.HostSetupFlow.State.UPDATED_PIN) { | 342 } else if (state == remoting.HostSetupFlow.State.UPDATED_PIN) { |
| 345 showDoneMessage(/*i18n-content*/'HOST_SETUP_UPDATED_PIN'); | 343 showDoneMessage(/*i18n-content*/'HOST_SETUP_UPDATED_PIN'); |
| 346 } else if (state == remoting.HostSetupFlow.State.HOST_STOPPED) { | 344 } else if (state == remoting.HostSetupFlow.State.HOST_STOPPED) { |
| 347 showDoneMessage(/*i18n-content*/'HOST_SETUP_STOPPED'); | 345 showDoneMessage(/*i18n-content*/'HOST_SETUP_STOPPED'); |
| 348 } else if (state == remoting.HostSetupFlow.State.REGISTRATION_FAILED) { | 346 } else if (state == remoting.HostSetupFlow.State.REGISTRATION_FAILED) { |
| 349 showErrorMessage(/*i18n-content*/'ERROR_HOST_REGISTRATION_FAILED'); | 347 showErrorMessage(/*i18n-content*/'ERROR_HOST_REGISTRATION_FAILED'); |
| 350 } else if (state == remoting.HostSetupFlow.State.START_HOST_FAILED) { | 348 } else if (state == remoting.HostSetupFlow.State.START_HOST_FAILED) { |
| 351 showErrorMessage(/*i18n-content*/'HOST_SETUP_HOST_FAILED'); | 349 showErrorMessage(/*i18n-content*/'HOST_SETUP_HOST_FAILED'); |
| 352 } else if (state == remoting.HostSetupFlow.State.UPDATE_PIN_FAILED) { | 350 } else if (state == remoting.HostSetupFlow.State.UPDATE_PIN_FAILED) { |
| 353 showErrorMessage(/*i18n-content*/'HOST_SETUP_UPDATE_PIN_FAILED'); | 351 showErrorMessage(/*i18n-content*/'HOST_SETUP_UPDATE_PIN_FAILED'); |
| 354 } else if (state == remoting.HostSetupFlow.State.STOP_HOST_FAILED) { | 352 } else if (state == remoting.HostSetupFlow.State.STOP_HOST_FAILED) { |
| 355 showErrorMessage(/*i18n-content*/'HOST_SETUP_STOP_FAILED'); | 353 showErrorMessage(/*i18n-content*/'HOST_SETUP_STOP_FAILED'); |
| 356 } | 354 } |
| 357 }; | 355 }; |
| 358 | 356 |
| 357 /* | |
| 358 * @returns {string} URL of the host package for the current platform or an | |
|
Jamie
2014/01/31 18:39:15
This function doesn't return anything.
Sergey Ulanov
2014/01/31 23:34:17
Done.
| |
| 359 * empty string if the platform is not supported | |
| 360 */ | |
| 361 remoting.HostSetupDialog.prototype.installHost_ = function() { | |
| 362 /** @type {remoting.HostSetupDialog} */ | |
| 363 var that = this; | |
| 364 /** @type {remoting.HostSetupFlow} */ | |
| 365 var flow = this.flow_; | |
| 366 | |
| 367 var hostPackageUrl = ''; | |
| 368 switch (navigator.platform) { | |
| 369 case 'Win32': | |
| 370 hostPackageUrl = 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/chr omeremotedesktophost.msi'; | |
| 371 break; | |
| 372 case 'MacIntel': | |
| 373 hostPackageUrl = 'https://dl.google.com/chrome-remote-desktop/chromeremote desktop.dmg'; | |
| 374 break; | |
| 375 case 'Linux x86_64': | |
| 376 hostPackageUrl = 'https://dl.google.com/linux/direct/chrome-remote-desktop _current_amd64.deb'; | |
| 377 break; | |
| 378 case 'Linux i386': | |
| 379 hostPackageUrl = 'https://dl.google.com/linux/direct/chrome-remote-desktop _current_i386.deb'; | |
| 380 break; | |
| 381 default: | |
| 382 // We never expect to get in this state. Host controls should not be shown | |
| 383 // on unsupported platform. | |
| 384 flow.switchToErrorState(remoting.Error.UNEXPECTED); | |
| 385 that.updateState_(); | |
| 386 return; | |
| 387 } | |
| 388 | |
| 389 // Start downloading the package. | |
| 390 window.location = hostPackageUrl; | |
|
Jamie
2014/01/31 18:39:15
This always assumes the Native Messaging case (ie,
Sergey Ulanov
2014/01/31 23:34:17
Good point. I've updated showForStartWithToken_()
| |
| 391 } | |
| 392 | |
| 359 /** | 393 /** |
| 360 * Registers and starts the host. | 394 * Registers and starts the host. |
| 361 */ | 395 */ |
| 362 remoting.HostSetupDialog.prototype.startHost_ = function() { | 396 remoting.HostSetupDialog.prototype.startHost_ = function() { |
| 363 /** @type {remoting.HostSetupDialog} */ | 397 /** @type {remoting.HostSetupDialog} */ |
| 364 var that = this; | 398 var that = this; |
| 365 /** @type {remoting.HostSetupFlow} */ | 399 /** @type {remoting.HostSetupFlow} */ |
| 366 var flow = this.flow_; | 400 var flow = this.flow_; |
| 367 | 401 |
| 368 /** @return {boolean} */ | 402 /** @return {boolean} */ |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 | 598 |
| 565 /** | 599 /** |
| 566 * @return {void} Nothing. | 600 * @return {void} Nothing. |
| 567 */ | 601 */ |
| 568 remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() { | 602 remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() { |
| 569 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); | 603 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); |
| 570 }; | 604 }; |
| 571 | 605 |
| 572 /** @type {remoting.HostSetupDialog} */ | 606 /** @type {remoting.HostSetupDialog} */ |
| 573 remoting.hostSetupDialog = null; | 607 remoting.hostSetupDialog = null; |
| OLD | NEW |