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

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

Issue 1823423002: [Password Manager] Changes implementation of left elided origins (Relanding) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added the comment on the order of method calls. Created 4 years, 9 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 | chrome/browser/resources/options/password_manager_list.css » ('j') | 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', function() { 5 cr.define('options', function() {
6 /** @const */ var Page = cr.ui.pageManager.Page; 6 /** @const */ var Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
9 9
10 ///////////////////////////////////////////////////////////////////////////// 10 /////////////////////////////////////////////////////////////////////////////
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 * @param {!cr.ui.List} list The list to toggle visilibility for. 158 * @param {!cr.ui.List} list The list to toggle visilibility for.
159 */ 159 */
160 updateListVisibility_: function(list) { 160 updateListVisibility_: function(list) {
161 var empty = list.dataModel.length == 0; 161 var empty = list.dataModel.length == 0;
162 var listPlaceHolderID = list.id + '-empty-placeholder'; 162 var listPlaceHolderID = list.id + '-empty-placeholder';
163 list.hidden = empty; 163 list.hidden = empty;
164 $(listPlaceHolderID).hidden = !empty; 164 $(listPlaceHolderID).hidden = !empty;
165 }, 165 },
166 166
167 /** 167 /**
168 * Updates eliding of origins. If there is no enough space to show the full
169 * origin, the origin is elided from the left with ellipsis.
170 * @param {!cr.ui.List} list The list to update eliding.
171 */
172 updateOriginsEliding_: function(list) {
173 var entries = list.getElementsByClassName('deletable-item');
174 if (entries.length == 0)
175 return;
176 var entry = entries[0];
177 var computedStyle = window.getComputedStyle(entry.urlDiv);
178 var columnWidth = entry.urlDiv.offsetWidth -
Evan Stade 2016/03/24 16:29:00 to be doubly safe, maybe make sure this doesn't do
kolos1 2016/03/29 08:35:53 Done.
179 parseInt(computedStyle.webkitMarginStart, 10) -
180 parseInt(computedStyle.webkitPaddingStart, 10);
181 for (var i = 0; i < entries.length; ++i) {
182 var urlLink = entries[i].urlLink;
183 if (entries[i].isAndroidUri || urlLink.offsetWidth <= columnWidth)
184 continue;
185 urlLink.textContent = '…' + urlLink.textContent.substring(1);
186 while (urlLink.offsetWidth > columnWidth)
187 urlLink.textContent = '…' + urlLink.textContent.substring(2);
188 }
189 },
190
191 /**
168 * Updates the data model for the saved passwords list with the values from 192 * Updates the data model for the saved passwords list with the values from
169 * |entries|. 193 * |entries|.
170 * @param {!Array} entries The list of saved password data. 194 * @param {!Array} entries The list of saved password data.
171 */ 195 */
172 setSavedPasswordsList_: function(entries) { 196 setSavedPasswordsList_: function(entries) {
173 if (this.lastQuery_) { 197 if (this.lastQuery_) {
174 // Implement password searching here in javascript, rather than in C++. 198 // Implement password searching here in javascript, rather than in C++.
175 // The number of saved passwords shouldn't be too big for us to handle. 199 // The number of saved passwords shouldn't be too big for us to handle.
176 var query = this.lastQuery_; 200 var query = this.lastQuery_;
177 var filter = function(entry, index, list) { 201 var filter = function(entry, index, list) {
178 // Search both shown URL and username. 202 // Search both shown URL and username.
179 var shownUrl = entry[options.passwordManager.SHOWN_URL_FIELD]; 203 var shownUrl = entry[options.passwordManager.SHOWN_URL_FIELD];
180 var username = entry[options.passwordManager.USERNAME_FIELD]; 204 var username = entry[options.passwordManager.USERNAME_FIELD];
181 if (shownUrl.toLowerCase().indexOf(query.toLowerCase()) >= 0 || 205 if (shownUrl.toLowerCase().indexOf(query.toLowerCase()) >= 0 ||
182 username.toLowerCase().indexOf(query.toLowerCase()) >= 0) { 206 username.toLowerCase().indexOf(query.toLowerCase()) >= 0) {
183 // Keep the original index so we can delete correctly. See also 207 // Keep the original index so we can delete correctly. See also
184 // deleteItemAtIndex() in password_manager_list.js that uses this. 208 // deleteItemAtIndex() in password_manager_list.js that uses this.
185 entry[options.passwordManager.ORIGINAL_INDEX_FIELD] = index; 209 entry[options.passwordManager.ORIGINAL_INDEX_FIELD] = index;
186 return true; 210 return true;
187 } 211 }
188 return false; 212 return false;
189 }; 213 };
190 entries = entries.filter(filter); 214 entries = entries.filter(filter);
191 } 215 }
192 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); 216 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries);
193 this.updateListVisibility_(this.savedPasswordsList_); 217 this.updateListVisibility_(this.savedPasswordsList_);
218 // updateOriginsEliding_ should be called after updateListVisibility_,
219 // otherwise updateOrigins... might be not able to read width of elements.
220 this.updateOriginsEliding_(this.savedPasswordsList_);
194 }, 221 },
195 222
196 /** 223 /**
197 * Updates the data model for the password exceptions list with the values 224 * Updates the data model for the password exceptions list with the values
198 * from |entries|. 225 * from |entries|.
199 * @param {!Array} entries The list of password exception data. 226 * @param {!Array} entries The list of password exception data.
200 */ 227 */
201 setPasswordExceptionsList_: function(entries) { 228 setPasswordExceptionsList_: function(entries) {
202 this.passwordExceptionsList_.dataModel = new ArrayDataModel(entries); 229 this.passwordExceptionsList_.dataModel = new ArrayDataModel(entries);
203 this.updateListVisibility_(this.passwordExceptionsList_); 230 this.updateListVisibility_(this.passwordExceptionsList_);
231 // updateOriginsEliding_ should be called after updateListVisibility_,
232 // otherwise updateOrigins... might be not able to read width of elements.
233 this.updateOriginsEliding_(this.passwordExceptionsList_);
204 }, 234 },
205 235
206 /** 236 /**
207 * Reveals the password for a saved password entry. This is called by the 237 * Reveals the password for a saved password entry. This is called by the
208 * backend after it has authenticated the user. 238 * backend after it has authenticated the user.
209 * @param {number} index The original index of the entry in the model. 239 * @param {number} index The original index of the entry in the model.
210 * @param {string} password The saved password. 240 * @param {string} password The saved password.
211 */ 241 */
212 showPassword_: function(index, password) { 242 showPassword_: function(index, password) {
213 var model = this.savedPasswordsList_.dataModel; 243 var model = this.savedPasswordsList_.dataModel;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 'setPasswordExceptionsList', 288 'setPasswordExceptionsList',
259 'showPassword' 289 'showPassword'
260 ]); 290 ]);
261 291
262 // Export 292 // Export
263 return { 293 return {
264 PasswordManager: PasswordManager 294 PasswordManager: PasswordManager
265 }; 295 };
266 296
267 }); 297 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/password_manager_list.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698