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

Unified Diff: chrome/browser/resources/settings/people_page/fingerprint_list.js

Issue 2538303002: md-settings: Added settings for fingerprint unlock. (Closed)
Patch Set: Modified the flags. Created 3 years, 11 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/settings/people_page/fingerprint_list.js
diff --git a/chrome/browser/resources/settings/people_page/fingerprint_list.js b/chrome/browser/resources/settings/people_page/fingerprint_list.js
new file mode 100644
index 0000000000000000000000000000000000000000..9fcacd1eeb961b7251f5e174670c48ae13e9293b
--- /dev/null
+++ b/chrome/browser/resources/settings/people_page/fingerprint_list.js
@@ -0,0 +1,87 @@
+// 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';
+
+/**
+ * The max number of fingerprints this list can hold.
+ * @const {number}
+ */
+var MAX_NUMBER_FINGERPRINTS_ALLOWED = 5;
+
+Polymer({
+ is: 'settings-fingerprint-list',
+
+ behaviors: [
+ I18nBehavior,
+ ],
+
+ properties: {
+ /**
+ * The list of fingerprint objects.
+ * @private {!Array<string>}
+ */
+ fingerprints_: {
+ type: Array,
+ value: function() {
+ return [];
+ }
+ }
+ },
+
+ /**
+ * Adds a fingerprint with a default name.
+ * @private
+ */
+ onAddFingerprint_: function() {
Dan Beam 2017/01/10 23:23:45 onAddFingerprint_: function() { var numPrints =
sammiequon 2017/01/11 00:29:09 This would give something slightly different than
+ // Determines what the newly added fingerprint's name should be.
+ // TODO(sammiequon): Add fingerprint using private API once it is ready.
+
+ var fingerprintName;
+ for (var i = 1; i <= MAX_NUMBER_FINGERPRINTS_ALLOWED; ++i) {
+ fingerprintName = this.i18n('lockScreenFingerprintNewName', i);
+ if (this.fingerprints_.includes(fingerprintName))
+ continue;
+ break;
+ }
+ this.push('fingerprints_', fingerprintName);
+ this.$.fingerprintsList.notifyResize();
Dan Beam 2017/01/10 23:23:46 why do you need notifyResize()?
sammiequon 2017/01/11 00:29:09 Done.
sammiequon 2017/01/17 19:59:09 Actually, without this, on options the list does n
+ },
+
+ /**
+ * Deletes a fingerprint from |fingerprints_|.
+ * @private
+ */
+ onFingerprintDelete_: function(e) {
+ // TODO(sammiequon): Remove fingerprint using private API once it is ready.
+ this.splice('fingerprints_', e.model.index, 1);
+ this.$.fingerprintsList.notifyResize();
Dan Beam 2017/01/10 23:23:45 why do you need notifyResize()?
sammiequon 2017/01/11 00:29:09 Done.
+ },
+
+ /**
+ * Returns the text to be displayed for the add fingerprint button.
+ * @param {number} numFingerprints
+ * @return {string}
+ * @private
+ */
+ getFingerprintButtonText_: function(numFingerprints) {
+ if (this.canAddNewFingerprint_(numFingerprints))
+ return this.i18n('lockScreenAddFingerprint');
+
+ return this.i18n('lockScreenCannotAddFingerprint',
+ MAX_NUMBER_FINGERPRINTS_ALLOWED);
+ },
+
+ /**
+ * Checks whether another fingerprint can be added.
+ * @param {number} numFingerprints
+ * @return {boolean}
+ * @private
+ */
+ canAddNewFingerprint_: function(numFingerprints) {
+ return numFingerprints < MAX_NUMBER_FINGERPRINTS_ALLOWED;
Dan Beam 2017/01/10 23:23:45 you only ever pass this.fingerprints_.length for n
sammiequon 2017/01/11 00:29:09 That is correct. If I do it that way, canAddNewFin
+ }
+});
+})();

Powered by Google App Engine
This is Rietveld 408576698