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

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

Issue 1615653005: [Password manager] Human readable origins for Android credentials on chrome://settings/passwords (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small changes addressed to reviewer comments 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
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
11 // The following constants should be synchronized with the constants in 11 // The following constants should be synchronized with the constants in
12 // chrome/browser/ui/webui/options/password_manager_handler.cc. 12 // chrome/browser/ui/webui/options/password_manager_handler.cc.
13 /** @const */ var ORIGIN_FIELD = 'origin'; 13 /** @const */ var URL_FIELD = 'url';
14 /** @const */ var SHOWN_URL_FIELD = 'shownUrl'; 14 /** @const */ var SHOWN_ORIGIN_FIELD = 'shownOrigin';
15 /** @const */ var IS_ANDROID_URI_FIELD = 'isAndroidUri'; 15 /** @const */ var IS_ANDROID_URI_FIELD = 'isAndroidUri';
16 /** @const */ var IS_CLICKABLE_FIELD = 'isClickable';
16 /** @const */ var IS_SECURE_FIELD = 'isSecure'; 17 /** @const */ var IS_SECURE_FIELD = 'isSecure';
17 /** @const */ var USERNAME_FIELD = 'username'; 18 /** @const */ var USERNAME_FIELD = 'username';
18 /** @const */ var PASSWORD_FIELD = 'password'; 19 /** @const */ var PASSWORD_FIELD = 'password';
19 /** @const */ var FEDERATION_FIELD = 'federation'; 20 /** @const */ var FEDERATION_FIELD = 'federation';
20 /** @const */ var ORIGINAL_INDEX_FIELD = 'index'; 21 /** @const */ var ORIGINAL_INDEX_FIELD = 'index';
21 22
22 /** 23 /**
23 * Creates a new passwords list item. 24 * Creates a new passwords list item.
24 * @param {cr.ui.ArrayDataModel} dataModel The data model that contains this 25 * @param {cr.ui.ArrayDataModel} dataModel The data model that contains this
25 * item. 26 * item.
26 * @param {Object} entry A dictionary of data on new list item. When the 27 * @param {Object} entry A dictionary of data on new list item. When the
27 * list has been filtered, one more element [index] may be present. 28 * list has been filtered, one more element [index] may be present.
28 * @param {boolean} showPasswords If true, add a button to the element to 29 * @param {boolean} showPasswords If true, add a button to the element to
29 * allow the user to reveal the saved password. 30 * allow the user to reveal the saved password.
30 * @constructor 31 * @constructor
31 * @extends {options.DeletableItem} 32 * @extends {options.DeletableItem}
32 */ 33 */
33 function PasswordListItem(dataModel, entry, showPasswords) { 34 function PasswordListItem(dataModel, entry, showPasswords) {
34 var el = cr.doc.createElement('div'); 35 var el = cr.doc.createElement('div');
35 el.dataItem = entry; 36 el.dataItem = entry;
36 el.dataModel = dataModel; 37 el.dataModel = dataModel;
37 el.__proto__ = PasswordListItem.prototype; 38 el.__proto__ = PasswordListItem.prototype;
38 el.showPasswords_ = showPasswords; 39 el.showPasswords_ = showPasswords;
39 el.decorate(); 40 el.decorate();
40 41
41 return el; 42 return el;
42 } 43 }
43 44
44 /** 45 /**
45 * Returns title for password's origin. If the origin is Android URI, returns 46 * Returns title for password's origin. If the origin is not clickable,
46 * the origin as it is. Removes the scheme if the url is insecure and removes 47 * returns the origin as it is. For clickable origins, removes the scheme if
47 * trailing punctuation symbols. 48 * the url is insecure and removes trailing punctuation symbols.
48 * @param {Object} item A dictionary of data on the list item. 49 * @param {Object} item A dictionary of data on the list item.
49 * @return {string} The title for password's origin. 50 * @return {string} The title for password's origin.
50 */ 51 */
51 function getTitleForPasswordOrigin(item) { 52 function getTitleForPasswordOrigin(item) {
52 var title = item.url; 53 var title = item.url;
53 if (item.isAndroidUri) 54 if (!item.isClickable)
54 return title; 55 return title;
55 if (!item.isSecure) { 56 if (!item.isSecure) {
56 var ind = title.indexOf('://'); 57 var ind = title.indexOf('://');
57 if (ind >= 0) { 58 if (ind >= 0) {
58 title = title.substring(ind + 3); 59 title = title.substring(ind + 3);
59 } 60 }
60 } 61 }
61 // Since the direction is switched to RTL, punctuation symbols appear on the 62 // Since the direction is switched to RTL, punctuation symbols appear on the
62 // left side, that is wrong. So, just remove trailing punctuation symbols. 63 // left side, that is wrong. So, just remove trailing punctuation symbols.
63 title = title.replace(/[^A-Za-z0-9]+$/, ''); 64 title = title.replace(/[^A-Za-z0-9]+$/, '');
64 return title; 65 return title;
65 } 66 }
66 67
67 /** 68 /**
68 * Helper function that creates an HTML element for displaying the origin of 69 * Helper function that creates an HTML element for displaying the origin of
69 * saved password. 70 * saved password.
70 * @param {Object} item A dictionary of data on the list item. 71 * @param {Object} item A dictionary of data on the list item.
71 * @param {Element} urlDiv div-element that will enclose the created 72 * @param {Element} urlDiv div-element that will enclose the created
72 * element. 73 * element.
73 * @return {Element} The element for displaying password origin. 74 * @return {Element} The element for displaying password origin.
74 */ 75 */
75 function createUrlLink(item, urlDiv) { 76 function createUrlLink(item, urlDiv) {
76 var urlLink; 77 var urlLink;
77 if (!item.isAndroidUri) { 78 if (item.isClickable) {
78 urlLink = item.ownerDocument.createElement('a'); 79 urlLink = item.ownerDocument.createElement('a');
79 urlLink.href = item.url; 80 urlLink.href = item.url;
80 urlLink.setAttribute('target', '_blank'); 81 urlLink.setAttribute('target', '_blank');
81 urlLink.textContent = item.shownUrl.split('').reverse().join(''); 82 var linkText = item.shownOrigin;
82 83 // Since the string will be reversed for RTL direction, the string starts
84 // with closed bracket and ends with open bracket.
85 if (item.isAndroidUri)
86 linkText += ' )Android(';
Evan Stade 2016/03/15 18:48:58 how do you know this is RTL? And wouldn't proper b
kolos1 2016/03/15 19:31:34 This is always RTL, because of CSS class left_elid
kolos1 2016/03/15 19:36:16 I think I understand. The parens should inherit di
Evan Stade 2016/03/15 20:05:26 OK, so, you're reversing the string in JS then ove
kolos1 2016/03/15 21:00:41 Yes, the solution is a bit confusing, because we h
Dan Beam 2016/03/17 22:24:08 Ultimately, I think anything involving text concat
87 urlLink.textContent = linkText.split('').reverse().join('');
83 urlDiv.classList.add('left-elided-url'); 88 urlDiv.classList.add('left-elided-url');
84 } else { 89 } else {
85 urlLink = item.ownerDocument.createElement('span'); 90 urlLink = item.ownerDocument.createElement('span');
86 urlLink.textContent = item.shownUrl; 91 urlLink.textContent = item.shownOrigin;
87 } 92 }
88 urlLink.addEventListener('focus', function() { 93 urlLink.addEventListener('focus', function() {
89 item.handleFocus(); 94 item.handleFocus();
90 }.bind(item)); 95 }.bind(item));
91 return urlLink; 96 return urlLink;
92 } 97 }
93 98
94 PasswordListItem.prototype = { 99 PasswordListItem.prototype = {
95 __proto__: DeletableItem.prototype, 100 __proto__: DeletableItem.prototype,
96 101
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } else { 264 } else {
260 this.hidePassword(); 265 this.hidePassword();
261 } 266 }
262 }, 267 },
263 268
264 /** 269 /**
265 * Get and set the URL for the entry. 270 * Get and set the URL for the entry.
266 * @type {string} 271 * @type {string}
267 */ 272 */
268 get url() { 273 get url() {
269 return this.dataItem[ORIGIN_FIELD]; 274 return this.dataItem[URL_FIELD];
270 }, 275 },
271 set url(url) { 276 set url(url) {
272 this.dataItem[ORIGIN_FIELD] = url; 277 this.dataItem[URL_FIELD] = url;
273 }, 278 },
274 279
275 /** 280 /**
276 * Get and set the shown url for the entry. 281 * Get and set the shown origin for the entry.
277 * @type {string} 282 * @type {string}
278 */ 283 */
279 get shownUrl() { 284 get shownOrigin() {
280 return this.dataItem[SHOWN_URL_FIELD]; 285 return this.dataItem[SHOWN_ORIGIN_FIELD];
281 }, 286 },
282 set shownUrl(shownUrl) { 287 set shownOrigin(shownOrigin) {
283 this.dataItem[SHOWN_URL_FIELD] = shownUrl; 288 this.dataItem[SHOWN_ORIGIN_FIELD] = shownOrigin;
284 }, 289 },
285 290
286 /** 291 /**
287 * Get and set whether the origin is Android URI. 292 * Get and set whether the origin is Android URI.
288 * @type {boolean} 293 * @type {boolean}
289 */ 294 */
290 get isAndroidUri() { 295 get isAndroidUri() {
291 return this.dataItem[IS_ANDROID_URI_FIELD]; 296 return this.dataItem[IS_ANDROID_URI_FIELD];
292 }, 297 },
293 set isAndroidUri(isAndroidUri) { 298 set isAndroidUri(isAndroidUri) {
294 this.dataItem[IS_ANDROID_URI_FIELD] = isAndroidUri; 299 this.dataItem[IS_ANDROID_URI_FIELD] = isAndroidUri;
295 }, 300 },
296 301
297 /** 302 /**
303 * Get and set whether the origin is clickable.
304 * @type {boolean}
305 */
306 get isClickable() {
307 return this.dataItem[IS_CLICKABLE_FIELD];
308 },
309 set isClickable(isClickable) {
310 this.dataItem[IS_CLICKABLE_FIELD] = isClickable;
311 },
312
313 /**
298 * Get and set whether the origin uses secure scheme. 314 * Get and set whether the origin uses secure scheme.
299 * @type {boolean} 315 * @type {boolean}
300 */ 316 */
301 get isSecure() { 317 get isSecure() {
302 return this.dataItem[IS_SECURE_FIELD]; 318 return this.dataItem[IS_SECURE_FIELD];
303 }, 319 },
304 set isSecure(isSecure) { 320 set isSecure(isSecure) {
305 this.dataItem[IS_SECURE_FIELD] = isSecure; 321 this.dataItem[IS_SECURE_FIELD] = isSecure;
306 }, 322 },
307 323
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 var tabIndex = focusable ? 0 : -1; 411 var tabIndex = focusable ? 0 : -1;
396 this.urlLink.tabIndex = tabIndex; 412 this.urlLink.tabIndex = tabIndex;
397 this.closeButtonElement.tabIndex = tabIndex; 413 this.closeButtonElement.tabIndex = tabIndex;
398 }, 414 },
399 415
400 /** 416 /**
401 * Get the url for the entry. 417 * Get the url for the entry.
402 * @type {string} 418 * @type {string}
403 */ 419 */
404 get url() { 420 get url() {
405 return this.dataItem[ORIGIN_FIELD]; 421 return this.dataItem[URL_FIELD];
406 }, 422 },
407 set url(url) { 423 set url(url) {
408 this.dataItem[ORIGIN_FIELD] = url; 424 this.dataItem[URL_FIELD] = url;
409 }, 425 },
410 426
411 /** 427 /**
412 * Get and set the shown url for the entry. 428 * Get and set the shown origin for the entry.
413 * @type {string} 429 * @type {string}
414 */ 430 */
415 get shownUrl() { 431 get shownOrigin() {
416 return this.dataItem[SHOWN_URL_FIELD]; 432 return this.dataItem[SHOWN_ORIGIN_FIELD];
417 }, 433 },
418 set shownUrl(shownUrl) { 434 set shownOrigin(shownOrigin) {
419 this.dataItem[SHOWN_URL_FIELD] = shownUrl; 435 this.dataItem[SHOWN_ORIGIN_FIELD] = shownOrigin;
420 }, 436 },
421 437
422 /** 438 /**
423 * Get and set whether the origin is Android URI. 439 * Get and set whether the origin is Android URI.
424 * @type {boolean} 440 * @type {boolean}
425 */ 441 */
426 get isAndroidUri() { 442 get isAndroidUri() {
427 return this.dataItem[IS_ANDROID_URI_FIELD]; 443 return this.dataItem[IS_ANDROID_URI_FIELD];
428 }, 444 },
429 set isAndroidUri(isAndroidUri) { 445 set isAndroidUri(isAndroidUri) {
430 this.dataItem[IS_ANDROID_URI_FIELD] = isAndroidUri; 446 this.dataItem[IS_ANDROID_URI_FIELD] = isAndroidUri;
431 }, 447 },
432 448
433 /** 449 /**
450 * Get and set whether the origin is clickable.
451 * @type {boolean}
452 */
453 get isClickable() {
454 return this.dataItem[IS_CLICKABLE_FIELD];
455 },
456 set isClickable(isClickable) {
457 this.dataItem[IS_CLICKABLE_FIELD] = isClickable;
458 },
459
460 /**
434 * Get and set whether the origin uses secure scheme. 461 * Get and set whether the origin uses secure scheme.
435 * @type {boolean} 462 * @type {boolean}
436 */ 463 */
437 get isSecure() { 464 get isSecure() {
438 return this.dataItem[IS_SECURE_FIELD]; 465 return this.dataItem[IS_SECURE_FIELD];
439 }, 466 },
440 set isSecure(isSecure) { 467 set isSecure(isSecure) {
441 this.dataItem[IS_SECURE_FIELD] = isSecure; 468 this.dataItem[IS_SECURE_FIELD] = isSecure;
442 }, 469 },
443 }; 470 };
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 get length() { 576 get length() {
550 return this.dataModel.length; 577 return this.dataModel.length;
551 }, 578 },
552 }; 579 };
553 580
554 return { 581 return {
555 PasswordListItem: PasswordListItem, 582 PasswordListItem: PasswordListItem,
556 PasswordExceptionsListItem: PasswordExceptionsListItem, 583 PasswordExceptionsListItem: PasswordExceptionsListItem,
557 PasswordsList: PasswordsList, 584 PasswordsList: PasswordsList,
558 PasswordExceptionsList: PasswordExceptionsList, 585 PasswordExceptionsList: PasswordExceptionsList,
559 ORIGIN_FIELD: ORIGIN_FIELD, 586 URL_FIELD: URL_FIELD,
560 SHOWN_URL_FIELD: SHOWN_URL_FIELD, 587 SHOWN_ORIGIN_FIELD: SHOWN_ORIGIN_FIELD,
588 IS_ANDROID_URI_FIELD: IS_ANDROID_URI_FIELD,
589 IS_CLICKABLE_FIELD: IS_CLICKABLE_FIELD,
561 IS_SECURE_FIELD: IS_SECURE_FIELD, 590 IS_SECURE_FIELD: IS_SECURE_FIELD,
562 USERNAME_FIELD: USERNAME_FIELD, 591 USERNAME_FIELD: USERNAME_FIELD,
563 PASSWORD_FIELD: PASSWORD_FIELD, 592 PASSWORD_FIELD: PASSWORD_FIELD,
564 FEDERATION_FIELD: FEDERATION_FIELD, 593 FEDERATION_FIELD: FEDERATION_FIELD,
565 ORIGINAL_INDEX_FIELD: ORIGINAL_INDEX_FIELD 594 ORIGINAL_INDEX_FIELD: ORIGINAL_INDEX_FIELD
566 }; 595 };
567 }); 596 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/password_manager.js ('k') | chrome/browser/ui/passwords/password_manager_presenter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698