OLD | NEW |
1 // Copyright (c) 2011 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 /** | 5 /** |
6 * This variable structure is here to document the structure that the template | 6 * This variable structure is here to document the structure that the template |
7 * expects to correctly populate the page. | 7 * expects to correctly populate the page. |
8 */ | 8 */ |
9 var pluginDataFormat = { | 9 var pluginDataFormat = { |
10 'plugins': [ | 10 'plugins': [ |
11 { | 11 { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 bodyContainer.style.visibility = 'hidden'; | 118 bodyContainer.style.visibility = 'hidden'; |
119 body.className = ''; | 119 body.className = ''; |
120 var slidables = document.getElementsByClassName('showInTmiMode'); | 120 var slidables = document.getElementsByClassName('showInTmiMode'); |
121 for (var i = 0; i < slidables.length; i++) | 121 for (var i = 0; i < slidables.length; i++) |
122 slidables[i].style.height = 'auto'; | 122 slidables[i].style.height = 'auto'; |
123 | 123 |
124 renderTemplate(pluginsData); | 124 renderTemplate(pluginsData); |
125 | 125 |
126 // Add handlers to dynamically created HTML elements. | 126 // Add handlers to dynamically created HTML elements. |
127 var links = document.getElementsByClassName('disable-plugin-link'); | 127 var links = document.getElementsByClassName('disable-plugin-link'); |
128 for (var i = 0; i < links.length; ++i) { | 128 for (var i = 0; i < links.length; i++) { |
129 links[i].onclick = function () { | 129 links[i].onclick = function () { |
130 handleEnablePlugin(this, false, false); | 130 handleEnablePlugin(this, false, false); |
131 return false; | 131 return false; |
132 }; | 132 }; |
133 } | 133 } |
134 links = document.getElementsByClassName('enable-plugin-link'); | 134 links = document.getElementsByClassName('enable-plugin-link'); |
135 for (var i = 0; i < links.length; ++i) { | 135 for (var i = 0; i < links.length; i++) { |
136 links[i].onclick = function () { | 136 links[i].onclick = function () { |
137 handleEnablePlugin(this, true, false); | 137 handleEnablePlugin(this, true, false); |
138 return false; | 138 return false; |
139 }; | 139 }; |
140 } | 140 } |
141 links = document.getElementsByClassName('disable-group-link'); | 141 links = document.getElementsByClassName('disable-group-link'); |
142 for (var i = 0; i < links.length; ++i) { | 142 for (var i = 0; i < links.length; i++) { |
143 links[i].onclick = function () { | 143 links[i].onclick = function () { |
144 handleEnablePlugin(this, false, true); | 144 handleEnablePlugin(this, false, true); |
145 return false; | 145 return false; |
146 }; | 146 }; |
147 } | 147 } |
148 links = document.getElementsByClassName('enable-group-link'); | 148 links = document.getElementsByClassName('enable-group-link'); |
149 for (var i = 0; i < links.length; ++i) { | 149 for (var i = 0; i < links.length; i++) { |
150 links[i].onclick = function () { | 150 links[i].onclick = function () { |
151 handleEnablePlugin(this, true, true); | 151 handleEnablePlugin(this, true, true); |
152 return false; | 152 return false; |
153 }; | 153 }; |
154 } | 154 } |
| 155 var checkboxes = document.getElementsByClassName('always-allow'); |
| 156 for (var i = 0; i < checkboxes.length; i++) { |
| 157 checkboxes[i].onclick = function () { |
| 158 handleSetPluginAlwaysAllowed(this) |
| 159 }; |
| 160 }; |
155 | 161 |
156 // Make sure the left column (with "Description:", "Location:", etc.) is the | 162 // Make sure the left column (with "Description:", "Location:", etc.) is the |
157 // same size for all plugins. | 163 // same size for all plugins. |
158 var labels = document.getElementsByClassName('plugin-details-label'); | 164 var labels = document.getElementsByClassName('plugin-details-label'); |
159 var maxLabelWidth = 0; | 165 var maxLabelWidth = 0; |
160 for (var i = 0; i < labels.length; i++) | 166 for (var i = 0; i < labels.length; i++) |
161 labels[i].style.width = 'auto'; | 167 labels[i].style.width = 'auto'; |
162 for (var i = 0; i < labels.length; i++) | 168 for (var i = 0; i < labels.length; i++) |
163 maxLabelWidth = Math.max(maxLabelWidth, labels[i].offsetWidth); | 169 maxLabelWidth = Math.max(maxLabelWidth, labels[i].offsetWidth); |
164 for (var i = 0; i < labels.length; i++) | 170 for (var i = 0; i < labels.length; i++) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 tmiModeExpanded ? 'inline' : 'none'; | 208 tmiModeExpanded ? 'inline' : 'none'; |
203 document.getElementById('expand').style.display = | 209 document.getElementById('expand').style.display = |
204 tmiModeExpanded ? 'none' : 'inline'; | 210 tmiModeExpanded ? 'none' : 'inline'; |
205 | 211 |
206 document.body.className = | 212 document.body.className = |
207 tmiModeExpanded ? 'showTmiMode' : 'hideTmiMode'; | 213 tmiModeExpanded ? 'showTmiMode' : 'hideTmiMode'; |
208 | 214 |
209 chrome.send('saveShowDetailsToPrefs', [String(tmiModeExpanded)]); | 215 chrome.send('saveShowDetailsToPrefs', [String(tmiModeExpanded)]); |
210 } | 216 } |
211 | 217 |
| 218 function handleSetPluginAlwaysAllowed(el) { |
| 219 chrome.send('setPluginAlwaysAllowed', [el.identifier, el.checked]); |
| 220 } |
| 221 |
212 /** | 222 /** |
213 * Determines whether a plugin's version should be displayed. | 223 * Determines whether a plugin's version should be displayed. |
214 */ | 224 */ |
215 function shouldDisplayPluginVersion(plugin) { | 225 function shouldDisplayPluginVersion(plugin) { |
216 return !!plugin.version && plugin.version != '0'; | 226 return !!plugin.version && plugin.version != '0'; |
217 } | 227 } |
218 | 228 |
219 /** | 229 /** |
220 * Determines whether a plugin's description should be displayed. | 230 * Determines whether a plugin's description should be displayed. |
221 */ | 231 */ |
(...skipping 20 matching lines...) Expand all Loading... |
242 setInterval(requestPluginsData, 30000); | 252 setInterval(requestPluginsData, 30000); |
243 | 253 |
244 // Get data and have it displayed upon loading. | 254 // Get data and have it displayed upon loading. |
245 document.addEventListener('DOMContentLoaded', requestPluginsData); | 255 document.addEventListener('DOMContentLoaded', requestPluginsData); |
246 | 256 |
247 // Add handlers to static HTML elements. | 257 // Add handlers to static HTML elements. |
248 document.getElementById('collapse').onclick = toggleTmiMode; | 258 document.getElementById('collapse').onclick = toggleTmiMode; |
249 document.getElementById('expand').onclick = toggleTmiMode; | 259 document.getElementById('expand').onclick = toggleTmiMode; |
250 document.getElementById('details-link').onclick = toggleTmiMode; | 260 document.getElementById('details-link').onclick = toggleTmiMode; |
251 | 261 |
OLD | NEW |