| 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.showButtonHandler = 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 incognito.changeHandler = function(e) { |
| 24 var checked = e.target.checked; |
| 25 butterBarVisibility[extension.id] = checked; |
| 26 var butterBar = node.querySelector('.butter-bar'); |
| 27 butterBar.hidden = !checked || extension.is_hosted_app; |
| 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.changeHandler = 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.clickHandler = 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.clickHandler = 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.clickHanlder = function() { |
| 65 chrome.send('extensionSettingsOptions', [extension.id]); |
| 66 }; |
| 67 |
| 68 var optionsButton = options = node.querySelector('.options-button'); |
| 69 optionsButton.clickHanlder = function() { |
| 70 this.showEmbeddedExtensionOptions_(extension.id, false); |
| 71 }.bind(this); |
| 72 |
| 73 // The 'Permissions' link. |
| 74 var permissions = node.querySelector('.permissions-link'); |
| 75 permissions.addEventListener('click', function(e) { |
| 76 chrome.send('extensionSettingsPermissions', [extension.id]); |
| 77 e.preventDefault(); |
| 78 }); |
| 79 |
| 80 // The 'Reload' link. |
| 81 var reload = node.querySelector('.reload-link'); |
| 82 reload.clickHanlder = function(e) { |
| 83 chrome.send('extensionSettingsReload', [extension.id]); |
| 84 extensionReloadedTimestamp[extension.id] = Date.now(); |
| 85 }; |
| 86 |
| 87 // The 'Launch' link. |
| 88 var launch = node.querySelector('.launch-link'); |
| 89 launch.clickHandler = function(e) { |
| 90 chrome.send('extensionSettingsLaunch', [extension.id]); |
| 91 }; |
| 92 |
| 93 // The 'Reload' terminated link. |
| 94 var terminatedReload = node.querySelector('.terminated-reload-link'); |
| 95 terminatedReload.clickHandler = function() { |
| 96 chrome.send('extensionSettingsReload', [extension.id]); |
| 97 }; |
| 98 |
| 99 // The 'Repair' corrupted link. |
| 100 var repair = node.querySelector('.corrupted-repair-button'); |
| 101 repair.clickHandler = function() { |
| 102 chrome.send('extensionSettingsRepair', [extension.id]); |
| 103 }; |
| 104 |
| 105 // The 'Enabled' checkbox. |
| 106 var enable = node.querySelector('.enable-checkbox'); |
| 107 enable.clickHandler = function(e) { |
| 108 // When e.target is the label instead of the checkbox, it doesn't |
| 109 // have the checked property and the state of the checkbox is |
| 110 // left unchanged. |
| 111 var checked = e.target.checked; |
| 112 if (checked == undefined) |
| 113 checked = !e.currentTarget.querySelector('input').checked; |
| 114 chrome.send('extensionSettingsEnable', |
| 115 [extension.id, checked ? 'true' : 'false']); |
| 116 |
| 117 // This may seem counter-intuitive (to not set/clear the checkmark) |
| 118 // but this page will be updated asynchronously if the extension |
| 119 // becomes enabled/disabled. It also might not become enabled or |
| 120 // disabled, because the user might e.g. get prompted when enabling |
| 121 // and choose not to. |
| 122 e.preventDefault(); |
| 123 }; |
| 124 |
| 125 // 'Remove' button. |
| 126 var trashTemplate = $('template-collection').querySelector('.trash'); |
| 127 var trash = trashTemplate.cloneNode(true); |
| 128 trash.title = loadTimeData.getString('extensionUninstall'); |
| 129 trash.addEventListener('click', function(e) { |
| 130 butterBarVisibility[extension.id] = false; |
| 131 chrome.send('extensionSettingsUninstall', [extension.id]); |
| 132 }); |
| 133 node.querySelector('.enable-controls').appendChild(trash); |
| 134 |
| 135 // Developer mode //////////////////////////////////////////////////////// |
| 136 |
| 137 // Then the path, if provided by unpacked extension. |
| 138 var loadPath = node.querySelector('.load-path'); |
| 139 var pathLink = loadPath.querySelector('a:nth-of-type(1)'); |
| 140 pathLink.clickHandler = function(e) { |
| 141 chrome.send('extensionSettingsShowPath', [String(extension.id)]); |
| 142 e.preventDefault(); |
| 143 }; |
| 144 |
| 145 this.appendChild(node); |
| 146 this.updateNode_(extension, node); |
| 147 }, |
| OLD | NEW |