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 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 function getTitleForPasswordOrigin(item) { | 51 function getTitleForPasswordOrigin(item) { |
52 var title = item.url; | 52 var title = item.url; |
53 if (item.isAndroidUri) | 53 if (item.isAndroidUri) |
54 return title; | 54 return title; |
55 if (!item.isSecure) { | 55 if (!item.isSecure) { |
56 var ind = title.indexOf('://'); | 56 var ind = title.indexOf('://'); |
57 if (ind >= 0) { | 57 if (ind >= 0) { |
58 title = title.substring(ind + 3); | 58 title = title.substring(ind + 3); |
59 } | 59 } |
60 } | 60 } |
61 // 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 title = title.replace(/[^A-Za-z0-9]+$/, ''); | |
64 return title; | 61 return title; |
65 } | 62 } |
66 | 63 |
67 /** | 64 /** |
68 * Helper function that creates an HTML element for displaying the origin of | 65 * Helper function that creates an HTML element for displaying the origin of |
69 * saved password. | 66 * saved password. |
70 * @param {Object} item A dictionary of data on the list item. | 67 * @param {Object} item A dictionary of data on the list item. |
71 * @param {Element} urlDiv div-element that will enclose the created | 68 * @param {Element} urlDiv div-element that will enclose the created |
72 * element. | 69 * element. |
73 * @return {Element} The element for displaying password origin. | 70 * @return {Element} The element for displaying password origin. |
74 */ | 71 */ |
75 function createUrlLink(item, urlDiv) { | 72 function createUrlLink(item, urlDiv) { |
76 var urlLink; | 73 var urlLink; |
77 if (!item.isAndroidUri) { | 74 if (!item.isAndroidUri) { |
78 urlLink = item.ownerDocument.createElement('a'); | 75 urlLink = item.ownerDocument.createElement('a'); |
79 urlLink.href = item.url; | 76 urlLink.href = item.url; |
80 urlLink.setAttribute('target', '_blank'); | 77 urlLink.setAttribute('target', '_blank'); |
81 urlLink.textContent = item.shownUrl.split('').reverse().join(''); | 78 urlLink.dir = 'ltr'; |
82 | |
83 urlDiv.classList.add('left-elided-url'); | |
84 } else { | 79 } else { |
85 urlLink = item.ownerDocument.createElement('span'); | 80 urlLink = item.ownerDocument.createElement('span'); |
86 urlLink.textContent = item.shownUrl; | |
87 } | 81 } |
| 82 urlLink.textContent = item.shownUrl; |
88 urlLink.addEventListener('focus', function() { | 83 urlLink.addEventListener('focus', function() { |
89 item.handleFocus(); | 84 item.handleFocus(); |
90 }.bind(item)); | 85 }.bind(item)); |
91 return urlLink; | 86 return urlLink; |
92 } | 87 } |
93 | 88 |
94 PasswordListItem.prototype = { | 89 PasswordListItem.prototype = { |
95 __proto__: DeletableItem.prototype, | 90 __proto__: DeletableItem.prototype, |
96 | 91 |
97 /** @override */ | 92 /** @override */ |
98 decorate: function() { | 93 decorate: function() { |
99 DeletableItem.prototype.decorate.call(this); | 94 DeletableItem.prototype.decorate.call(this); |
100 | 95 |
101 // The URL of the site. | 96 // The URL of the site. |
102 var urlDiv = this.ownerDocument.createElement('div'); | 97 var urlDiv = this.ownerDocument.createElement('div'); |
103 urlDiv.className = 'favicon-cell url'; | 98 urlDiv.className = 'favicon-cell url'; |
104 urlDiv.setAttribute('title', getTitleForPasswordOrigin(this)); | 99 urlDiv.setAttribute('title', getTitleForPasswordOrigin(this)); |
105 urlDiv.style.backgroundImage = getFaviconImageSet( | 100 urlDiv.style.backgroundImage = getFaviconImageSet( |
106 'origin/' + this.url, 16); | 101 'origin/' + this.url, 16); |
107 | 102 |
108 this.urlLink = createUrlLink(this, urlDiv); | 103 this.urlLink = createUrlLink(this, urlDiv); |
109 urlDiv.appendChild(this.urlLink); | 104 urlDiv.appendChild(this.urlLink); |
110 | 105 |
| 106 this.urlDiv = urlDiv; |
111 this.contentElement.appendChild(urlDiv); | 107 this.contentElement.appendChild(urlDiv); |
112 | 108 |
113 // The stored username. | 109 // The stored username. |
114 var usernameDiv = this.ownerDocument.createElement('div'); | 110 var usernameDiv = this.ownerDocument.createElement('div'); |
115 usernameDiv.className = 'name'; | 111 usernameDiv.className = 'name'; |
116 usernameDiv.title = this.username; | 112 usernameDiv.title = this.username; |
117 this.contentElement.appendChild(usernameDiv); | 113 this.contentElement.appendChild(usernameDiv); |
118 var usernameInput = this.ownerDocument.createElement('input'); | 114 var usernameInput = this.ownerDocument.createElement('input'); |
119 usernameInput.type = 'text'; | 115 usernameInput.type = 'text'; |
120 usernameInput.className = 'inactive-item'; | 116 usernameInput.className = 'inactive-item'; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // The URL of the site. | 362 // The URL of the site. |
367 var urlDiv = this.ownerDocument.createElement('div'); | 363 var urlDiv = this.ownerDocument.createElement('div'); |
368 urlDiv.className = 'favicon-cell url'; | 364 urlDiv.className = 'favicon-cell url'; |
369 urlDiv.setAttribute('title', getTitleForPasswordOrigin(this)); | 365 urlDiv.setAttribute('title', getTitleForPasswordOrigin(this)); |
370 urlDiv.style.backgroundImage = getFaviconImageSet( | 366 urlDiv.style.backgroundImage = getFaviconImageSet( |
371 'origin/' + this.url, 16); | 367 'origin/' + this.url, 16); |
372 | 368 |
373 this.urlLink = createUrlLink(this, urlDiv); | 369 this.urlLink = createUrlLink(this, urlDiv); |
374 urlDiv.appendChild(this.urlLink); | 370 urlDiv.appendChild(this.urlLink); |
375 | 371 |
| 372 this.urlDiv = urlDiv; |
376 this.contentElement.appendChild(urlDiv); | 373 this.contentElement.appendChild(urlDiv); |
377 }, | 374 }, |
378 | 375 |
379 /** @override */ | 376 /** @override */ |
380 selectionChanged: function() { | 377 selectionChanged: function() { |
381 if (this.selected) { | 378 if (this.selected) { |
382 this.setFocusable_(true); | 379 this.setFocusable_(true); |
383 this.urlLink.focus(); | 380 this.urlLink.focus(); |
384 } else { | 381 } else { |
385 this.setFocusable_(false); | 382 this.setFocusable_(false); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 PasswordExceptionsList: PasswordExceptionsList, | 555 PasswordExceptionsList: PasswordExceptionsList, |
559 ORIGIN_FIELD: ORIGIN_FIELD, | 556 ORIGIN_FIELD: ORIGIN_FIELD, |
560 SHOWN_URL_FIELD: SHOWN_URL_FIELD, | 557 SHOWN_URL_FIELD: SHOWN_URL_FIELD, |
561 IS_SECURE_FIELD: IS_SECURE_FIELD, | 558 IS_SECURE_FIELD: IS_SECURE_FIELD, |
562 USERNAME_FIELD: USERNAME_FIELD, | 559 USERNAME_FIELD: USERNAME_FIELD, |
563 PASSWORD_FIELD: PASSWORD_FIELD, | 560 PASSWORD_FIELD: PASSWORD_FIELD, |
564 FEDERATION_FIELD: FEDERATION_FIELD, | 561 FEDERATION_FIELD: FEDERATION_FIELD, |
565 ORIGINAL_INDEX_FIELD: ORIGINAL_INDEX_FIELD | 562 ORIGINAL_INDEX_FIELD: ORIGINAL_INDEX_FIELD |
566 }; | 563 }; |
567 }); | 564 }); |
OLD | NEW |