|
OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('options', function() { | |
6 /** | |
7 * Creates a new list of extensions. | |
8 * @param {Object=} opt_propertyBag Optional properties. | |
9 * @constructor | |
10 * @extends {cr.ui.div} | |
11 */ | |
12 var ExtensionsList = cr.ui.define('div'); | |
13 | |
14 var handleInstalled = false; | |
15 | |
16 ExtensionsList.prototype = { | |
17 __proto__: HTMLDivElement.prototype, | |
18 | |
19 /** @inheritDoc */ | |
20 decorate: function() { | |
21 this.InitControlsAndHandlers_(); | |
22 | |
23 var showingDetails = []; | |
24 var showingWarning = []; | |
25 this.DeleteExistingExtensionNodes_(showingDetails, showingWarning); | |
26 | |
27 this.ShowExtensionNodes_(showingDetails, showingWarning); | |
28 }, | |
29 | |
30 InitControlsAndHandlers_: function() { | |
csilv
2011/09/01 19:52:53
style nit: lower-case method name, initControlAndH
csilv
2011/09/01 19:52:53
Add jsdoc comments for this method and the next tw
Finnur
2011/09/02 13:58:47
Done.
| |
31 // Make sure developer mode section is set correctly as per saved setting. | |
32 var toggleButton = $('toggle-dev-on'); | |
33 var toggleSection = $('dev'); | |
34 if (this.data_.developerMode) { | |
35 toggleSection.classList.add('dev-open'); | |
36 toggleSection.classList.remove('dev-closed'); | |
37 toggleButton.setAttribute("checked", ""); | |
csilv
2011/09/01 19:52:53
could we use toggleButton.checked = true/false ins
csilv
2011/09/01 19:52:53
style nit: use single quotes for strings, here and
Finnur
2011/09/02 13:58:47
Done.
| |
38 } else { | |
39 toggleSection.classList.remove('dev-open'); | |
40 toggleSection.classList.add('dev-closed'); | |
41 } | |
42 | |
43 // Install handler for key presses. | |
44 if (!handleInstalled) { | |
45 document.addEventListener('keyup', this.upEventHandler_.bind(this)); | |
46 document.addEventListener('mouseup', this.upEventHandler_.bind(this)); | |
47 handleInstalled = true; | |
48 } | |
49 }, | |
50 | |
51 DeleteExistingExtensionNodes_: function(showingDetails, showingWarning) { | |
csilv
2011/09/01 19:52:53
style nit: lower-case method name, deleteExistingE
Finnur
2011/09/02 13:58:47
Done.
| |
52 // Delete all child nodes before adding them back and while we are at it | |
53 // make a note of which ones were in expanded state (and which showing | |
54 // the warning) so we can restore those to the same state afterwards. | |
55 while (this.hasChildNodes()){ | |
56 var child = this.firstChild; | |
57 | |
58 // See if the item is expanded. | |
59 if (child.className.indexOf('extensionListItemExpanded') >= 0) { | |
csilv
2011/09/01 19:52:53
simply to:
if (child.classList.contains('extension
Finnur
2011/09/02 13:58:47
Done.
| |
60 showingDetails.push(child.id); | |
61 } | |
62 // See if the butterbar is showing. | |
63 var butterBar = document.getElementById(child.id + "_incognitoWarning"); | |
64 if (!(butterBar === null) && butterBar.style.display == "block") { | |
csilv
2011/09/01 19:52:53
prefer hidden attribute over display for visibilit
Finnur
2011/09/02 13:58:47
Done.
| |
65 showingWarning.push(child.id); | |
66 } | |
67 | |
68 // Now we can delete it. | |
69 this.removeChild(child); | |
70 } | |
71 }, | |
72 | |
73 ShowExtensionNodes_: function(showingDetails, showingWarning) { | |
csilv
2011/09/01 19:52:53
style nit: lower-case method name, showExtensionNo
Finnur
2011/09/02 13:58:47
Done.
| |
74 // Keeps track of differences in checkbox width. | |
75 var minCheckboxWidth = 999999; | |
76 var maxCheckboxWidth = 0; | |
77 | |
78 // Iterate over the extension data and add each item to the list. | |
79 for (var i = 0; i < this.data_.extensions.length; ++i) { | |
80 var extension = this.data_.extensions[i]; | |
81 var id = extension.id; | |
82 | |
83 var wrapper = this.ownerDocument.createElement('div'); | |
84 | |
85 // Figure out if the item should open expanded or not based on the state | |
86 // of things before we deleted the items. | |
87 var iter = showingDetails.length; | |
88 var expanded = false; | |
89 while (iter--) { | |
90 if (showingDetails[iter] == id) { | |
91 expanded = true; | |
92 break; | |
93 } | |
94 } | |
95 // Figure out if the butterbar should be showing. | |
96 iter = showingWarning.length; | |
97 var butterbar = false; | |
98 while (iter--) { | |
99 if (showingWarning[iter] == id) { | |
100 butterbar = true; | |
101 break; | |
102 } | |
103 } | |
104 | |
105 wrapper.classList.add(expanded ? 'extensionListItemExpanded' : | |
106 'extensionListItemCollapsed'); | |
107 if (!extension.enabled) { | |
csilv
2011/09/01 19:52:53
style nit: no need for brackets for single line, h
Finnur
2011/09/02 13:58:47
Done.
| |
108 wrapper.classList.add('disabled'); | |
109 } | |
110 wrapper.id = id; | |
111 this.appendChild(wrapper); | |
112 | |
113 var vbox_outer = this.ownerDocument.createElement('div'); | |
114 vbox_outer.classList.add('vbox'); | |
115 vbox_outer.classList.add('extensionListItem'); | |
116 wrapper.appendChild(vbox_outer); | |
117 | |
118 var hbox = this.ownerDocument.createElement('div'); | |
119 hbox.classList.add('hbox'); | |
120 vbox_outer.appendChild(hbox); | |
121 | |
122 // Add a container div for the zippy, so we can extend the hit area. | |
123 var container = this.ownerDocument.createElement('div'); | |
124 // Clicking anywhere on the div expands/collapses the details. | |
125 container.classList.add('extension-zippy-container'); | |
126 container.addEventListener('click', this.handleZippyClick_.bind(this)); | |
127 hbox.appendChild(container); | |
128 | |
129 // On the far left we have the zippy icon. | |
130 div = this.ownerDocument.createElement('div'); | |
131 div.id = id + '_zippy'; | |
132 div.classList.add('extension-zippy-default'); | |
133 div.classList.add(expanded ? 'extension-zippy-expanded' : | |
134 'extension-zippy-collapsed'); | |
135 container.appendChild(div); | |
136 | |
137 // Next to it, we have the extension icon. | |
138 icon = this.ownerDocument.createElement('img'); | |
139 icon.classList.add('extension-icon'); | |
140 icon.src = extension.icon; | |
141 hbox.appendChild(icon); | |
142 | |
143 // Start a vertical box for showing the details. | |
144 var vbox = this.ownerDocument.createElement('div'); | |
145 vbox.classList.add('vbox'); | |
146 vbox.classList.add('stretch'); | |
147 hbox.appendChild(vbox); | |
148 | |
149 div = this.ownerDocument.createElement('div'); | |
150 vbox.appendChild(div); | |
151 | |
152 // Title comes next. | |
153 var title = this.ownerDocument.createElement('span'); | |
154 title.classList.add('extension-title'); | |
155 title.textContent = extension.name; | |
156 vbox.appendChild(title); | |
157 | |
158 // Followed by version. | |
159 var version = this.ownerDocument.createElement('span'); | |
160 version.classList.add('extension-version'); | |
161 version.textContent = extension.version; | |
162 vbox.appendChild(version); | |
163 | |
164 div = this.ownerDocument.createElement('div'); | |
165 vbox.appendChild(div); | |
166 | |
167 // And below that we have description (if provided). | |
168 if (extension.description.length > 0) { | |
169 var description = this.ownerDocument.createElement('span'); | |
170 description.classList.add('extension-description'); | |
171 description.textContent = extension.description; | |
172 vbox.appendChild(description); | |
173 } | |
174 | |
175 // Immediately following the description, we have the | |
176 // Options link (optional). | |
177 if (extension.options_url) { | |
178 var link = this.ownerDocument.createElement('a'); | |
179 link.classList.add('extension-links-trailing'); | |
180 link.textContent = localStrings.getString('options'); | |
181 link.href = "#"; | |
182 link.addEventListener('click', this.handleOptions_.bind(this)); | |
183 vbox.appendChild(link); | |
184 } | |
185 | |
186 // Then the optional Visit Website link. | |
187 if (extension.homepageUrl) { | |
188 var link = this.ownerDocument.createElement('a'); | |
189 link.classList.add('extension-links-trailing'); | |
190 link.textContent = localStrings.getString("visitWebsite"); | |
191 link.href = "#"; | |
192 link.addEventListener('click', this.handleVisitWebsite_.bind(this)); | |
193 vbox.appendChild(link); | |
194 } | |
195 | |
196 // And now the details section that is normally hidden. | |
197 var details = this.ownerDocument.createElement('div'); | |
198 details.classList.add('vbox'); | |
199 vbox.appendChild(details); | |
200 | |
201 this.decorateDetailsSection_(details, extension, expanded, butterbar); | |
202 | |
203 // And on the right of the details we have the Enable/Enabled checkbox. | |
204 div = this.ownerDocument.createElement('div'); | |
205 hbox.appendChild(div); | |
206 | |
207 var section = this.ownerDocument.createElement('section'); | |
208 section.classList.add('extension-enabling'); | |
209 div.appendChild(section); | |
210 | |
211 // The Enable checkbox. | |
212 var input = this.ownerDocument.createElement('input'); | |
213 input.addEventListener('click', this.handleEnable_.bind(this)); | |
214 input.type = "checkbox"; | |
215 input.name = "toggle-" + id; | |
216 if (!extension.mayDisable) { | |
217 input.setAttribute("disabled", ""); | |
csilv
2011/09/01 19:52:53
input.disabled = true/false (here and below)
Finnur
2011/09/02 13:58:47
Done.
| |
218 } | |
219 if (extension.enabled) { | |
220 input.setAttribute("checked", ""); | |
csilv
2011/09/01 19:52:53
input.checked = true/false (here and below)
Finnur
2011/09/02 13:58:47
Done.
| |
221 } | |
222 input.id = "toggle-" + id; | |
223 section.appendChild(input); | |
224 var label = this.ownerDocument.createElement('label'); | |
225 label.classList.add('extension-enabling-label'); | |
226 if (extension.enabled) { | |
227 label.classList.add('extension-enabling-label-bold'); | |
228 } | |
229 label.setAttribute("for", "toggle-" + id); | |
230 label.id = "toggle-" + id + "-label"; | |
231 if (extension.enabled) { | |
232 label.textContent = localStrings.getString("enabled"); | |
233 } else { | |
234 label.textContent = localStrings.getString("enable"); | |
235 } | |
236 section.appendChild(label); | |
237 | |
238 if (label.offsetWidth > maxCheckboxWidth) | |
239 maxCheckboxWidth = label.offsetWidth; | |
240 if (label.offsetWidth < minCheckboxWidth) | |
241 minCheckboxWidth = label.offsetWidth; | |
242 | |
243 // And, on the far right we have the uninstall button. | |
244 var button = this.ownerDocument.createElement('button'); | |
245 button.classList.add('extension-delete'); | |
246 button.id = id; | |
247 if (!extension.mayDisable) { | |
248 button.setAttribute("disabled", ""); | |
249 } | |
250 button.textContent = localStrings.getString("remove"); | |
251 button.addEventListener('click', this.handleUninstall_.bind(this)); | |
252 hbox.appendChild(button); | |
253 } | |
254 | |
255 // Do another pass, making sure checkboxes line up. | |
256 var difference = maxCheckboxWidth - minCheckboxWidth; | |
257 for (var i = 0; i < this.data_.extensions.length; ++i) { | |
258 var extension = this.data_.extensions[i]; | |
259 var id = extension.id; | |
260 var label = $("toggle-" + id + "-label"); | |
261 if (label.offsetWidth < maxCheckboxWidth) { | |
262 label.setAttribute("style", "margin-right: " + | |
csilv
2011/09/01 19:52:53
lable.style.marginRight = ...
Finnur
2011/09/02 13:58:47
Done.
| |
263 difference.toString() + "px;"); | |
264 } | |
265 } | |
266 }, | |
267 | |
268 /** | |
269 * Handles decorating the details section. | |
270 * @param {Element} details The div that the details should be attached to. | |
271 * @param {Object} extension The extension we are shoting the details for. | |
272 * @param {boolean} expanded Whether to show the details expanded or not. | |
273 * @param {boolean} showButterbar Whether to show the incognito warning or | |
274 * not. | |
275 * @private | |
276 */ | |
277 decorateDetailsSection_: function(details, extension, | |
278 expanded, showButterbar) { | |
279 // This container div is needed because vbox display | |
280 // overrides display:hidden. | |
281 var details_contents = this.ownerDocument.createElement('div'); | |
282 details_contents.classList.add(expanded ? 'extension-details-visible' : | |
283 'extension-details-hidden'); | |
284 details_contents.id = extension.id + '_details'; | |
285 details.appendChild(details_contents); | |
286 | |
287 var div = this.ownerDocument.createElement('div'); | |
288 div.classList.add('gray-text'); | |
289 details_contents.appendChild(div); | |
290 | |
291 // Keep track of how many items we'll show in the details section. | |
292 var itemsShown = 0; | |
293 | |
294 if (this.data_.developerMode) { | |
295 // First we have the id. | |
296 var content = this.ownerDocument.createElement('div'); | |
297 content.textContent = localStrings.getString("extensionId") + | |
298 " " + extension.id; | |
299 div.appendChild(content); | |
300 itemsShown++; | |
301 | |
302 // Then, the path, if provided by unpacked extension. | |
303 if (extension.isUnpacked) { | |
304 content = this.ownerDocument.createElement('div'); | |
305 content.textContent = localStrings.getString("extensionPath") + | |
306 " " + extension.path; | |
307 div.appendChild(content); | |
308 itemsShown++; | |
309 } | |
310 | |
311 // Then, the 'managed, cannot uninstall/disable' message. | |
312 if (!extension.mayDisable) { | |
313 content = this.ownerDocument.createElement('div'); | |
314 content.textContent = localStrings.getString("policyControlled"); | |
315 div.appendChild(content); | |
316 itemsShown++; | |
317 } | |
318 | |
319 // Then active views: | |
320 if (extension.views.length > 0) { | |
321 var table = this.ownerDocument.createElement('table'); | |
322 table.classList.add('extension-inspect-table'); | |
323 div.appendChild(table); | |
324 var tr = this.ownerDocument.createElement('tr'); | |
325 table.appendChild(tr); | |
326 var td = this.ownerDocument.createElement('td'); | |
327 td.classList.add('extension-inspect-left-column'); | |
328 tr.appendChild(td); | |
329 var span = this.ownerDocument.createElement('span'); | |
330 td.appendChild(span); | |
331 span.textContent = localStrings.getString("inspectViews"); | |
332 | |
333 td = this.ownerDocument.createElement('td'); | |
334 for (var i = 0; i < extension.views.length; ++i) { | |
335 // Then active views: | |
336 content = this.ownerDocument.createElement('div'); | |
337 var link = this.ownerDocument.createElement('a'); | |
338 link.classList.add('extension-links-view'); | |
339 link.textContent = extension.views[i].path; | |
340 link.id = extension.id; | |
341 link.href = "#"; | |
342 link.addEventListener('click', this.sendInspectMessage_.bind(this)); | |
343 content.appendChild(link); | |
344 td.appendChild(content); | |
345 tr.appendChild(td); | |
346 | |
347 itemsShown++; | |
348 } | |
349 } | |
350 } | |
351 | |
352 content = this.ownerDocument.createElement('div'); | |
csilv
2011/09/01 19:52:53
var content =
Finnur
2011/09/02 13:58:47
Seriously? :) Don't tell my you found this without
| |
353 details_contents.appendChild(content); | |
354 | |
355 // Then Reload: | |
356 if (extension.enabled && extension.allow_reload) { | |
357 var link = this.ownerDocument.createElement('a'); | |
358 link.classList.add('extension-links-trailing'); | |
359 link.textContent = localStrings.getString('reload'); | |
360 link.id = extension.id; | |
361 link.href = "#"; | |
362 link.addEventListener('click', this.handleReload_.bind(this)); | |
363 content.appendChild(link); | |
364 itemsShown++; | |
365 } | |
366 | |
367 // Then Show (Browser Action) Button: | |
368 if (extension.enabled && extension.enable_show_button) { | |
369 link = this.ownerDocument.createElement('a'); | |
370 link.classList.add('extension-links-trailing'); | |
371 link.textContent = localStrings.getString('showButton'); | |
372 link.id = extension.id; | |
373 link.href = "#"; | |
374 link.addEventListener('click', this.handleShowButton_.bind(this)); | |
375 content.appendChild(link); | |
376 itemsShown++; | |
377 } | |
378 | |
379 if (extension.enabled && !extension.wantsFileAccess) { | |
380 // The 'allow in incognito' checkbox. | |
381 var label = this.ownerDocument.createElement('label'); | |
382 label.classList.add('extension-checkbox-label'); | |
383 content.appendChild(label); | |
384 var input = this.ownerDocument.createElement('input'); | |
385 input.addEventListener('click', | |
386 this.handleToggleEnableIncognito_.bind(this)); | |
387 input.id = extension.id; | |
388 input.type = "checkbox"; | |
389 if (extension.enabledIncognito) { | |
390 input.setAttribute("checked", ""); | |
391 } | |
392 label.appendChild(input); | |
393 var span = this.ownerDocument.createElement('span'); | |
394 span.classList.add('extension-checkbox-span'); | |
395 span.textContent = localStrings.getString('enableIncognito'); | |
396 label.appendChild(span); | |
397 itemsShown++; | |
398 } | |
399 | |
400 if (extension.enabled && !extension.wantsFileAccess) { | |
401 // The 'allow access to file URLs' checkbox. | |
402 label = this.ownerDocument.createElement('label'); | |
403 label.classList.add('extension-checkbox-label'); | |
404 content.appendChild(label); | |
405 var input = this.ownerDocument.createElement('input'); | |
406 input.addEventListener('click', | |
407 this.handleToggleAllowFileUrls_.bind(this)); | |
408 input.id = extension.id; | |
409 input.type = "checkbox"; | |
410 if (extension.allowFileAccess) { | |
411 input.setAttribute("checked", ""); | |
412 } | |
413 label.appendChild(input); | |
414 var span = this.ownerDocument.createElement('span'); | |
415 span.classList.add('extension-checkbox-span'); | |
416 span.textContent = localStrings.getString('allowFileAccess'); | |
417 label.appendChild(span); | |
418 itemsShown++; | |
419 } | |
420 | |
421 if (extension.enabled && !extension.is_hosted_app) { | |
422 // And add a hidden warning message for allowInIncognito. | |
423 content = this.ownerDocument.createElement('div'); | |
424 content.id = extension.id + "_incognitoWarning"; | |
425 content.classList.add('butter-bar'); | |
426 content.style.display = showButterbar ? "block" : "none"; | |
427 details_contents.appendChild(content); | |
428 | |
429 var span = this.ownerDocument.createElement('span'); | |
430 span.innerHTML = localStrings.getString('incognitoWarning'); | |
431 content.appendChild(span); | |
432 itemsShown++; | |
433 } | |
434 | |
435 var zippy = extension.id + "_zippy"; | |
436 $(zippy).style.display = (itemsShown > 0) ? "block" : "none"; | |
437 }, | |
438 | |
439 /** | |
440 * A lookup helper function to find an extension based on an id. | |
441 * @param {string} id The |id| of the extension to look up. | |
442 * @private | |
443 */ | |
444 getExtensionWithId_: function(id) { | |
445 for (var i = 0; i < this.data_.extensions.length; ++i) { | |
446 if (this.data_.extensions[i].id == id) | |
447 return this.data_.extensions[i]; | |
448 } | |
449 return null; | |
450 }, | |
451 | |
452 /** | |
453 * A lookup helper function to find the first node that has an id (starting | |
454 * at |node| and going up the parent chain. | |
455 * @param {Element} node The node to start looking at. | |
456 * @private | |
457 */ | |
458 findIdNode_: function(node) { | |
459 while (node.id.length == 0) { | |
460 node = node.parentNode; | |
461 if (!node) | |
462 return null; | |
463 } | |
464 return node; | |
465 }, | |
466 | |
467 /** | |
468 * Handles the mouseclick on the zippy icon (that expands and collapses the | |
469 * details section). | |
470 * @param {Event} e Change event. | |
471 * @private | |
472 */ | |
473 handleZippyClick_: function(e) { | |
474 var node = this.findIdNode_(e.target.parentNode); | |
475 var iter = this.firstChild; | |
476 while (iter) { | |
477 var zippy = this.ownerDocument.getElementById(iter.id + '_zippy'); | |
csilv
2011/09/01 19:52:53
var zippy = $(iter.id + '_zippy');
Finnur
2011/09/02 13:58:47
Done.
| |
478 var details = this.ownerDocument.getElementById(iter.id + '_details'); | |
csilv
2011/09/01 19:52:53
var details = $(iter.id + '_details');
Finnur
2011/09/02 13:58:47
Done.
| |
479 if (iter.id == node.id) { | |
480 // Toggle visibility. | |
481 if (iter.classList.contains('extensionListItemExpanded')) { | |
482 // Hide yo kids! Hide yo wife! | |
483 zippy.classList.remove('extension-zippy-expanded'); | |
484 zippy.classList.add('extension-zippy-collapsed'); | |
485 details.classList.remove('extension-details-visible'); | |
486 details.classList.add('extension-details-hidden'); | |
487 iter.classList.remove('extensionListItemExpanded'); | |
488 iter.classList.add('extensionListItemCollapsed'); | |
489 | |
490 // Hide yo incognito warning. | |
491 var butterBar = this.ownerDocument.getElementById( | |
492 iter.id + '_incognitoWarning'); | |
493 if (!(butterBar === null)) { | |
494 butterBar.style.display = "none"; | |
csilv
2011/09/01 19:52:53
butterBar.hidden = true;
Finnur
2011/09/02 13:58:47
Done.
| |
495 } | |
496 } else { | |
497 // Show the contents. | |
498 zippy.classList.remove('extension-zippy-collapsed'); | |
499 zippy.classList.add('extension-zippy-expanded'); | |
500 details.classList.remove('extension-details-hidden'); | |
501 details.classList.add('extension-details-visible'); | |
502 iter.classList.remove('extensionListItemCollapsed'); | |
503 iter.classList.add('extensionListItemExpanded'); | |
504 } | |
505 } | |
506 iter = iter.nextSibling; | |
507 } | |
508 }, | |
509 | |
510 /** | |
511 * Handles the mouse-up and keyboard-up events. This is used to limit the | |
512 * number of items to show in the list, when the user is searching for items | |
513 * with the search box. Otherwise, if one match is found, the whole list of | |
514 * extensions would be shown when we only want the matching items to be | |
515 * found. | |
516 * @param {Event} e Change event. | |
517 * @private | |
518 */ | |
519 upEventHandler_: function(e) { | |
520 var searchString = | |
521 document.getElementById('search-field').value.toLowerCase(); | |
csilv
2011/09/01 19:52:53
$('search-field').value.toLowerCase();
Finnur
2011/09/02 13:58:47
Done.
| |
522 var child = this.firstChild; | |
523 while (child){ | |
524 var extension = this.getExtensionWithId_(child.id); | |
525 if (searchString.length == 0) { | |
526 // Show all. | |
527 child.classList.remove('search-suppress'); | |
528 } else { | |
529 // If the search string does not appear within the text of the | |
530 // extension, then hide it. | |
531 if ((extension.name.toLowerCase().indexOf(searchString) < 0) && | |
532 (extension.version.toLowerCase().indexOf(searchString) < 0) && | |
533 (extension.description.toLowerCase().indexOf(searchString) < 0)) { | |
534 // Hide yo extension! | |
535 child.classList.add('search-suppress'); | |
536 } else { | |
537 // Show yourself! | |
538 child.classList.remove('search-suppress'); | |
539 } | |
540 } | |
541 child = child.nextSibling; | |
542 } | |
543 }, | |
544 | |
545 /** | |
546 * Handles the Reload Extension functionality. | |
547 * @param {Event} e Change event. | |
548 * @private | |
549 */ | |
550 handleReload_: function(e) { | |
551 var node = this.findIdNode_(e.target); | |
552 chrome.send('reload', [node.id]); | |
553 }, | |
554 | |
555 /** | |
556 * Handles the Show (Browser Action) Button functionality. | |
557 * @param {Event} e Change event. | |
558 * @private | |
559 */ | |
560 handleShowButton_: function(e) { | |
561 var node = this.findIdNode_(e.target); | |
562 chrome.send('showButton', [node.id]); | |
563 }, | |
564 | |
565 /** | |
566 * Handles the Enable/Disable Extension functionality. | |
567 * @param {Event} e Change event. | |
568 * @private | |
569 */ | |
570 handleEnable_: function(e) { | |
571 var node = this.findIdNode_(e.target.parentNode); | |
572 var extension = this.getExtensionWithId_(node.id); | |
573 chrome.send('enable', | |
574 [node.id, extension.enabled ? "false" : "true"]); | |
575 chrome.send('requestExtensionsData'); | |
576 }, | |
577 | |
578 /** | |
579 * Handles the Uninstall Extension functionality. | |
580 * @param {Event} e Change event. | |
581 * @private | |
582 */ | |
583 handleUninstall_: function(e) { | |
584 var node = this.findIdNode_(e.target.parentNode); | |
585 chrome.send('uninstall', [node.id]); | |
586 chrome.send('requestExtensionsData'); | |
587 }, | |
588 | |
589 /** | |
590 * Handles the View Options link. | |
591 * @param {Event} e Change event. | |
592 * @private | |
593 */ | |
594 handleOptions_: function(e) { | |
595 var node = this.findIdNode_(e.target.parentNode); | |
596 var extension = this.getExtensionWithId_(node.id); | |
597 chrome.send('options', [extension.id]); | |
598 }, | |
599 | |
600 /** | |
601 * Handles the Visit Extension Website link. | |
602 * @param {Event} e Change event. | |
603 * @private | |
604 */ | |
605 handleVisitWebsite_: function(e) { | |
606 var node = this.findIdNode_(e.target.parentNode); | |
607 var extension = this.getExtensionWithId_(node.id); | |
608 document.location = extension.homepageUrl; | |
609 }, | |
610 | |
611 /** | |
612 * Handles the Enable Extension In Incognito functionality. | |
613 * @param {Event} e Change event. | |
614 * @private | |
615 */ | |
616 handleToggleEnableIncognito_: function(e) { | |
617 var node = this.findIdNode_(e.target); | |
618 var butterBar = document.getElementById(node.id + "_incognitoWarning"); | |
619 if (e.target.checked) { | |
620 if (butterBar.style.display == "none") { | |
csilv
2011/09/01 19:52:53
butterBar.hidden = true/false (here and below)
Finnur
2011/09/02 13:58:47
Done.
| |
621 butterBar.style.display = "block"; | |
622 } | |
623 } else { | |
624 if (butterBar.style.display == "block") { | |
625 butterBar.style.display = "none"; | |
626 } | |
627 } | |
628 | |
629 chrome.send('enableIncognito', [node.id, String(e.target.checked)]); | |
630 }, | |
631 | |
632 /** | |
633 * Handles the Allow On File URLs functionality. | |
634 * @param {Event} e Change event. | |
635 * @private | |
636 */ | |
637 handleToggleAllowFileUrls_: function(e) { | |
638 var node = this.findIdNode_(e.target); | |
639 chrome.send('allowFileAccess', [node.id, String(e.target.checked)]); | |
640 }, | |
641 | |
642 /** | |
643 * Tell the C++ ExtensionDOMHandler to inspect the page detailed in | |
644 * |viewData|. | |
645 * @param {Event} e Change event. | |
646 * @private | |
647 */ | |
648 sendInspectMessage_: function(e) { | |
649 var extension = this.getExtensionWithId_(e.srcElement.id); | |
650 for (var i = 0; i < extension.views.length; ++i) { | |
651 if (extension.views[i].path == e.srcElement.innerText) { | |
652 // TODO(aa): This is ghetto, but WebUIBindings doesn't support sending | |
653 // anything other than arrays of strings, and this is all going to get | |
654 // replaced with V8 extensions soon anyway. | |
655 chrome.send('inspect', [ | |
656 String(extension.views[i].renderProcessId), | |
657 String(extension.views[i].renderViewId) | |
658 ]); | |
659 } | |
660 } | |
661 }, | |
662 }; | |
663 | |
664 return { | |
665 ExtensionsList: ExtensionsList | |
666 }; | |
667 }); | |
OLD | NEW |