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 */ |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 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 |
| 64 offline_ad_ui_: undefined, | |
|
xiyuan
2016/10/26 22:03:16
offline_ad_ui_ -> offlineAdUi_ to fit JS var name
Roman Sorokin (ftl)
2016/10/27 13:10:45
Done.
| |
| 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.offline_ad_ui_ = $('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.offline_ad_ui_.addEventListener('authCompleted', | |
| 121 (function(e) { | |
| 122 this.offline_ad_ui_.disabled = true; | |
| 123 chrome.send('oauthEnrollADCompleteLogin', | |
| 124 [e.detail.machinename, e.detail.username, e.detail.password]); | |
| 125 }).bind(this)); | |
| 126 | |
| 127 | |
|
xiyuan
2016/10/26 22:03:16
nit: nuke one empty line ?
Roman Sorokin (ftl)
2016/10/27 13:10:45
Done.
| |
| 115 this.authenticator_.addEventListener('authFlowChange', | 128 this.authenticator_.addEventListener('authFlowChange', |
| 116 (function(e) { | 129 (function(e) { |
| 117 var isSAML = this.authenticator_.authFlow == | 130 var isSAML = this.authenticator_.authFlow == |
| 118 cr.login.Authenticator.AuthFlow.SAML; | 131 cr.login.Authenticator.AuthFlow.SAML; |
| 119 if (isSAML) { | 132 if (isSAML) { |
| 120 $('oauth-saml-notice-message').textContent = | 133 $('oauth-saml-notice-message').textContent = |
| 121 loadTimeData.getStringF('samlNotice', | 134 loadTimeData.getStringF('samlNotice', |
| 122 this.authenticator_.authDomain); | 135 this.authenticator_.authDomain); |
| 123 } | 136 } |
| 124 this.classList.toggle('saml', isSAML); | 137 this.classList.toggle('saml', isSAML); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 $('oauth-enroll-success-card').addEventListener( | 173 $('oauth-enroll-success-card').addEventListener( |
| 161 'buttonclick', doneCallback); | 174 'buttonclick', doneCallback); |
| 162 $('oauth-enroll-abe-success-card').addEventListener( | 175 $('oauth-enroll-abe-success-card').addEventListener( |
| 163 'buttonclick', doneCallback); | 176 'buttonclick', doneCallback); |
| 164 | 177 |
| 165 this.navigation_.addEventListener('close', this.cancel.bind(this)); | 178 this.navigation_.addEventListener('close', this.cancel.bind(this)); |
| 166 this.navigation_.addEventListener('refresh', this.cancel.bind(this)); | 179 this.navigation_.addEventListener('refresh', this.cancel.bind(this)); |
| 167 | 180 |
| 168 this.navigation_.addEventListener('back', function() { | 181 this.navigation_.addEventListener('back', function() { |
| 169 this.navigation_.backVisible = false; | 182 this.navigation_.backVisible = false; |
| 170 $('oauth-enroll-auth-view').back(); | 183 if (this.currentStep_ == STEP_SIGNIN) { |
| 184 $('oauth-enroll-auth-view').back(); | |
| 185 } | |
|
xiyuan
2016/10/26 22:03:16
What would "back" do for STEP_AD_JOIN ?
Roman Sorokin (ftl)
2016/10/27 13:10:45
We don't show the button on domain join screen yet
| |
| 171 }.bind(this)); | 186 }.bind(this)); |
| 172 | 187 |
| 173 $('oauth-enroll-attribute-prompt-card').addEventListener('submit', | 188 $('oauth-enroll-attribute-prompt-card').addEventListener('submit', |
| 174 this.onAttributesSubmitted.bind(this)); | 189 this.onAttributesSubmitted.bind(this)); |
| 175 | 190 |
| 176 $('oauth-enroll-learn-more-link').addEventListener('click', | 191 $('oauth-enroll-learn-more-link').addEventListener('click', |
| 177 function(event) { | 192 function(event) { |
| 178 chrome.send('oauthEnrollOnLearnMore'); | 193 chrome.send('oauthEnrollOnLearnMore'); |
| 179 }); | 194 }); |
| 180 | 195 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 } else if (step == STEP_ERROR) { | 302 } else if (step == STEP_ERROR) { |
| 288 $('oauth-enroll-error-card').submitButton.focus(); | 303 $('oauth-enroll-error-card').submitButton.focus(); |
| 289 } else if (step == STEP_SUCCESS) { | 304 } else if (step == STEP_SUCCESS) { |
| 290 $('oauth-enroll-success-card').submitButton.focus(); | 305 $('oauth-enroll-success-card').submitButton.focus(); |
| 291 } else if (step == STEP_ABE_SUCCESS) { | 306 } else if (step == STEP_ABE_SUCCESS) { |
| 292 $('oauth-enroll-abe-success-card').submitButton.focus(); | 307 $('oauth-enroll-abe-success-card').submitButton.focus(); |
| 293 } else if (step == STEP_ATTRIBUTE_PROMPT) { | 308 } else if (step == STEP_ATTRIBUTE_PROMPT) { |
| 294 $('oauth-enroll-asset-id').focus(); | 309 $('oauth-enroll-asset-id').focus(); |
| 295 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { | 310 } else if (step == STEP_ATTRIBUTE_PROMPT_ERROR) { |
| 296 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); | 311 $('oauth-enroll-attribute-prompt-error-card').submitButton.focus(); |
| 312 } else if (step == STEP_AD_JOIN) { | |
| 313 this.offline_ad_ui_.disabled = false; | |
| 314 this.offline_ad_ui_.setUser(); | |
| 297 } | 315 } |
| 298 | 316 |
| 299 this.currentStep_ = step; | 317 this.currentStep_ = step; |
| 300 this.lastBackMessageValue_ = false; | 318 this.lastBackMessageValue_ = false; |
| 301 this.updateControlsState(); | 319 this.updateControlsState(); |
| 302 }, | 320 }, |
| 303 | 321 |
| 304 /** | 322 /** |
| 305 * Sets an error message and switches to the error screen. | 323 * Sets an error message and switches to the error screen. |
| 306 * @param {string} message the error message. | 324 * @param {string} message the error message. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 318 retry ? loadTimeData.getString('oauthEnrollRetry') : ''; | 336 retry ? loadTimeData.getString('oauthEnrollRetry') : ''; |
| 319 this.showStep(STEP_ERROR); | 337 this.showStep(STEP_ERROR); |
| 320 }, | 338 }, |
| 321 | 339 |
| 322 doReload: function() { | 340 doReload: function() { |
| 323 this.lastBackMessageValue_ = false; | 341 this.lastBackMessageValue_ = false; |
| 324 this.authenticator_.reload(); | 342 this.authenticator_.reload(); |
| 325 this.updateControlsState(); | 343 this.updateControlsState(); |
| 326 }, | 344 }, |
| 327 | 345 |
| 346 invalidateAD: function(machineName, user) { | |
| 347 this.offline_ad_ui_.disabled = false; | |
| 348 this.offline_ad_ui_.setUser(user, machineName); | |
| 349 }, | |
| 350 | |
| 328 /** | 351 /** |
| 329 * Retries the enrollment process after an error occurred in a previous | 352 * 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 | 353 * 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. | 354 * profile, so that the next attempt is performed with a clean state. |
| 332 */ | 355 */ |
| 333 doRetry_: function() { | 356 doRetry_: function() { |
| 334 chrome.send('oauthEnrollRetry'); | 357 chrome.send('oauthEnrollRetry'); |
| 335 }, | 358 }, |
| 336 | 359 |
| 337 /** | 360 /** |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 359 * @type {boolean} | 382 * @type {boolean} |
| 360 */ | 383 */ |
| 361 isAtTheBeginning: function() { | 384 isAtTheBeginning: function() { |
| 362 return !this.navigation_.backVisible && this.currentStep_ == STEP_SIGNIN; | 385 return !this.navigation_.backVisible && this.currentStep_ == STEP_SIGNIN; |
| 363 }, | 386 }, |
| 364 | 387 |
| 365 /** | 388 /** |
| 366 * Updates visibility of navigation buttons. | 389 * Updates visibility of navigation buttons. |
| 367 */ | 390 */ |
| 368 updateControlsState: function() { | 391 updateControlsState: function() { |
| 369 this.navigation_.backVisible = this.currentStep_ == STEP_SIGNIN && | 392 this.navigation_.backVisible = (this.currentStep_ == STEP_SIGNIN || |
| 393 this.currentStep_ == STEP_AD_JOIN) && | |
| 370 this.lastBackMessageValue_; | 394 this.lastBackMessageValue_; |
| 371 this.navigation_.refreshVisible = this.isAtTheBeginning() && | 395 this.navigation_.refreshVisible = this.isAtTheBeginning() && |
| 372 !this.isManualEnrollment_; | 396 !this.isManualEnrollment_; |
| 373 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || | 397 this.navigation_.closeVisible = (this.currentStep_ == STEP_SIGNIN || |
| 374 this.currentStep_ == STEP_ERROR) && | 398 this.currentStep_ == STEP_ERROR || |
| 399 this.currentStep_ == STEP_AD_JOIN) && | |
| 375 !this.navigation_.refreshVisible; | 400 !this.navigation_.refreshVisible; |
| 376 $('login-header-bar').updateUI_(); | 401 $('login-header-bar').updateUI_(); |
| 377 } | 402 } |
| 378 }; | 403 }; |
| 379 }); | 404 }); |
| OLD | NEW |