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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 */ | 60 */ |
61 createNode_: function(extension) { | 61 createNode_: function(extension) { |
62 var template = $('template-collection').querySelector( | 62 var template = $('template-collection').querySelector( |
63 '.extension-list-item-wrapper'); | 63 '.extension-list-item-wrapper'); |
64 var node = template.cloneNode(true); | 64 var node = template.cloneNode(true); |
65 node.id = extension.id; | 65 node.id = extension.id; |
66 | 66 |
67 if (!extension.enabled) | 67 if (!extension.enabled) |
68 node.classList.add('disabled-extension'); | 68 node.classList.add('disabled-extension'); |
69 | 69 |
| 70 if (!extension.mayDisable) |
| 71 node.classList.add('may-not-disable'); |
| 72 |
70 var item = node.querySelector('.extension-list-item'); | 73 var item = node.querySelector('.extension-list-item'); |
71 item.style.backgroundImage = 'url(' + extension.icon + ')'; | 74 item.style.backgroundImage = 'url(' + extension.icon + ')'; |
72 | 75 |
73 var title = node.querySelector('.extension-title'); | 76 var title = node.querySelector('.extension-title'); |
74 title.textContent = extension.name; | 77 title.textContent = extension.name; |
75 | 78 |
76 var version = node.querySelector('.extension-version'); | 79 var version = node.querySelector('.extension-version'); |
77 version.textContent = extension.version; | 80 version.textContent = extension.version; |
78 | 81 |
79 var description = node.querySelector('.extension-description'); | 82 var description = node.querySelector('.extension-description'); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 localStrings.getString('extensionSettingsEnable').length) + 'em'; | 169 localStrings.getString('extensionSettingsEnable').length) + 'em'; |
167 } else { | 170 } else { |
168 var terminated_reload = node.querySelector('.terminated-reload-link'); | 171 var terminated_reload = node.querySelector('.terminated-reload-link'); |
169 terminated_reload.hidden = false; | 172 terminated_reload.hidden = false; |
170 terminated_reload.addEventListener('click', function(e) { | 173 terminated_reload.addEventListener('click', function(e) { |
171 chrome.send('extensionSettingsReload', [extension.id]); | 174 chrome.send('extensionSettingsReload', [extension.id]); |
172 }); | 175 }); |
173 } | 176 } |
174 | 177 |
175 // 'Remove' button. | 178 // 'Remove' button. |
176 | 179 var trashTemplate = $('template-collection').querySelector('.trash'); |
177 if (extension.mayDisable) { | 180 var trash = trashTemplate.cloneNode(true); |
178 var trashTemplate = $('template-collection').querySelector('.trash'); | 181 trash.title = templateData.extensionUninstall; |
179 var trash = trashTemplate.cloneNode(true); | 182 trash.addEventListener('click', function(e) { |
180 trash.title = templateData.extensionUninstall; | 183 chrome.send('extensionSettingsUninstall', [extension.id]); |
181 trash.addEventListener('click', function(e) { | 184 }); |
182 chrome.send('extensionSettingsUninstall', [extension.id]); | 185 node.querySelector('.enable-controls').appendChild(trash); |
183 }); | |
184 node.querySelector('.enable-controls').appendChild(trash); | |
185 } | |
186 | 186 |
187 // Developer mode //////////////////////////////////////////////////////// | 187 // Developer mode //////////////////////////////////////////////////////// |
188 | 188 |
189 // First we have the id. | 189 // First we have the id. |
190 var idLabel = node.querySelector('.extension-id'); | 190 var idLabel = node.querySelector('.extension-id'); |
191 idLabel.textContent = ' ' + extension.id; | 191 idLabel.textContent = ' ' + extension.id; |
192 | 192 |
193 // Then the path, if provided by unpacked extension. | 193 // Then the path, if provided by unpacked extension. |
194 if (extension.isUnpacked) { | 194 if (extension.isUnpacked) { |
195 var loadPath = node.querySelector('.load-path'); | 195 var loadPath = node.querySelector('.load-path'); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 | 229 |
230 this.appendChild(node); | 230 this.appendChild(node); |
231 }, | 231 }, |
232 }; | 232 }; |
233 | 233 |
234 return { | 234 return { |
235 ExtensionsList: ExtensionsList | 235 ExtensionsList: ExtensionsList |
236 }; | 236 }; |
237 }); | 237 }); |
OLD | NEW |