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

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: Adapt to new implementation of left elided origins 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 return title; 62 return title;
62 } 63 }
63 64
64 /** 65 /**
65 * Helper function that creates an HTML element for displaying the origin of 66 * Helper function that creates an HTML element for displaying the origin of
66 * saved password. 67 * saved password.
67 * @param {Object} item A dictionary of data on the list item. 68 * @param {Object} item A dictionary of data on the list item.
68 * @param {Element} urlDiv div-element that will enclose the created 69 * @param {Element} urlDiv div-element that will enclose the created
69 * element. 70 * element.
70 * @return {Element} The element for displaying password origin. 71 * @return {Element} The element for displaying password origin.
71 */ 72 */
72 function createUrlLink(item, urlDiv) { 73 function createUrlLink(item, urlDiv) {
73 var urlLink; 74 var urlLink;
74 if (!item.isAndroidUri) { 75 if (item.isClickable) {
75 urlLink = item.ownerDocument.createElement('a'); 76 urlLink = item.ownerDocument.createElement('a');
76 urlLink.href = item.url; 77 urlLink.href = item.url;
77 urlLink.setAttribute('target', '_blank'); 78 urlLink.setAttribute('target', '_blank');
78 urlLink.dir = 'ltr'; 79 urlLink.dir = 'ltr';
79 } else { 80 } else {
80 urlLink = item.ownerDocument.createElement('span'); 81 urlLink = item.ownerDocument.createElement('span');
81 } 82 }
82 urlLink.textContent = item.shownUrl; 83 urlLink.textContent = item.shownOrigin;
83 urlLink.addEventListener('focus', function() { 84 urlLink.addEventListener('focus', function() {
84 item.handleFocus(); 85 item.handleFocus();
85 }.bind(item)); 86 }.bind(item));
86 return urlLink; 87 return urlLink;
87 } 88 }
88 89
90 /**
91 * Helper function that creates an HTML element that is appended to the
92 * clickable origins of Android credentials.
93 * @return {Element} The element to append Android clickable origins.
94 */
95 function createAndroidSpan() {
96 var androidSpan = cr.doc.createElement('span');
97 androidSpan.textContent = ' (Android)';
Evan Stade 2016/03/22 20:13:37 I think this needs to be left up to translators. A
Dan Beam 2016/03/22 20:36:49 content: "$i18n{...}"; might work in the near futu
kolos1 2016/03/22 21:00:52 Where shall I define androidUriSuffix} that will b
98 return androidSpan;
99 }
100
89 PasswordListItem.prototype = { 101 PasswordListItem.prototype = {
90 __proto__: DeletableItem.prototype, 102 __proto__: DeletableItem.prototype,
91 103
92 /** @override */ 104 /** @override */
93 decorate: function() { 105 decorate: function() {
94 DeletableItem.prototype.decorate.call(this); 106 DeletableItem.prototype.decorate.call(this);
95 107
96 // The URL of the site. 108 // The URL of the site.
97 var urlDiv = this.ownerDocument.createElement('div'); 109 var urlDiv = this.ownerDocument.createElement('div');
98 urlDiv.className = 'favicon-cell url'; 110 urlDiv.className = 'favicon-cell url';
99 urlDiv.setAttribute('title', getTitleForPasswordOrigin(this)); 111 urlDiv.setAttribute('title', getTitleForPasswordOrigin(this));
100 urlDiv.style.backgroundImage = getFaviconImageSet( 112 urlDiv.style.backgroundImage = getFaviconImageSet(
101 'origin/' + this.url, 16); 113 'origin/' + this.url, 16);
102 114
103 this.urlLink = createUrlLink(this, urlDiv); 115 this.urlLink = createUrlLink(this, urlDiv);
104 urlDiv.appendChild(this.urlLink); 116 urlDiv.appendChild(this.urlLink);
105 117
118 if (this.isAndroidUri && this.isClickable) {
119 this.androidSpan = createAndroidSpan();
120 urlDiv.appendChild(this.androidSpan);
121 }
122
106 this.urlDiv = urlDiv; 123 this.urlDiv = urlDiv;
107 this.contentElement.appendChild(urlDiv); 124 this.contentElement.appendChild(urlDiv);
108 125
109 // The stored username. 126 // The stored username.
110 var usernameDiv = this.ownerDocument.createElement('div'); 127 var usernameDiv = this.ownerDocument.createElement('div');
111 usernameDiv.className = 'name'; 128 usernameDiv.className = 'name';
112 usernameDiv.title = this.username; 129 usernameDiv.title = this.username;
113 this.contentElement.appendChild(usernameDiv); 130 this.contentElement.appendChild(usernameDiv);
114 var usernameInput = this.ownerDocument.createElement('input'); 131 var usernameInput = this.ownerDocument.createElement('input');
115 usernameInput.type = 'text'; 132 usernameInput.type = 'text';
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } else { 272 } else {
256 this.hidePassword(); 273 this.hidePassword();
257 } 274 }
258 }, 275 },
259 276
260 /** 277 /**
261 * Get and set the URL for the entry. 278 * Get and set the URL for the entry.
262 * @type {string} 279 * @type {string}
263 */ 280 */
264 get url() { 281 get url() {
265 return this.dataItem[ORIGIN_FIELD]; 282 return this.dataItem[URL_FIELD];
266 }, 283 },
267 set url(url) { 284 set url(url) {
268 this.dataItem[ORIGIN_FIELD] = url; 285 this.dataItem[URL_FIELD] = url;
269 }, 286 },
270 287
271 /** 288 /**
272 * Get and set the shown url for the entry. 289 * Get and set the shown origin for the entry.
273 * @type {string} 290 * @type {string}
274 */ 291 */
275 get shownUrl() { 292 get shownOrigin() {
276 return this.dataItem[SHOWN_URL_FIELD]; 293 return this.dataItem[SHOWN_ORIGIN_FIELD];
277 }, 294 },
278 set shownUrl(shownUrl) { 295 set shownOrigin(shownOrigin) {
279 this.dataItem[SHOWN_URL_FIELD] = shownUrl; 296 this.dataItem[SHOWN_ORIGIN_FIELD] = shownOrigin;
280 }, 297 },
281 298
282 /** 299 /**
283 * Get and set whether the origin is Android URI. 300 * Get and set whether the origin is Android URI.
284 * @type {boolean} 301 * @type {boolean}
285 */ 302 */
286 get isAndroidUri() { 303 get isAndroidUri() {
287 return this.dataItem[IS_ANDROID_URI_FIELD]; 304 return this.dataItem[IS_ANDROID_URI_FIELD];
288 }, 305 },
289 set isAndroidUri(isAndroidUri) { 306 set isAndroidUri(isAndroidUri) {
Evan Stade 2016/03/22 20:13:37 is this used?
kolos1 2016/03/23 11:59:46 Yes, we need these properties. isAndroidUri to ch
Evan Stade 2016/03/23 18:54:29 where?
290 this.dataItem[IS_ANDROID_URI_FIELD] = isAndroidUri; 307 this.dataItem[IS_ANDROID_URI_FIELD] = isAndroidUri;
291 }, 308 },
292 309
293 /** 310 /**
311 * Get and set whether the origin is clickable.
312 * @type {boolean}
313 */
314 get isClickable() {
315 return this.dataItem[IS_CLICKABLE_FIELD];
316 },
317 set isClickable(isClickable) {
Evan Stade 2016/03/22 20:13:37 is this used?
318 this.dataItem[IS_CLICKABLE_FIELD] = isClickable;
319 },
320
321 /**
294 * Get and set whether the origin uses secure scheme. 322 * Get and set whether the origin uses secure scheme.
295 * @type {boolean} 323 * @type {boolean}
296 */ 324 */
297 get isSecure() { 325 get isSecure() {
298 return this.dataItem[IS_SECURE_FIELD]; 326 return this.dataItem[IS_SECURE_FIELD];
299 }, 327 },
300 set isSecure(isSecure) { 328 set isSecure(isSecure) {
301 this.dataItem[IS_SECURE_FIELD] = isSecure; 329 this.dataItem[IS_SECURE_FIELD] = isSecure;
302 }, 330 },
303 331
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 var tabIndex = focusable ? 0 : -1; 420 var tabIndex = focusable ? 0 : -1;
393 this.urlLink.tabIndex = tabIndex; 421 this.urlLink.tabIndex = tabIndex;
394 this.closeButtonElement.tabIndex = tabIndex; 422 this.closeButtonElement.tabIndex = tabIndex;
395 }, 423 },
396 424
397 /** 425 /**
398 * Get the url for the entry. 426 * Get the url for the entry.
399 * @type {string} 427 * @type {string}
400 */ 428 */
401 get url() { 429 get url() {
402 return this.dataItem[ORIGIN_FIELD]; 430 return this.dataItem[URL_FIELD];
403 }, 431 },
404 set url(url) { 432 set url(url) {
405 this.dataItem[ORIGIN_FIELD] = url; 433 this.dataItem[URL_FIELD] = url;
406 }, 434 },
407 435
408 /** 436 /**
409 * Get and set the shown url for the entry. 437 * Get and set the shown origin for the entry.
410 * @type {string} 438 * @type {string}
411 */ 439 */
412 get shownUrl() { 440 get shownOrigin() {
413 return this.dataItem[SHOWN_URL_FIELD]; 441 return this.dataItem[SHOWN_ORIGIN_FIELD];
414 }, 442 },
415 set shownUrl(shownUrl) { 443 set shownOrigin(shownOrigin) {
416 this.dataItem[SHOWN_URL_FIELD] = shownUrl; 444 this.dataItem[SHOWN_ORIGIN_FIELD] = shownOrigin;
417 }, 445 },
418 446
419 /** 447 /**
420 * Get and set whether the origin is Android URI. 448 * Get and set whether the origin is Android URI.
421 * @type {boolean} 449 * @type {boolean}
422 */ 450 */
423 get isAndroidUri() { 451 get isAndroidUri() {
Evan Stade 2016/03/22 20:13:37 is this used somewhere?
424 return this.dataItem[IS_ANDROID_URI_FIELD]; 452 return this.dataItem[IS_ANDROID_URI_FIELD];
425 }, 453 },
426 set isAndroidUri(isAndroidUri) { 454 set isAndroidUri(isAndroidUri) {
427 this.dataItem[IS_ANDROID_URI_FIELD] = isAndroidUri; 455 this.dataItem[IS_ANDROID_URI_FIELD] = isAndroidUri;
428 }, 456 },
429 457
430 /** 458 /**
459 * Get and set whether the origin is clickable.
460 * @type {boolean}
461 */
462 get isClickable() {
463 return this.dataItem[IS_CLICKABLE_FIELD];
464 },
465 set isClickable(isClickable) {
466 this.dataItem[IS_CLICKABLE_FIELD] = isClickable;
467 },
468
469 /**
431 * Get and set whether the origin uses secure scheme. 470 * Get and set whether the origin uses secure scheme.
432 * @type {boolean} 471 * @type {boolean}
433 */ 472 */
434 get isSecure() { 473 get isSecure() {
435 return this.dataItem[IS_SECURE_FIELD]; 474 return this.dataItem[IS_SECURE_FIELD];
436 }, 475 },
437 set isSecure(isSecure) { 476 set isSecure(isSecure) {
438 this.dataItem[IS_SECURE_FIELD] = isSecure; 477 this.dataItem[IS_SECURE_FIELD] = isSecure;
439 }, 478 },
440 }; 479 };
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 get length() { 585 get length() {
547 return this.dataModel.length; 586 return this.dataModel.length;
548 }, 587 },
549 }; 588 };
550 589
551 return { 590 return {
552 PasswordListItem: PasswordListItem, 591 PasswordListItem: PasswordListItem,
553 PasswordExceptionsListItem: PasswordExceptionsListItem, 592 PasswordExceptionsListItem: PasswordExceptionsListItem,
554 PasswordsList: PasswordsList, 593 PasswordsList: PasswordsList,
555 PasswordExceptionsList: PasswordExceptionsList, 594 PasswordExceptionsList: PasswordExceptionsList,
556 ORIGIN_FIELD: ORIGIN_FIELD, 595 URL_FIELD: URL_FIELD,
557 SHOWN_URL_FIELD: SHOWN_URL_FIELD, 596 SHOWN_ORIGIN_FIELD: SHOWN_ORIGIN_FIELD,
597 IS_ANDROID_URI_FIELD: IS_ANDROID_URI_FIELD,
598 IS_CLICKABLE_FIELD: IS_CLICKABLE_FIELD,
558 IS_SECURE_FIELD: IS_SECURE_FIELD, 599 IS_SECURE_FIELD: IS_SECURE_FIELD,
559 USERNAME_FIELD: USERNAME_FIELD, 600 USERNAME_FIELD: USERNAME_FIELD,
560 PASSWORD_FIELD: PASSWORD_FIELD, 601 PASSWORD_FIELD: PASSWORD_FIELD,
561 FEDERATION_FIELD: FEDERATION_FIELD, 602 FEDERATION_FIELD: FEDERATION_FIELD,
562 ORIGINAL_INDEX_FIELD: ORIGINAL_INDEX_FIELD 603 ORIGINAL_INDEX_FIELD: ORIGINAL_INDEX_FIELD
563 }; 604 };
564 }); 605 });
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