summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/about_nacl.js
blob: f0265e8820d85420308c75fd9a657f31fc7ea940 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var nacl = nacl || {};

(function() {
  /**
   * Takes the |moduleListData| input argument which represents data about
   * the currently available modules and populates the html jstemplate
   * with that data. It expects an object structure like the above.
   * @param {Object} moduleListData Information about available modules
   */
  function renderTemplate(moduleListData) {
    // Process the template.
    var input = new JsEvalContext(moduleListData);
    var output = $('naclInfoTemplate');
    jstProcess(input, output);
  };

  /**
   * Asks the C++ NaClUIDOMHandler to get details about the NaCl and return
   * the data in returnNaClInfo() (below).
   */
  function requestNaClInfo() {
    chrome.send('requestNaClInfo');
  };

  /**
   * Called by the WebUI to re-populate the page with data representing the
   * current state of NaCl.
   * @param {Object} moduleListData Information about available modules
   */
  nacl.returnNaClInfo = function(moduleListData) {
    $('loading-message').hidden = 'hidden';
    $('body-container').hidden = '';
    renderTemplate(moduleListData);
  };

  // Get data and have it displayed upon loading.
  document.addEventListener('DOMContentLoaded', requestNaClInfo);
})();