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

Side by Side Diff: chrome/test/data/webui/settings/fake_quick_unlock_private.js

Issue 2376293005: cros: Tweaked the good/bad pin checking on the js to use the new quick unlock api function. (Closed)
Patch Set: Added a comment. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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 Fake implementation of chrome.quickUnlockPrivate for testing. 6 * @fileoverview Fake implementation of chrome.quickUnlockPrivate for testing.
7 */ 7 */
8
9 /**
10 * A couple weak pins to use for testing.
11 * @const
12 */
13 var TEST_WEAK_PINS = ['1111', '1234', '1313', '2001', '1010'];
14
8 cr.define('settings', function() { 15 cr.define('settings', function() {
9 /** 16 /**
10 * Fake of the chrome.quickUnlockPrivate API. 17 * Fake of the chrome.quickUnlockPrivate API.
11 * @constructor 18 * @constructor
12 * @implements {QuickUnlockPrivate} 19 * @implements {QuickUnlockPrivate}
13 */ 20 */
14 function FakeQuickUnlockPrivate() { 21 function FakeQuickUnlockPrivate() {
15 /** @type {!Array<!chrome.quickUnlockPrivate.QuickUnlockMode>} */ 22 /** @type {!Array<!chrome.quickUnlockPrivate.QuickUnlockMode>} */
16 this.availableModes = [chrome.quickUnlockPrivate.QuickUnlockMode.PIN]; 23 this.availableModes = [chrome.quickUnlockPrivate.QuickUnlockMode.PIN];
17 /** @type {!Array<!chrome.quickUnlockPrivate.QuickUnlockMode>} */ 24 /** @type {!Array<!chrome.quickUnlockPrivate.QuickUnlockMode>} */
(...skipping 29 matching lines...) Expand all
47 * @param {!Array<string>} credentials 54 * @param {!Array<string>} credentials
48 * @param {function(boolean):void} onComplete 55 * @param {function(boolean):void} onComplete
49 */ 56 */
50 setModes: function(accountPassword, modes, credentials, onComplete) { 57 setModes: function(accountPassword, modes, credentials, onComplete) {
51 // Even if the account password is wrong we still update activeModes and 58 // Even if the account password is wrong we still update activeModes and
52 // credentials so that the mock owner has a chance to see what was given 59 // credentials so that the mock owner has a chance to see what was given
53 // to the API. 60 // to the API.
54 this.activeModes = modes; 61 this.activeModes = modes;
55 this.credentials = credentials; 62 this.credentials = credentials;
56 onComplete(this.accountPassword == accountPassword); 63 onComplete(this.accountPassword == accountPassword);
57 } 64 },
65
66 /**
67 * @override
68 * @param {!chrome.quickUnlockPrivate.QuickUnlockMode} mode
69 * @param {string} credential
70 * @param {function(
71 * !chrome.quickUnlockPrivate.CredentialCheck):void} onComplete
72 */
73 checkCredential: function(mode, credential, onComplete) {
74 var message = {};
75 var errors = [];
76 var warnings = [];
77
78 // For testing we will use a min length of 4.
79 if (!!credential && credential.length < 4)
80 errors.push(chrome.quickUnlockPrivate.CredentialProblem.TOO_SHORT);
81
82 if (!!credential && TEST_WEAK_PINS.includes(credential))
83 warnings.push(chrome.quickUnlockPrivate.CredentialProblem.TOO_WEAK);
84
85 message.errors = errors;
86 message.warnings = warnings;
87 onComplete(message);
88 },
89
90 /**
91 * @override.
92 * @param {!chrome.quickUnlockPrivate.QuickUnlockMode} mode
93 * @param {function(
94 * !chrome.quickUnlockPrivate.CredentialRequirements):void onComplete
95 */
96 getCredentialRequirements: function(mode, onComplete) {
97 var fakeCredentials = {};
98
99 // For testing we will use a min length of 4 and a max length of 0 (no max
100 // length).
101 fakeCredentials.minLength = 4;
102 fakeCredentials.maxLength = 0;
103 onComplete(fakeCredentials);
104 },
58 }; 105 };
59 106
60 /** @type {!ChromeEvent} */ 107 /** @type {!ChromeEvent} */
61 FakeQuickUnlockPrivate.prototype.onActiveModesChanged = new FakeChromeEvent(); 108 FakeQuickUnlockPrivate.prototype.onActiveModesChanged = new FakeChromeEvent();
62 109
63 return {FakeQuickUnlockPrivate: FakeQuickUnlockPrivate}; 110 return {FakeQuickUnlockPrivate: FakeQuickUnlockPrivate};
64 }); 111 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698