Chromium Code Reviews| Index: chrome/browser/resources/extensions/create_node.js |
| diff --git a/chrome/browser/resources/extensions/create_node.js b/chrome/browser/resources/extensions/create_node.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c46adf114bd894ee94a47a33ffc405ae4dba8fb6 |
| --- /dev/null |
| +++ b/chrome/browser/resources/extensions/create_node.js |
| @@ -0,0 +1,149 @@ |
| +// TODO(hcarmona): Remove this temporary file. |
| + |
| + /** |
| + * Synthesizes and initializes an HTML element for the extension metadata |
| + * given in |extension|. |
| + * @param {ExtensionData} extension A dictionary of extension metadata. |
| + * @private |
| + */ |
| + createNode_: function(extension) { |
| + var template = $('template-collection').querySelector( |
| + '.extension-list-item-wrapper'); |
| + var node = template.cloneNode(true); |
| + node.id = extension.id; |
| + |
| + // The 'Show Browser Action' button. |
| + var showButton = node.querySelector('.show-button'); |
| + showButton.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsShowButton', [extension.id]); |
| + }); |
| + |
| + // The 'allow in incognito' checkbox. |
| + var incognito = node.querySelector('.incognito-control input'); |
| + var butterBar = node.querySelector('.butter-bar'); |
| + incognito.addEventListener('change', function(e) { |
| + var checked = e.target.checked; |
| + butterBarVisibility[extension.id] = checked; |
| + butterBar.hidden = !checked || extension.is_hosted_app; |
|
not at google - send to devlin
2015/02/05 22:25:03
This butterbar visibility logic should be in updat
hcarmona
2015/02/05 23:27:14
There's already code in update_node.js to update t
not at google - send to devlin
2015/02/05 23:34:06
I tried this with your patch, and nothing seems to
hcarmona
2015/02/06 02:25:10
This new patch has this working so the butterbar s
|
| + chrome.send('extensionSettingsEnableIncognito', |
| + [extension.id, String(checked)]); |
| + }); |
| + |
| + // The 'collect errors' checkbox. This should only be visible if the |
| + // error console is enabled - we can detect this by the existence of the |
| + // |errorCollectionEnabled| property. |
| + var errorCollection = |
| + node.querySelector('.error-collection-control input'); |
| + errorCollection.addEventListener('change', function(e) { |
| + chrome.send('extensionSettingsEnableErrorCollection', |
| + [extension.id, String(e.target.checked)]); |
| + }); |
| + |
| + // The 'allow on all urls' checkbox. This should only be visible if |
| + // active script restrictions are enabled. If they are not enabled, no |
| + // extensions should want all urls. |
| + var allUrls = node.querySelector('.all-urls-control'); |
| + allUrls.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsAllowOnAllUrls', |
| + [extension.id, String(e.target.checked)]); |
| + }); |
| + |
| + // The 'allow file:// access' checkbox. |
| + var fileAccess = node.querySelector('.file-access-control'); |
| + fileAccess.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsAllowFileAccess', |
| + [extension.id, String(e.target.checked)]); |
| + }); |
| + |
| + // The 'Options' button or link, depending on its behaviour. |
| + var optionsLink = node.querySelector('.options-link'); |
| + // Set an href to get the correct mouse-over appearance (link, |
| + // footer) - but the actual link opening is done through chrome.send |
| + // with a preventDefault(). |
| + optionsLink.setAttribute('href', extension.optionsPageHref); |
| + optionsLink.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsOptions', [extension.id]); |
| + e.preventDefault(); |
| + }); |
| + |
| + var optionsButton = options = node.querySelector('.options-button'); |
| + optionsButton.addEventListener('click', function(e) { |
| + this.showEmbeddedExtensionOptions_(extension.id, false); |
| + e.preventDefault(); |
| + }.bind(this)); |
| + |
| + // The 'Permissions' link. |
| + var permissions = node.querySelector('.permissions-link'); |
| + permissions.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsPermissions', [extension.id]); |
| + e.preventDefault(); |
| + }); |
| + |
| + // The 'Reload' link. |
| + var reload = node.querySelector('.reload-link'); |
| + reload.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsReload', [extension.id]); |
| + extensionReloadedTimestamp[extension.id] = Date.now(); |
| + }); |
| + |
| + // The 'Launch' link. |
| + var launch = node.querySelector('.launch-link'); |
| + launch.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsLaunch', [extension.id]); |
| + }); |
| + |
| + // The 'Reload' terminated link. |
| + var terminatedReload = node.querySelector('.terminated-reload-link'); |
| + terminatedReload.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsReload', [extension.id]); |
| + }); |
| + |
| + // The 'Repair' corrupted link. |
| + var repair = node.querySelector('.corrupted-repair-button'); |
| + repair.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsRepair', [extension.id]); |
| + }); |
| + |
| + // The 'Enabled' checkbox. |
| + var enable = node.querySelector('.enable-checkbox'); |
| + enable.addEventListener('click', function(e) { |
| + // When e.target is the label instead of the checkbox, it doesn't |
| + // have the checked property and the state of the checkbox is |
| + // left unchanged. |
|
not at google - send to devlin
2015/02/05 22:25:03
This (existing) code is weird, I wonder why it doe
hcarmona
2015/02/05 23:27:14
enable is a div. if the click event happens on the
not at google - send to devlin
2015/02/05 23:34:06
You've lost me, but I think that if you change the
not at google - send to devlin
2015/02/05 23:39:35
What is said is wrong. You should be checking enab
hcarmona
2015/02/06 02:25:10
It's not possible to rely on the value of the chec
not at google - send to devlin
2015/02/06 15:48:00
I just tried this and clicking on the label toggle
hcarmona
2015/02/06 23:41:27
I'm getting a bit confused now. Current functional
|
| + var checked = e.target.checked; |
| + if (checked == undefined) |
| + checked = !e.currentTarget.querySelector('input').checked; |
| + chrome.send('extensionSettingsEnable', |
| + [extension.id, checked ? 'true' : 'false']); |
| + |
| + // This may seem counter-intuitive (to not set/clear the checkmark) |
| + // but this page will be updated asynchronously if the extension |
| + // becomes enabled/disabled. It also might not become enabled or |
| + // disabled, because the user might e.g. get prompted when enabling |
| + // and choose not to. |
| + e.preventDefault(); |
| + }); |
| + |
| + // 'Remove' button. |
| + var trashTemplate = $('template-collection').querySelector('.trash'); |
| + var trash = trashTemplate.cloneNode(true); |
| + trash.title = loadTimeData.getString('extensionUninstall'); |
| + trash.addEventListener('click', function(e) { |
| + butterBarVisibility[extension.id] = false; |
| + chrome.send('extensionSettingsUninstall', [extension.id]); |
| + }); |
| + node.querySelector('.enable-controls').appendChild(trash); |
| + |
| + // Developer mode //////////////////////////////////////////////////////// |
| + |
| + // The path, if provided by unpacked extension. |
| + var loadPath = node.querySelector('.load-path'); |
| + var pathLink = loadPath.querySelector('a:nth-of-type(1)'); |
| + pathLink.addEventListener('click', function(e) { |
| + chrome.send('extensionSettingsShowPath', [String(extension.id)]); |
| + e.preventDefault(); |
| + }); |
| + |
| + this.appendChild(node); |
| + this.updateNode_(extension, node); |
| + }, |