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 */ |
11 function requestCrashes() { | 11 function requestCrashes() { |
12 chrome.send('requestCrashList'); | 12 chrome.send('requestCrashList'); |
13 } | 13 } |
14 | 14 |
15 /** | 15 /** |
16 * Callback from backend with the list of crashes. Builds the UI. | 16 * Callback from backend with the list of crashes. Builds the UI. |
17 * @param {boolean} enabled Whether or not crash reporting is enabled. | 17 * @param {boolean} enabled Whether or not crash reporting is enabled. |
18 * @param {boolean} dynamicBackend Whether the crash backend is dynamic. | 18 * @param {boolean} dynamicBackend Whether the crash backend is dynamic. |
| 19 * @param {boolean} manualUploads Whether the manual uploads are supported. |
19 * @param {array} crashes The list of crashes. | 20 * @param {array} crashes The list of crashes. |
20 * @param {string} version The browser version. | 21 * @param {string} version The browser version. |
21 * @param {string} os The OS name and version. | 22 * @param {string} os The OS name and version. |
22 */ | 23 */ |
23 function updateCrashList(enabled, dynamicBackend, crashes, version, os) { | 24 function updateCrashList( |
| 25 enabled, dynamicBackend, manualUploads, |
| 26 crashes, version, os) { |
24 $('countBanner').textContent = | 27 $('countBanner').textContent = |
25 loadTimeData.getStringF('crashCountFormat', | 28 loadTimeData.getStringF('crashCountFormat', |
26 crashes.length.toLocaleString()); | 29 crashes.length.toLocaleString()); |
27 | 30 |
28 var crashSection = $('crashList'); | 31 var crashSection = $('crashList'); |
29 | 32 |
30 $('enabledMode').hidden = !enabled; | 33 $('enabledMode').hidden = !enabled; |
31 $('disabledMode').hidden = enabled; | 34 $('disabledMode').hidden = enabled; |
32 $('crashUploadStatus').hidden = !enabled || !dynamicBackend; | 35 $('crashUploadStatus').hidden = !enabled || !dynamicBackend; |
33 | 36 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 }; | 98 }; |
96 var href = 'https://code.google.com/p/chromium/issues/entry'; | 99 var href = 'https://code.google.com/p/chromium/issues/entry'; |
97 for (var param in params) { | 100 for (var param in params) { |
98 href = appendParam(href, param, params[param]); | 101 href = appendParam(href, param, params[param]); |
99 } | 102 } |
100 link.href = href; | 103 link.href = href; |
101 link.target = '_blank'; | 104 link.target = '_blank'; |
102 link.textContent = loadTimeData.getString('bugLinkText'); | 105 link.textContent = loadTimeData.getString('bugLinkText'); |
103 linkBlock.appendChild(link); | 106 linkBlock.appendChild(link); |
104 crashBlock.appendChild(linkBlock); | 107 crashBlock.appendChild(linkBlock); |
105 } else if (crash['state'] == 'pending') { | 108 } else if (crash['state'] == 'user_requested') { |
106 var pending = document.createElement('p'); | 109 var user_requested = document.createElement('p'); |
107 pending.textContent = loadTimeData.getStringF('crashPending', | 110 user_requested.textContent = |
108 crash['time']); | 111 loadTimeData.getStringF('crashUserRequested', crash['time']); |
109 crashBlock.appendChild(pending); | 112 crashBlock.appendChild(user_requested); |
110 } else if (crash['state'] == 'not_uploaded') { | 113 } else { |
111 var not_uploaded = document.createElement('p'); | 114 if (crash['state'] == 'pending') { |
112 not_uploaded.textContent = loadTimeData.getStringF('crashNotUploaded', | 115 var pending = document.createElement('p'); |
113 crash['time']); | 116 pending.textContent = loadTimeData.getStringF('crashPending', |
114 crashBlock.appendChild(not_uploaded); | 117 crash['time']); |
| 118 crashBlock.appendChild(pending); |
| 119 } else if (crash['state'] == 'not_uploaded') { |
| 120 var not_uploaded = document.createElement('p'); |
| 121 not_uploaded.textContent = loadTimeData.getStringF('crashNotUploaded', |
| 122 crash['time']); |
| 123 crashBlock.appendChild(not_uploaded); |
| 124 } |
| 125 |
| 126 if (manualUploads) { |
| 127 var uploadNowLinkBlock = document.createElement('p'); |
| 128 var link = document.createElement('a'); |
| 129 link.href = ''; |
| 130 link.textContent = loadTimeData.getString('uploadNowLinkText'); |
| 131 link['local_id'] = crash['local_id']; |
| 132 link.onclick = function() { |
| 133 chrome.send('requestSingleCrashUpload', [this['local_id']]); |
| 134 } |
| 135 uploadNowLinkBlock.appendChild(link); |
| 136 crashBlock.appendChild(uploadNowLinkBlock) |
| 137 } |
115 } | 138 } |
116 crashSection.appendChild(crashBlock); | 139 crashSection.appendChild(crashBlock); |
117 } | 140 } |
118 | 141 |
119 $('noCrashes').hidden = crashes.length != 0; | 142 $('noCrashes').hidden = crashes.length != 0; |
120 } | 143 } |
121 | 144 |
122 /** | 145 /** |
123 * Request crashes get uploaded in the background. | 146 * Request crashes get uploaded in the background. |
124 */ | 147 */ |
125 function requestCrashUpload() { | 148 function requestCrashUpload() { |
126 // Don't need locking with this call because the system crash reporter | 149 // Don't need locking with this call because the system crash reporter |
127 // has locking built into itself. | 150 // has locking built into itself. |
128 chrome.send('requestCrashUpload'); | 151 chrome.send('requestCrashUpload'); |
129 | 152 |
130 // Trigger a refresh in 5 seconds. Clear any previous requests. | 153 // Trigger a refresh in 5 seconds. Clear any previous requests. |
131 clearTimeout(refreshCrashListId); | 154 clearTimeout(refreshCrashListId); |
132 refreshCrashListId = setTimeout(requestCrashes, 5000); | 155 refreshCrashListId = setTimeout(requestCrashes, 5000); |
133 } | 156 } |
134 | 157 |
135 document.addEventListener('DOMContentLoaded', function() { | 158 document.addEventListener('DOMContentLoaded', function() { |
136 $('uploadCrashes').onclick = requestCrashUpload; | 159 $('uploadCrashes').onclick = requestCrashUpload; |
137 requestCrashes(); | 160 requestCrashes(); |
138 }); | 161 }); |
OLD | NEW |