| 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 * |
| 11 * If a method needs to be shared between the oobe and login screens, add it to | 11 * If a method needs to be shared between the oobe and login screens, add it to |
| 12 * login_non_lock_shared.js. | 12 * login_non_lock_shared.js. |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 // <include src="test_util.js"> | 15 // <include src="test_util.js"> |
| 16 // <include src="../../../../../ui/login/screen.js"> | 16 // <include src="../../../../../ui/login/screen.js"> |
| 17 // <include src="screen_context.js"> | 17 // <include src="screen_context.js"> |
| 18 // <include src="../user_images_grid.js"> | 18 // <include src="../user_images_grid.js"> |
| 19 // <include src="apps_menu.js"> | 19 // <include src="apps_menu.js"> |
| 20 // <include src="../../../../../ui/login/bubble.js"> | 20 // <include src="../../../../../ui/login/bubble.js"> |
| 21 // <include src="../../../../../ui/login/display_manager.js"> | 21 // <include src="../../../../../ui/login/display_manager.js"> |
| 22 // <include src="md_header_bar.js"> | 22 // <include src="md_header_bar.js"> |
| 23 | 23 |
| 24 // <include src="../../../../../ui/login/account_picker/md_screen_account_picker
.js"> | 24 // <include |
| 25 // src="../../../../../ui/login/account_picker/md_screen_account_picker.js"> |
| 25 | 26 |
| 26 // <include src="../../../../../ui/login/login_ui_tools.js"> | 27 // <include src="../../../../../ui/login/login_ui_tools.js"> |
| 27 // <include src="../../../../../ui/login/account_picker/md_user_pod_row.js"> | 28 // <include src="../../../../../ui/login/account_picker/md_user_pod_row.js"> |
| 28 // <include src="../../../../../ui/login/resource_loader.js"> | 29 // <include src="../../../../../ui/login/resource_loader.js"> |
| 29 | 30 |
| 30 cr.define('cr.ui', function() { | 31 cr.define('cr.ui', function() { |
| 31 var DisplayManager = cr.ui.login.DisplayManager; | 32 var DisplayManager = cr.ui.login.DisplayManager; |
| 32 | 33 |
| 33 /** | 34 /** |
| 34 * Constructs an Out of box controller. It manages initialization of screens, | 35 * Constructs an Out of box controller. It manages initialization of screens, |
| 35 * transitions, error messages display. | 36 * transitions, error messages display. |
| 36 * @extends {DisplayManager} | 37 * @extends {DisplayManager} |
| 37 * @constructor | 38 * @constructor |
| 38 */ | 39 */ |
| 39 function Oobe() { | 40 function Oobe() {} |
| 40 } | |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Delay in milliseconds between start of OOBE animation and start of | 43 * Delay in milliseconds between start of OOBE animation and start of |
| 44 * header bar animation. | 44 * header bar animation. |
| 45 */ | 45 */ |
| 46 var HEADER_BAR_DELAY_MS = 300; | 46 var HEADER_BAR_DELAY_MS = 300; |
| 47 | 47 |
| 48 cr.addSingletonGetter(Oobe); | 48 cr.addSingletonGetter(Oobe); |
| 49 | 49 |
| 50 Oobe.prototype = { | 50 Oobe.prototype = { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 Oobe.disableSigninUI(); | 304 Oobe.disableSigninUI(); |
| 305 chrome.send('skipToLoginForTesting'); | 305 chrome.send('skipToLoginForTesting'); |
| 306 }; | 306 }; |
| 307 | 307 |
| 308 /** | 308 /** |
| 309 * Login for telemetry. | 309 * Login for telemetry. |
| 310 * @param {string} username Login username. | 310 * @param {string} username Login username. |
| 311 * @param {string} password Login password. | 311 * @param {string} password Login password. |
| 312 * @param {boolean} enterpriseEnroll Login as an enterprise enrollment? | 312 * @param {boolean} enterpriseEnroll Login as an enterprise enrollment? |
| 313 */ | 313 */ |
| 314 Oobe.loginForTesting = function(username, password, gaia_id, | 314 Oobe.loginForTesting = function( |
| 315 enterpriseEnroll = false) { | 315 username, password, gaia_id, enterpriseEnroll = false) { |
| 316 // Helper method that runs |fn| after |screenName| is visible. | 316 // Helper method that runs |fn| after |screenName| is visible. |
| 317 function waitForOobeScreen(screenName, fn) { | 317 function waitForOobeScreen(screenName, fn) { |
| 318 if (Oobe.getInstance().currentScreen && | 318 if (Oobe.getInstance().currentScreen && |
| 319 Oobe.getInstance().currentScreen.id === screenName) { | 319 Oobe.getInstance().currentScreen.id === screenName) { |
| 320 fn(); | 320 fn(); |
| 321 } else { | 321 } else { |
| 322 $('oobe').addEventListener('screenchanged', function handler(e) { | 322 $('oobe').addEventListener('screenchanged', function handler(e) { |
| 323 if (e.detail == screenName) { | 323 if (e.detail == screenName) { |
| 324 $('oobe').removeEventListener('screenchanged', handler); | 324 $('oobe').removeEventListener('screenchanged', handler); |
| 325 fn(); | 325 fn(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 }; | 401 }; |
| 402 | 402 |
| 403 /** | 403 /** |
| 404 * Returns true if enrollment was successful. Dismisses the enrollment | 404 * Returns true if enrollment was successful. Dismisses the enrollment |
| 405 * attribute screen if it's present. | 405 * attribute screen if it's present. |
| 406 */ | 406 */ |
| 407 Oobe.isEnrollmentSuccessfulForTest = function() { | 407 Oobe.isEnrollmentSuccessfulForTest = function() { |
| 408 if (document.querySelector('.oauth-enroll-state-attribute-prompt')) | 408 if (document.querySelector('.oauth-enroll-state-attribute-prompt')) |
| 409 chrome.send('oauthEnrollAttributes', ['', '']); | 409 chrome.send('oauthEnrollAttributes', ['', '']); |
| 410 | 410 |
| 411 return $('oauth-enrollment').classList.contains( | 411 return $('oauth-enrollment') |
| 412 'oauth-enroll-state-success'); | 412 .classList.contains('oauth-enroll-state-success'); |
| 413 }; | 413 }; |
| 414 | 414 |
| 415 /** | 415 /** |
| 416 * Shows/hides login UI control bar with buttons like [Shut down]. | 416 * Shows/hides login UI control bar with buttons like [Shut down]. |
| 417 */ | 417 */ |
| 418 Oobe.showControlBar = function(show) { | 418 Oobe.showControlBar = function(show) { |
| 419 Oobe.getInstance().headerHidden = !show; | 419 Oobe.getInstance().headerHidden = !show; |
| 420 }; | 420 }; |
| 421 | 421 |
| 422 /** | 422 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 436 /** | 436 /** |
| 437 * Sets the current size of the client area (display size). | 437 * Sets the current size of the client area (display size). |
| 438 * @param {number} width client area width | 438 * @param {number} width client area width |
| 439 * @param {number} height client area height | 439 * @param {number} height client area height |
| 440 */ | 440 */ |
| 441 Oobe.setClientAreaSize = function(width, height) { | 441 Oobe.setClientAreaSize = function(width, height) { |
| 442 Oobe.getInstance().setClientAreaSize(width, height); | 442 Oobe.getInstance().setClientAreaSize(width, height); |
| 443 }; | 443 }; |
| 444 | 444 |
| 445 // Export | 445 // Export |
| 446 return { | 446 return {Oobe: Oobe}; |
| 447 Oobe: Oobe | |
| 448 }; | |
| 449 }); | 447 }); |
| 450 | 448 |
| 451 var Oobe = cr.ui.Oobe; | 449 var Oobe = cr.ui.Oobe; |
| 452 | 450 |
| 453 // Allow selection events on components with editable text (password field) | 451 // Allow selection events on components with editable text (password field) |
| 454 // bug (http://code.google.com/p/chromium/issues/detail?id=125863) | 452 // bug (http://code.google.com/p/chromium/issues/detail?id=125863) |
| 455 disableTextSelectAndDrag(function(e) { | 453 disableTextSelectAndDrag(function(e) { |
| 456 var src = e.target; | 454 var src = e.target; |
| 457 return src instanceof HTMLTextAreaElement || | 455 return src instanceof HTMLTextAreaElement || |
| 458 src instanceof HTMLInputElement && | 456 src instanceof HTMLInputElement && /text|password|search/.test(src.type); |
| 459 /text|password|search/.test(src.type); | |
| 460 }); | 457 }); |
| 461 | 458 |
| 462 | 459 |
| 463 (function() { | 460 (function() { |
| 464 'use strict'; | 461 'use strict'; |
| 465 | 462 |
| 466 document.addEventListener('DOMContentLoaded', function() { | 463 document.addEventListener('DOMContentLoaded', function() { |
| 467 try { | 464 try { |
| 468 Oobe.initialize(); | 465 Oobe.initialize(); |
| 469 } finally { | 466 } finally { |
| 470 // TODO(crbug.com/712078): Do not set readyForTesting in case of that | 467 // TODO(crbug.com/712078): Do not set readyForTesting in case of that |
| 471 // initialize() is failed. Currently, in some situation, initialize() | 468 // initialize() is failed. Currently, in some situation, initialize() |
| 472 // raises an exception unexpectedly. It means testing APIs should not | 469 // raises an exception unexpectedly. It means testing APIs should not |
| 473 // be called then. However, checking it here now causes bots failures | 470 // be called then. However, checking it here now causes bots failures |
| 474 // unfortunately. So, as a short term workaround, here set | 471 // unfortunately. So, as a short term workaround, here set |
| 475 // readyForTesting even on failures, just to make test bots happy. | 472 // readyForTesting even on failures, just to make test bots happy. |
| 476 Oobe.readyForTesting = true; | 473 Oobe.readyForTesting = true; |
| 477 } | 474 } |
| 478 }); | 475 }); |
| 479 | 476 |
| 480 // Install a global error handler so stack traces are included in logs. | 477 // Install a global error handler so stack traces are included in logs. |
| 481 window.onerror = function(message, file, line, column, error) { | 478 window.onerror = function(message, file, line, column, error) { |
| 482 console.error(error.stack); | 479 console.error(error.stack); |
| 483 }; | 480 }; |
| 484 })(); | 481 })(); |
| OLD | NEW |