OLD | NEW |
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 |
11 /** | 11 /** |
12 * Creates a new passwords list item. | 12 * Creates a new passwords list item. |
13 * @param {cr.ui.ArrayDataModel} dataModel The data model that contains this | 13 * @param {cr.ui.ArrayDataModel} dataModel The data model that contains this |
14 * item. | 14 * item. |
15 * @param {Array} entry An array of the form [url, username, password]. When | 15 * @param {Array} entry An array of the form [url, username, password]. When |
16 * the list has been filtered, a fourth element [index] may be present. | 16 * the list has been filtered, a fourth element [index] may be present. |
17 * @param {boolean} showPasswords If true, add a button to the element to | 17 * @param {boolean} showPasswords If true, add a button to the element to |
18 * allow the user to reveal the saved password. | 18 * allow the user to reveal the saved password. |
19 * @constructor | 19 * @constructor |
20 * @extends {options.DeletableItem} | 20 * @extends {options.DeletableItem} |
21 */ | 21 */ |
22 function PasswordListItem(dataModel, entry, showPasswords) { | 22 function PasswordListItem(dataModel, entry, showPasswords) { |
23 var el = cr.doc.createElement('div'); | 23 var el = cr.doc.createElement('div'); |
24 el.dataItem = entry; | 24 el.dataItem = entry; |
25 el.dataModel = dataModel; | 25 el.dataModel = dataModel; |
26 el.__proto__ = PasswordListItem.prototype; | 26 el.__proto__ = PasswordListItem.prototype; |
27 el.decorate(showPasswords); | 27 el.showPasswords_ = showPasswords; |
| 28 el.decorate(); |
28 | 29 |
29 return el; | 30 return el; |
30 } | 31 } |
31 | 32 |
32 PasswordListItem.prototype = { | 33 PasswordListItem.prototype = { |
33 __proto__: DeletableItem.prototype, | 34 __proto__: DeletableItem.prototype, |
34 | 35 |
35 /** @override */ | 36 /** @override */ |
36 decorate: function(showPasswords) { | 37 decorate: function() { |
37 DeletableItem.prototype.decorate.call(this); | 38 DeletableItem.prototype.decorate.call(this); |
38 | 39 |
39 // The URL of the site. | 40 // The URL of the site. |
40 var urlLabel = this.ownerDocument.createElement('div'); | 41 var urlLabel = this.ownerDocument.createElement('div'); |
41 urlLabel.classList.add('favicon-cell'); | 42 urlLabel.classList.add('favicon-cell'); |
42 urlLabel.classList.add('weakrtl'); | 43 urlLabel.classList.add('weakrtl'); |
43 urlLabel.classList.add('url'); | 44 urlLabel.classList.add('url'); |
44 urlLabel.setAttribute('title', this.url); | 45 urlLabel.setAttribute('title', this.url); |
45 urlLabel.textContent = this.url; | 46 urlLabel.textContent = this.url; |
46 | 47 |
(...skipping 15 matching lines...) Expand all Loading... |
62 | 63 |
63 // The stored password. | 64 // The stored password. |
64 var passwordInputDiv = this.ownerDocument.createElement('div'); | 65 var passwordInputDiv = this.ownerDocument.createElement('div'); |
65 passwordInputDiv.className = 'password'; | 66 passwordInputDiv.className = 'password'; |
66 | 67 |
67 // The password input field. | 68 // The password input field. |
68 var passwordInput = this.ownerDocument.createElement('input'); | 69 var passwordInput = this.ownerDocument.createElement('input'); |
69 passwordInput.type = 'password'; | 70 passwordInput.type = 'password'; |
70 passwordInput.className = 'inactive-password'; | 71 passwordInput.className = 'inactive-password'; |
71 passwordInput.readOnly = true; | 72 passwordInput.readOnly = true; |
72 passwordInput.value = showPasswords ? this.password : '********'; | 73 passwordInput.value = this.showPasswords_ ? this.password : '********'; |
73 passwordInputDiv.appendChild(passwordInput); | 74 passwordInputDiv.appendChild(passwordInput); |
74 this.passwordField = passwordInput; | 75 this.passwordField = passwordInput; |
75 | 76 |
76 // The show/hide button. | 77 // The show/hide button. |
77 if (showPasswords) { | 78 if (this.showPasswords_) { |
78 var button = this.ownerDocument.createElement('button'); | 79 var button = this.ownerDocument.createElement('button'); |
79 button.hidden = true; | 80 button.hidden = true; |
80 button.className = 'list-inline-button custom-appearance'; | 81 button.className = 'list-inline-button custom-appearance'; |
81 button.textContent = loadTimeData.getString('passwordShowButton'); | 82 button.textContent = loadTimeData.getString('passwordShowButton'); |
82 button.addEventListener('click', this.onClick_.bind(this), true); | 83 button.addEventListener('click', this.onClick_.bind(this), true); |
83 button.addEventListener('mousedown', function(event) { | 84 button.addEventListener('mousedown', function(event) { |
84 // Don't focus on this button by mousedown. | 85 // Don't focus on this button by mousedown. |
85 event.preventDefault(); | 86 event.preventDefault(); |
86 // Don't handle list item selection. It causes focus change. | 87 // Don't handle list item selection. It causes focus change. |
87 event.stopPropagation(); | 88 event.stopPropagation(); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 * The length of the list. | 307 * The length of the list. |
307 */ | 308 */ |
308 get length() { | 309 get length() { |
309 return this.dataModel.length; | 310 return this.dataModel.length; |
310 }, | 311 }, |
311 }; | 312 }; |
312 | 313 |
313 /** | 314 /** |
314 * Create a new passwords list. | 315 * Create a new passwords list. |
315 * @constructor | 316 * @constructor |
316 * @extends {cr.ui.List} | 317 * @extends {options.DeletableItemList} |
317 */ | 318 */ |
318 var PasswordExceptionsList = cr.ui.define('list'); | 319 var PasswordExceptionsList = cr.ui.define('list'); |
319 | 320 |
320 PasswordExceptionsList.prototype = { | 321 PasswordExceptionsList.prototype = { |
321 __proto__: DeletableItemList.prototype, | 322 __proto__: DeletableItemList.prototype, |
322 | 323 |
323 /** | 324 /** |
324 * @override | 325 * @override |
325 * @param {Array} entry | 326 * @param {Array} entry |
326 */ | 327 */ |
(...skipping 14 matching lines...) Expand all Loading... |
341 }, | 342 }, |
342 }; | 343 }; |
343 | 344 |
344 return { | 345 return { |
345 PasswordListItem: PasswordListItem, | 346 PasswordListItem: PasswordListItem, |
346 PasswordExceptionsListItem: PasswordExceptionsListItem, | 347 PasswordExceptionsListItem: PasswordExceptionsListItem, |
347 PasswordsList: PasswordsList, | 348 PasswordsList: PasswordsList, |
348 PasswordExceptionsList: PasswordExceptionsList, | 349 PasswordExceptionsList: PasswordExceptionsList, |
349 }; | 350 }; |
350 }); | 351 }); |
OLD | NEW |