| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 220 } |
| 221 | 221 |
| 222 // NOTE: Need to keep a global reference to the |pageImpl| such that it is not | 222 // NOTE: Need to keep a global reference to the |pageImpl| such that it is not |
| 223 // garbage collected, which causes the pipe to close and future calls from C++ | 223 // garbage collected, which causes the pipe to close and future calls from C++ |
| 224 // to JS to get dropped. This also allows tests to make direct calls on it. | 224 // to JS to get dropped. This also allows tests to make direct calls on it. |
| 225 var pageImpl = null; | 225 var pageImpl = null; |
| 226 var browserProxy = null; | 226 var browserProxy = null; |
| 227 | 227 |
| 228 function initializeProxies() { | 228 function initializeProxies() { |
| 229 return importModules([ | 229 return importModules([ |
| 230 'mojo/public/js/bindings', |
| 230 'mojo/public/js/connection', | 231 'mojo/public/js/connection', |
| 231 'chrome/browser/ui/webui/plugins/plugins.mojom', | 232 'chrome/browser/ui/webui/plugins/plugins.mojom', |
| 232 'content/public/renderer/frame_interfaces', | 233 'content/public/renderer/frame_interfaces', |
| 233 ]).then(function(modules) { | 234 ]).then(function(modules) { |
| 234 var connection = modules[0]; | 235 var bindings = modules[0]; |
| 235 var pluginsMojom = modules[1]; | 236 var connection = modules[1]; |
| 236 var frameInterfaces = modules[2]; | 237 var pluginsMojom = modules[2]; |
| 238 var frameInterfaces = modules[3]; |
| 237 | 239 |
| 238 browserProxy = connection.bindHandleToProxy( | 240 browserProxy = connection.bindHandleToProxy( |
| 239 frameInterfaces.getInterface(pluginsMojom.PluginsPageHandler.name), | 241 frameInterfaces.getInterface(pluginsMojom.PluginsPageHandler.name), |
| 240 pluginsMojom.PluginsPageHandler); | 242 pluginsMojom.PluginsPageHandler); |
| 241 | 243 |
| 242 /** @constructor */ | 244 /** @constructor */ |
| 243 var PluginsPageImpl = function() {}; | 245 var PluginsPageImpl = function() { |
| 246 this.binding = new bindings.Binding(pluginsMojom.PluginsPage, this); |
| 247 }; |
| 244 | 248 |
| 245 PluginsPageImpl.prototype = { | 249 PluginsPageImpl.prototype = { |
| 246 __proto__: pluginsMojom.PluginsPage.stubClass.prototype, | |
| 247 | |
| 248 /** @override */ | 250 /** @override */ |
| 249 onPluginsUpdated: function(plugins) { | 251 onPluginsUpdated: function(plugins) { |
| 250 returnPluginsData({plugins: plugins}); | 252 returnPluginsData({plugins: plugins}); |
| 251 }, | 253 }, |
| 252 }; | 254 }; |
| 253 pageImpl = new PluginsPageImpl(); | 255 pageImpl = new PluginsPageImpl(); |
| 254 | 256 browserProxy.setClientPage(pageImpl.binding.createInterfacePtrAndBind()); |
| 255 // Create a message pipe, with one end of the pipe already connected to JS. | |
| 256 var handle = connection.bindStubDerivedImpl(pageImpl); | |
| 257 // Send the other end of the pipe to C++. | |
| 258 browserProxy.setClientPage(handle); | |
| 259 }); | 257 }); |
| 260 } | 258 } |
| 261 | 259 |
| 262 /** | 260 /** |
| 263 * Overriden by tests to give them a chance to setup a fake Mojo browser proxy | 261 * Overriden by tests to give them a chance to setup a fake Mojo browser proxy |
| 264 * before any other code executes. | 262 * before any other code executes. |
| 265 * @return {!Promise} A promise firing once necessary setup has been completed. | 263 * @return {!Promise} A promise firing once necessary setup has been completed. |
| 266 */ | 264 */ |
| 267 var setupFn = setupFn || function() { return Promise.resolve(); }; | 265 var setupFn = setupFn || function() { return Promise.resolve(); }; |
| 268 | 266 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 285 | 283 |
| 286 // Unfortunately, we don't have notifications for plugin (list) status | 284 // Unfortunately, we don't have notifications for plugin (list) status |
| 287 // changes (yet), so in the meanwhile just update regularly. | 285 // changes (yet), so in the meanwhile just update regularly. |
| 288 setInterval(function() { | 286 setInterval(function() { |
| 289 browserProxy.getPluginsData().then(returnPluginsData); | 287 browserProxy.getPluginsData().then(returnPluginsData); |
| 290 }, 30000); | 288 }, 30000); |
| 291 }); | 289 }); |
| 292 } | 290 } |
| 293 | 291 |
| 294 document.addEventListener('DOMContentLoaded', main); | 292 document.addEventListener('DOMContentLoaded', main); |
| OLD | NEW |