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

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

Issue 6990026: WebUI: Add password manager search feature. Also add tooltips for the URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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', function() { 5 cr.define('options', function() {
6 const OptionsPage = options.OptionsPage; 6 const OptionsPage = options.OptionsPage;
7 const ArrayDataModel = cr.ui.ArrayDataModel; 7 const ArrayDataModel = cr.ui.ArrayDataModel;
8 8
9 ///////////////////////////////////////////////////////////////////////////// 9 /////////////////////////////////////////////////////////////////////////////
10 // PasswordManager class: 10 // PasswordManager class:
(...skipping 22 matching lines...) Expand all
33 */ 33 */
34 savedPasswordsList_: null, 34 savedPasswordsList_: null,
35 35
36 /** 36 /**
37 * The password exceptions list. 37 * The password exceptions list.
38 * @type {DeletableItemList} 38 * @type {DeletableItemList}
39 * @private 39 * @private
40 */ 40 */
41 passwordExceptionsList_: null, 41 passwordExceptionsList_: null,
42 42
43 /**
44 * The timer id of the timer set on search query change events.
45 * @type {number}
46 * @private
47 */
48 queryDelayTimerId_: 0,
49
50 /**
51 * The most recent search query, or null if the query is empty.
52 * @type {?string}
53 * @private
54 */
55 lastQuery_: null,
56
43 /** @inheritDoc */ 57 /** @inheritDoc */
44 initializePage: function() { 58 initializePage: function() {
45 OptionsPage.prototype.initializePage.call(this); 59 OptionsPage.prototype.initializePage.call(this);
46 60
61 $('password-search-box').addEventListener('search',
62 this.handleSearchQueryChange_.bind(this));
63
47 this.createSavedPasswordsList_(); 64 this.createSavedPasswordsList_();
48 this.createPasswordExceptionsList_(); 65 this.createPasswordExceptionsList_();
49 }, 66 },
50 67
51 /** @inheritDoc */ 68 /** @inheritDoc */
52 canShowPage: function() { 69 canShowPage: function() {
53 return !PersonalOptions.disablePasswordManagement(); 70 return !PersonalOptions.disablePasswordManagement();
54 }, 71 },
55 72
56 /** @inheritDoc */ 73 /** @inheritDoc */
(...skipping 18 matching lines...) Expand all
75 * @private 92 * @private
76 */ 93 */
77 createPasswordExceptionsList_: function() { 94 createPasswordExceptionsList_: function() {
78 this.passwordExceptionsList_ = $('password-exceptions-list'); 95 this.passwordExceptionsList_ = $('password-exceptions-list');
79 options.passwordManager.PasswordExceptionsList.decorate( 96 options.passwordManager.PasswordExceptionsList.decorate(
80 this.passwordExceptionsList_); 97 this.passwordExceptionsList_);
81 this.passwordExceptionsList_.autoExpands = true; 98 this.passwordExceptionsList_.autoExpands = true;
82 }, 99 },
83 100
84 /** 101 /**
102 * Handles search query changes.
103 * @param {!Event} e The event object.
104 * @private
105 */
106 handleSearchQueryChange_: function(e) {
107 if (this.queryDelayTimerId_)
108 window.clearTimeout(this.queryDelayTimerId_);
109
110 // Searching cookies uses a timeout of 500ms. We use a shorter timeout
111 // because there are probably fewer passwords and we want the UI to be
112 // snappier since users will expect that it's "less work."
113 this.queryDelayTimerId_ = window.setTimeout(
114 this.searchPasswords_.bind(this), 250);
115 },
116
117 /**
118 * Search passwords using text in |password-search-box|.
119 * @private
120 */
121 searchPasswords_: function() {
122 this.queryDelayTimerId_ = 0;
123 var filter = $('password-search-box').value;
124 filter = (filter == '') ? null : filter;
125 if (this.lastQuery_ != filter) {
126 this.lastQuery_ = filter;
127 // Searching for passwords has the side effect of requerying the
128 // underlying password store. This is done intentionally, as on OS X and
129 // Linux they can change from outside and we won't be notified of it.
130 chrome.send('updatePasswordLists');
131 }
132 },
133
134 /**
85 * Updates the visibility of the list and empty list placeholder. 135 * Updates the visibility of the list and empty list placeholder.
86 * @param {!List} list The list to toggle visilibility for. 136 * @param {!List} list The list to toggle visilibility for.
87 */ 137 */
88 updateListVisibility_: function(list) { 138 updateListVisibility_: function(list) {
89 var empty = list.dataModel.length == 0; 139 var empty = list.dataModel.length == 0;
90 var listPlaceHolderID = list.id + '-empty-placeholder'; 140 var listPlaceHolderID = list.id + '-empty-placeholder';
91 list.hidden = empty; 141 list.hidden = empty;
92 $(listPlaceHolderID).hidden = !empty; 142 $(listPlaceHolderID).hidden = !empty;
93 }, 143 },
94 144
95 /** 145 /**
96 * Updates the data model for the saved passwords list with the values from 146 * Updates the data model for the saved passwords list with the values from
97 * |entries|. 147 * |entries|.
98 * @param {Array} entries The list of saved password data. 148 * @param {Array} entries The list of saved password data.
99 */ 149 */
100 setSavedPasswordsList_: function(entries) { 150 setSavedPasswordsList_: function(entries) {
151 if (this.lastQuery_) {
152 // Implement password searching here in javascript, rather than in C++.
153 // The number of saved passwords shouldn't be too big for us to handle.
154 var query = this.lastQuery_;
155 var filter = function(entry) {
156 // Search both URL and username.
157 return entry[0].indexOf(query) >= 0 || entry[1].indexOf(query) >= 0;
158 };
159 entries = entries.filter(filter);
160 }
101 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); 161 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries);
102 this.updateListVisibility_(this.savedPasswordsList_); 162 this.updateListVisibility_(this.savedPasswordsList_);
103 }, 163 },
104 164
105 /** 165 /**
106 * Updates the data model for the password exceptions list with the values 166 * Updates the data model for the password exceptions list with the values
107 * from |entries|. 167 * from |entries|.
108 * @param {Array} entries The list of password exception data. 168 * @param {Array} entries The list of password exception data.
109 */ 169 */
110 setPasswordExceptionsList_: function(entries) { 170 setPasswordExceptionsList_: function(entries) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 PasswordManager.setPasswordExceptionsList = function(entries) { 212 PasswordManager.setPasswordExceptionsList = function(entries) {
153 PasswordManager.getInstance().setPasswordExceptionsList_(entries); 213 PasswordManager.getInstance().setPasswordExceptionsList_(entries);
154 }; 214 };
155 215
156 // Export 216 // Export
157 return { 217 return {
158 PasswordManager: PasswordManager 218 PasswordManager: PasswordManager
159 }; 219 };
160 220
161 }); 221 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/password_manager.html ('k') | chrome/browser/resources/options/password_manager_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698