| OLD | NEW |
| 1 // Copyright (c) 2012 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 * Takes the |pluginsData| input argument which represents data about the | 6 * Takes the |pluginsData| input argument which represents data about the |
| 7 * currently installed/running plugins and populates the html jstemplate with | 7 * currently installed/running plugins and populates the html jstemplate with |
| 8 * that data. | 8 * that data. |
| 9 * @param {Object} pluginsData Detailed info about installed plugins. Same | 9 * @param {Object} pluginsData Detailed info about installed plugins. Same |
| 10 * expected format as returnPluginsData(). | 10 * expected format as returnPluginsData(). |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Set all page content to be visible so we can measure heights. | 96 // Set all page content to be visible so we can measure heights. |
| 97 bodyContainer.style.visibility = 'hidden'; | 97 bodyContainer.style.visibility = 'hidden'; |
| 98 body.className = ''; | 98 body.className = ''; |
| 99 var slidables = document.getElementsByClassName('show-in-tmi-mode'); | 99 var slidables = document.getElementsByClassName('show-in-tmi-mode'); |
| 100 for (var i = 0; i < slidables.length; i++) | 100 for (var i = 0; i < slidables.length; i++) |
| 101 slidables[i].style.height = 'auto'; | 101 slidables[i].style.height = 'auto'; |
| 102 | 102 |
| 103 renderTemplate(pluginsData); | 103 renderTemplate(pluginsData); |
| 104 | 104 |
| 105 // Add handlers to dynamically created HTML elements. | 105 // Add handlers to dynamically created HTML elements. |
| 106 var links = document.getElementsByClassName('disable-plugin-link'); | |
| 107 for (var i = 0; i < links.length; i++) { | |
| 108 links[i].onclick = function() { | |
| 109 handleEnablePlugin(this, false, false); | |
| 110 return false; | |
| 111 }; | |
| 112 } | |
| 113 links = document.getElementsByClassName('enable-plugin-link'); | |
| 114 for (var i = 0; i < links.length; i++) { | |
| 115 links[i].onclick = function() { | |
| 116 handleEnablePlugin(this, true, false); | |
| 117 return false; | |
| 118 }; | |
| 119 } | |
| 120 links = document.getElementsByClassName('disable-group-link'); | |
| 121 for (var i = 0; i < links.length; i++) { | |
| 122 links[i].onclick = function() { | |
| 123 handleEnablePlugin(this, false, true); | |
| 124 return false; | |
| 125 }; | |
| 126 } | |
| 127 links = document.getElementsByClassName('enable-group-link'); | |
| 128 for (var i = 0; i < links.length; i++) { | |
| 129 links[i].onclick = function() { | |
| 130 handleEnablePlugin(this, true, true); | |
| 131 return false; | |
| 132 }; | |
| 133 } | |
| 134 var checkboxes = document.getElementsByClassName('always-allow'); | 106 var checkboxes = document.getElementsByClassName('always-allow'); |
| 135 for (var i = 0; i < checkboxes.length; i++) { | 107 for (var i = 0; i < checkboxes.length; i++) { |
| 136 checkboxes[i].onclick = function() { | 108 checkboxes[i].onclick = function() { |
| 137 handleSetPluginAlwaysAllowed(this); | 109 handleSetPluginAlwaysAllowed(this); |
| 138 }; | 110 }; |
| 139 } | 111 } |
| 140 | 112 |
| 141 if (cr.isChromeOS) { | 113 if (cr.isChromeOS) { |
| 142 // Disable some controls for Guest in ChromeOS. | 114 // Disable some controls for Guest in ChromeOS. |
| 143 uiAccountTweaks.UIAccountTweaks.applyGuestSessionVisibility(document); | 115 uiAccountTweaks.UIAccountTweaks.applyGuestSessionVisibility(document); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 165 // Reset visibility of page based on the current tmi mode. | 137 // Reset visibility of page based on the current tmi mode. |
| 166 $('collapse').style.display = | 138 $('collapse').style.display = |
| 167 tmiModeExpanded ? 'inline' : 'none'; | 139 tmiModeExpanded ? 'inline' : 'none'; |
| 168 $('expand').style.display = | 140 $('expand').style.display = |
| 169 tmiModeExpanded ? 'none' : 'inline'; | 141 tmiModeExpanded ? 'none' : 'inline'; |
| 170 bodyContainer.style.visibility = 'visible'; | 142 bodyContainer.style.visibility = 'visible'; |
| 171 body.className = tmiModeExpanded ? | 143 body.className = tmiModeExpanded ? |
| 172 'show-tmi-mode-initial' : 'hide-tmi-mode-initial'; | 144 'show-tmi-mode-initial' : 'hide-tmi-mode-initial'; |
| 173 } | 145 } |
| 174 | 146 |
| 175 /** | |
| 176 * Handles a 'enable' or 'disable' button getting clicked. | |
| 177 * @param {HTMLElement} node The HTML element for the plugin being changed. | |
| 178 * @param {boolean} enable Whether to enable or disable the plugin. | |
| 179 * @param {boolean} isGroup True if we're enabling/disabling a plugin group, | |
| 180 * rather than a single plugin. | |
| 181 */ | |
| 182 function handleEnablePlugin(node, enable, isGroup) { | |
| 183 if (isGroup) | |
| 184 browserProxy.setPluginGroupEnabled(node.path, enable); | |
| 185 else | |
| 186 browserProxy.setPluginEnabled(node.path, enable); | |
| 187 } | |
| 188 | |
| 189 /* | 147 /* |
| 190 * Toggles visibility of details. | 148 * Toggles visibility of details. |
| 191 */ | 149 */ |
| 192 function toggleTmiMode() { | 150 function toggleTmiMode() { |
| 193 tmiModeExpanded = !tmiModeExpanded; | 151 tmiModeExpanded = !tmiModeExpanded; |
| 194 | 152 |
| 195 $('collapse').style.display = | 153 $('collapse').style.display = |
| 196 tmiModeExpanded ? 'inline' : 'none'; | 154 tmiModeExpanded ? 'inline' : 'none'; |
| 197 $('expand').style.display = | 155 $('expand').style.display = |
| 198 tmiModeExpanded ? 'none' : 'inline'; | 156 tmiModeExpanded ? 'none' : 'inline'; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 285 |
| 328 // Unfortunately, we don't have notifications for plugin (list) status | 286 // Unfortunately, we don't have notifications for plugin (list) status |
| 329 // changes (yet), so in the meanwhile just update regularly. | 287 // changes (yet), so in the meanwhile just update regularly. |
| 330 setInterval(function() { | 288 setInterval(function() { |
| 331 browserProxy.getPluginsData().then(returnPluginsData); | 289 browserProxy.getPluginsData().then(returnPluginsData); |
| 332 }, 30000); | 290 }, 30000); |
| 333 }); | 291 }); |
| 334 } | 292 } |
| 335 | 293 |
| 336 document.addEventListener('DOMContentLoaded', main); | 294 document.addEventListener('DOMContentLoaded', main); |
| OLD | NEW |