| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 Login UI based on a stripped down OOBE controller. | 6 * @fileoverview Login UI based on a stripped down OOBE controller. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 <include src="login_shared.js"> | 9 <include src="login_shared.js"> |
| 10 | 10 |
| 11 // Lazy load polymer. |
| 12 (function() { |
| 13 'use strict'; |
| 14 |
| 15 // How long until we wait for an idle event before forcibly loading polymer. |
| 16 /** @const */ var IDLE_TIMEOUT_MS = 250; |
| 17 |
| 18 // Called after polymer has been loaded. Fades the pin element in. |
| 19 var onPolymerLoaded = function() { |
| 20 var pinContainer = $('pin-container'); |
| 21 pinContainer.style.opacity = 1; |
| 22 }; |
| 23 |
| 24 // Load an arbitrary JavaScript file from |href|. |onload| is called after |
| 25 // the file has been loaded. |
| 26 var injectScript = function(href, onload) { |
| 27 var link = document.createElement('link'); |
| 28 link.rel = 'import'; |
| 29 link.href = href; |
| 30 link.onload = onload; |
| 31 document.head.appendChild(link); |
| 32 }; |
| 33 |
| 34 // We only need to load polymer on the lock screen if we are showing the PIN |
| 35 // keypad. The PIN keypad is implemented with various paper elements and can |
| 36 // take a significant amount of time to load. Moreover, if the user does not |
| 37 // have PIN unlock enabled, we can skip loading all of polymer. |
| 38 // |
| 39 // Directly loading the element in DOMContentLoaded or load results in the pod |
| 40 // intro animation getting interrupted because the DOM is blocked while |
| 41 // loading polymer. Loading it in an idle callback defers the load enough |
| 42 // that the animation does not get interrupted. |
| 43 var showPin = loadTimeData.getBoolean('showPin'); |
| 44 if (showPin) { |
| 45 window.addEventListener('DOMContentLoaded', function() { |
| 46 window.requestIdleCallback(function() { |
| 47 injectScript('chrome://oobe/custom_elements.html', onPolymerLoaded); |
| 48 }, { timeout: IDLE_TIMEOUT_MS }); |
| 49 }); |
| 50 } |
| 51 })(); |
| 52 |
| 11 cr.define('cr.ui.Oobe', function() { | 53 cr.define('cr.ui.Oobe', function() { |
| 12 return { | 54 return { |
| 13 /** | 55 /** |
| 14 * Initializes the OOBE flow. This will cause all C++ handlers to | 56 * Initializes the OOBE flow. This will cause all C++ handlers to |
| 15 * be invoked to do final setup. | 57 * be invoked to do final setup. |
| 16 */ | 58 */ |
| 17 initialize: function() { | 59 initialize: function() { |
| 18 // TODO(jdufault): Remove this after resolving crbug.com/452599. | 60 // TODO(jdufault): Remove this after resolving crbug.com/452599. |
| 19 console.log('Start initializing LOCK OOBE'); | 61 console.log('Start initializing LOCK OOBE'); |
| 20 | 62 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 42 * Reloads content of the page. | 84 * Reloads content of the page. |
| 43 * @param {!Object} data New dictionary with i18n values. | 85 * @param {!Object} data New dictionary with i18n values. |
| 44 */ | 86 */ |
| 45 reloadContent: function(data) { | 87 reloadContent: function(data) { |
| 46 loadTimeData.overrideValues(data); | 88 loadTimeData.overrideValues(data); |
| 47 i18nTemplate.process(document, loadTimeData); | 89 i18nTemplate.process(document, loadTimeData); |
| 48 Oobe.getInstance().updateLocalizedContent_(); | 90 Oobe.getInstance().updateLocalizedContent_(); |
| 49 }, | 91 }, |
| 50 }; | 92 }; |
| 51 }); | 93 }); |
| OLD | NEW |