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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 this.usageStats_.hidden = false; | 216 this.usageStats_.hidden = false; |
217 this.usageStatsCheckbox_.checked = false; | 217 this.usageStatsCheckbox_.checked = false; |
218 | 218 |
219 // Prevent user from ticking the box until the current consent status is | 219 // Prevent user from ticking the box until the current consent status is |
220 // known. | 220 // known. |
221 this.usageStatsCheckbox_.disabled = true; | 221 this.usageStatsCheckbox_.disabled = true; |
222 | 222 |
223 this.hostController_.getConsent(onGetConsent, onError); | 223 this.hostController_.getConsent(onGetConsent, onError); |
224 | 224 |
225 var flow = [ | 225 var flow = [ |
| 226 remoting.HostSetupFlow.State.INSTALL_HOST, |
226 remoting.HostSetupFlow.State.ASK_PIN, | 227 remoting.HostSetupFlow.State.ASK_PIN, |
227 remoting.HostSetupFlow.State.STARTING_HOST, | 228 remoting.HostSetupFlow.State.STARTING_HOST, |
228 remoting.HostSetupFlow.State.HOST_STARTED]; | 229 remoting.HostSetupFlow.State.HOST_STARTED]; |
229 | 230 |
230 var installed = | 231 var installed = |
231 state != remoting.HostController.State.NOT_INSTALLED && | 232 state != remoting.HostController.State.NOT_INSTALLED && |
232 state != remoting.HostController.State.INSTALLING; | 233 state != remoting.HostController.State.INSTALLING; |
233 | 234 |
234 if (navigator.platform.indexOf('Mac') != -1 && !installed) { | 235 // Skip the installation step when the host is already installed or when using |
235 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST); | 236 // NPAPI plugin on Windows (because on Windows the plugin takes care of |
| 237 // installation). |
| 238 if (installed || (navigator.platform == 'Win32' && |
| 239 this.hostController_.usingNpapiPlugin())) { |
| 240 flow.shift(); |
236 } | 241 } |
237 | 242 |
238 this.startNewFlow_(flow); | 243 this.startNewFlow_(flow); |
239 }; | 244 }; |
240 | 245 |
241 /** | 246 /** |
242 * Show the dialog in order to change the PIN associated with a running daemon. | 247 * Show the dialog in order to change the PIN associated with a running daemon. |
243 * | 248 * |
244 * @return {void} Nothing. | 249 * @return {void} Nothing. |
245 */ | 250 */ |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 remoting.setMode(remoting.AppMode.HOST_SETUP_ERROR); | 323 remoting.setMode(remoting.AppMode.HOST_SETUP_ERROR); |
319 } | 324 } |
320 | 325 |
321 var state = this.flow_.getState(); | 326 var state = this.flow_.getState(); |
322 if (state == remoting.HostSetupFlow.State.NONE) { | 327 if (state == remoting.HostSetupFlow.State.NONE) { |
323 this.hide(); | 328 this.hide(); |
324 } else if (state == remoting.HostSetupFlow.State.ASK_PIN) { | 329 } else if (state == remoting.HostSetupFlow.State.ASK_PIN) { |
325 remoting.setMode(remoting.AppMode.HOST_SETUP_ASK_PIN); | 330 remoting.setMode(remoting.AppMode.HOST_SETUP_ASK_PIN); |
326 } else if (state == remoting.HostSetupFlow.State.INSTALL_HOST) { | 331 } else if (state == remoting.HostSetupFlow.State.INSTALL_HOST) { |
327 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); | 332 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); |
328 window.location = | 333 this.installHost_(); |
329 'https://dl.google.com/chrome-remote-desktop/chromeremotedesktop.dmg'; | |
330 } else if (state == remoting.HostSetupFlow.State.STARTING_HOST) { | 334 } else if (state == remoting.HostSetupFlow.State.STARTING_HOST) { |
331 showProcessingMessage(/*i18n-content*/'HOST_SETUP_STARTING'); | 335 showProcessingMessage(/*i18n-content*/'HOST_SETUP_STARTING'); |
332 this.startHost_(); | 336 this.startHost_(); |
333 } else if (state == remoting.HostSetupFlow.State.UPDATING_PIN) { | 337 } else if (state == remoting.HostSetupFlow.State.UPDATING_PIN) { |
334 showProcessingMessage(/*i18n-content*/'HOST_SETUP_UPDATING_PIN'); | 338 showProcessingMessage(/*i18n-content*/'HOST_SETUP_UPDATING_PIN'); |
335 this.updatePin_(); | 339 this.updatePin_(); |
336 } else if (state == remoting.HostSetupFlow.State.STOPPING_HOST) { | 340 } else if (state == remoting.HostSetupFlow.State.STOPPING_HOST) { |
337 showProcessingMessage(/*i18n-content*/'HOST_SETUP_STOPPING'); | 341 showProcessingMessage(/*i18n-content*/'HOST_SETUP_STOPPING'); |
338 this.stopHost_(); | 342 this.stopHost_(); |
339 } else if (state == remoting.HostSetupFlow.State.HOST_STARTED) { | 343 } else if (state == remoting.HostSetupFlow.State.HOST_STARTED) { |
(...skipping 10 matching lines...) Expand all Loading... |
350 } else if (state == remoting.HostSetupFlow.State.START_HOST_FAILED) { | 354 } else if (state == remoting.HostSetupFlow.State.START_HOST_FAILED) { |
351 showErrorMessage(/*i18n-content*/'HOST_SETUP_HOST_FAILED'); | 355 showErrorMessage(/*i18n-content*/'HOST_SETUP_HOST_FAILED'); |
352 } else if (state == remoting.HostSetupFlow.State.UPDATE_PIN_FAILED) { | 356 } else if (state == remoting.HostSetupFlow.State.UPDATE_PIN_FAILED) { |
353 showErrorMessage(/*i18n-content*/'HOST_SETUP_UPDATE_PIN_FAILED'); | 357 showErrorMessage(/*i18n-content*/'HOST_SETUP_UPDATE_PIN_FAILED'); |
354 } else if (state == remoting.HostSetupFlow.State.STOP_HOST_FAILED) { | 358 } else if (state == remoting.HostSetupFlow.State.STOP_HOST_FAILED) { |
355 showErrorMessage(/*i18n-content*/'HOST_SETUP_STOP_FAILED'); | 359 showErrorMessage(/*i18n-content*/'HOST_SETUP_STOP_FAILED'); |
356 } | 360 } |
357 }; | 361 }; |
358 | 362 |
359 /** | 363 /** |
| 364 * Installs Host component. |
| 365 */ |
| 366 remoting.HostSetupDialog.prototype.installHost_ = function() { |
| 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 this.flow_.switchToErrorState(remoting.Error.UNEXPECTED); |
| 385 this.updateState_(); |
| 386 return; |
| 387 } |
| 388 |
| 389 // Start downloading the package. |
| 390 window.location = hostPackageUrl; |
| 391 } |
| 392 |
| 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} */ |
369 function isFlowActive() { | 403 function isFlowActive() { |
(...skipping 194 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 |