| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * @fileoverview Common OOBE controller methods. This method is shared between | 6 * @fileoverview Common OOBE controller methods. This method is shared between |
| 7 * OOBE, login, and the lock screen. Add only methods that need to be shared | 7 * OOBE, login, and the lock screen. Add only methods that need to be shared |
| 8 * between all *three* screens here, as each additional method increases the | 8 * between all *three* screens here, as each additional method increases the |
| 9 * time it takes to show the lock screen. | 9 * time it takes to show the lock screen. |
| 10 * | 10 * |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 */ | 279 */ |
| 280 Oobe.skipToLoginForTesting = function() { | 280 Oobe.skipToLoginForTesting = function() { |
| 281 Oobe.disableSigninUI(); | 281 Oobe.disableSigninUI(); |
| 282 chrome.send('skipToLoginForTesting'); | 282 chrome.send('skipToLoginForTesting'); |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 /** | 285 /** |
| 286 * Login for telemetry. | 286 * Login for telemetry. |
| 287 * @param {string} username Login username. | 287 * @param {string} username Login username. |
| 288 * @param {string} password Login password. | 288 * @param {string} password Login password. |
| 289 * @param {boolean} enterpriseEnroll Login as an enterprise enrollment? | |
| 290 */ | 289 */ |
| 291 Oobe.loginForTesting = function(username, password, gaia_id, | 290 Oobe.loginForTesting = function(username, password, gaia_id) { |
| 292 enterpriseEnroll = false) { | |
| 293 // Helper method that runs |fn| after |screenName| is visible. | |
| 294 function waitForOobeScreen(screenName, fn) { | |
| 295 if (Oobe.getInstance().currentScreen.id === screenName) { | |
| 296 fn(); | |
| 297 } else { | |
| 298 $('oobe').addEventListener('screenchanged', function handler(e) { | |
| 299 if (e.detail == screenName) { | |
| 300 $('oobe').removeEventListener('screenchanged', handler); | |
| 301 fn(); | |
| 302 } | |
| 303 }); | |
| 304 } | |
| 305 } | |
| 306 | |
| 307 Oobe.disableSigninUI(); | 291 Oobe.disableSigninUI(); |
| 308 chrome.send('skipToLoginForTesting', [username]); | 292 chrome.send('skipToLoginForTesting', [username]); |
| 309 | 293 chrome.send('completeLogin', [gaia_id, username, password, false]); |
| 310 if (!enterpriseEnroll) { | |
| 311 chrome.send('completeLogin', [gaia_id, username, password, false]); | |
| 312 } else { | |
| 313 waitForOobeScreen('gaia-signin', function() { | |
| 314 chrome.send('toggleEnrollmentScreen'); | |
| 315 chrome.send('toggleFakeEnrollment'); | |
| 316 }); | |
| 317 | |
| 318 waitForOobeScreen('oauth-enrollment', function() { | |
| 319 chrome.send('oauthEnrollCompleteLogin', [username, 'authcode']); | |
| 320 chrome.send('completeLogin', [gaia_id, username, password, false]); | |
| 321 }); | |
| 322 } | |
| 323 }; | 294 }; |
| 324 | 295 |
| 325 /** | 296 /** |
| 326 * Guest login for telemetry. | 297 * Guest login for telemetry. |
| 327 */ | 298 */ |
| 328 Oobe.guestLoginForTesting = function() { | 299 Oobe.guestLoginForTesting = function() { |
| 329 Oobe.skipToLoginForTesting(); | 300 Oobe.skipToLoginForTesting(); |
| 330 chrome.send('launchIncognito'); | 301 chrome.send('launchIncognito'); |
| 331 }; | 302 }; |
| 332 | 303 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 394 |
| 424 | 395 |
| 425 (function() { | 396 (function() { |
| 426 'use strict'; | 397 'use strict'; |
| 427 | 398 |
| 428 document.addEventListener('DOMContentLoaded', function() { | 399 document.addEventListener('DOMContentLoaded', function() { |
| 429 Oobe.initialize(); | 400 Oobe.initialize(); |
| 430 }); | 401 }); |
| 431 })(); | 402 })(); |
| 432 | 403 |
| OLD | NEW |