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

Side by Side Diff: chrome/browser/resources/options/password_manager_list.js

Issue 869813002: Fix tabindex in chrome://settings/passwords (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 cr.define('options.passwordManager', function() { 5 cr.define('options.passwordManager', function() {
6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
7 /** @const */ var DeletableItemList = options.DeletableItemList; 7 /** @const */ var DeletableItemList = options.DeletableItemList;
8 /** @const */ var DeletableItem = options.DeletableItem; 8 /** @const */ var DeletableItem = options.DeletableItem;
9 /** @const */ var List = cr.ui.List; 9 /** @const */ var List = cr.ui.List;
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 this.contentElement.appendChild(usernameLabel); 62 this.contentElement.appendChild(usernameLabel);
63 63
64 // The stored password. 64 // The stored password.
65 var passwordInputDiv = this.ownerDocument.createElement('div'); 65 var passwordInputDiv = this.ownerDocument.createElement('div');
66 passwordInputDiv.className = 'password'; 66 passwordInputDiv.className = 'password';
67 67
68 // The password input field. 68 // The password input field.
69 var passwordInput = this.ownerDocument.createElement('input'); 69 var passwordInput = this.ownerDocument.createElement('input');
70 passwordInput.type = 'password'; 70 passwordInput.type = 'password';
71 passwordInput.className = 'inactive-password'; 71 passwordInput.className = 'inactive-password';
72 this.closeButtonElement.tabIndex = -1;
73 passwordInput.tabIndex = -1;
74 passwordInput.readOnly = true; 72 passwordInput.readOnly = true;
75 passwordInput.value = this.showPasswords_ ? this.password : '********'; 73 passwordInput.value = this.showPasswords_ ? this.password : '********';
76 passwordInputDiv.appendChild(passwordInput); 74 passwordInputDiv.appendChild(passwordInput);
77 this.passwordField = passwordInput; 75 this.passwordField = passwordInput;
76 this.setFocusable(false);
78 77
79 // The show/hide button. 78 // The show/hide button.
80 if (this.showPasswords_) { 79 if (this.showPasswords_) {
81 var button = this.ownerDocument.createElement('button'); 80 var button = this.ownerDocument.createElement('button');
82 button.hidden = true; 81 button.hidden = true;
83 button.className = 'list-inline-button custom-appearance'; 82 button.className = 'list-inline-button custom-appearance';
84 button.textContent = loadTimeData.getString('passwordShowButton'); 83 button.textContent = loadTimeData.getString('passwordShowButton');
85 button.addEventListener('click', this.onClick_.bind(this), true); 84 button.addEventListener('click', this.onClick_.bind(this), true);
86 button.addEventListener('mousedown', function(event) { 85 button.addEventListener('mousedown', function(event) {
87 // Don't focus on this button by mousedown. 86 // Don't focus on this button by mousedown.
88 event.preventDefault(); 87 event.preventDefault();
89 // Don't handle list item selection. It causes focus change. 88 // Don't handle list item selection. It causes focus change.
90 event.stopPropagation(); 89 event.stopPropagation();
91 }, false); 90 }, false);
92 passwordInputDiv.appendChild(button); 91 passwordInputDiv.appendChild(button);
93 this.passwordShowButton = button; 92 this.passwordShowButton = button;
94 } 93 }
95 94
95 // A row should be focused when any element in it is focused, not just
96 // the close button.
97 this.closeButtonElement_.removeEventListener(this.handleFocus, 'focus');
Dan Beam 2015/01/23 00:00:37 i'm confused. a) the order is 'eventName', eventH
hcarmona 2015/01/23 21:27:35 Done.
98 this.addEventListener('focusin', this.handleFocus.bind(this));
Dan Beam 2015/01/23 00:00:37 why do we need to use focusin here? because it bu
hcarmona 2015/01/23 21:27:34 Yes, we need to focus event to bubble up from the
99
96 this.contentElement.appendChild(passwordInputDiv); 100 this.contentElement.appendChild(passwordInputDiv);
97 }, 101 },
98 102
99 /** @override */ 103 /** @override */
100 selectionChanged: function() { 104 selectionChanged: function() {
101 var input = this.passwordField; 105 var input = this.passwordField;
102 var button = this.passwordShowButton; 106 var button = this.passwordShowButton;
103 // The button doesn't exist when passwords can't be shown. 107 // The button doesn't exist when passwords can't be shown.
104 if (!button) 108 if (!button)
105 return; 109 return;
106 110
107 if (this.selected) { 111 if (this.selected) {
112 input.classList.remove('inactive-password');
113 this.setFocusable(true);
114 button.hidden = false;
115 // Move the focus away from anything else that may have been focused.
Dan Beam 2015/01/23 00:00:37 this comment is confusing. needed?
hcarmona 2015/01/23 21:27:35 Done.
108 input.focus(); 116 input.focus();
109 input.classList.remove('inactive-password');
110 input.tabIndex = 0;
111 this.closeButtonElement.tabIndex = 0;
112 button.hidden = false;
113 } else { 117 } else {
114 input.classList.add('inactive-password'); 118 input.classList.add('inactive-password');
115 input.tabIndex = -1; 119 this.setFocusable(false);
116 this.closeButtonElement.tabIndex = -1;
117 button.hidden = true; 120 button.hidden = true;
118 } 121 }
119 }, 122 },
120 123
121 /** 124 /**
125 * Set the focusability of this row.
126 * @param {bool} focusable
Dan Beam 2015/01/23 00:00:37 boolean
hcarmona 2015/01/23 21:27:34 Done.
127 */
128 setFocusable: function(focusable) {
129 var tabIndex = focusable ? 0 : -1;
130 this.passwordField.tabIndex = this.closeButtonElement.tabIndex = tabIndex;
131 },
132
133 /**
122 * Reveals the plain text password of this entry. 134 * Reveals the plain text password of this entry.
123 */ 135 */
124 showPassword: function(password) { 136 showPassword: function(password) {
125 this.passwordField.value = password; 137 this.passwordField.value = password;
126 this.passwordField.type = 'text'; 138 this.passwordField.type = 'text';
127 139
128 var button = this.passwordShowButton; 140 var button = this.passwordShowButton;
129 if (button) 141 if (button)
130 button.textContent = loadTimeData.getString('passwordHideButton'); 142 button.textContent = loadTimeData.getString('passwordHideButton');
131 }, 143 },
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 * @private 280 * @private
269 */ 281 */
270 showPasswords_: true, 282 showPasswords_: true,
271 283
272 /** @override */ 284 /** @override */
273 decorate: function() { 285 decorate: function() {
274 DeletableItemList.prototype.decorate.call(this); 286 DeletableItemList.prototype.decorate.call(this);
275 Preferences.getInstance().addEventListener( 287 Preferences.getInstance().addEventListener(
276 'profile.password_manager_allow_show_passwords', 288 'profile.password_manager_allow_show_passwords',
277 this.onPreferenceChanged_.bind(this)); 289 this.onPreferenceChanged_.bind(this));
290 this.addEventListener('focusin', this.onFocusIn_);
278 }, 291 },
279 292
280 /** 293 /**
281 * Listener for changes on the preference. 294 * Listener for changes on the preference.
282 * @param {Event} event The preference update event. 295 * @param {Event} event The preference update event.
283 * @private 296 * @private
284 */ 297 */
285 onPreferenceChanged_: function(event) { 298 onPreferenceChanged_: function(event) {
286 this.showPasswords_ = event.value.value; 299 this.showPasswords_ = event.value.value;
287 this.redraw(); 300 this.redraw();
(...skipping 21 matching lines...) Expand all
309 } 322 }
310 PasswordManager.removeSavedPassword(index); 323 PasswordManager.removeSavedPassword(index);
311 }, 324 },
312 325
313 /** 326 /**
314 * The length of the list. 327 * The length of the list.
315 */ 328 */
316 get length() { 329 get length() {
317 return this.dataModel.length; 330 return this.dataModel.length;
318 }, 331 },
332
333 /**
334 * Called when focus enters this list. Will make the first row focusable if
335 * nothing is selected.
336 * Without this: the list will be focused and no row will be focused until
337 * up/down is pressed making it appear that the row items are not focusable.
Dan Beam 2015/01/23 00:00:37 write this sentence using the word "focus" less
hcarmona 2015/01/23 21:27:35 Reworded to make more clear.
338 * @param {Event} e The focusin event.
339 * @private
340 */
341 onFocusIn_: function(e) {
342 if (e.target == this && !this.selectedItem && this.items)
Dan Beam 2015/01/23 00:00:37 if we're only looking for the case where e.target
hcarmona 2015/01/23 21:27:34 Done.
343 this.items[0].setFocusable(true);
344 },
319 }; 345 };
320 346
321 /** 347 /**
322 * Create a new passwords list. 348 * Create a new passwords list.
323 * @constructor 349 * @constructor
324 * @extends {options.DeletableItemList} 350 * @extends {options.DeletableItemList}
325 */ 351 */
326 var PasswordExceptionsList = cr.ui.define('list'); 352 var PasswordExceptionsList = cr.ui.define('list');
327 353
328 PasswordExceptionsList.prototype = { 354 PasswordExceptionsList.prototype = {
(...skipping 20 matching lines...) Expand all
349 }, 375 },
350 }; 376 };
351 377
352 return { 378 return {
353 PasswordListItem: PasswordListItem, 379 PasswordListItem: PasswordListItem,
354 PasswordExceptionsListItem: PasswordExceptionsListItem, 380 PasswordExceptionsListItem: PasswordExceptionsListItem,
355 PasswordsList: PasswordsList, 381 PasswordsList: PasswordsList,
356 PasswordExceptionsList: PasswordExceptionsList, 382 PasswordExceptionsList: PasswordExceptionsList,
357 }; 383 };
358 }); 384 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698