Home | History | Annotate | Download | only in media
      1 // Copyright 2013 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  * Requests the list of uploads from the backend.
      7  */
      8 function requestUploads() {
      9   chrome.send('requestWebRtcLogsList');
     10 }
     11 
     12 /**
     13  * Callback from backend with the list of uploads. Builds the UI.
     14  * @param {array} uploads The list of uploads.
     15  * @param {string} version The browser version.
     16  */
     17 function updateWebRtcLogsList(uploads, version) {
     18   $('log-banner').textContent = loadTimeData.getStringF('webrtcLogCountFormat',
     19                                                         uploads.length);
     20 
     21   var logSection = $('log-list');
     22 
     23   // Clear any previous list.
     24   logSection.textContent = '';
     25 
     26   for (var i = 0; i < uploads.length; i++) {
     27     var upload = uploads[i];
     28 
     29     var logBlock = document.createElement('div');
     30 
     31     var title = document.createElement('h3');
     32     title.textContent =
     33         loadTimeData.getStringF('webrtcLogHeaderFormat',
     34                                 upload['capture_time'].length != 0 ?
     35                                     upload['capture_time'] :
     36                                     upload['upload_time']);
     37     logBlock.appendChild(title);
     38 
     39     var localFileLine = document.createElement('p');
     40     if (upload['local_file'].length == 0) {
     41       localFileLine.textContent =
     42           loadTimeData.getString('noLocalLogFileMessage');
     43     } else {
     44       localFileLine.textContent =
     45           loadTimeData.getString('webrtcLogLocalFileLabelFormat') + ' ';
     46       var localFileLink = document.createElement('a');
     47       localFileLink.href = 'file://' + upload['local_file'];
     48       localFileLink.textContent =
     49           loadTimeData.getStringF('webrtcLogLocalFileFormat',
     50                                   upload['local_file']);
     51       localFileLine.appendChild(localFileLink);
     52     }
     53     logBlock.appendChild(localFileLine);
     54 
     55     var uploadLine = document.createElement('p');
     56     if (upload['id'].length == 0) {
     57       uploadLine.textContent =
     58           loadTimeData.getString('webrtcLogNotUploadedMessage');
     59     } else {
     60       uploadLine.textContent =
     61           loadTimeData.getStringF('webrtcLogUploadTimeFormat',
     62                                   upload['upload_time']) + '. ' +
     63           loadTimeData.getStringF('webrtcLogReportIdFormat',
     64                                   upload['id']) + '. ';
     65       var link = document.createElement('a');
     66       var commentLines = [
     67           'Chrome Version: ' + version,
     68           // TODO(tbreisacher): fill in the OS automatically?
     69           'Operating System: e.g., "Windows 7", "Mac OSX 10.6"',
     70           '',
     71           'URL (if applicable) where the problem occurred:',
     72           '',
     73           'Can you reproduce this problem?',
     74           '',
     75           'What steps will reproduce this problem? (or if it\'s not ' +
     76           'reproducible, what were you doing just before the problem)?',
     77           '',
     78           '1.', '2.', '3.',
     79           '',
     80           '*Please note that issues filed with no information filled in ' +
     81           'above will be marked as WontFix*',
     82           '',
     83           '****DO NOT CHANGE BELOW THIS LINE****',
     84           'report_id:' + upload.id
     85       ];
     86       var params = {
     87         template: 'Defect report from user',
     88         comment: commentLines.join('\n'),
     89       };
     90       var href = 'http://code.google.com/p/chromium/issues/entry';
     91       for (var param in params) {
     92         href = appendParam(href, param, params[param]);
     93       }
     94       link.href = href;
     95       link.target = '_blank';
     96       link.textContent = loadTimeData.getString('bugLinkText');
     97       uploadLine.appendChild(link);
     98     }
     99     logBlock.appendChild(uploadLine);
    100 
    101     logSection.appendChild(logBlock);
    102   }
    103 
    104   $('no-logs').hidden = uploads.length != 0;
    105 }
    106 
    107 document.addEventListener('DOMContentLoaded', requestUploads);
    108