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 var showButton = node.querySelector('.show-button'); | |
| 17 showButton.addEventListener('click', function(e) { | |
| 18 chrome.send('extensionSettingsShowButton', [extension.id]); | |
| 19 }); | |
| 20 | |
| 21 // The 'allow in incognito' checkbox. | |
| 22 var incognito = node.querySelector('.incognito-control input'); | |
| 23 var butterBar = node.querySelector('.butter-bar'); | |
| 24 incognito.addEventListener('change', function(e) { | |
| 25 var checked = e.target.checked; | |
| 26 butterBarVisibility[extension.id] = checked; | |
| 27 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
| |
| 28 chrome.send('extensionSettingsEnableIncognito', | |
| 29 [extension.id, String(checked)]); | |
| 30 }); | |
| 31 | |
| 32 // The 'collect errors' checkbox. This should only be visible if the | |
| 33 // error console is enabled - we can detect this by the existence of the | |
| 34 // |errorCollectionEnabled| property. | |
| 35 var errorCollection = | |
| 36 node.querySelector('.error-collection-control input'); | |
| 37 errorCollection.addEventListener('change', function(e) { | |
| 38 chrome.send('extensionSettingsEnableErrorCollection', | |
| 39 [extension.id, String(e.target.checked)]); | |
| 40 }); | |
| 41 | |
| 42 // The 'allow on all urls' checkbox. This should only be visible if | |
| 43 // active script restrictions are enabled. If they are not enabled, no | |
| 44 // extensions should want all urls. | |
| 45 var allUrls = node.querySelector('.all-urls-control'); | |
| 46 allUrls.addEventListener('click', function(e) { | |
| 47 chrome.send('extensionSettingsAllowOnAllUrls', | |
| 48 [extension.id, String(e.target.checked)]); | |
| 49 }); | |
| 50 | |
| 51 // The 'allow file:// access' checkbox. | |
| 52 var fileAccess = node.querySelector('.file-access-control'); | |
| 53 fileAccess.addEventListener('click', function(e) { | |
| 54 chrome.send('extensionSettingsAllowFileAccess', | |
| 55 [extension.id, String(e.target.checked)]); | |
| 56 }); | |
| 57 | |
| 58 // The 'Options' button or link, depending on its behaviour. | |
| 59 var optionsLink = node.querySelector('.options-link'); | |
| 60 // Set an href to get the correct mouse-over appearance (link, | |
| 61 // footer) - but the actual link opening is done through chrome.send | |
| 62 // with a preventDefault(). | |
| 63 optionsLink.setAttribute('href', extension.optionsPageHref); | |
| 64 optionsLink.addEventListener('click', function(e) { | |
| 65 chrome.send('extensionSettingsOptions', [extension.id]); | |
| 66 e.preventDefault(); | |
| 67 }); | |
| 68 | |
| 69 var optionsButton = options = node.querySelector('.options-button'); | |
| 70 optionsButton.addEventListener('click', function(e) { | |
| 71 this.showEmbeddedExtensionOptions_(extension.id, false); | |
| 72 e.preventDefault(); | |
| 73 }.bind(this)); | |
| 74 | |
| 75 // The 'Permissions' link. | |
| 76 var permissions = node.querySelector('.permissions-link'); | |
| 77 permissions.addEventListener('click', function(e) { | |
| 78 chrome.send('extensionSettingsPermissions', [extension.id]); | |
| 79 e.preventDefault(); | |
| 80 }); | |
| 81 | |
| 82 // The 'Reload' link. | |
| 83 var reload = node.querySelector('.reload-link'); | |
| 84 reload.addEventListener('click', function(e) { | |
| 85 chrome.send('extensionSettingsReload', [extension.id]); | |
| 86 extensionReloadedTimestamp[extension.id] = Date.now(); | |
| 87 }); | |
| 88 | |
| 89 // The 'Launch' link. | |
| 90 var launch = node.querySelector('.launch-link'); | |
| 91 launch.addEventListener('click', function(e) { | |
| 92 chrome.send('extensionSettingsLaunch', [extension.id]); | |
| 93 }); | |
| 94 | |
| 95 // The 'Reload' terminated link. | |
| 96 var terminatedReload = node.querySelector('.terminated-reload-link'); | |
| 97 terminatedReload.addEventListener('click', function(e) { | |
| 98 chrome.send('extensionSettingsReload', [extension.id]); | |
| 99 }); | |
| 100 | |
| 101 // The 'Repair' corrupted link. | |
| 102 var repair = node.querySelector('.corrupted-repair-button'); | |
| 103 repair.addEventListener('click', function(e) { | |
| 104 chrome.send('extensionSettingsRepair', [extension.id]); | |
| 105 }); | |
| 106 | |
| 107 // The 'Enabled' checkbox. | |
| 108 var enable = node.querySelector('.enable-checkbox'); | |
| 109 enable.addEventListener('click', function(e) { | |
| 110 // When e.target is the label instead of the checkbox, it doesn't | |
| 111 // have the checked property and the state of the checkbox is | |
| 112 // 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
| |
| 113 var checked = e.target.checked; | |
| 114 if (checked == undefined) | |
| 115 checked = !e.currentTarget.querySelector('input').checked; | |
| 116 chrome.send('extensionSettingsEnable', | |
| 117 [extension.id, checked ? 'true' : 'false']); | |
| 118 | |
| 119 // This may seem counter-intuitive (to not set/clear the checkmark) | |
| 120 // but this page will be updated asynchronously if the extension | |
| 121 // becomes enabled/disabled. It also might not become enabled or | |
| 122 // disabled, because the user might e.g. get prompted when enabling | |
| 123 // and choose not to. | |
| 124 e.preventDefault(); | |
| 125 }); | |
| 126 | |
| 127 // 'Remove' button. | |
| 128 var trashTemplate = $('template-collection').querySelector('.trash'); | |
| 129 var trash = trashTemplate.cloneNode(true); | |
| 130 trash.title = loadTimeData.getString('extensionUninstall'); | |
| 131 trash.addEventListener('click', function(e) { | |
| 132 butterBarVisibility[extension.id] = false; | |
| 133 chrome.send('extensionSettingsUninstall', [extension.id]); | |
| 134 }); | |
| 135 node.querySelector('.enable-controls').appendChild(trash); | |
| 136 | |
| 137 // Developer mode //////////////////////////////////////////////////////// | |
| 138 | |
| 139 // The path, if provided by unpacked extension. | |
| 140 var loadPath = node.querySelector('.load-path'); | |
| 141 var pathLink = loadPath.querySelector('a:nth-of-type(1)'); | |
| 142 pathLink.addEventListener('click', function(e) { | |
| 143 chrome.send('extensionSettingsShowPath', [String(extension.id)]); | |
| 144 e.preventDefault(); | |
| 145 }); | |
| 146 | |
| 147 this.appendChild(node); | |
| 148 this.updateNode_(extension, node); | |
| 149 }, | |
| OLD | NEW |