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

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment.js

Issue 2959853003: Add UI components for license type selection in ChromeOS login UI. (Closed)
Patch Set: Created 3 years, 5 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
OLDNEW
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
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
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
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 * screen (either the next authentication or the login screen). 333 * screen (either the next authentication or the login screen).
319 */ 334 */
320 cancel: function() { 335 cancel: function() {
321 if (this.isCancelDisabled) 336 if (this.isCancelDisabled)
322 return; 337 return;
323 this.isCancelDisabled = true; 338 this.isCancelDisabled = true;
324 chrome.send('oauthEnrollClose', ['cancel']); 339 chrome.send('oauthEnrollClose', ['cancel']);
325 }, 340 },
326 341
327 /** 342 /**
343 * Updates the list of available license types in license selection dialog.
344 */
345 setAvailableLicenseTypes: function(licenseTypes) {
346 var licenses = [
347 {
348 id: 'perpetual',
349 label: 'perpetualLicenseTypeTitle',
350 },
351 {
352 id: 'annual',
353 label: 'annualLicenseTypeTitle',
354 },
355 {
356 id: 'kiosk',
357 label: 'kioskLicenseTypeTitle',
358 }
359 ];
360 for (var i = 0, item; item = licenses[i]; ++i) {
361 if (item.id in licenseTypes) {
362 item.count = parseInt(licenseTypes[item.id]);
363 item.disabled = item.count == 0;
364 item.hidden = false;
365 } else {
366 item.count = 0;
367 item.disabled = true;
368 item.hidden = true;
369 }
370 }
371 this.licenseUi_.disabled = false;
372 this.licenseUi_.licenses = licenses;
373 },
374
375 /**
328 * Switches between the different steps in the enrollment flow. 376 * Switches between the different steps in the enrollment flow.
329 * @param {string} step the steps to show, one of "signin", "working", 377 * @param {string} step the steps to show, one of "signin", "working",
330 * "attribute-prompt", "error", "success". 378 * "attribute-prompt", "error", "success".
331 */ 379 */
332 showStep: function(step) { 380 showStep: function(step) {
333 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); 381 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false);
334 this.classList.toggle('oauth-enroll-state-' + step, true); 382 this.classList.toggle('oauth-enroll-state-' + step, true);
335 383
336 if (step == STEP_SIGNIN) { 384 if (step == STEP_SIGNIN) {
337 $('oauth-enroll-auth-view').focus(); 385 $('oauth-enroll-auth-view').focus();
386 } else if (step == STEP_LICENSE_TYPE) {
387 $('oauth-enroll-license-ui').submitButton.focus();
338 } else if (step == STEP_ERROR) { 388 } else if (step == STEP_ERROR) {
339 $('oauth-enroll-error-card').submitButton.focus(); 389 $('oauth-enroll-error-card').submitButton.focus();
340 } else if (step == STEP_SUCCESS) { 390 } else if (step == STEP_SUCCESS) {
341 $('oauth-enroll-success-card').submitButton.focus(); 391 $('oauth-enroll-success-card').submitButton.focus();
342 } else if (step == STEP_ABE_SUCCESS) { 392 } else if (step == STEP_ABE_SUCCESS) {
343 $('oauth-enroll-abe-success-card').submitButton.focus(); 393 $('oauth-enroll-abe-success-card').submitButton.focus();
344 } else if (step == STEP_ATTRIBUTE_PROMPT) { 394 } else if (step == STEP_ATTRIBUTE_PROMPT) {
345 $('oauth-enroll-asset-id').focus(); 395 $('oauth-enroll-asset-id').focus();
346 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { 396 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) {
347 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); 397 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 this.navigation_.closeVisible = 493 this.navigation_.closeVisible =
444 (this.currentStep_ == STEP_SIGNIN || 494 (this.currentStep_ == STEP_SIGNIN ||
445 this.currentStep_ == STEP_ERROR || 495 this.currentStep_ == STEP_ERROR ||
446 this.currentStep_ == STEP_ACTIVE_DIRECTORY_JOIN_ERROR || 496 this.currentStep_ == STEP_ACTIVE_DIRECTORY_JOIN_ERROR ||
447 this.currentStep_ == STEP_AD_JOIN) && 497 this.currentStep_ == STEP_AD_JOIN) &&
448 !this.navigation_.refreshVisible; 498 !this.navigation_.refreshVisible;
449 $('login-header-bar').updateUI_(); 499 $('login-header-bar').updateUI_();
450 } 500 }
451 }; 501 };
452 }); 502 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698