summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/user_actions/user_actions.js
blob: 0064d66b862194efe99d14d908176ef93f1be263 (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
// Copyright 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.

/**
 * Javascript for user_actions.html, served from chrome://user-actions/
 * This is used to debug user actions recording. It displays a live
 * stream of all user action events that occur in chromium while the
 * chrome://user-actions/ page is open.
 *
 * The simple object defined in this javascript file listens for
 * callbacks from the C++ code saying that a new user action was seen.
 */

cr.define('userActions', function() {
  'use strict';

  /**
   * Appends a row to the output table listing the user action observed
   * and the current timestamp.
   * @param {string} userAction the name of the user action observed.
   */
  function observeUserAction(userAction) {
    var table = $('user-actions-table');
    var tr = document.createElement('tr');
    var td = document.createElement('td');
    td.textContent = userAction;
    tr.appendChild(td);
    td = document.createElement('td');
    td.textContent = Date.now() / 1000;  // in seconds since epoch
    tr.appendChild(td);
    table.appendChild(tr);
  }

  return {
    observeUserAction: observeUserAction
  };
});