| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** @const */ var STEP_SIGNIN = 'signin'; | 6 /** @const */ var STEP_SIGNIN = 'signin'; |
| 7 /** @const */ var STEP_WORKING = 'working'; | 7 /** @const */ var STEP_WORKING = 'working'; |
| 8 /** @const */ var STEP_ERROR = 'error'; | 8 /** @const */ var STEP_ERROR = 'error'; |
| 9 /** @const */ var STEP_EXPLAIN = 'explain'; | 9 /** @const */ var STEP_EXPLAIN = 'explain'; |
| 10 /** @const */ var STEP_SUCCESS = 'success'; | 10 /** @const */ var STEP_SUCCESS = 'success'; |
| 11 | 11 |
| 12 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; | 12 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; |
| 13 | 13 |
| 14 return { | 14 return { |
| 15 EXTERNAL_API: [ | 15 EXTERNAL_API: [ |
| 16 'showStep', | 16 'showStep', |
| 17 'showError', | 17 'showError', |
| 18 'showWorking', | 18 'showWorking', |
| 19 'setAuthenticatedUserEmail', | |
| 20 'doReload', | 19 'doReload', |
| 21 ], | 20 ], |
| 22 | 21 |
| 23 /** | 22 /** |
| 24 * URL to load in the sign in frame. | 23 * URL to load in the sign in frame. |
| 25 */ | 24 */ |
| 26 signInUrl_: null, | 25 signInUrl_: null, |
| 27 | 26 |
| 28 /** | 27 /** |
| 29 * Dialog to confirm that auto-enrollment should really be cancelled. | 28 * Dialog to confirm that auto-enrollment should really be cancelled. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 198 |
| 200 /** | 199 /** |
| 201 * Sets a progress message and switches to the working screen. | 200 * Sets a progress message and switches to the working screen. |
| 202 * @param {string} message the progress message. | 201 * @param {string} message the progress message. |
| 203 */ | 202 */ |
| 204 showWorking: function(message) { | 203 showWorking: function(message) { |
| 205 $('oauth-enroll-working-message').textContent = message; | 204 $('oauth-enroll-working-message').textContent = message; |
| 206 this.showStep(STEP_WORKING); | 205 this.showStep(STEP_WORKING); |
| 207 }, | 206 }, |
| 208 | 207 |
| 209 /** | |
| 210 * Invoked when the authenticated user's e-mail address has been retrieved. | |
| 211 * This completes SAML authentication. | |
| 212 * @param {number} attemptToken An opaque token used to correlate this | |
| 213 * method invocation with the corresponding request to retrieve the | |
| 214 * user's e-mail address. | |
| 215 * @param {string} email The authenticated user's e-mail address. | |
| 216 */ | |
| 217 setAuthenticatedUserEmail: function(attemptToken, email) { | |
| 218 if (this.attemptToken_ != attemptToken) | |
| 219 return; | |
| 220 | |
| 221 if (!email) | |
| 222 this.showError(loadTimeData.getString('fatalEnrollmentError'), false); | |
| 223 else | |
| 224 chrome.send('oauthEnrollCompleteLogin', [email]); | |
| 225 }, | |
| 226 | |
| 227 doReload: function() { | 208 doReload: function() { |
| 228 $('oauth-enroll-signin-frame').contentWindow.location.href = | 209 $('oauth-enroll-signin-frame').contentWindow.location.href = |
| 229 this.signInUrl_; | 210 this.signInUrl_; |
| 230 }, | 211 }, |
| 231 | 212 |
| 232 /** | 213 /** |
| 233 * Handler for cancellations of an enforced auto-enrollment. | 214 * Handler for cancellations of an enforced auto-enrollment. |
| 234 */ | 215 */ |
| 235 cancelAutoEnrollment: function() { | 216 cancelAutoEnrollment: function() { |
| 236 // Only to be activated for the explain step in auto-enrollment. | 217 // Only to be activated for the explain step in auto-enrollment. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 * Event handler for HTML5 messages. | 263 * Event handler for HTML5 messages. |
| 283 * @param {Object} m HTML5 message. | 264 * @param {Object} m HTML5 message. |
| 284 */ | 265 */ |
| 285 onMessage_: function(m) { | 266 onMessage_: function(m) { |
| 286 if (!this.isSigninMessage_(m)) | 267 if (!this.isSigninMessage_(m)) |
| 287 return; | 268 return; |
| 288 | 269 |
| 289 var msg = m.data; | 270 var msg = m.data; |
| 290 | 271 |
| 291 if (msg.method == 'completeLogin') { | 272 if (msg.method == 'completeLogin') { |
| 292 // A user has successfully authenticated via regular GAIA. | 273 // A user has successfully authenticated via regular GAIA or SAML. |
| 293 chrome.send('oauthEnrollCompleteLogin', [msg.email]); | 274 chrome.send('oauthEnrollCompleteLogin', [msg.email]); |
| 294 } | 275 } |
| 295 | 276 |
| 296 if (msg.method == 'retrieveAuthenticatedUserEmail') { | |
| 297 // A user has successfully authenticated via SAML. However, the user's | |
| 298 // identity is not known. Instead of reporting success immediately, | |
| 299 // retrieve the user's e-mail address first. | |
| 300 this.attemptToken_ = msg.attemptToken; | |
| 301 this.showWorking(null); | |
| 302 chrome.send('oauthEnrollRetrieveAuthenticatedUserEmail', | |
| 303 [msg.attemptToken]); | |
| 304 } | |
| 305 | |
| 306 if (msg.method == 'authPageLoaded' && this.currentStep_ == STEP_SIGNIN) { | 277 if (msg.method == 'authPageLoaded' && this.currentStep_ == STEP_SIGNIN) { |
| 307 if (msg.isSAML) { | 278 if (msg.isSAML) { |
| 308 $('oauth-saml-notice-message').textContent = loadTimeData.getStringF( | 279 $('oauth-saml-notice-message').textContent = loadTimeData.getStringF( |
| 309 'samlNotice', | 280 'samlNotice', |
| 310 msg.domain); | 281 msg.domain); |
| 311 } | 282 } |
| 312 this.classList.toggle('saml', msg.isSAML); | 283 this.classList.toggle('saml', msg.isSAML); |
| 313 chrome.send('frameLoadingCompleted', [0]); | 284 chrome.send('frameLoadingCompleted', [0]); |
| 314 } | 285 } |
| 315 | 286 |
| 316 if (msg.method == 'insecureContentBlocked') { | 287 if (msg.method == 'insecureContentBlocked') { |
| 317 this.showError( | 288 this.showError( |
| 318 loadTimeData.getStringF('insecureURLEnrollmentError', msg.url), | 289 loadTimeData.getStringF('insecureURLEnrollmentError', msg.url), |
| 319 false); | 290 false); |
| 320 } | 291 } |
| 292 |
| 293 if (msg.method == 'missingGaiaInfo') { |
| 294 this.showError( |
| 295 loadTimeData.getString('fatalEnrollmentError'), |
| 296 false); |
| 297 } |
| 321 } | 298 } |
| 322 }; | 299 }; |
| 323 }); | 300 }); |
| 324 | 301 |
| OLD | NEW |