Chromium Code Reviews| 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 var onPolymerLoaded = function() { | |
| 19 var pinContainer = $('pin-container'); | |
| 20 pinContainer.style.opacity = 1; | |
| 21 }; | |
| 22 | |
| 23 // We only need to load polymer on the lock screen if we are showing the PIN | |
| 24 // keypad. The PIN keypad is implemented with various paper elements and can | |
| 25 // take a significant amount of time to load. Moreover, if the user does not | |
| 26 // have PIN unlock enabled, we can skip loading all of polymer. | |
| 27 // | |
| 28 // Directly loading the element in DOMContentLoaded or load results in the | |
| 29 // pod intro animation getting interrupted. Loading it in an idle callback | |
| 30 // defers the load enough that the animation does not get interrupted. | |
| 31 // | |
| 32 // TODO(jdufault): Reevaluate if we need the requestIdleCallback bit if we are | |
| 33 // not showing user pods with the PIN keypad. | |
| 34 var showPin = loadTimeData.getBoolean('showPin'); | |
| 35 if (true || showPin) { | |
|
tommycli
2016/05/04 19:29:02
leftover true ||
jdufault
2016/05/06 00:05:46
Done.
| |
| 36 window.addEventListener('DOMContentLoaded', function() { | |
| 37 var loadPolymer = function() { | |
| 38 var link = document.createElement('link'); | |
| 39 link.rel = 'import'; | |
| 40 link.href = 'chrome://oobe/custom_elements.html'; | |
| 41 link.onload = onPolymerLoaded; | |
| 42 document.head.appendChild(link); | |
| 43 }; | |
| 44 | |
| 45 window.requestIdleCallback(loadPolymer, { timeout: IDLE_TIMEOUT_MS }); | |
| 46 }); | |
| 47 } | |
| 48 })(); | |
| 49 | |
| 11 cr.define('cr.ui.Oobe', function() { | 50 cr.define('cr.ui.Oobe', function() { |
| 12 return { | 51 return { |
| 13 /** | 52 /** |
| 14 * Initializes the OOBE flow. This will cause all C++ handlers to | 53 * Initializes the OOBE flow. This will cause all C++ handlers to |
| 15 * be invoked to do final setup. | 54 * be invoked to do final setup. |
| 16 */ | 55 */ |
| 17 initialize: function() { | 56 initialize: function() { |
| 18 // TODO(jdufault): Remove this after resolving crbug.com/452599. | 57 // TODO(jdufault): Remove this after resolving crbug.com/452599. |
| 19 console.log('Start initializing LOCK OOBE'); | 58 console.log('Start initializing LOCK OOBE'); |
| 20 | 59 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 42 * Reloads content of the page. | 81 * Reloads content of the page. |
| 43 * @param {!Object} data New dictionary with i18n values. | 82 * @param {!Object} data New dictionary with i18n values. |
| 44 */ | 83 */ |
| 45 reloadContent: function(data) { | 84 reloadContent: function(data) { |
| 46 loadTimeData.overrideValues(data); | 85 loadTimeData.overrideValues(data); |
| 47 i18nTemplate.process(document, loadTimeData); | 86 i18nTemplate.process(document, loadTimeData); |
| 48 Oobe.getInstance().updateLocalizedContent_(); | 87 Oobe.getInstance().updateLocalizedContent_(); |
| 49 }, | 88 }, |
| 50 }; | 89 }; |
| 51 }); | 90 }); |
| OLD | NEW |