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

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

Issue 2538303002: md-settings: Added settings for fingerprint unlock. (Closed)
Patch Set: Nit. Created 4 years 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..1c4ac476ccf082bc2d998b5ba3d6fe3e817a308e
--- /dev/null
+++ b/chrome/browser/resources/settings/people_page/fingerprint_list.js
@@ -0,0 +1,107 @@
+// 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.
+
+/**
+ * @fileoverview
+ * Polymer element for displaying a list of fingerprints.
+ *
+ * Example:
+ * <settings-fingerprint-list></settings-fingerprint-list>
Dan Beam 2016/12/13 19:53:23 can you drop this @fileoverview? we decided these
sammiequon 2016/12/13 23:33:34 Done.
+ */
+
Dan Beam 2016/12/13 19:53:24 if we stick with the object wrapper with a name ke
sammiequon 2016/12/13 23:33:33 Changed to array of string.
+(function() {
+'use strict';
+
+/**
+ * The max number of fingerprints this list can hold.
+ * @type {number}
+ * @const
Dan Beam 2016/12/13 19:53:24 nit: @const {number} or just @const
sammiequon 2016/12/13 23:33:34 Done.
+ */
+var MAX_NUMBER_FINGERPRINTS_ALLOWED = 5;
+
+Polymer({
+ is: 'settings-fingerprint-list',
+
+ behaviors: [
+ I18nBehavior,
+ ],
+
+ properties: {
+ /**
+ * The list of fingerprint objects.
+ * @private {Array<Object>}
Dan Beam 2016/12/13 19:53:24 !Array<!Fingerprint>
sammiequon 2016/12/13 23:33:34 Done.
+ */
+ fingerprints_: {
+ type: Array,
+ value: function() {
+ return [];
+ },
+ notify: true
Dan Beam 2016/12/13 19:53:24 why do you need this notify true? it seems like y
sammiequon 2016/12/13 23:33:34 Done.
+ }
+ },
+
+ /**
+ * Check if |fingerprints_| has a fingerprint with name |name|.
+ * @param {string} name The name we are looking for.
+ * @return {boolean}
+ * @private
+ */
+ isNameUsed_: function(name) {
+ return !!this.fingerprints_.find(function(e) {
+ return e.name == name;
+ });
+ },
+
+ /**
+ * Adds a fingerprint with a default name.
+ * @private
+ */
+ onAddFingerprint_: function() {
+ // 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.isNameUsed_(fingerprintName))
+ continue;
+ break;
+ }
+ this.push('fingerprints_', { 'name': fingerprintName });
Dan Beam 2016/12/13 19:53:23 this.push('fingerprints_', {'name': fingerprintNam
Dan Beam 2016/12/13 19:53:24 wait, why are you using {name: <string>} as the it
sammiequon 2016/12/13 23:33:34 Done.
sammiequon 2016/12/13 23:33:34 Done.
+ this.$.fingerprintsList.fire('iron-resize');
Dan Beam 2016/12/13 19:53:24 nit: notifyResize() instead of fire('iron-resize')
sammiequon 2016/12/13 23:33:34 Done.
+ },
+
+ /**
+ * 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.fire('iron-resize');
+ },
+
+ /**
+ * Returns the text to be displayed for the add fingerprint button.
Dan Beam 2016/12/13 19:53:24 @param
sammiequon 2016/12/13 23:33:34 Done.
+ * @return {string}
+ * @private
+ */
+ getFingerprintButtonText_: function(length) {
Dan Beam 2016/12/13 19:53:24 can you name this argument something other than "l
sammiequon 2016/12/13 23:33:34 Done.
+ if (this.canAddNewFingerprint_(length))
+ return this.i18n('lockScreenAddFingerprint');
+
+ return this.i18n('lockScreenCannotAddFingerprint',
+ MAX_NUMBER_FINGERPRINTS_ALLOWED);
+ },
+
+ /**
+ * Checks whether another fingerprint can be added.
Dan Beam 2016/12/13 19:53:24 @param
sammiequon 2016/12/13 23:33:34 Done.
+ * @return {boolean}
+ * @private
+ */
+ canAddNewFingerprint_: function(length) {
+ return length < MAX_NUMBER_FINGERPRINTS_ALLOWED;
+ }
+});
+})();

Powered by Google App Engine
This is Rietveld 408576698