| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 login.createScreen('OAuthEnrollmentScreen', 'oauth-enrollment', function() { | 5 login.createScreen('OAuthEnrollmentScreen', 'oauth-enrollment', function() { |
| 6 /* Code which is embedded inside of the webview. See below for details. | 6 /* Code which is embedded inside of the webview. See below for details. |
| 7 /** @const */ var INJECTED_WEBVIEW_SCRIPT = String.raw` | 7 /** @const */ var INJECTED_WEBVIEW_SCRIPT = String.raw` |
| 8 (function() { | 8 (function() { |
| 9 // <include src="../keyboard/keyboard_utils.js"> | 9 // <include src="../keyboard/keyboard_utils.js"> |
| 10 keyboard.initializeKeyboardFlow(true); | 10 keyboard.initializeKeyboardFlow(true); |
| 11 })();`; | 11 })();`; |
| 12 | 12 |
| 13 /** @const */ var STEP_SIGNIN = 'signin'; | 13 /** @const */ var STEP_SIGNIN = 'signin'; |
| 14 /** @const */ var STEP_AD_JOIN = 'ad-join'; | 14 /** @const */ var STEP_AD_JOIN = 'ad-join'; |
| 15 /** @const */ var STEP_LICENSE_TYPE = 'license'; |
| 15 /** @const */ var STEP_WORKING = 'working'; | 16 /** @const */ var STEP_WORKING = 'working'; |
| 16 /** @const */ var STEP_ATTRIBUTE_PROMPT = 'attribute-prompt'; | 17 /** @const */ var STEP_ATTRIBUTE_PROMPT = 'attribute-prompt'; |
| 17 /** @const */ var STEP_ERROR = 'error'; | 18 /** @const */ var STEP_ERROR = 'error'; |
| 18 /** @const */ var STEP_SUCCESS = 'success'; | 19 /** @const */ var STEP_SUCCESS = 'success'; |
| 19 /** @const */ var STEP_ABE_SUCCESS = 'abe-success'; | 20 /** @const */ var STEP_ABE_SUCCESS = 'abe-success'; |
| 20 | 21 |
| 21 /* TODO(dzhioev): define this step on C++ side. | 22 /* TODO(dzhioev): define this step on C++ side. |
| 22 /** @const */ var STEP_ATTRIBUTE_PROMPT_ERROR = 'attribute-prompt-error'; | 23 /** @const */ var STEP_ATTRIBUTE_PROMPT_ERROR = 'attribute-prompt-error'; |
| 23 /** @const */ var STEP_ACTIVE_DIRECTORY_JOIN_ERROR = | 24 /** @const */ var STEP_ACTIVE_DIRECTORY_JOIN_ERROR = |
| 24 'active-directory-join-error'; | 25 'active-directory-join-error'; |
| 25 | 26 |
| 26 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; | 27 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; |
| 27 | 28 |
| 28 return { | 29 return { |
| 29 EXTERNAL_API: [ | 30 EXTERNAL_API: [ |
| 30 'showStep', | 31 'showStep', |
| 31 'showError', | 32 'showError', |
| 32 'doReload', | 33 'doReload', |
| 34 'setAvailableLicenseTypes', |
| 33 'showAttributePromptStep', | 35 'showAttributePromptStep', |
| 34 'showAttestationBasedEnrollmentSuccess', | 36 'showAttestationBasedEnrollmentSuccess', |
| 35 'invalidateAd', | 37 'invalidateAd', |
| 36 ], | 38 ], |
| 37 | 39 |
| 38 /** | 40 /** |
| 39 * Authenticator object that wraps GAIA webview. | 41 * Authenticator object that wraps GAIA webview. |
| 40 */ | 42 */ |
| 41 authenticator_: null, | 43 authenticator_: null, |
| 42 | 44 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 get isCancelDisabled() { | 56 get isCancelDisabled() { |
| 55 return this.isCancelDisabled_; | 57 return this.isCancelDisabled_; |
| 56 }, | 58 }, |
| 57 set isCancelDisabled(disabled) { | 59 set isCancelDisabled(disabled) { |
| 58 this.isCancelDisabled_ = disabled; | 60 this.isCancelDisabled_ = disabled; |
| 59 }, | 61 }, |
| 60 | 62 |
| 61 isManualEnrollment_: undefined, | 63 isManualEnrollment_: undefined, |
| 62 | 64 |
| 63 /** | 65 /** |
| 66 * An element containing UI for picking license type. |
| 67 * @type {EnrollmentLicenseCard} |
| 68 * @private |
| 69 */ |
| 70 licenseUi_: undefined, |
| 71 |
| 72 /** |
| 64 * An element containg navigation buttons. | 73 * An element containg navigation buttons. |
| 65 */ | 74 */ |
| 66 navigation_: undefined, | 75 navigation_: undefined, |
| 67 | 76 |
| 68 /** | 77 /** |
| 69 * An element containing UI to join an AD domain. | 78 * An element containing UI to join an AD domain. |
| 70 * @type {OfflineAdLoginElement} | 79 * @type {OfflineAdLoginElement} |
| 71 * @private | 80 * @private |
| 72 */ | 81 */ |
| 73 offlineAdUi_: undefined, | 82 offlineAdUi_: undefined, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 88 * Value contained in the last received 'backButton' event. | 97 * Value contained in the last received 'backButton' event. |
| 89 * @type {boolean} | 98 * @type {boolean} |
| 90 * @private | 99 * @private |
| 91 */ | 100 */ |
| 92 lastBackMessageValue_: false, | 101 lastBackMessageValue_: false, |
| 93 | 102 |
| 94 /** @override */ | 103 /** @override */ |
| 95 decorate: function() { | 104 decorate: function() { |
| 96 this.navigation_ = $('oauth-enroll-navigation'); | 105 this.navigation_ = $('oauth-enroll-navigation'); |
| 97 this.offlineAdUi_ = $('oauth-enroll-ad-join-ui'); | 106 this.offlineAdUi_ = $('oauth-enroll-ad-join-ui'); |
| 107 this.licenseUi_ = $('oauth-enroll-license-ui'); |
| 98 | 108 |
| 99 this.authenticator_ = | 109 this.authenticator_ = |
| 100 new cr.login.Authenticator($('oauth-enroll-auth-view')); | 110 new cr.login.Authenticator($('oauth-enroll-auth-view')); |
| 101 | 111 |
| 102 // Establish an initial messaging between content script and | 112 // Establish an initial messaging between content script and |
| 103 // host script so that content script can message back. | 113 // host script so that content script can message back. |
| 104 $('oauth-enroll-auth-view').addEventListener('loadstop', function(e) { | 114 $('oauth-enroll-auth-view').addEventListener('loadstop', function(e) { |
| 105 e.target.contentWindow.postMessage( | 115 e.target.contentWindow.postMessage( |
| 106 'initialMessage', $('oauth-enroll-auth-view').src); | 116 'initialMessage', $('oauth-enroll-auth-view').src); |
| 107 }); | 117 }); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 $('oauth-enroll-attribute-prompt-card') | 231 $('oauth-enroll-attribute-prompt-card') |
| 222 .addEventListener('submit', this.onAttributesSubmitted.bind(this)); | 232 .addEventListener('submit', this.onAttributesSubmitted.bind(this)); |
| 223 | 233 |
| 224 $('oauth-enroll-learn-more-link') | 234 $('oauth-enroll-learn-more-link') |
| 225 .addEventListener('click', function(event) { | 235 .addEventListener('click', function(event) { |
| 226 chrome.send('oauthEnrollOnLearnMore'); | 236 chrome.send('oauthEnrollOnLearnMore'); |
| 227 }); | 237 }); |
| 228 | 238 |
| 229 $('oauth-enroll-skip-button') | 239 $('oauth-enroll-skip-button') |
| 230 .addEventListener('click', this.onSkipButtonClicked.bind(this)); | 240 .addEventListener('click', this.onSkipButtonClicked.bind(this)); |
| 241 |
| 242 this.licenseUi_.addEventListener('buttonclick', function() { |
| 243 chrome.send('onLicenseTypeSelected', [this.licenseUi_.selected]); |
| 244 }.bind(this)); |
| 245 |
| 231 }, | 246 }, |
| 232 | 247 |
| 233 /** | 248 /** |
| 234 * Header text of the screen. | 249 * Header text of the screen. |
| 235 * @type {string} | 250 * @type {string} |
| 236 */ | 251 */ |
| 237 get header() { | 252 get header() { |
| 238 return loadTimeData.getString('oauthEnrollScreenTitle'); | 253 return loadTimeData.getString('oauthEnrollScreenTitle'); |
| 239 }, | 254 }, |
| 240 | 255 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 this.currentStep_ == STEP_AD_JOIN) { | 337 this.currentStep_ == STEP_AD_JOIN) { |
| 323 return; | 338 return; |
| 324 } | 339 } |
| 325 if (this.isCancelDisabled) | 340 if (this.isCancelDisabled) |
| 326 return; | 341 return; |
| 327 this.isCancelDisabled = true; | 342 this.isCancelDisabled = true; |
| 328 chrome.send('oauthEnrollClose', ['cancel']); | 343 chrome.send('oauthEnrollClose', ['cancel']); |
| 329 }, | 344 }, |
| 330 | 345 |
| 331 /** | 346 /** |
| 347 * Updates the list of available license types in license selection dialog. |
| 348 */ |
| 349 setAvailableLicenseTypes: function(licenseTypes) { |
| 350 var licenses = [ |
| 351 { |
| 352 id: 'perpetual', |
| 353 label: 'perpetualLicenseTypeTitle', |
| 354 }, |
| 355 { |
| 356 id: 'annual', |
| 357 label: 'annualLicenseTypeTitle', |
| 358 }, |
| 359 { |
| 360 id: 'kiosk', |
| 361 label: 'kioskLicenseTypeTitle', |
| 362 } |
| 363 ]; |
| 364 for (var i = 0, item; item = licenses[i]; ++i) { |
| 365 if (item.id in licenseTypes) { |
| 366 item.count = parseInt(licenseTypes[item.id]); |
| 367 item.disabled = item.count == 0; |
| 368 item.hidden = false; |
| 369 } else { |
| 370 item.count = 0; |
| 371 item.disabled = true; |
| 372 item.hidden = true; |
| 373 } |
| 374 } |
| 375 this.licenseUi_.disabled = false; |
| 376 this.licenseUi_.licenses = licenses; |
| 377 }, |
| 378 |
| 379 /** |
| 332 * Switches between the different steps in the enrollment flow. | 380 * Switches between the different steps in the enrollment flow. |
| 333 * @param {string} step the steps to show, one of "signin", "working", | 381 * @param {string} step the steps to show, one of "signin", "working", |
| 334 * "attribute-prompt", "error", "success". | 382 * "attribute-prompt", "error", "success". |
| 335 */ | 383 */ |
| 336 showStep: function(step) { | 384 showStep: function(step) { |
| 337 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); | 385 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); |
| 338 this.classList.toggle('oauth-enroll-state-' + step, true); | 386 this.classList.toggle('oauth-enroll-state-' + step, true); |
| 339 | 387 |
| 340 if (step == STEP_SIGNIN) { | 388 if (step == STEP_SIGNIN) { |
| 341 $('oauth-enroll-auth-view').focus(); | 389 $('oauth-enroll-auth-view').focus(); |
| 390 } else if (step == STEP_LICENSE_TYPE) { |
| 391 $('oauth-enroll-license-ui').submitButton.focus(); |
| 342 } else if (step == STEP_ERROR) { | 392 } else if (step == STEP_ERROR) { |
| 343 $('oauth-enroll-error-card').submitButton.focus(); | 393 $('oauth-enroll-error-card').submitButton.focus(); |
| 344 } else if (step == STEP_SUCCESS) { | 394 } else if (step == STEP_SUCCESS) { |
| 345 $('oauth-enroll-success-card').submitButton.focus(); | 395 $('oauth-enroll-success-card').submitButton.focus(); |
| 346 } else if (step == STEP_ABE_SUCCESS) { | 396 } else if (step == STEP_ABE_SUCCESS) { |
| 347 $('oauth-enroll-abe-success-card').submitButton.focus(); | 397 $('oauth-enroll-abe-success-card').submitButton.focus(); |
| 348 } else if (step == STEP_ATTRIBUTE_PROMPT) { | 398 } else if (step == STEP_ATTRIBUTE_PROMPT) { |
| 349 $('oauth-enroll-asset-id').focus(); | 399 $('oauth-enroll-asset-id').focus(); |
| 350 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { | 400 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { |
| 351 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); | 401 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 this.currentStep_ == STEP_SIGNIN && this.lastBackMessageValue_; | 494 this.currentStep_ == STEP_SIGNIN && this.lastBackMessageValue_; |
| 445 this.navigation_.refreshVisible = | 495 this.navigation_.refreshVisible = |
| 446 this.isAtTheBeginning() && !this.isManualEnrollment_; | 496 this.isAtTheBeginning() && !this.isManualEnrollment_; |
| 447 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || | 497 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || |
| 448 this.currentStep_ == STEP_ERROR) && | 498 this.currentStep_ == STEP_ERROR) && |
| 449 !this.navigation_.refreshVisible; | 499 !this.navigation_.refreshVisible; |
| 450 $('login-header-bar').updateUI_(); | 500 $('login-header-bar').updateUI_(); |
| 451 } | 501 } |
| 452 }; | 502 }; |
| 453 }); | 503 }); |
| OLD | NEW |