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
3// found in the LICENSE file.
4
5var nacl = nacl || {};
6
7(function() {
8  /**
9   * Takes the |moduleListData| input argument which represents data about
10   * the currently available modules and populates the html jstemplate
11   * with that data. It expects an object structure like the above.
12   * @param {Object} moduleListData Information about available modules
13   */
14  function renderTemplate(moduleListData) {
15    // Process the template.
16    var input = new JsEvalContext(moduleListData);
17    var output = $('naclInfoTemplate');
18    jstProcess(input, output);
19  };
20
21  /**
22   * Asks the C++ NaClUIDOMHandler to get details about the NaCl and return
23   * the data in returnNaClInfo() (below).
24   */
25  function requestNaClInfo() {
26    chrome.send('requestNaClInfo');
27  };
28
29  /**
30   * Called by the WebUI to re-populate the page with data representing the
31   * current state of NaCl.
32   * @param {Object} moduleListData Information about available modules
33   */
34  nacl.returnNaClInfo = function(moduleListData) {
35    $('loading-message').hidden = 'hidden';
36    $('body-container').hidden = '';
37    renderTemplate(moduleListData);
38  };
39
40  // Get data and have it displayed upon loading.
41  document.addEventListener('DOMContentLoaded', requestNaClInfo);
42})();
43