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

Side by Side Diff: chrome/browser/resources/chromeos/quick_unlock/pin.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, 7 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 (function() {
tommycli 2016/05/02 16:11:27 Since there's no variables to hide, there's no nee
jdufault 2016/05/03 19:21:58 Done. iirc, the "use strict;" enables let. I've r
6 'use strict';
7
8 Polymer({
9 is: 'pin-keyboard',
10 properties: {
tommycli 2016/05/02 16:11:27 missing \n above this line
jdufault 2016/05/03 19:21:58 Done.
11 username: String,
12 profilePictureSrc: String
13 },
14
15 observers: [
16 'onUsernameChanged(username)',
17 'onProfilePictureChanged(profilePictureSrc)'
18 ],
19
20 onUsernameChanged: function(username) {
tommycli 2016/05/02 16:11:27 These are leftovers right? In any case, We can use
jdufault 2016/05/03 19:21:58 I've removed these observers for now. I'll add the
21 // TODO(jdufault): Save this value, use it with authenticateUserWithPin.
22 console.log('Got new username ' + username);
23 },
24 onProfilePictureChanged: function(profilePictureSrc) {
25 // TODO(jdufault): Update profile picture with this value.
26 console.log('Got new profilePictureSrc ' + profilePictureSrc);
27 },
28
29 ready: function() {
30 let input = this.$$('#pin-input');
tommycli 2016/05/02 16:11:27 Does Chromium support 'let'? i haven't seen much u
jdufault 2016/05/03 19:21:58 Yes, Chromium is fine, but I'm not sure if we need
31
32 // Add click handlers to each of the buttons.
33 for (let i = 0; i <= 9; ++i) {
34 let buttonElement = this.$$('#btn' + i);
35 buttonElement.onclick = function() {
tommycli 2016/05/02 16:11:27 Instead of doing this, you can declaratively choos
jdufault 2016/05/03 19:21:58 Done.
36 input.value += i;
37 };
38 }
39
40 // Add support for actually sending the entered PIN.
41 let handleInputSubmitted = function(pin) {
tommycli 2016/05/02 16:11:27 Likewise, use the declarative syntax for submittin
jdufault 2016/05/03 19:21:58 Done.
42 console.log('Submitting pin ' + pin);
tommycli 2016/05/02 16:11:27 Remove stray console.logs
jdufault 2016/05/03 19:21:58 Done.
43
44 // TODO(jdufault): Use real values.
tommycli 2016/05/02 16:11:27 Hmm... if we aren't using real values, I'm not sur
jdufault 2016/05/03 19:21:58 Discussed in chat. I'd like to land this CL to cre
45 let username = 'foo@gmail.com';
46 let password = pin;
47 chrome.send('authenticateUserWithPin', [username, password]);
tommycli 2016/05/02 16:11:27 Instead of doing chrome.send directly, try using t
xiyuan 2016/05/02 20:03:33 nit: On C++ side, the handler expect a serialized
jdufault 2016/05/03 19:21:58 I've opted instead to just fire an event, which th
jdufault 2016/05/03 19:21:58 Done.
48 };
49
50 input.onkeydown = function(event) {
tommycli 2016/05/02 16:11:27 Likewise here, you should use the declarative even
jdufault 2016/05/03 19:21:58 Done.
51 // Up/down pressed, swallow the event to prevent the input value from
52 // being incremented or decremented.
53 if (event.keyCode == 38 || event.keyCode == 40)
54 event.preventDefault();
55
56 // enter pressed
57 if (event.keyCode == 13) {
58 handleInputSubmitted(input.value);
59 event.preventDefault();
60 }
61 };
62 this.$.submitButton.onclick = function() {
63 handleInputSubmitted(input.value);
64 };
65 }
66 });
67 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698