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', function() { | 5 cr.define('options', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * A lookup helper function to find the first node that has an id (starting | 9 * A lookup helper function to find the first node that has an id (starting |
10 * at |node| and going up the parent chain). | 10 * at |node| and going up the parent chain). |
(...skipping 14 matching lines...) Expand all Loading... |
25 */ | 25 */ |
26 var ExtensionsList = cr.ui.define('div'); | 26 var ExtensionsList = cr.ui.define('div'); |
27 | 27 |
28 /** | 28 /** |
29 * @type {Object.<string, boolean>} A map from extension id to a boolean | 29 * @type {Object.<string, boolean>} A map from extension id to a boolean |
30 * indicating whether the incognito warning is showing. This persists | 30 * indicating whether the incognito warning is showing. This persists |
31 * between calls to decorate. | 31 * between calls to decorate. |
32 */ | 32 */ |
33 var butterBarVisibility = {}; | 33 var butterBarVisibility = {}; |
34 | 34 |
| 35 /** |
| 36 * @type {Object.<string, string>} A map from extension id to last reloaded |
| 37 * timestamp. The timestamp is recorded when the user click the 'Reload' |
| 38 * link. It is used to refresh the icon of an unpacked extension. |
| 39 * This persists between calls to decorate. |
| 40 */ |
| 41 var extensionReloadedTimestamp = {}; |
| 42 |
35 ExtensionsList.prototype = { | 43 ExtensionsList.prototype = { |
36 __proto__: HTMLDivElement.prototype, | 44 __proto__: HTMLDivElement.prototype, |
37 | 45 |
38 /** @override */ | 46 /** @override */ |
39 decorate: function() { | 47 decorate: function() { |
40 this.textContent = ''; | 48 this.textContent = ''; |
41 | 49 |
42 this.showExtensionNodes_(); | 50 this.showExtensionNodes_(); |
43 }, | 51 }, |
44 | 52 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 node.classList.add('inactive-extension'); | 98 node.classList.add('inactive-extension'); |
91 | 99 |
92 if (!extension.userModifiable) | 100 if (!extension.userModifiable) |
93 node.classList.add('may-not-disable'); | 101 node.classList.add('may-not-disable'); |
94 | 102 |
95 var idToHighlight = this.getIdQueryParam_(); | 103 var idToHighlight = this.getIdQueryParam_(); |
96 if (node.id == idToHighlight) | 104 if (node.id == idToHighlight) |
97 node.classList.add('extension-highlight'); | 105 node.classList.add('extension-highlight'); |
98 | 106 |
99 var item = node.querySelector('.extension-list-item'); | 107 var item = node.querySelector('.extension-list-item'); |
100 var extensionIconUrl = extension.icon; | 108 // Prevent the image cache of extension icon by using the reloaded |
101 if (extension.allow_reload) | 109 // timestamp as a query string. The timestamp is recorded when the user |
102 extensionIconUrl = extension.icon + '?' + Date.now(); | 110 // clicks the 'Reload' link. http://crbug.com/159302. |
103 item.style.backgroundImage = 'url(' + extensionIconUrl + ')'; | 111 if (extensionReloadedTimestamp[extension.id]) { |
| 112 item.style.backgroundImage = |
| 113 'url(' + extension.icon + '?' + |
| 114 extensionReloadedTimestamp[extension.id] + ')'; |
| 115 } else { |
| 116 item.style.backgroundImage = 'url(' + extension.icon + ')'; |
| 117 } |
104 | 118 |
105 var title = node.querySelector('.extension-title'); | 119 var title = node.querySelector('.extension-title'); |
106 title.textContent = extension.name; | 120 title.textContent = extension.name; |
107 | 121 |
108 var version = node.querySelector('.extension-version'); | 122 var version = node.querySelector('.extension-version'); |
109 version.textContent = extension.version; | 123 version.textContent = extension.version; |
110 | 124 |
111 var locationText = node.querySelector('.location-text'); | 125 var locationText = node.querySelector('.location-text'); |
112 locationText.textContent = extension.locationText; | 126 locationText.textContent = extension.locationText; |
113 | 127 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 extension.homepageProvided ? 'extensionSettingsVisitWebsite' : | 189 extension.homepageProvided ? 'extensionSettingsVisitWebsite' : |
176 'extensionSettingsVisitWebStore'); | 190 'extensionSettingsVisitWebStore'); |
177 siteLink.hidden = false; | 191 siteLink.hidden = false; |
178 } | 192 } |
179 | 193 |
180 if (extension.allow_reload) { | 194 if (extension.allow_reload) { |
181 // The 'Reload' link. | 195 // The 'Reload' link. |
182 var reload = node.querySelector('.reload-link'); | 196 var reload = node.querySelector('.reload-link'); |
183 reload.addEventListener('click', function(e) { | 197 reload.addEventListener('click', function(e) { |
184 chrome.send('extensionSettingsReload', [extension.id]); | 198 chrome.send('extensionSettingsReload', [extension.id]); |
| 199 extensionReloadedTimestamp[extension.id] = Date.now(); |
185 }); | 200 }); |
186 reload.hidden = false; | 201 reload.hidden = false; |
187 | 202 |
188 if (extension.is_platform_app) { | 203 if (extension.is_platform_app) { |
189 // The 'Launch' link. | 204 // The 'Launch' link. |
190 var launch = node.querySelector('.launch-link'); | 205 var launch = node.querySelector('.launch-link'); |
191 launch.addEventListener('click', function(e) { | 206 launch.addEventListener('click', function(e) { |
192 chrome.send('extensionSettingsLaunch', [extension.id]); | 207 chrome.send('extensionSettingsLaunch', [extension.id]); |
193 }); | 208 }); |
194 launch.hidden = false; | 209 launch.hidden = false; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 topScroll -= pad / 2; | 342 topScroll -= pad / 2; |
328 document.body.scrollTop = topScroll; | 343 document.body.scrollTop = topScroll; |
329 } | 344 } |
330 } | 345 } |
331 }; | 346 }; |
332 | 347 |
333 return { | 348 return { |
334 ExtensionsList: ExtensionsList | 349 ExtensionsList: ExtensionsList |
335 }; | 350 }; |
336 }); | 351 }); |
OLD | NEW |