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

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

Issue 2538303002: md-settings: Added settings for fingerprint unlock. (Closed)
Patch Set: Added flags to histograms.xml. 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..8819997736377c954d0259cbf6be7469f3e2af3e
--- /dev/null
+++ b/chrome/browser/resources/settings/people_page/fingerprint_list.js
@@ -0,0 +1,112 @@
+// 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.
+ *
+ * Properties:
+ * items: The fingerprints to display.
+ *
+ * Example:
+ * <settings-fingerprint-list items="{{items}}"></settings-fingerprint-list>
jdufault 2016/12/05 22:29:36 should this be fingerprints="{{items}}"? Actually
sammiequon 2016/12/05 22:57:15 Done.
+ */
+
+(function() {
+'use strict';
+
+/**
+ * The max number of fingerprints this list can hold.
+ * @type {number}
+ * @const
+ */
+var MAX_NUMBER_FINGERPRINTS_ALLOWED = 5;
+
+Polymer({
+ is: 'settings-fingerprint-list',
+
+ behaviors: [
+ I18nBehavior,
+ ],
+
+ properties: {
+ /**
+ * The list of fingerprint objects.
+ * @type {Array<Object>}
+ * @private
+ */
+ fingerprints: {
jdufault 2016/12/05 22:29:36 Add _ to the end of the name.
sammiequon 2016/12/05 22:57:15 Done.
+ type: Array,
+ value: function() {
+ return [];
+ },
+ notify: true,
+ }
+ },
+
+ /**
+ * Returns the text to be displayed when the user has set up
+ * |MAX_NUMBER_FINGERPRINTS_ALLOWED|.
+ * @return {string}
+ * @private
+ */
+ getFingerprintButtonCannotAddText_: function() {
+ return this.i18n('lockScreenCannotAddFingerprint',
+ MAX_NUMBER_FINGERPRINTS_ALLOWED);
+ },
+
+ /**
+ * Check if the registered fingerprints has a fingerprint with name |name|.
+ * @param {string} name The name we are looking for.
+ * @return {boolean}
+ * @private
+ */
+ isNameUsed_: function(name) {
+ for (var i = 0; i < this.fingerprints.length; ++i) {
jdufault 2016/12/05 22:29:36 You could also implement this as: return !!thi
sammiequon 2016/12/05 22:57:15 Done.
+ if (this.fingerprints[i]['name'] == name)
jdufault 2016/12/05 22:29:36 Replace ['name'] with .name
sammiequon 2016/12/05 22:57:15 Done.
+ return true;
+ }
+ return false;
+ },
+
+ /**
+ * Adds a fingerprint with a default name.
+ * @private
+ */
+ onAddFingerprint_: function() {
+ // Determines what the newly added fingerprint's name should be. The name
+ // should be in the format "Finger x" where x should be the lowest unused
jdufault 2016/12/05 22:29:36 Update comment (the discussion about the required
sammiequon 2016/12/05 22:57:15 Done.
+ // number. A number is considered used if it matches the pattern "Finger x".
+ // Note that finger x or Fingerx are not considered matches.
+ // TODO(sammiequon): Add fingerprint using private API once it is ready.
+
+ var fingerprintName = this.i18n('lockScreenFingerprintNewName', 1);
jdufault 2016/12/05 22:29:36 Do not seed an initial fingerprintName value.
sammiequon 2016/12/05 22:57:15 Done.
+ 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 });
+ },
+
+ /**
+ * 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);
+ },
+
+ /**
+ * Checks whether another fingerprint can be added.
+ * @return {boolean}
+ * @private
+ */
+ canAddNewFingerprint_: function(length) {
+ return length < MAX_NUMBER_FINGERPRINTS_ALLOWED;
+ }
+});
+})();

Powered by Google App Engine
This is Rietveld 408576698