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.
5 /* Id for tracking automatic refresh of crash list. */
6 var refreshCrashListId
= undefined;
9 * Requests the list of crashes from the backend.
11 function requestCrashes() {
12 chrome
.send('requestCrashList');
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.
22 function updateCrashList(enabled
, dynamicBackend
, crashes
, version
) {
23 $('countBanner').textContent
= loadTimeData
.getStringF('crashCountFormat',
26 var crashSection
= $('crashList');
28 $('enabledMode').hidden
= !enabled
;
29 $('disabledMode').hidden
= enabled
;
30 $('crashUploadStatus').hidden
= !enabled
|| !dynamicBackend
;
35 // Clear any previous list.
36 crashSection
.textContent
= '';
38 var productName
= loadTimeData
.getString('shortProductName');
40 for (var i
= 0; i
< crashes
.length
; i
++) {
41 var crash
= crashes
[i
];
42 if (crash
['local_id'] == '')
43 crash
['local_id'] = productName
;
45 var crashBlock
= document
.createElement('div');
46 var title
= document
.createElement('h3');
47 title
.textContent
= loadTimeData
.getStringF('crashHeaderFormat',
50 crashBlock
.appendChild(title
);
51 var date
= document
.createElement('p');
52 date
.textContent
= loadTimeData
.getStringF('crashTimeFormat',
54 crashBlock
.appendChild(date
);
55 var linkBlock
= document
.createElement('p');
56 var link
= document
.createElement('a');
58 'Chrome Version: ' + version
,
59 // TODO(tbreisacher): fill in the OS automatically?
60 'Operating System: e.g., "Windows 7", "Mac OSX 10.6"',
62 'URL (if applicable) where crash occurred:',
64 'Can you reproduce this crash?',
66 'What steps will reproduce this crash? (or if it\'s not ' +
67 'reproducible, what were you doing just before the crash)?',
71 '*Please note that issues filed with no information filled in ' +
72 'above will be marked as WontFix*',
74 '****DO NOT CHANGE BELOW THIS LINE****',
75 'report_id:' + crash
.id
78 template
: 'Crash Report',
79 comment
: commentLines
.join('\n'),
81 var href
= 'http://code.google.com/p/chromium/issues/entry';
82 for (var param
in params
) {
83 href
= appendParam(href
, param
, params
[param
]);
86 link
.target
= '_blank';
87 link
.textContent
= loadTimeData
.getString('bugLinkText');
88 linkBlock
.appendChild(link
);
89 crashBlock
.appendChild(linkBlock
);
90 crashSection
.appendChild(crashBlock
);
93 $('noCrashes').hidden
= crashes
.length
!= 0;
97 * Request crashes get uploaded in the background.
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');
104 // Trigger a refresh in 5 seconds. Clear any previous requests.
105 clearTimeout(refreshCrashListId
);
106 refreshCrashListId
= setTimeout(requestCrashes
, 5000);
109 document
.addEventListener('DOMContentLoaded', function() {
110 $('uploadCrashes').onclick
= requestCrashUpload
;