Home | History | Annotate | Download | only in resources
      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 /**
      6 * This variable structure is here to document the structure that the template
      7 * expects to correctly populate the page.
      8 */
      9 var moduleListDataFormat = {
     10   'moduleList': [
     11   {
     12     'type': 'The type of module found',
     13     'type_description':
     14     'The type of module (string), defaults to blank for regular modules',
     15     'status': 'The module status',
     16     'location': 'The module path, not including filename',
     17     'name': 'The name of the module',
     18     'product_name': 'The name of the product the module belongs to',
     19     'description': 'The module description',
     20     'version': 'The module version',
     21     'digital_signer': 'The signer of the digital certificate for the module',
     22     'recommended_action': 'The help tips bitmask',
     23     'possible_resolution': 'The help tips in string form',
     24     'help_url': 'The link to the Help Center article'
     25   }
     26 ]
     27 };
     28 
     29 /**
     30 * Takes the |moduleListData| input argument which represents data about
     31 * the currently available modules and populates the html jstemplate
     32 * with that data. It expects an object structure like the above.
     33 * @param {Object} moduleListData Information about available modules.
     34 */
     35 function renderTemplate(moduleListData) {
     36   // This is the javascript code that processes the template:
     37   var input = new JsEvalContext(moduleListData);
     38   var output = $('modulesTemplate');
     39   jstProcess(input, output);
     40 }
     41 
     42 /**
     43 * Asks the C++ ConflictsDOMHandler to get details about the available modules
     44 * and return detailed data about the configuration. The ConflictsDOMHandler
     45 * should reply to returnModuleList() (below).
     46 */
     47 function requestModuleListData() {
     48   chrome.send('requestModuleList');
     49 }
     50 
     51 /**
     52 * Called by the WebUI to re-populate the page with data representing the
     53 * current state of installed modules.
     54 * @param {Object} moduleListData Information about available modules.
     55 */
     56 function returnModuleList(moduleListData) {
     57   renderTemplate(moduleListData);
     58   $('loading-message').style.visibility = 'hidden';
     59   $('body-container').style.visibility = 'visible';
     60 }
     61 
     62 // Get data and have it displayed upon loading.
     63 document.addEventListener('DOMContentLoaded', requestModuleListData);
     64