Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // TODO(hcarmona): Remove this temporary file. | |
| 2 | |
| 3 /** | |
| 4 * Synthesizes and initializes an HTML element for the extension metadata | |
| 5 * given in |extension|. | |
| 6 * @param {ExtensionData} extension A dictionary of extension metadata. | |
| 7 * @private | |
| 8 */ | |
| 9 createNode_: function(extension) { | |
| 10 var template = $('template-collection').querySelector( | |
| 11 '.extension-list-item-wrapper'); | |
| 12 var node = template.cloneNode(true); | |
| 13 node.id = extension.id; | |
| 14 | |
| 15 // The 'Show Browser Action' button. | |
| 16 this.addListener_('click', node, '.show-button', function(e) { | |
| 17 chrome.send('extensionSettingsShowButton', [extension.id]); | |
| 18 }); | |
| 19 | |
| 20 // The 'allow in incognito' checkbox. | |
| 21 this.addListener_('change', node, '.incognito-control input', | |
| 22 function(e) { | |
| 23 var butterBar = node.querySelector('.butter-bar'); | |
| 24 var checked = e.target.checked; | |
| 25 if (!this.butterbarShown_) { | |
| 26 butterBar.hidden = !checked || extension.is_hosted_app; | |
| 27 butterBarVisibility[extension.id] = !butterBar.hidden; | |
| 28 this.butterbarShown_ = !butterBar.hidden; | |
| 29 } else { | |
| 30 butterBarVisibility[extension.id] = false; | |
| 31 butterBar.hidden = true; | |
| 32 } | |
| 33 chrome.send('extensionSettingsEnableIncognito', | |
| 34 [extension.id, String(checked)]); | |
| 35 }.bind(this)); | |
| 36 | |
| 37 // The 'collect errors' checkbox. This should only be visible if the | |
| 38 // error console is enabled - we can detect this by the existence of the | |
| 39 // |errorCollectionEnabled| property. | |
| 40 this.addListener_('change', node, '.error-collection-control input', | |
| 41 function(e) { | |
| 42 chrome.send('extensionSettingsEnableErrorCollection', | |
| 43 [extension.id, String(e.target.checked)]); | |
| 44 }); | |
| 45 | |
| 46 // The 'allow on all urls' checkbox. This should only be visible if | |
| 47 // active script restrictions are enabled. If they are not enabled, no | |
| 48 // extensions should want all urls. | |
| 49 this.addListener_('click', node, '.all-urls-control', function(e) { | |
| 50 chrome.send('extensionSettingsAllowOnAllUrls', | |
| 51 [extension.id, String(e.target.checked)]); | |
| 52 }); | |
| 53 | |
| 54 // The 'allow file:// access' checkbox. | |
| 55 this.addListener_('click', node, '.file-access-control', function(e) { | |
| 56 chrome.send('extensionSettingsAllowFileAccess', | |
| 57 [extension.id, String(e.target.checked)]); | |
| 58 }); | |
| 59 | |
| 60 // The 'Options' button or link, depending on its behaviour. | |
| 61 // Set an href to get the correct mouse-over appearance (link, | |
| 62 // footer) - but the actual link opening is done through chrome.send | |
| 63 // with a preventDefault(). | |
| 64 node.querySelector('.options-link').setAttribute( | |
| 65 'href', extension.optionsPageHref); | |
| 66 this.addListener_('click', node, '.options-link', function(e) { | |
| 67 chrome.send('extensionSettingsOptions', [extension.id]); | |
| 68 e.preventDefault(); | |
| 69 }); | |
| 70 | |
| 71 this.addListener_('click', node, '.options-button', function(e) { | |
| 72 this.showEmbeddedExtensionOptions_(extension.id, false); | |
| 73 e.preventDefault(); | |
| 74 }.bind(this)); | |
| 75 | |
| 76 // The 'Permissions' link. | |
| 77 this.addListener_('click', node, '.permissions-link', function(e) { | |
| 78 chrome.send('extensionSettingsPermissions', [extension.id]); | |
| 79 e.preventDefault(); | |
| 80 }); | |
| 81 | |
| 82 // The 'Reload' link. | |
| 83 this.addListener_('click', node, '.reload-link', function(e) { | |
| 84 chrome.send('extensionSettingsReload', [extension.id]); | |
| 85 extensionReloadedTimestamp[extension.id] = Date.now(); | |
| 86 }); | |
| 87 | |
| 88 // The 'Launch' link. | |
| 89 this.addListener_('click', node, '.launch-link', function(e) { | |
| 90 chrome.send('extensionSettingsLaunch', [extension.id]); | |
| 91 }); | |
| 92 | |
| 93 // The 'Reload' terminated link. | |
| 94 this.addListener_('click', node, '.terminated-reload-link', function(e) { | |
| 95 chrome.send('extensionSettingsReload', [extension.id]); | |
| 96 }); | |
| 97 | |
| 98 // The 'Repair' corrupted link. | |
| 99 this.addListener_('click', node, '.corrupted-repair-button', function(e) { | |
| 100 chrome.send('extensionSettingsRepair', [extension.id]); | |
| 101 }); | |
| 102 | |
| 103 // The 'Enabled' checkbox. | |
| 104 this.addListener_('click', node, '.enable-checkbox input', function(e) { | |
| 105 var checked = e.target.checked; | |
| 106 chrome.send('extensionSettingsEnable', [extension.id, String(checked)]); | |
| 107 | |
| 108 // This may seem counter-intuitive (to not set/clear the checkmark) | |
| 109 // but this page will be updated asynchronously if the extension | |
| 110 // becomes enabled/disabled. It also might not become enabled or | |
| 111 // disabled, because the user might e.g. get prompted when enabling | |
| 112 // and choose not to. | |
| 113 e.preventDefault(); | |
| 114 }); | |
| 115 | |
| 116 // 'Remove' button. | |
| 117 var trashTemplate = $('template-collection').querySelector('.trash'); | |
| 118 var trash = trashTemplate.cloneNode(true); | |
| 119 trash.title = loadTimeData.getString('extensionUninstall'); | |
| 120 trash.addEventListener('click', function(e) { | |
| 121 butterBarVisibility[extension.id] = false; | |
|
not at google - send to devlin
2015/02/10 22:14:37
Is this necessary? I would hope that uninstalling
not at google - send to devlin
2015/02/10 22:15:27
I guess if you install the extension again you don
hcarmona
2015/02/11 02:22:07
Got rid of butterBarVisibility since it holds the
| |
| 122 chrome.send('extensionSettingsUninstall', [extension.id]); | |
| 123 }); | |
| 124 node.querySelector('.enable-controls').appendChild(trash); | |
| 125 | |
| 126 // Developer mode //////////////////////////////////////////////////////// | |
| 127 | |
| 128 // The path, if provided by unpacked extension. | |
| 129 this.addListener_('click', node, '.load-path a:nth-of-type(1)', | |
| 130 function(e) { | |
| 131 chrome.send('extensionSettingsShowPath', [String(extension.id)]); | |
| 132 e.preventDefault(); | |
| 133 }); | |
| 134 | |
| 135 this.appendChild(node); | |
| 136 this.updateNode_(extension, node); | |
| 137 }, | |
| OLD | NEW |