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

Side by Side Diff: chrome/browser/resources/settings/people_page/setup_pin_dialog.js

Issue 2441043004: Accessibility fixes for quick unlock settings. (Closed)
Patch Set: Initial patch Created 4 years, 1 month 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 6 * @fileoverview
7 * 'settings-setup-pin-dialog' is the settings page for choosing a PIN. 7 * 'settings-setup-pin-dialog' is the settings page for choosing a PIN.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 this.initialPin_ == this.pinKeyboardValue_; 150 this.initialPin_ == this.pinKeyboardValue_;
151 }, 151 },
152 152
153 /** 153 /**
154 * Notify the user about a problem. 154 * Notify the user about a problem.
155 * @private 155 * @private
156 * @param {string} messageId 156 * @param {string} messageId
157 * @param {string} problemClass 157 * @param {string} problemClass
158 */ 158 */
159 showProblem_: function(messageId, problemClass) { 159 showProblem_: function(messageId, problemClass) {
160 var previousMessage = this.problemMessage_;
161
162 // Update problem info.
160 this.problemMessage_ = this.i18n(messageId); 163 this.problemMessage_ = this.i18n(messageId);
161 this.problemClass_ = problemClass; 164 this.problemClass_ = problemClass;
162 this.updateStyles(); 165 this.updateStyles();
163 }, 166
167 // If the problem message has changed, fire an alert.
168 if (previousMessage != this.problemMessage_)
169 this.$.problemDiv.setAttribute('role', 'alert');
170 },
164 171
165 /** @private */ 172 /** @private */
166 hideProblem_: function() { 173 hideProblem_: function() {
167 this.problemMessage_ = ''; 174 this.problemMessage_ = '';
168 this.problemClass_ = ''; 175 this.problemClass_ = '';
169 }, 176 },
170 177
171 /** @private */ 178 /** @private */
172 onPinChange_: function() { 179 onPinChange_: function() {
173 if (!this.isConfirmStep_) { 180 if (!this.isConfirmStep_) {
174 var isPinLongEnough = this.isPinLongEnough_(this.pinKeyboardValue_); 181 var isPinLongEnough = this.isPinLongEnough_(this.pinKeyboardValue_);
175 var isWeak = isPinLongEnough && this.isPinWeak_(this.pinKeyboardValue_); 182 var isWeak = isPinLongEnough && this.isPinWeak_(this.pinKeyboardValue_);
176 183
177 if (!isPinLongEnough && this.pinKeyboardValue_) 184 if (!isPinLongEnough)
178 this.showProblem_('configurePinTooShort', 'error'); 185 this.showProblem_('configurePinTooShort', 'warning');
179 else if (isWeak) 186 else if (isWeak)
180 this.showProblem_('configurePinWeakPin', 'warning'); 187 this.showProblem_('configurePinWeakPin', 'warning');
181 else 188 else
182 this.hideProblem_(); 189 this.hideProblem_();
183 190
184 this.enableSubmit_ = isPinLongEnough; 191 this.enableSubmit_ = isPinLongEnough;
185 192
186 } else { 193 } else {
187 var canSubmit = this.canSubmit_(); 194 if (this.canSubmit_())
195 this.hideProblem_();
196 else
197 this.showProblem_('configurePinMismatched', 'warning');
188 198
189 if (!canSubmit && this.pinKeyboardValue_) 199 this.enableSubmit_ = true;
tommycli 2016/10/25 18:13:50 Should we rename canSubmit? Since that means somet
jdufault 2016/10/26 22:38:36 Renamed to isPinConfirmed_.
tommycli 2016/10/27 00:13:25 Hey I'm still not sure what isPinConfirmed_ means.
jdufault 2016/10/27 19:22:08 Done; I've updated the comment.
190 this.showProblem_('configurePinMismatched', 'error');
191 else
192 this.hideProblem_();
193
194 this.enableSubmit_ = canSubmit;
195 } 200 }
196 }, 201 },
197 202
198 /** @private */ 203 /** @private */
199 onPinSubmit_: function() { 204 onPinSubmit_: function() {
200 if (!this.isConfirmStep_) { 205 if (!this.isConfirmStep_) {
201 if (this.isPinLongEnough_(this.pinKeyboardValue_)) { 206 if (this.isPinLongEnough_(this.pinKeyboardValue_)) {
202 this.initialPin_ = this.pinKeyboardValue_; 207 this.initialPin_ = this.pinKeyboardValue_;
203 this.pinKeyboardValue_ = ''; 208 this.pinKeyboardValue_ = '';
204 this.isConfirmStep_ = true; 209 this.isConfirmStep_ = true;
205 this.onPinChange_(); 210 this.onPinChange_();
206 this.$.pinKeyboard.focus(); 211 this.$.pinKeyboard.focus();
207 } 212 }
208 } else { 213 } else {
209 // onPinSubmit_ gets called if the user hits enter on the PIN keyboard. 214 // onPinSubmit_ gets called if the user hits enter on the PIN keyboard.
210 // The PIN is not guaranteed to be valid in that case. 215 // The PIN is not guaranteed to be valid in that case.
211 if (!this.canSubmit_()) 216 if (!this.canSubmit_()) {
217 this.showProblem_('configurePinMismatched', 'error');
212 return; 218 return;
219 }
213 220
214 function onSetModesCompleted(didSet) { 221 function onSetModesCompleted(didSet) {
215 if (!didSet) { 222 if (!didSet) {
216 console.error('Failed to update pin'); 223 console.error('Failed to update pin');
217 return; 224 return;
218 } 225 }
219 226
220 this.resetState_(); 227 this.resetState_();
221 this.fire('done'); 228 this.fire('done');
222 } 229 }
(...skipping 29 matching lines...) Expand all
252 * @private 259 * @private
253 * @param {boolean} isConfirmStep 260 * @param {boolean} isConfirmStep
254 * @return {string} 261 * @return {string}
255 */ 262 */
256 getContinueMessage_: function(isConfirmStep) { 263 getContinueMessage_: function(isConfirmStep) {
257 return this.i18n(isConfirmStep ? 'confirm' : 'configurePinContinueButton'); 264 return this.i18n(isConfirmStep ? 'confirm' : 'configurePinContinueButton');
258 }, 265 },
259 }); 266 });
260 267
261 })(); 268 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698