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', |
19 'doReload', | 20 'doReload', |
20 ], | 21 ], |
21 | 22 |
22 /** | 23 /** |
23 * URL to load in the sign in frame. | 24 * URL to load in the sign in frame. |
24 */ | 25 */ |
25 signInUrl_: null, | 26 signInUrl_: null, |
26 | 27 |
27 /** | 28 /** |
28 * Dialog to confirm that auto-enrollment should really be cancelled. | 29 * Dialog to confirm that auto-enrollment should really be cancelled. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 199 |
199 /** | 200 /** |
200 * Sets a progress message and switches to the working screen. | 201 * Sets a progress message and switches to the working screen. |
201 * @param {string} message the progress message. | 202 * @param {string} message the progress message. |
202 */ | 203 */ |
203 showWorking: function(message) { | 204 showWorking: function(message) { |
204 $('oauth-enroll-working-message').textContent = message; | 205 $('oauth-enroll-working-message').textContent = message; |
205 this.showStep(STEP_WORKING); | 206 this.showStep(STEP_WORKING); |
206 }, | 207 }, |
207 | 208 |
| 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 |
208 doReload: function() { | 227 doReload: function() { |
209 $('oauth-enroll-signin-frame').contentWindow.location.href = | 228 $('oauth-enroll-signin-frame').contentWindow.location.href = |
210 this.signInUrl_; | 229 this.signInUrl_; |
211 }, | 230 }, |
212 | 231 |
213 /** | 232 /** |
214 * Handler for cancellations of an enforced auto-enrollment. | 233 * Handler for cancellations of an enforced auto-enrollment. |
215 */ | 234 */ |
216 cancelAutoEnrollment: function() { | 235 cancelAutoEnrollment: function() { |
217 // Only to be activated for the explain step in auto-enrollment. | 236 // Only to be activated for the explain step in auto-enrollment. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 * Event handler for HTML5 messages. | 282 * Event handler for HTML5 messages. |
264 * @param {Object} m HTML5 message. | 283 * @param {Object} m HTML5 message. |
265 */ | 284 */ |
266 onMessage_: function(m) { | 285 onMessage_: function(m) { |
267 if (!this.isSigninMessage_(m)) | 286 if (!this.isSigninMessage_(m)) |
268 return; | 287 return; |
269 | 288 |
270 var msg = m.data; | 289 var msg = m.data; |
271 | 290 |
272 if (msg.method == 'completeLogin') { | 291 if (msg.method == 'completeLogin') { |
273 // A user has successfully authenticated via regular GAIA or SAML. | 292 // A user has successfully authenticated via regular GAIA. |
274 chrome.send('oauthEnrollCompleteLogin', [msg.email]); | 293 chrome.send('oauthEnrollCompleteLogin', [msg.email]); |
275 } | 294 } |
276 | 295 |
| 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 |
277 if (msg.method == 'authPageLoaded' && this.currentStep_ == STEP_SIGNIN) { | 306 if (msg.method == 'authPageLoaded' && this.currentStep_ == STEP_SIGNIN) { |
278 if (msg.isSAML) { | 307 if (msg.isSAML) { |
279 $('oauth-saml-notice-message').textContent = loadTimeData.getStringF( | 308 $('oauth-saml-notice-message').textContent = loadTimeData.getStringF( |
280 'samlNotice', | 309 'samlNotice', |
281 msg.domain); | 310 msg.domain); |
282 } | 311 } |
283 this.classList.toggle('saml', msg.isSAML); | 312 this.classList.toggle('saml', msg.isSAML); |
284 chrome.send('frameLoadingCompleted', [0]); | 313 chrome.send('frameLoadingCompleted', [0]); |
285 } | 314 } |
286 | 315 |
287 if (msg.method == 'insecureContentBlocked') { | 316 if (msg.method == 'insecureContentBlocked') { |
288 this.showError( | 317 this.showError( |
289 loadTimeData.getStringF('insecureURLEnrollmentError', msg.url), | 318 loadTimeData.getStringF('insecureURLEnrollmentError', msg.url), |
290 false); | 319 false); |
291 } | 320 } |
292 | |
293 if (msg.method == 'missingGaiaInfo') { | |
294 this.showError( | |
295 loadTimeData.getString('fatalEnrollmentError'), | |
296 false); | |
297 } | |
298 } | 321 } |
299 }; | 322 }; |
300 }); | 323 }); |
301 | 324 |
OLD | NEW |