Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/resources/plugins.js

Issue 1576183003: chrome://plugins Mojo-ification part 2/2, populating the page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plugins_mojo1
Patch Set: More work Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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. It expects an object structure like the above. 8 * that data. It expects an object structure like the above.
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 /** 195 /**
196 * Handles a 'enable' or 'disable' button getting clicked. 196 * Handles a 'enable' or 'disable' button getting clicked.
197 * @param {HTMLElement} node The HTML element for the plugin being changed. 197 * @param {HTMLElement} node The HTML element for the plugin being changed.
198 * @param {boolean} enable Whether to enable or disable the plugin. 198 * @param {boolean} enable Whether to enable or disable the plugin.
199 * @param {boolean} isGroup True if we're enabling/disabling a plugin group, 199 * @param {boolean} isGroup True if we're enabling/disabling a plugin group,
200 * rather than a single plugin. 200 * rather than a single plugin.
201 */ 201 */
202 function handleEnablePlugin(node, enable, isGroup) { 202 function handleEnablePlugin(node, enable, isGroup) {
203 // Tell the C++ PluginsDOMHandler to enable/disable the plugin. 203 // Tell the C++ PluginsDOMHandler to enable/disable the plugin.
204 chrome.send('enablePlugin', [String(node.path), String(enable), 204 whenBrowserProxyReady.then(function(browserProxy) {
205 String(isGroup)]); 205 isGroup ?
206 browserProxy.setPluginGroupEnabled(node.path, enable) :
207 browserProxy.setPluginEnabled(node.path, enable);
208 });
209 //chrome.send('enablePlugin', [String(node.path), String(enable),
210 // String(isGroup)]);
206 } 211 }
207 212
208 // Keeps track of whether details have been made visible (expanded) or not. 213 // Keeps track of whether details have been made visible (expanded) or not.
209 var tmiModeExpanded = false; 214 var tmiModeExpanded = false;
210 215
211 /* 216 /*
212 * Toggles visibility of details. 217 * Toggles visibility of details.
213 */ 218 */
214 function toggleTmiMode() { 219 function toggleTmiMode() {
215 tmiModeExpanded = !tmiModeExpanded; 220 tmiModeExpanded = !tmiModeExpanded;
216 221
217 $('collapse').style.display = 222 $('collapse').style.display =
218 tmiModeExpanded ? 'inline' : 'none'; 223 tmiModeExpanded ? 'inline' : 'none';
219 $('expand').style.display = 224 $('expand').style.display =
220 tmiModeExpanded ? 'none' : 'inline'; 225 tmiModeExpanded ? 'none' : 'inline';
221 226
222 document.body.className = 227 document.body.className =
223 tmiModeExpanded ? 'show-tmi-mode' : 'hide-tmi-mode'; 228 tmiModeExpanded ? 'show-tmi-mode' : 'hide-tmi-mode';
224 229
225 chrome.send('saveShowDetailsToPrefs', [String(tmiModeExpanded)]); 230 whenBrowserProxyReady.then(function(browserProxy) {
231 browserProxy.saveShowDetailsToPrefs(tmiModeExpanded);
232 });
233 //chrome.send('saveShowDetailsToPrefs', [String(tmiModeExpanded)]);
226 } 234 }
227 235
228 function handleSetPluginAlwaysAllowed(el) { 236 function handleSetPluginAlwaysAllowed(el) {
229 chrome.send('setPluginAlwaysAllowed', [el.identifier, el.checked]); 237 whenBrowserProxyReady.then(function(browserProxy) {
238 browserProxy.setPluginAlwaysAllowed(el.identifier, el.checked);
239 });
240 //chrome.send('setPluginAlwaysAllowed', [el.identifier, el.checked]);
230 } 241 }
231 242
232 /** 243 /**
233 * @param {Object} plugin An object containing the information about a plugin. 244 * @param {Object} plugin An object containing the information about a plugin.
234 * See returnPluginsData() for the format of this object. 245 * See returnPluginsData() for the format of this object.
235 * @return {boolean} Whether the plugin's version should be displayed. 246 * @return {boolean} Whether the plugin's version should be displayed.
236 */ 247 */
237 function shouldDisplayPluginVersion(plugin) { 248 function shouldDisplayPluginVersion(plugin) {
238 return !!plugin.version && plugin.version != '0'; 249 return !!plugin.version && plugin.version != '0';
239 } 250 }
(...skipping 12 matching lines...) Expand all
252 plugin.description != 'Version ' + plugin.version && 263 plugin.description != 'Version ' + plugin.version &&
253 plugin.description != plugin.name + ' ' + plugin.version; 264 plugin.description != plugin.name + ' ' + plugin.version;
254 } 265 }
255 266
256 /** 267 /**
257 * @param {Object} plugin An object containing the information about a plugin. 268 * @param {Object} plugin An object containing the information about a plugin.
258 * See returnPluginsData() for the format of this object. 269 * See returnPluginsData() for the format of this object.
259 * @return {boolean} Whether the plugin is enabled. 270 * @return {boolean} Whether the plugin is enabled.
260 */ 271 */
261 function isPluginEnabled(plugin) { 272 function isPluginEnabled(plugin) {
262 return plugin.enabledMode == 'enabledByUser' || 273 return plugin.enabled_mode == 'enabledByUser' ||
263 plugin.enabledMode == 'enabledByPolicy'; 274 plugin.enabled_mode == 'enabledByPolicy';
264 } 275 }
265 276
266 // Unfortunately, we don't have notifications for plugin (list) status changes 277 // Unfortunately, we don't have notifications for plugin (list) status changes
267 // (yet), so in the meanwhile just update regularly. 278 // (yet), so in the meanwhile just update regularly.
268 setInterval(requestPluginsData, 30000); 279 //setInterval(requestPluginsData, 30000);
269 280
270 // Get data and have it displayed upon loading. 281 // Get data and have it displayed upon loading.
271 document.addEventListener('DOMContentLoaded', requestPluginsData); 282 //document.addEventListener('DOMContentLoaded', requestPluginsData);
272 283
273 // Add handlers to static HTML elements. 284 // Add handlers to static HTML elements.
274 $('collapse').onclick = toggleTmiMode; 285 $('collapse').onclick = toggleTmiMode;
275 $('expand').onclick = toggleTmiMode; 286 $('expand').onclick = toggleTmiMode;
276 $('details-link').onclick = toggleTmiMode; 287 $('details-link').onclick = toggleTmiMode;
288
289
290 /** @type {!Promise} */
291 var whenBrowserProxyReady = getBrowserProxy_();
292
293 /** @return {!Promise} */
294 function getBrowserProxy_() {
295 return new Promise(function(resolve, reject) {
296 define([
297 'mojo/public/js/connection',
298 'chrome/browser/ui/webui/plugins/plugins.mojom',
299 'content/public/renderer/service_provider',
300 ], function(connection, pluginsMojom, serviceProvider) {
301 var browserProxy = connection.bindHandleToProxy(
302 serviceProvider.connectToService(
303 pluginsMojom.PluginsHandlerMojo.name),
304 pluginsMojom.PluginsHandlerMojo);
305 resolve(browserProxy);
306 });
307 });
308 }
309
310 whenBrowserProxyReady.then(function(browserProxy) {
311 Promise.all([
312 browserProxy.getPluginsData(),
313 browserProxy.getShowDetails()
314 ]).then(function(responses) {
315 var getPluginsResponse = responses[0];
316 var getShowDetailsResponse = responses[1];
317
318 console.log(JSON.stringify(getPluginsResponse, undefined, 2));
319
320 returnPluginsData(getPluginsResponse);
321 loadShowDetailsFromPrefs(getShowDetailsResponse.show_details);
322 });
323 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698