Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Unified Diff: chrome/browser/resources/chromeos/login/custom_elements_lock.js

Issue 1933913002: Add a very basic PIN UI implementation that is shared between lock and settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/login/custom_elements_lock.js
diff --git a/chrome/browser/resources/chromeos/login/custom_elements_lock.js b/chrome/browser/resources/chromeos/login/custom_elements_lock.js
index 6853db73b68936cd3ee35d8b0ac4811bd738f192..c6eec8b339b47dfe0e9ace897cc39f6148e829e8 100644
--- a/chrome/browser/resources/chromeos/login/custom_elements_lock.js
+++ b/chrome/browser/resources/chromeos/login/custom_elements_lock.js
@@ -1,3 +1,42 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
+(function() {
+ 'use strict';
+
+ // How long until we wait for an idle event before forcibly loading the PIN
+ // HTML.
+ /** @const */ var PIN_IDLE_TIMEOUT_MS = 250;
+
+ let onPinLoaded = function() {
+ let pinContainer = $('pin-container');
+ pinContainer.style.opacity = 1;
+ };
+
+ // We only want to load the PIN HTML if we are actually showing it. The PIN
+ // element pulls in polymer with paper elements and can take a significant
+ // amount of time to load. If the user does not have a PIN unlock, we can skip
+ // loading all of the PIN-related code.
+ //
+ // TODO(jdufault): If we don't have pods, we don't need to worry about the
+ // intro-animation, and we can load directly in DOMContentLoaded.
+ //
+ // 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.
+ let showPin = loadTimeData.getBoolean('showPin');
+ if (showPin) {
+ window.addEventListener('DOMContentLoaded', function() {
tommycli 2016/05/02 16:11:26 Can we commit the "naive" and obvious approach for
jdufault 2016/05/03 19:21:57 We can't load this directly from the HTML file, be
tommycli 2016/05/04 19:29:02 Hmm, this still seems pretty non-obvious. Can we l
jdufault 2016/05/06 00:05:46 I did some investigation here. Using polymer lazy
xiyuan 2016/05/06 16:52:34 I wonder whether we could use existing cr.ui.login
jdufault 2016/05/06 23:44:17 Done - moving the resource loading code to Resourc
+ let loadPin = function() {
+ let link = document.createElement('link');
+ link.rel = 'import';
+ link.href = 'chrome://oobe/custom_elements/pin.html';
+ link.onload = onPinLoaded;
+ document.head.appendChild(link);
+ };
+
+ window.requestIdleCallback(loadPin, { timeout: PIN_IDLE_TIMEOUT_MS });
+ });
+ }
+})();

Powered by Google App Engine
This is Rietveld 408576698