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

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

Issue 2433363004: Chromad: added AD Join ui, authpolicy_client (Closed)
Patch Set: Nits Created 4 years, 1 month 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_WORKING = 'working'; 15 /** @const */ var STEP_WORKING = 'working';
15 /** @const */ var STEP_ATTRIBUTE_PROMPT = 'attribute-prompt'; 16 /** @const */ var STEP_ATTRIBUTE_PROMPT = 'attribute-prompt';
16 /** @const */ var STEP_ERROR = 'error'; 17 /** @const */ var STEP_ERROR = 'error';
17 /** @const */ var STEP_SUCCESS = 'success'; 18 /** @const */ var STEP_SUCCESS = 'success';
18 /** @const */ var STEP_ABE_SUCCESS = 'abe-success'; 19 /** @const */ var STEP_ABE_SUCCESS = 'abe-success';
19 20
20 /* TODO(dzhioev): define this step on C++ side. 21 /* TODO(dzhioev): define this step on C++ side.
21 /** @const */ var STEP_ATTRIBUTE_PROMPT_ERROR = 'attribute-prompt-error'; 22 /** @const */ var STEP_ATTRIBUTE_PROMPT_ERROR = 'attribute-prompt-error';
22 23
23 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; 24 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259;
24 25
25 return { 26 return {
26 EXTERNAL_API: [ 27 EXTERNAL_API: [
27 'showStep', 28 'showStep',
28 'showError', 29 'showError',
29 'doReload', 30 'doReload',
30 'showAttributePromptStep', 31 'showAttributePromptStep',
31 'showAttestationBasedEnrollmentSuccess', 32 'showAttestationBasedEnrollmentSuccess',
33 'invalidateAD',
32 ], 34 ],
33 35
34 /** 36 /**
35 * Authenticator object that wraps GAIA webview. 37 * Authenticator object that wraps GAIA webview.
36 */ 38 */
37 authenticator_: null, 39 authenticator_: null,
38 40
39 /** 41 /**
40 * The current step. This is the last value passed to showStep(). 42 * The current step. This is the last value passed to showStep().
41 */ 43 */
(...skipping 11 matching lines...) Expand all
53 }, 55 },
54 56
55 isManualEnrollment_: undefined, 57 isManualEnrollment_: undefined,
56 58
57 /** 59 /**
58 * An element containg navigation buttons. 60 * An element containg navigation buttons.
59 */ 61 */
60 navigation_: undefined, 62 navigation_: undefined,
61 63
62 /** 64 /**
65 * An element containing UI to join an AD domain.
66 * @type {OfflineAdLoginElement}
67 * @private
68 */
69 offlineAdUi_: undefined,
70
71 /**
63 * Value contained in the last received 'backButton' event. 72 * Value contained in the last received 'backButton' event.
64 * @type {boolean} 73 * @type {boolean}
65 * @private 74 * @private
66 */ 75 */
67 lastBackMessageValue_: false, 76 lastBackMessageValue_: false,
68 77
69 /** @override */ 78 /** @override */
70 decorate: function() { 79 decorate: function() {
71 this.navigation_ = $('oauth-enroll-navigation'); 80 this.navigation_ = $('oauth-enroll-navigation');
81 this.offlineAdUi_ = $('oauth-enroll-ad-join-ui');
72 82
73 this.authenticator_ = 83 this.authenticator_ =
74 new cr.login.Authenticator($('oauth-enroll-auth-view')); 84 new cr.login.Authenticator($('oauth-enroll-auth-view'));
75 85
76 // Establish an initial messaging between content script and 86 // Establish an initial messaging between content script and
77 // host script so that content script can message back. 87 // host script so that content script can message back.
78 $('oauth-enroll-auth-view').addEventListener('loadstop', 88 $('oauth-enroll-auth-view').addEventListener('loadstop',
79 function(e) { 89 function(e) {
80 e.target.contentWindow.postMessage( 90 e.target.contentWindow.postMessage(
81 'initialMessage', $('oauth-enroll-auth-view').src); 91 'initialMessage', $('oauth-enroll-auth-view').src);
(...skipping 23 matching lines...) Expand all
105 if (!detail.email || !detail.authCode) { 115 if (!detail.email || !detail.authCode) {
106 this.showError( 116 this.showError(
107 loadTimeData.getString('fatalEnrollmentError'), 117 loadTimeData.getString('fatalEnrollmentError'),
108 false); 118 false);
109 return; 119 return;
110 } 120 }
111 chrome.send('oauthEnrollCompleteLogin', [detail.email, 121 chrome.send('oauthEnrollCompleteLogin', [detail.email,
112 detail.authCode]); 122 detail.authCode]);
113 }).bind(this)); 123 }).bind(this));
114 124
125 this.offlineAdUi_.addEventListener('authCompleted', function(e) {
126 this.offlineAdUi_.disabled = true;
127 chrome.send('oauthEnrollADCompleteLogin',
128 [e.detail.machinename, e.detail.username, e.detail.password]);
129 }.bind(this));
130
115 this.authenticator_.addEventListener('authFlowChange', 131 this.authenticator_.addEventListener('authFlowChange',
116 (function(e) { 132 (function(e) {
117 var isSAML = this.authenticator_.authFlow == 133 var isSAML = this.authenticator_.authFlow ==
118 cr.login.Authenticator.AuthFlow.SAML; 134 cr.login.Authenticator.AuthFlow.SAML;
119 if (isSAML) { 135 if (isSAML) {
120 $('oauth-saml-notice-message').textContent = 136 $('oauth-saml-notice-message').textContent =
121 loadTimeData.getStringF('samlNotice', 137 loadTimeData.getStringF('samlNotice',
122 this.authenticator_.authDomain); 138 this.authenticator_.authDomain);
123 } 139 }
124 this.classList.toggle('saml', isSAML); 140 this.classList.toggle('saml', isSAML);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 $('oauth-enroll-success-card').addEventListener( 176 $('oauth-enroll-success-card').addEventListener(
161 'buttonclick', doneCallback); 177 'buttonclick', doneCallback);
162 $('oauth-enroll-abe-success-card').addEventListener( 178 $('oauth-enroll-abe-success-card').addEventListener(
163 'buttonclick', doneCallback); 179 'buttonclick', doneCallback);
164 180
165 this.navigation_.addEventListener('close', this.cancel.bind(this)); 181 this.navigation_.addEventListener('close', this.cancel.bind(this));
166 this.navigation_.addEventListener('refresh', this.cancel.bind(this)); 182 this.navigation_.addEventListener('refresh', this.cancel.bind(this));
167 183
168 this.navigation_.addEventListener('back', function() { 184 this.navigation_.addEventListener('back', function() {
169 this.navigation_.backVisible = false; 185 this.navigation_.backVisible = false;
170 $('oauth-enroll-auth-view').back(); 186 if (this.currentStep_ == STEP_SIGNIN)
187 $('oauth-enroll-auth-view').back();
171 }.bind(this)); 188 }.bind(this));
172 189
173 $('oauth-enroll-attribute-prompt-card').addEventListener('submit', 190 $('oauth-enroll-attribute-prompt-card').addEventListener('submit',
174 this.onAttributesSubmitted.bind(this)); 191 this.onAttributesSubmitted.bind(this));
175 192
176 $('oauth-enroll-learn-more-link').addEventListener('click', 193 $('oauth-enroll-learn-more-link').addEventListener('click',
177 function(event) { 194 function(event) {
178 chrome.send('oauthEnrollOnLearnMore'); 195 chrome.send('oauthEnrollOnLearnMore');
179 }); 196 });
180 197
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } else if (step == STEP_ERROR) { 304 } else if (step == STEP_ERROR) {
288 $('oauth-enroll-error-card').submitButton.focus(); 305 $('oauth-enroll-error-card').submitButton.focus();
289 } else if (step == STEP_SUCCESS) { 306 } else if (step == STEP_SUCCESS) {
290 $('oauth-enroll-success-card').submitButton.focus(); 307 $('oauth-enroll-success-card').submitButton.focus();
291 } else if (step == STEP_ABE_SUCCESS) { 308 } else if (step == STEP_ABE_SUCCESS) {
292 $('oauth-enroll-abe-success-card').submitButton.focus(); 309 $('oauth-enroll-abe-success-card').submitButton.focus();
293 } else if (step == STEP_ATTRIBUTE_PROMPT) { 310 } else if (step == STEP_ATTRIBUTE_PROMPT) {
294 $('oauth-enroll-asset-id').focus(); 311 $('oauth-enroll-asset-id').focus();
295 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { 312 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) {
296 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); 313 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus();
314 } else if (step == STEP_AD_JOIN) {
315 this.offlineAdUi_.disabled = false;
316 this.offlineAdUi_.setUser();
297 } 317 }
298 318
299 this.currentStep_ = step; 319 this.currentStep_ = step;
300 this.lastBackMessageValue_ = false; 320 this.lastBackMessageValue_ = false;
301 this.updateControlsState(); 321 this.updateControlsState();
302 }, 322 },
303 323
304 /** 324 /**
305 * Sets an error message and switches to the error screen. 325 * Sets an error message and switches to the error screen.
306 * @param {string} message the error message. 326 * @param {string} message the error message.
(...skipping 11 matching lines...) Expand all
318 retry ? loadTimeData.getString('oauthEnrollRetry') : ''; 338 retry ? loadTimeData.getString('oauthEnrollRetry') : '';
319 this.showStep(STEP_ERROR); 339 this.showStep(STEP_ERROR);
320 }, 340 },
321 341
322 doReload: function() { 342 doReload: function() {
323 this.lastBackMessageValue_ = false; 343 this.lastBackMessageValue_ = false;
324 this.authenticator_.reload(); 344 this.authenticator_.reload();
325 this.updateControlsState(); 345 this.updateControlsState();
326 }, 346 },
327 347
348 invalidateAD: function(machineName, user) {
349 this.offlineAdUi_.disabled = false;
michaelpg 2016/11/02 23:08:53 nit (throughout): can you decide whether you want
Roman Sorokin (ftl) 2016/11/03 14:03:46 Done.
michaelpg 2016/11/04 00:34:21 thanks. Makes the code easier to modify when you d
350 this.offlineAdUi_.setUser(user, machineName);
351 },
352
328 /** 353 /**
329 * Retries the enrollment process after an error occurred in a previous 354 * Retries the enrollment process after an error occurred in a previous
330 * attempt. This goes to the C++ side through |chrome| first to clean up the 355 * attempt. This goes to the C++ side through |chrome| first to clean up the
331 * profile, so that the next attempt is performed with a clean state. 356 * profile, so that the next attempt is performed with a clean state.
332 */ 357 */
333 doRetry_: function() { 358 doRetry_: function() {
334 chrome.send('oauthEnrollRetry'); 359 chrome.send('oauthEnrollRetry');
335 }, 360 },
336 361
337 /** 362 /**
(...skipping 26 matching lines...) Expand all
364 389
365 /** 390 /**
366 * Updates visibility of navigation buttons. 391 * Updates visibility of navigation buttons.
367 */ 392 */
368 updateControlsState: function() { 393 updateControlsState: function() {
369 this.navigation_.backVisible = this.currentStep_ == STEP_SIGNIN && 394 this.navigation_.backVisible = this.currentStep_ == STEP_SIGNIN &&
370 this.lastBackMessageValue_; 395 this.lastBackMessageValue_;
371 this.navigation_.refreshVisible = this.isAtTheBeginning() && 396 this.navigation_.refreshVisible = this.isAtTheBeginning() &&
372 !this.isManualEnrollment_; 397 !this.isManualEnrollment_;
373 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || 398 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN ||
374 this.currentStep_ == STEP_ERROR) && 399 this.currentStep_ == STEP_ERROR ||
400 this.currentStep_ == STEP_AD_JOIN) &&
375 !this.navigation_.refreshVisible; 401 !this.navigation_.refreshVisible;
376 $('login-header-bar').updateUI_(); 402 $('login-header-bar').updateUI_();
377 } 403 }
378 }; 404 };
379 }); 405 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698