Chromium Code Reviews| 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 a icon url | |
| 37 * with timestamp. The timestamp is a query string to prevent the | |
| 38 * icon from caching and is recorded when the user click the 'Reload' | |
| 39 * link. It is used to refresh the icon of an unpacked extension. | |
| 40 * This persists between calls to decorate. | |
| 41 */ | |
| 42 var extensionReloadedIconURL = {}; | |
| 43 | |
| 35 ExtensionsList.prototype = { | 44 ExtensionsList.prototype = { |
| 36 __proto__: HTMLDivElement.prototype, | 45 __proto__: HTMLDivElement.prototype, |
| 37 | 46 |
| 38 /** @override */ | 47 /** @override */ |
| 39 decorate: function() { | 48 decorate: function() { |
| 40 this.textContent = ''; | 49 this.textContent = ''; |
| 41 | 50 |
| 42 this.showExtensionNodes_(); | 51 this.showExtensionNodes_(); |
| 43 }, | 52 }, |
| 44 | 53 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 node.classList.add('inactive-extension'); | 99 node.classList.add('inactive-extension'); |
| 91 | 100 |
| 92 if (!extension.userModifiable) | 101 if (!extension.userModifiable) |
| 93 node.classList.add('may-not-disable'); | 102 node.classList.add('may-not-disable'); |
| 94 | 103 |
| 95 var idToHighlight = this.getIdQueryParam_(); | 104 var idToHighlight = this.getIdQueryParam_(); |
| 96 if (node.id == idToHighlight) | 105 if (node.id == idToHighlight) |
| 97 node.classList.add('extension-highlight'); | 106 node.classList.add('extension-highlight'); |
| 98 | 107 |
| 99 var item = node.querySelector('.extension-list-item'); | 108 var item = node.querySelector('.extension-list-item'); |
| 100 var extensionIconUrl = extension.icon; | 109 if (extensionReloadedIconURL[extension.id]) { |
| 101 if (extension.allow_reload) | 110 item.style.backgroundImage = |
| 102 extensionIconUrl = extension.icon + '?' + Date.now(); | 111 'url(' + extensionReloadedIconURL[extension.id] + ')'; |
| 103 item.style.backgroundImage = 'url(' + extensionIconUrl + ')'; | 112 } else { |
| 113 item.style.backgroundImage = 'url(' + extension.icon + ')'; | |
| 114 } | |
| 104 | 115 |
| 105 var title = node.querySelector('.extension-title'); | 116 var title = node.querySelector('.extension-title'); |
| 106 title.textContent = extension.name; | 117 title.textContent = extension.name; |
| 107 | 118 |
| 108 var version = node.querySelector('.extension-version'); | 119 var version = node.querySelector('.extension-version'); |
| 109 version.textContent = extension.version; | 120 version.textContent = extension.version; |
| 110 | 121 |
| 111 var locationText = node.querySelector('.location-text'); | 122 var locationText = node.querySelector('.location-text'); |
| 112 locationText.textContent = extension.locationText; | 123 locationText.textContent = extension.locationText; |
| 113 | 124 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 extension.homepageProvided ? 'extensionSettingsVisitWebsite' : | 186 extension.homepageProvided ? 'extensionSettingsVisitWebsite' : |
| 176 'extensionSettingsVisitWebStore'); | 187 'extensionSettingsVisitWebStore'); |
| 177 siteLink.hidden = false; | 188 siteLink.hidden = false; |
| 178 } | 189 } |
| 179 | 190 |
| 180 if (extension.allow_reload) { | 191 if (extension.allow_reload) { |
| 181 // The 'Reload' link. | 192 // The 'Reload' link. |
| 182 var reload = node.querySelector('.reload-link'); | 193 var reload = node.querySelector('.reload-link'); |
| 183 reload.addEventListener('click', function(e) { | 194 reload.addEventListener('click', function(e) { |
| 184 chrome.send('extensionSettingsReload', [extension.id]); | 195 chrome.send('extensionSettingsReload', [extension.id]); |
| 196 extensionReloadedIconURL[extension.id] = extension.icon + '?' + | |
| 197 new Date().getTime(); | |
|
not at google - send to devlin
2013/07/26 16:48:07
if the icon changes will this assignment happen be
zhchbin
2013/07/29 15:43:59
However, I couldn't make sure I got your meaning o
not at google - send to devlin
2013/07/29 17:26:24
Like this:
1. Extension changes its icon URL in t
| |
| 185 }); | 198 }); |
| 186 reload.hidden = false; | 199 reload.hidden = false; |
| 187 | 200 |
| 188 if (extension.is_platform_app) { | 201 if (extension.is_platform_app) { |
| 189 // The 'Launch' link. | 202 // The 'Launch' link. |
| 190 var launch = node.querySelector('.launch-link'); | 203 var launch = node.querySelector('.launch-link'); |
| 191 launch.addEventListener('click', function(e) { | 204 launch.addEventListener('click', function(e) { |
| 192 chrome.send('extensionSettingsLaunch', [extension.id]); | 205 chrome.send('extensionSettingsLaunch', [extension.id]); |
| 193 }); | 206 }); |
| 194 launch.hidden = false; | 207 launch.hidden = false; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 } | 331 } |
| 319 | 332 |
| 320 this.appendChild(node); | 333 this.appendChild(node); |
| 321 } | 334 } |
| 322 }; | 335 }; |
| 323 | 336 |
| 324 return { | 337 return { |
| 325 ExtensionsList: ExtensionsList | 338 ExtensionsList: ExtensionsList |
| 326 }; | 339 }; |
| 327 }); | 340 }); |
| OLD | NEW |