summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/media/webrtc_logs.js
blob: 21c8c120133008a6b3441955606e537a4fe32ca0 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2013 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.

/**
 * Requests the list of uploads from the backend.
 */
function requestUploads() {
  chrome.send('requestWebRtcLogsList');
}

/**
 * Callback from backend with the list of uploads. Builds the UI.
 * @param {array} uploads The list of uploads.
 * @param {string} version The browser version.
 */
function updateWebRtcLogsList(uploads, version) {
  $('log-banner').textContent = loadTimeData.getStringF('webrtcLogCountFormat',
                                                        uploads.length);

  var logSection = $('log-list');

  // Clear any previous list.
  logSection.textContent = '';

  for (var i = 0; i < uploads.length; i++) {
    var upload = uploads[i];

    var logBlock = document.createElement('div');

    var title = document.createElement('h3');
    title.textContent =
        loadTimeData.getStringF('webrtcLogHeaderFormat',
                                upload['capture_time'].length != 0 ?
                                    upload['capture_time'] :
                                    upload['upload_time']);
    logBlock.appendChild(title);

    var localFileLine = document.createElement('p');
    if (upload['local_file'].length == 0) {
      localFileLine.textContent =
          loadTimeData.getString('noLocalLogFileMessage');
    } else {
      localFileLine.textContent =
          loadTimeData.getString('webrtcLogLocalFileLabelFormat') + ' ';
      var localFileLink = document.createElement('a');
      localFileLink.href = 'file://' + upload['local_file'];
      localFileLink.textContent = upload['local_file'];
      localFileLine.appendChild(localFileLink);
    }
    logBlock.appendChild(localFileLine);

    var uploadLine = document.createElement('p');
    if (upload['id'].length == 0) {
      uploadLine.textContent =
          loadTimeData.getString('webrtcLogNotUploadedMessage');
    } else {
      uploadLine.textContent =
          loadTimeData.getStringF('webrtcLogUploadTimeFormat',
                                  upload['upload_time']) + '. ' +
          loadTimeData.getStringF('webrtcLogReportIdFormat',
                                  upload['id']) + '. ';
      var link = document.createElement('a');
      var commentLines = [
          'Chrome Version: ' + version,
          // TODO(tbreisacher): fill in the OS automatically?
          'Operating System: e.g., "Windows 7", "Mac OSX 10.6"',
          '',
          'URL (if applicable) where the problem occurred:',
          '',
          'Can you reproduce this problem?',
          '',
          'What steps will reproduce this problem? (or if it\'s not ' +
          'reproducible, what were you doing just before the problem)?',
          '',
          '1.', '2.', '3.',
          '',
          '*Please note that issues filed with no information filled in ' +
          'above will be marked as WontFix*',
          '',
          '****DO NOT CHANGE BELOW THIS LINE****',
          'report_id:' + upload.id
      ];
      var params = {
        template: 'Defect report from user',
        comment: commentLines.join('\n'),
      };
      var href = 'http://code.google.com/p/chromium/issues/entry';
      for (var param in params) {
        href = appendParam(href, param, params[param]);
      }
      link.href = href;
      link.target = '_blank';
      link.textContent = loadTimeData.getString('bugLinkText');
      uploadLine.appendChild(link);
    }
    logBlock.appendChild(uploadLine);

    logSection.appendChild(logBlock);
  }

  $('no-logs').hidden = uploads.length != 0;
}

document.addEventListener('DOMContentLoaded', requestUploads);