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_WORKING = 'working'; | 14 /** @const */ var STEP_WORKING = 'working'; |
15 /** @const */ var STEP_ATTRIBUTE_PROMPT = 'attribute-prompt'; | 15 /** @const */ var STEP_ATTRIBUTE_PROMPT = 'attribute-prompt'; |
16 /** @const */ var STEP_ERROR = 'error'; | 16 /** @const */ var STEP_ERROR = 'error'; |
17 /** @const */ var STEP_SUCCESS = 'success'; | 17 /** @const */ var STEP_SUCCESS = 'success'; |
| 18 /** @const */ var STEP_ABE_SUCCESS = 'abe-success'; |
18 | 19 |
19 /* TODO(dzhioev): define this step on C++ side. | 20 /* TODO(dzhioev): define this step on C++ side. |
20 /** @const */ var STEP_ATTRIBUTE_PROMPT_ERROR = 'attribute-prompt-error'; | 21 /** @const */ var STEP_ATTRIBUTE_PROMPT_ERROR = 'attribute-prompt-error'; |
21 | 22 |
22 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; | 23 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; |
23 | 24 |
24 return { | 25 return { |
25 EXTERNAL_API: [ | 26 EXTERNAL_API: [ |
26 'showStep', | 27 'showStep', |
27 'showError', | 28 'showError', |
28 'doReload', | 29 'doReload', |
29 'showAttributePromptStep', | 30 'showAttributePromptStep', |
| 31 'showAttestationBasedEnrollmentSuccess', |
30 ], | 32 ], |
31 | 33 |
32 /** | 34 /** |
33 * Authenticator object that wraps GAIA webview. | 35 * Authenticator object that wraps GAIA webview. |
34 */ | 36 */ |
35 authenticator_: null, | 37 authenticator_: null, |
36 | 38 |
37 /** | 39 /** |
38 * The current step. This is the last value passed to showStep(). | 40 * The current step. This is the last value passed to showStep(). |
39 */ | 41 */ |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 $('oauth-enroll-error-card').addEventListener('buttonclick', | 152 $('oauth-enroll-error-card').addEventListener('buttonclick', |
151 this.doRetry_.bind(this)); | 153 this.doRetry_.bind(this)); |
152 function doneCallback() { | 154 function doneCallback() { |
153 chrome.send('oauthEnrollClose', ['done']); | 155 chrome.send('oauthEnrollClose', ['done']); |
154 }; | 156 }; |
155 | 157 |
156 $('oauth-enroll-attribute-prompt-error-card').addEventListener( | 158 $('oauth-enroll-attribute-prompt-error-card').addEventListener( |
157 'buttonclick', doneCallback); | 159 'buttonclick', doneCallback); |
158 $('oauth-enroll-success-card').addEventListener( | 160 $('oauth-enroll-success-card').addEventListener( |
159 'buttonclick', doneCallback); | 161 'buttonclick', doneCallback); |
| 162 $('oauth-enroll-abe-success-card').addEventListener( |
| 163 'buttonclick', doneCallback); |
160 | 164 |
161 this.navigation_.addEventListener('close', this.cancel.bind(this)); | 165 this.navigation_.addEventListener('close', this.cancel.bind(this)); |
162 this.navigation_.addEventListener('refresh', this.cancel.bind(this)); | 166 this.navigation_.addEventListener('refresh', this.cancel.bind(this)); |
163 | 167 |
164 this.navigation_.addEventListener('back', function() { | 168 this.navigation_.addEventListener('back', function() { |
165 this.navigation_.backVisible = false; | 169 this.navigation_.backVisible = false; |
166 $('oauth-enroll-auth-view').back(); | 170 $('oauth-enroll-auth-view').back(); |
167 }.bind(this)); | 171 }.bind(this)); |
168 | 172 |
169 $('oauth-enroll-attribute-prompt-card').addEventListener('submit', | 173 $('oauth-enroll-attribute-prompt-card').addEventListener('submit', |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 }, | 239 }, |
236 | 240 |
237 onBeforeHide: function() { | 241 onBeforeHide: function() { |
238 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN; | 242 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN; |
239 }, | 243 }, |
240 | 244 |
241 /** | 245 /** |
242 * Shows attribute-prompt step with pre-filled asset ID and | 246 * Shows attribute-prompt step with pre-filled asset ID and |
243 * location. | 247 * location. |
244 */ | 248 */ |
245 showAttributePromptStep: function(annotated_asset_id, annotated_location) { | 249 showAttributePromptStep: function(annotatedAssetId, annotatedLocation) { |
246 $('oauth-enroll-asset-id').value = annotated_asset_id; | 250 $('oauth-enroll-asset-id').value = annotatedAssetId; |
247 $('oauth-enroll-location').value = annotated_location; | 251 $('oauth-enroll-location').value = annotatedLocation; |
248 this.showStep(STEP_ATTRIBUTE_PROMPT); | 252 this.showStep(STEP_ATTRIBUTE_PROMPT); |
249 }, | 253 }, |
250 | 254 |
251 /** | 255 /** |
| 256 * Shows a success card for attestation-based enrollment that shows |
| 257 * which domain the device was enrolled into. |
| 258 */ |
| 259 showAttestationBasedEnrollmentSuccess: function(enterpriseDomain) { |
| 260 $('oauth-enroll-abe-success-card').innerHTML = |
| 261 loadTimeData.getStringF('oauthEnrollAbeSuccess', enterpriseDomain); |
| 262 this.showStep(STEP_ABE_SUCCESS); |
| 263 }, |
| 264 |
| 265 /** |
252 * Cancels the current authentication and drops the user back to the next | 266 * Cancels the current authentication and drops the user back to the next |
253 * screen (either the next authentication or the login screen). | 267 * screen (either the next authentication or the login screen). |
254 */ | 268 */ |
255 cancel: function() { | 269 cancel: function() { |
256 if (this.isCancelDisabled) | 270 if (this.isCancelDisabled) |
257 return; | 271 return; |
258 this.isCancelDisabled = true; | 272 this.isCancelDisabled = true; |
259 chrome.send('oauthEnrollClose', ['cancel']); | 273 chrome.send('oauthEnrollClose', ['cancel']); |
260 }, | 274 }, |
261 | 275 |
262 /** | 276 /** |
263 * Switches between the different steps in the enrollment flow. | 277 * Switches between the different steps in the enrollment flow. |
264 * @param {string} step the steps to show, one of "signin", "working", | 278 * @param {string} step the steps to show, one of "signin", "working", |
265 * "attribute-prompt", "error", "success". | 279 * "attribute-prompt", "error", "success". |
266 */ | 280 */ |
267 showStep: function(step) { | 281 showStep: function(step) { |
268 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); | 282 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); |
269 this.classList.toggle('oauth-enroll-state-' + step, true); | 283 this.classList.toggle('oauth-enroll-state-' + step, true); |
270 | 284 |
271 if (step == STEP_SIGNIN) { | 285 if (step == STEP_SIGNIN) { |
272 $('oauth-enroll-auth-view').focus(); | 286 $('oauth-enroll-auth-view').focus(); |
273 } else if (step == STEP_ERROR) { | 287 } else if (step == STEP_ERROR) { |
274 $('oauth-enroll-error-card').submitButton.focus(); | 288 $('oauth-enroll-error-card').submitButton.focus(); |
275 } else if (step == STEP_SUCCESS) { | 289 } else if (step == STEP_SUCCESS) { |
276 $('oauth-enroll-success-card').submitButton.focus(); | 290 $('oauth-enroll-success-card').submitButton.focus(); |
| 291 } else if (step == STEP_ABE_SUCCESS) { |
| 292 $('oauth-enroll-abe-success-card').submitButton.focus(); |
277 } else if (step == STEP_ATTRIBUTE_PROMPT) { | 293 } else if (step == STEP_ATTRIBUTE_PROMPT) { |
278 $('oauth-enroll-asset-id').focus(); | 294 $('oauth-enroll-asset-id').focus(); |
279 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { | 295 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { |
280 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); | 296 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); |
281 } | 297 } |
282 | 298 |
283 this.currentStep_ = step; | 299 this.currentStep_ = step; |
284 this.lastBackMessageValue_ = false; | 300 this.lastBackMessageValue_ = false; |
285 this.updateControlsState(); | 301 this.updateControlsState(); |
286 }, | 302 }, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 this.lastBackMessageValue_; | 370 this.lastBackMessageValue_; |
355 this.navigation_.refreshVisible = this.isAtTheBeginning() && | 371 this.navigation_.refreshVisible = this.isAtTheBeginning() && |
356 !this.isManualEnrollment_; | 372 !this.isManualEnrollment_; |
357 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || | 373 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || |
358 this.currentStep_ == STEP_ERROR) && | 374 this.currentStep_ == STEP_ERROR) && |
359 !this.navigation_.refreshVisible; | 375 !this.navigation_.refreshVisible; |
360 $('login-header-bar').updateUI_(); | 376 $('login-header-bar').updateUI_(); |
361 } | 377 } |
362 }; | 378 }; |
363 }); | 379 }); |
OLD | NEW |