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(); | 10 keyboard.initializeKeyboardFlow(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 * Shows attribute-prompt step with pre-filled asset ID and | 224 * Shows attribute-prompt step with pre-filled asset ID and |
225 * location. | 225 * location. |
226 */ | 226 */ |
227 showAttributePromptStep: function(annotated_asset_id, annotated_location) { | 227 showAttributePromptStep: function(annotated_asset_id, annotated_location) { |
228 $('oauth-enroll-asset-id').value = annotated_asset_id; | 228 $('oauth-enroll-asset-id').value = annotated_asset_id; |
229 $('oauth-enroll-location').value = annotated_location; | 229 $('oauth-enroll-location').value = annotated_location; |
230 this.showStep(STEP_ATTRIBUTE_PROMPT); | 230 this.showStep(STEP_ATTRIBUTE_PROMPT); |
231 }, | 231 }, |
232 | 232 |
233 /** | 233 /** |
234 * Cancels enrollment and drops the user back to the login screen. | 234 * Cancels the current authentication and drops the user back to the next |
| 235 * screen (either the next authentication or the login screen). |
235 */ | 236 */ |
236 cancel: function() { | 237 cancel: function() { |
237 if (this.isCancelDisabled) | 238 if (this.isCancelDisabled) |
238 return; | 239 return; |
239 this.isCancelDisabled = true; | 240 this.isCancelDisabled = true; |
240 chrome.send('oauthEnrollClose', ['cancel']); | 241 chrome.send('oauthEnrollClose', ['cancel']); |
241 }, | 242 }, |
242 | 243 |
243 /** | 244 /** |
244 * Switches between the different steps in the enrollment flow. | 245 * Switches between the different steps in the enrollment flow. |
(...skipping 25 matching lines...) Expand all Loading... |
270 * Sets an error message and switches to the error screen. | 271 * Sets an error message and switches to the error screen. |
271 * @param {string} message the error message. | 272 * @param {string} message the error message. |
272 * @param {boolean} retry whether the retry link should be shown. | 273 * @param {boolean} retry whether the retry link should be shown. |
273 */ | 274 */ |
274 showError: function(message, retry) { | 275 showError: function(message, retry) { |
275 if (this.currentStep_ == STEP_ATTRIBUTE_PROMPT) { | 276 if (this.currentStep_ == STEP_ATTRIBUTE_PROMPT) { |
276 $('oauth-enroll-attribute-prompt-error-card').textContent = message; | 277 $('oauth-enroll-attribute-prompt-error-card').textContent = message; |
277 this.showStep(STEP_ATTRIBUTE_PROMPT_ERROR); | 278 this.showStep(STEP_ATTRIBUTE_PROMPT_ERROR); |
278 return; | 279 return; |
279 } | 280 } |
| 281 this.isCancelDisabled_ = false; // Re-enable if called before Gaia loads. |
280 $('oauth-enroll-error-card').textContent = message; | 282 $('oauth-enroll-error-card').textContent = message; |
281 $('oauth-enroll-error-card').buttonLabel = | 283 $('oauth-enroll-error-card').buttonLabel = |
282 retry ? loadTimeData.getString('oauthEnrollRetry') : ''; | 284 retry ? loadTimeData.getString('oauthEnrollRetry') : ''; |
283 this.showStep(STEP_ERROR); | 285 this.showStep(STEP_ERROR); |
284 }, | 286 }, |
285 | 287 |
286 doReload: function() { | 288 doReload: function() { |
287 this.lastBackMessageValue_ = false; | 289 this.lastBackMessageValue_ = false; |
288 this.authenticator_.reload(); | 290 this.authenticator_.reload(); |
289 this.updateControlsState(); | 291 this.updateControlsState(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 this.lastBackMessageValue_; | 336 this.lastBackMessageValue_; |
335 this.navigation_.refreshVisible = this.isAtTheBeginning() && | 337 this.navigation_.refreshVisible = this.isAtTheBeginning() && |
336 !this.isManualEnrollment_; | 338 !this.isManualEnrollment_; |
337 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || | 339 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || |
338 this.currentStep_ == STEP_ERROR) && | 340 this.currentStep_ == STEP_ERROR) && |
339 !this.navigation_.refreshVisible; | 341 !this.navigation_.refreshVisible; |
340 $('login-header-bar').updateUI_(); | 342 $('login-header-bar').updateUI_(); |
341 } | 343 } |
342 }; | 344 }; |
343 }); | 345 }); |
OLD | NEW |