| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* Id for tracking automatic refresh of crash list. */ | 5 /* Id for tracking automatic refresh of crash list. */ |
| 6 var refreshCrashListId = undefined; | 6 var refreshCrashListId = undefined; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Requests the list of crashes from the backend. | 9 * Requests the list of crashes from the backend. |
| 10 */ | 10 */ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 crashSection.textContent = ''; | 38 crashSection.textContent = ''; |
| 39 | 39 |
| 40 var productName = loadTimeData.getString('shortProductName'); | 40 var productName = loadTimeData.getString('shortProductName'); |
| 41 | 41 |
| 42 for (var i = 0; i < crashes.length; i++) { | 42 for (var i = 0; i < crashes.length; i++) { |
| 43 var crash = crashes[i]; | 43 var crash = crashes[i]; |
| 44 if (crash['local_id'] == '') | 44 if (crash['local_id'] == '') |
| 45 crash['local_id'] = productName; | 45 crash['local_id'] = productName; |
| 46 | 46 |
| 47 var crashBlock = document.createElement('div'); | 47 var crashBlock = document.createElement('div'); |
| 48 if (crash['state'] != 'uploaded') |
| 49 crashBlock.className = 'notUploaded'; |
| 48 var title = document.createElement('h3'); | 50 var title = document.createElement('h3'); |
| 49 title.textContent = loadTimeData.getStringF('crashHeaderFormat', | 51 title.textContent = loadTimeData.getStringF('crashHeaderFormat', |
| 50 crash['id'], | 52 crash['id'], |
| 51 crash['local_id']); | 53 crash['local_id']); |
| 52 crashBlock.appendChild(title); | 54 crashBlock.appendChild(title); |
| 53 var date = document.createElement('p'); | 55 if (crash['state'] == 'uploaded') { |
| 54 date.textContent = loadTimeData.getStringF('crashTimeFormat', | 56 var date = document.createElement('p'); |
| 55 crash['time']); | 57 date.textContent = loadTimeData.getStringF('crashTimeFormat', |
| 56 crashBlock.appendChild(date); | 58 crash['time']); |
| 57 var linkBlock = document.createElement('p'); | 59 crashBlock.appendChild(date); |
| 58 var link = document.createElement('a'); | 60 var linkBlock = document.createElement('p'); |
| 59 var commentLines = [ | 61 var link = document.createElement('a'); |
| 60 'IMPORTANT: Your crash has already been automatically reported ' + | 62 var commentLines = [ |
| 61 'to our crash system. Please file this bug only if you can provide ' + | 63 'IMPORTANT: Your crash has already been automatically reported ' + |
| 62 'more information about it.', | 64 'to our crash system. Please file this bug only if you can provide ' + |
| 63 '', | 65 'more information about it.', |
| 64 '', | 66 '', |
| 65 'Chrome Version: ' + version, | 67 '', |
| 66 'Operating System: ' + os, | 68 'Chrome Version: ' + version, |
| 67 '', | 69 'Operating System: ' + os, |
| 68 'URL (if applicable) where crash occurred:', | 70 '', |
| 69 '', | 71 'URL (if applicable) where crash occurred:', |
| 70 'Can you reproduce this crash?', | 72 '', |
| 71 '', | 73 'Can you reproduce this crash?', |
| 72 'What steps will reproduce this crash? (If it\'s not ' + | 74 '', |
| 73 'reproducible, what were you doing just before the crash?)', | 75 'What steps will reproduce this crash? (If it\'s not ' + |
| 74 '1.', '2.', '3.', | 76 'reproducible, what were you doing just before the crash?)', |
| 75 '', | 77 '1.', '2.', '3.', |
| 76 '****DO NOT CHANGE BELOW THIS LINE****', | 78 '', |
| 77 'Crash ID: crash/' + crash.id | 79 '****DO NOT CHANGE BELOW THIS LINE****', |
| 78 ]; | 80 'Crash ID: crash/' + crash.id |
| 79 var params = { | 81 ]; |
| 80 template: 'Crash Report', | 82 var params = { |
| 81 comment: commentLines.join('\n'), | 83 template: 'Crash Report', |
| 82 }; | 84 comment: commentLines.join('\n'), |
| 83 var href = 'https://code.google.com/p/chromium/issues/entry'; | 85 }; |
| 84 for (var param in params) { | 86 var href = 'https://code.google.com/p/chromium/issues/entry'; |
| 85 href = appendParam(href, param, params[param]); | 87 for (var param in params) { |
| 88 href = appendParam(href, param, params[param]); |
| 89 } |
| 90 link.href = href; |
| 91 link.target = '_blank'; |
| 92 link.textContent = loadTimeData.getString('bugLinkText'); |
| 93 linkBlock.appendChild(link); |
| 94 crashBlock.appendChild(linkBlock); |
| 95 } else if (crash['state'] == 'pending') { |
| 96 var pending = document.createElement('p'); |
| 97 pending.textContent = loadTimeData.getStringF('crashPendingUpload', |
| 98 crash['time']); |
| 99 crashBlock.appendChild(pending); |
| 100 } else if (crash['state'] == 'not_uploaded') { |
| 101 var not_uploaded = document.createElement('p'); |
| 102 not_uploaded.textContent = loadTimeData.getStringF('crashNotUploaded', |
| 103 crash['time']); |
| 104 crashBlock.appendChild(not_uploaded); |
| 86 } | 105 } |
| 87 link.href = href; | |
| 88 link.target = '_blank'; | |
| 89 link.textContent = loadTimeData.getString('bugLinkText'); | |
| 90 linkBlock.appendChild(link); | |
| 91 crashBlock.appendChild(linkBlock); | |
| 92 crashSection.appendChild(crashBlock); | 106 crashSection.appendChild(crashBlock); |
| 93 } | 107 } |
| 94 | 108 |
| 95 $('noCrashes').hidden = crashes.length != 0; | 109 $('noCrashes').hidden = crashes.length != 0; |
| 96 } | 110 } |
| 97 | 111 |
| 98 /** | 112 /** |
| 99 * Request crashes get uploaded in the background. | 113 * Request crashes get uploaded in the background. |
| 100 */ | 114 */ |
| 101 function requestCrashUpload() { | 115 function requestCrashUpload() { |
| 102 // Don't need locking with this call because the system crash reporter | 116 // Don't need locking with this call because the system crash reporter |
| 103 // has locking built into itself. | 117 // has locking built into itself. |
| 104 chrome.send('requestCrashUpload'); | 118 chrome.send('requestCrashUpload'); |
| 105 | 119 |
| 106 // Trigger a refresh in 5 seconds. Clear any previous requests. | 120 // Trigger a refresh in 5 seconds. Clear any previous requests. |
| 107 clearTimeout(refreshCrashListId); | 121 clearTimeout(refreshCrashListId); |
| 108 refreshCrashListId = setTimeout(requestCrashes, 5000); | 122 refreshCrashListId = setTimeout(requestCrashes, 5000); |
| 109 } | 123 } |
| 110 | 124 |
| 111 document.addEventListener('DOMContentLoaded', function() { | 125 document.addEventListener('DOMContentLoaded', function() { |
| 112 $('uploadCrashes').onclick = requestCrashUpload; | 126 $('uploadCrashes').onclick = requestCrashUpload; |
| 113 requestCrashes(); | 127 requestCrashes(); |
| 114 }); | 128 }); |
| OLD | NEW |