Chromium Code Reviews| Index: chrome/browser/resources/chromeos/login/lock.js |
| diff --git a/chrome/browser/resources/chromeos/login/lock.js b/chrome/browser/resources/chromeos/login/lock.js |
| index 9800faec319595ee3dc148d52b6662c405682dd0..916f3fb679aba2adae85de7167861a111d9350fa 100644 |
| --- a/chrome/browser/resources/chromeos/login/lock.js |
| +++ b/chrome/browser/resources/chromeos/login/lock.js |
| @@ -8,6 +8,45 @@ |
| <include src="login_shared.js"> |
| +// Lazy load polymer. |
| +(function() { |
| + 'use strict'; |
| + |
| + // How long until we wait for an idle event before forcibly loading polymer. |
| + /** @const */ var IDLE_TIMEOUT_MS = 250; |
| + |
| + var onPolymerLoaded = function() { |
| + var pinContainer = $('pin-container'); |
| + pinContainer.style.opacity = 1; |
| + }; |
| + |
| + // We only need to load polymer on the lock screen if we are showing the PIN |
| + // keypad. The PIN keypad is implemented with various paper elements and can |
| + // take a significant amount of time to load. Moreover, if the user does not |
| + // have PIN unlock enabled, we can skip loading all of polymer. |
| + // |
| + // Directly loading the element in DOMContentLoaded or load results in the |
| + // pod intro animation getting interrupted. Loading it in an idle callback |
| + // defers the load enough that the animation does not get interrupted. |
| + // |
| + // TODO(jdufault): Reevaluate if we need the requestIdleCallback bit if we are |
| + // not showing user pods with the PIN keypad. |
| + var showPin = loadTimeData.getBoolean('showPin'); |
| + if (true || showPin) { |
|
tommycli
2016/05/04 19:29:02
leftover true ||
jdufault
2016/05/06 00:05:46
Done.
|
| + window.addEventListener('DOMContentLoaded', function() { |
| + var loadPolymer = function() { |
| + var link = document.createElement('link'); |
| + link.rel = 'import'; |
| + link.href = 'chrome://oobe/custom_elements.html'; |
| + link.onload = onPolymerLoaded; |
| + document.head.appendChild(link); |
| + }; |
| + |
| + window.requestIdleCallback(loadPolymer, { timeout: IDLE_TIMEOUT_MS }); |
| + }); |
| + } |
| +})(); |
| + |
| cr.define('cr.ui.Oobe', function() { |
| return { |
| /** |