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 5 /* Id for tracking automatic refresh of crash list. */ 6 var refreshCrashListId = undefined; 7 8 /** 9 * Requests the list of crashes from the backend. 10 */ 11 function requestCrashes() { 12 chrome.send('requestCrashList'); 13 } 14 15 /** 16 * Callback from backend with the list of crashes. Builds the UI. 17 * @param {boolean} enabled Whether or not crash reporting is enabled. 18 * @param {boolean} dynamicBackend Whether the crash backend is dynamic. 19 * @param {array} crashes The list of crashes. 20 * @param {string} version The browser version. 21 */ 22 function updateCrashList(enabled, dynamicBackend, crashes, version) { 23 $('countBanner').textContent = loadTimeData.getStringF('crashCountFormat', 24 crashes.length); 25 26 var crashSection = $('crashList'); 27 28 $('enabledMode').hidden = !enabled; 29 $('disabledMode').hidden = enabled; 30 $('crashUploadStatus').hidden = !enabled || !dynamicBackend; 31 32 if (!enabled) 33 return; 34 35 // Clear any previous list. 36 crashSection.textContent = ''; 37 38 var productName = loadTimeData.getString('shortProductName'); 39 40 for (var i = 0; i < crashes.length; i++) { 41 var crash = crashes[i]; 42 if (crash['local_id'] == '') 43 crash['local_id'] = productName; 44 45 var crashBlock = document.createElement('div'); 46 var title = document.createElement('h3'); 47 title.textContent = loadTimeData.getStringF('crashHeaderFormat', 48 crash['id'], 49 crash['local_id']); 50 crashBlock.appendChild(title); 51 var date = document.createElement('p'); 52 date.textContent = loadTimeData.getStringF('crashTimeFormat', 53 crash['time']); 54 crashBlock.appendChild(date); 55 var linkBlock = document.createElement('p'); 56 var link = document.createElement('a'); 57 var commentLines = [ 58 'Chrome Version: ' + version, 59 // TODO(tbreisacher): fill in the OS automatically? 60 'Operating System: e.g., "Windows 7", "Mac OSX 10.6"', 61 '', 62 'URL (if applicable) where crash occurred:', 63 '', 64 'Can you reproduce this crash?', 65 '', 66 'What steps will reproduce this crash? (or if it\'s not ' + 67 'reproducible, what were you doing just before the crash)?', 68 '', 69 '1.', '2.', '3.', 70 '', 71 '*Please note that issues filed with no information filled in ' + 72 'above will be marked as WontFix*', 73 '', 74 '****DO NOT CHANGE BELOW THIS LINE****', 75 'report_id:' + crash.id 76 ]; 77 var params = { 78 template: 'Crash Report', 79 comment: commentLines.join('\n'), 80 }; 81 var href = 'http://code.google.com/p/chromium/issues/entry'; 82 for (var param in params) { 83 href = appendParam(href, param, params[param]); 84 } 85 link.href = href; 86 link.target = '_blank'; 87 link.textContent = loadTimeData.getString('bugLinkText'); 88 linkBlock.appendChild(link); 89 crashBlock.appendChild(linkBlock); 90 crashSection.appendChild(crashBlock); 91 } 92 93 $('noCrashes').hidden = crashes.length != 0; 94 } 95 96 /** 97 * Request crashes get uploaded in the background. 98 */ 99 function requestCrashUpload() { 100 // Don't need locking with this call because the system crash reporter 101 // has locking built into itself. 102 chrome.send('requestCrashUpload'); 103 104 // Trigger a refresh in 5 seconds. Clear any previous requests. 105 clearTimeout(refreshCrashListId); 106 refreshCrashListId = setTimeout(requestCrashes, 5000); 107 } 108 109 document.addEventListener('DOMContentLoaded', function() { 110 $('uploadCrashes').onclick = requestCrashUpload; 111 requestCrashes(); 112 }); 113