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

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: Apply Feedback Created 5 years, 10 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);
75 var deletableItem = this;
76 passwordInput.addEventListener('focus', function() {
77 deletableItem.handleFocus();
78 });
77 this.passwordField = passwordInput; 79 this.passwordField = passwordInput;
80 this.setFocusable_(false);
78 81
79 // The show/hide button. 82 // The show/hide button.
80 if (this.showPasswords_) { 83 if (this.showPasswords_) {
81 var button = this.ownerDocument.createElement('button'); 84 var button = this.ownerDocument.createElement('button');
82 button.hidden = true; 85 button.hidden = true;
83 button.className = 'list-inline-button custom-appearance'; 86 button.className = 'list-inline-button custom-appearance';
84 button.textContent = loadTimeData.getString('passwordShowButton'); 87 button.textContent = loadTimeData.getString('passwordShowButton');
85 button.addEventListener('click', this.onClick_.bind(this), true); 88 button.addEventListener('click', this.onClick_.bind(this), true);
86 button.addEventListener('mousedown', function(event) { 89 button.addEventListener('mousedown', function(event) {
87 // Don't focus on this button by mousedown. 90 // Don't focus on this button by mousedown.
88 event.preventDefault(); 91 event.preventDefault();
89 // Don't handle list item selection. It causes focus change. 92 // Don't handle list item selection. It causes focus change.
90 event.stopPropagation(); 93 event.stopPropagation();
91 }, false); 94 }, false);
95 button.addEventListener('focus', function() {
96 deletableItem.handleFocus();
97 });
92 passwordInputDiv.appendChild(button); 98 passwordInputDiv.appendChild(button);
93 this.passwordShowButton = button; 99 this.passwordShowButton = button;
94 } 100 }
95 101
96 this.contentElement.appendChild(passwordInputDiv); 102 this.contentElement.appendChild(passwordInputDiv);
97 }, 103 },
98 104
99 /** @override */ 105 /** @override */
100 selectionChanged: function() { 106 selectionChanged: function() {
101 var input = this.passwordField; 107 var input = this.passwordField;
102 var button = this.passwordShowButton; 108 var button = this.passwordShowButton;
103 // The button doesn't exist when passwords can't be shown. 109 // The button doesn't exist when passwords can't be shown.
104 if (!button) 110 if (!button)
105 return; 111 return;
106 112
107 if (this.selected) { 113 if (this.selected) {
114 input.classList.remove('inactive-password');
115 this.setFocusable_(true);
116 button.hidden = false;
108 input.focus(); 117 input.focus();
109 input.classList.remove('inactive-password');
110 input.tabIndex = 0;
111 this.closeButtonElement.tabIndex = 0;
112 button.hidden = false;
113 } else { 118 } else {
114 input.classList.add('inactive-password'); 119 input.classList.add('inactive-password');
115 input.tabIndex = -1; 120 this.setFocusable_(false);
116 this.closeButtonElement.tabIndex = -1;
117 button.hidden = true; 121 button.hidden = true;
118 } 122 }
119 }, 123 },
120 124
121 /** 125 /**
126 * Set the focusability of this row.
127 * @param {boolean} focusable
128 * @private
129 */
130 setFocusable_: function(focusable) {
131 var tabIndex = focusable ? 0 : -1;
132 this.passwordField.tabIndex = this.closeButtonElement.tabIndex = tabIndex;
133 },
134
135 /**
122 * Reveals the plain text password of this entry. 136 * Reveals the plain text password of this entry.
123 */ 137 */
124 showPassword: function(password) { 138 showPassword: function(password) {
125 this.passwordField.value = password; 139 this.passwordField.value = password;
126 this.passwordField.type = 'text'; 140 this.passwordField.type = 'text';
127 141
128 var button = this.passwordShowButton; 142 var button = this.passwordShowButton;
129 if (button) 143 if (button)
130 button.textContent = loadTimeData.getString('passwordHideButton'); 144 button.textContent = loadTimeData.getString('passwordHideButton');
131 }, 145 },
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 * @private 282 * @private
269 */ 283 */
270 showPasswords_: true, 284 showPasswords_: true,
271 285
272 /** @override */ 286 /** @override */
273 decorate: function() { 287 decorate: function() {
274 DeletableItemList.prototype.decorate.call(this); 288 DeletableItemList.prototype.decorate.call(this);
275 Preferences.getInstance().addEventListener( 289 Preferences.getInstance().addEventListener(
276 'profile.password_manager_allow_show_passwords', 290 'profile.password_manager_allow_show_passwords',
277 this.onPreferenceChanged_.bind(this)); 291 this.onPreferenceChanged_.bind(this));
292 this.addEventListener('focus', this.onFocus_.bind(this));
278 }, 293 },
279 294
280 /** 295 /**
281 * Listener for changes on the preference. 296 * Listener for changes on the preference.
282 * @param {Event} event The preference update event. 297 * @param {Event} event The preference update event.
283 * @private 298 * @private
284 */ 299 */
285 onPreferenceChanged_: function(event) { 300 onPreferenceChanged_: function(event) {
286 this.showPasswords_ = event.value.value; 301 this.showPasswords_ = event.value.value;
287 this.redraw(); 302 this.redraw();
(...skipping 21 matching lines...) Expand all
309 } 324 }
310 PasswordManager.removeSavedPassword(index); 325 PasswordManager.removeSavedPassword(index);
311 }, 326 },
312 327
313 /** 328 /**
314 * The length of the list. 329 * The length of the list.
315 */ 330 */
316 get length() { 331 get length() {
317 return this.dataModel.length; 332 return this.dataModel.length;
318 }, 333 },
334
335 /**
336 * Will make to first row focusable if none are selected. This makes it
337 * possible to tab into the rows without pressing up/down first.
338 * @param {Event} e The focus event.
339 * @private
340 */
341 onFocus_: function(e) {
342 if (!this.selectedItem && this.items)
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