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