Chromium Code Reviews| 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_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 */ |
| 42 currentStep_: null, | 44 currentStep_: null, |
| 43 | 45 |
| 44 /** | 46 /** |
| 45 * We block esc, back button and cancel button until gaia is loaded to | 47 * We block esc, back button and cancel button until gaia is loaded to |
| 46 * prevent multiple cancel events. | 48 * prevent multiple cancel events. |
| 47 */ | 49 */ |
| 48 isCancelDisabled_: null, | 50 isCancelDisabled_: null, |
| 49 | 51 |
| 50 get isCancelDisabled() { return this.isCancelDisabled_ }, | 52 get isCancelDisabled() { return this.isCancelDisabled_ }, |
| 51 set isCancelDisabled(disabled) { | 53 set isCancelDisabled(disabled) { |
| 52 this.isCancelDisabled_ = disabled; | 54 this.isCancelDisabled_ = disabled; |
| 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 |
|
Dan Beam
2016/10/28 21:13:03
can you document and/or type this? and maybe add
Roman Sorokin (ftl)
2016/10/31 11:37:10
Done.
| |
| 64 offlineAdUi_: undefined, | |
| 65 | |
| 62 /** | 66 /** |
| 63 * Value contained in the last received 'backButton' event. | 67 * Value contained in the last received 'backButton' event. |
| 64 * @type {boolean} | 68 * @type {boolean} |
| 65 * @private | 69 * @private |
| 66 */ | 70 */ |
| 67 lastBackMessageValue_: false, | 71 lastBackMessageValue_: false, |
| 68 | 72 |
| 69 /** @override */ | 73 /** @override */ |
| 70 decorate: function() { | 74 decorate: function() { |
| 71 this.navigation_ = $('oauth-enroll-navigation'); | 75 this.navigation_ = $('oauth-enroll-navigation'); |
| 76 this.offlineAdUi_ = $('oauth-enroll-ad-join-ui'); | |
| 72 | 77 |
| 73 this.authenticator_ = | 78 this.authenticator_ = |
| 74 new cr.login.Authenticator($('oauth-enroll-auth-view')); | 79 new cr.login.Authenticator($('oauth-enroll-auth-view')); |
| 75 | 80 |
| 76 // Establish an initial messaging between content script and | 81 // Establish an initial messaging between content script and |
| 77 // host script so that content script can message back. | 82 // host script so that content script can message back. |
| 78 $('oauth-enroll-auth-view').addEventListener('loadstop', | 83 $('oauth-enroll-auth-view').addEventListener('loadstop', |
| 79 function(e) { | 84 function(e) { |
| 80 e.target.contentWindow.postMessage( | 85 e.target.contentWindow.postMessage( |
| 81 'initialMessage', $('oauth-enroll-auth-view').src); | 86 'initialMessage', $('oauth-enroll-auth-view').src); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 105 if (!detail.email || !detail.authCode) { | 110 if (!detail.email || !detail.authCode) { |
| 106 this.showError( | 111 this.showError( |
| 107 loadTimeData.getString('fatalEnrollmentError'), | 112 loadTimeData.getString('fatalEnrollmentError'), |
| 108 false); | 113 false); |
| 109 return; | 114 return; |
| 110 } | 115 } |
| 111 chrome.send('oauthEnrollCompleteLogin', [detail.email, | 116 chrome.send('oauthEnrollCompleteLogin', [detail.email, |
| 112 detail.authCode]); | 117 detail.authCode]); |
| 113 }).bind(this)); | 118 }).bind(this)); |
| 114 | 119 |
| 120 this.offlineAdUi_.addEventListener('authCompleted', | |
| 121 (function(e) { | |
| 122 this.offlineAdUi_.disabled = true; | |
| 123 chrome.send('oauthEnrollADCompleteLogin', | |
| 124 [e.detail.machinename, e.detail.username, e.detail.password]); | |
| 125 }).bind(this)); | |
|
Dan Beam
2016/10/28 21:13:03
these outer () aren't necessary, i.e. you can just
Roman Sorokin (ftl)
2016/10/31 11:37:10
Done.
| |
| 126 | |
| 115 this.authenticator_.addEventListener('authFlowChange', | 127 this.authenticator_.addEventListener('authFlowChange', |
| 116 (function(e) { | 128 (function(e) { |
| 117 var isSAML = this.authenticator_.authFlow == | 129 var isSAML = this.authenticator_.authFlow == |
| 118 cr.login.Authenticator.AuthFlow.SAML; | 130 cr.login.Authenticator.AuthFlow.SAML; |
| 119 if (isSAML) { | 131 if (isSAML) { |
| 120 $('oauth-saml-notice-message').textContent = | 132 $('oauth-saml-notice-message').textContent = |
| 121 loadTimeData.getStringF('samlNotice', | 133 loadTimeData.getStringF('samlNotice', |
| 122 this.authenticator_.authDomain); | 134 this.authenticator_.authDomain); |
| 123 } | 135 } |
| 124 this.classList.toggle('saml', isSAML); | 136 this.classList.toggle('saml', isSAML); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 $('oauth-enroll-success-card').addEventListener( | 172 $('oauth-enroll-success-card').addEventListener( |
| 161 'buttonclick', doneCallback); | 173 'buttonclick', doneCallback); |
| 162 $('oauth-enroll-abe-success-card').addEventListener( | 174 $('oauth-enroll-abe-success-card').addEventListener( |
| 163 'buttonclick', doneCallback); | 175 'buttonclick', doneCallback); |
| 164 | 176 |
| 165 this.navigation_.addEventListener('close', this.cancel.bind(this)); | 177 this.navigation_.addEventListener('close', this.cancel.bind(this)); |
| 166 this.navigation_.addEventListener('refresh', this.cancel.bind(this)); | 178 this.navigation_.addEventListener('refresh', this.cancel.bind(this)); |
| 167 | 179 |
| 168 this.navigation_.addEventListener('back', function() { | 180 this.navigation_.addEventListener('back', function() { |
| 169 this.navigation_.backVisible = false; | 181 this.navigation_.backVisible = false; |
| 170 $('oauth-enroll-auth-view').back(); | 182 if (this.currentStep_ == STEP_SIGNIN) { |
|
Dan Beam
2016/10/28 21:13:03
nit: no curlies
Roman Sorokin (ftl)
2016/10/31 11:37:11
Done.
| |
| 183 $('oauth-enroll-auth-view').back(); | |
| 184 } | |
| 171 }.bind(this)); | 185 }.bind(this)); |
| 172 | 186 |
| 173 $('oauth-enroll-attribute-prompt-card').addEventListener('submit', | 187 $('oauth-enroll-attribute-prompt-card').addEventListener('submit', |
| 174 this.onAttributesSubmitted.bind(this)); | 188 this.onAttributesSubmitted.bind(this)); |
| 175 | 189 |
| 176 $('oauth-enroll-learn-more-link').addEventListener('click', | 190 $('oauth-enroll-learn-more-link').addEventListener('click', |
| 177 function(event) { | 191 function(event) { |
| 178 chrome.send('oauthEnrollOnLearnMore'); | 192 chrome.send('oauthEnrollOnLearnMore'); |
| 179 }); | 193 }); |
| 180 | 194 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 } else if (step == STEP_ERROR) { | 301 } else if (step == STEP_ERROR) { |
| 288 $('oauth-enroll-error-card').submitButton.focus(); | 302 $('oauth-enroll-error-card').submitButton.focus(); |
| 289 } else if (step == STEP_SUCCESS) { | 303 } else if (step == STEP_SUCCESS) { |
| 290 $('oauth-enroll-success-card').submitButton.focus(); | 304 $('oauth-enroll-success-card').submitButton.focus(); |
| 291 } else if (step == STEP_ABE_SUCCESS) { | 305 } else if (step == STEP_ABE_SUCCESS) { |
| 292 $('oauth-enroll-abe-success-card').submitButton.focus(); | 306 $('oauth-enroll-abe-success-card').submitButton.focus(); |
| 293 } else if (step == STEP_ATTRIBUTE_PROMPT) { | 307 } else if (step == STEP_ATTRIBUTE_PROMPT) { |
| 294 $('oauth-enroll-asset-id').focus(); | 308 $('oauth-enroll-asset-id').focus(); |
| 295 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { | 309 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { |
| 296 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); | 310 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); |
| 311 } else if (step == STEP_AD_JOIN) { | |
| 312 this.offlineAdUi_.disabled = false; | |
| 313 this.offlineAdUi_.setUser(); | |
| 297 } | 314 } |
| 298 | 315 |
| 299 this.currentStep_ = step; | 316 this.currentStep_ = step; |
| 300 this.lastBackMessageValue_ = false; | 317 this.lastBackMessageValue_ = false; |
| 301 this.updateControlsState(); | 318 this.updateControlsState(); |
| 302 }, | 319 }, |
| 303 | 320 |
| 304 /** | 321 /** |
| 305 * Sets an error message and switches to the error screen. | 322 * Sets an error message and switches to the error screen. |
| 306 * @param {string} message the error message. | 323 * @param {string} message the error message. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 318 retry ? loadTimeData.getString('oauthEnrollRetry') : ''; | 335 retry ? loadTimeData.getString('oauthEnrollRetry') : ''; |
| 319 this.showStep(STEP_ERROR); | 336 this.showStep(STEP_ERROR); |
| 320 }, | 337 }, |
| 321 | 338 |
| 322 doReload: function() { | 339 doReload: function() { |
| 323 this.lastBackMessageValue_ = false; | 340 this.lastBackMessageValue_ = false; |
| 324 this.authenticator_.reload(); | 341 this.authenticator_.reload(); |
| 325 this.updateControlsState(); | 342 this.updateControlsState(); |
| 326 }, | 343 }, |
| 327 | 344 |
| 345 invalidateAD: function(machineName, user) { | |
| 346 this.offlineAdUi_.disabled = false; | |
| 347 this.offlineAdUi_.setUser(user, machineName); | |
| 348 }, | |
| 349 | |
| 328 /** | 350 /** |
| 329 * Retries the enrollment process after an error occurred in a previous | 351 * 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 | 352 * 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. | 353 * profile, so that the next attempt is performed with a clean state. |
| 332 */ | 354 */ |
| 333 doRetry_: function() { | 355 doRetry_: function() { |
| 334 chrome.send('oauthEnrollRetry'); | 356 chrome.send('oauthEnrollRetry'); |
| 335 }, | 357 }, |
| 336 | 358 |
| 337 /** | 359 /** |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 364 | 386 |
| 365 /** | 387 /** |
| 366 * Updates visibility of navigation buttons. | 388 * Updates visibility of navigation buttons. |
| 367 */ | 389 */ |
| 368 updateControlsState: function() { | 390 updateControlsState: function() { |
| 369 this.navigation_.backVisible = this.currentStep_ == STEP_SIGNIN && | 391 this.navigation_.backVisible = this.currentStep_ == STEP_SIGNIN && |
| 370 this.lastBackMessageValue_; | 392 this.lastBackMessageValue_; |
| 371 this.navigation_.refreshVisible = this.isAtTheBeginning() && | 393 this.navigation_.refreshVisible = this.isAtTheBeginning() && |
| 372 !this.isManualEnrollment_; | 394 !this.isManualEnrollment_; |
| 373 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || | 395 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || |
| 374 this.currentStep_ == STEP_ERROR) && | 396 this.currentStep_ == STEP_ERROR || |
| 397 this.currentStep_ == STEP_AD_JOIN) && | |
| 375 !this.navigation_.refreshVisible; | 398 !this.navigation_.refreshVisible; |
| 376 $('login-header-bar').updateUI_(); | 399 $('login-header-bar').updateUI_(); |
| 377 } | 400 } |
| 378 }; | 401 }; |
| 379 }); | 402 }); |
| OLD | NEW |