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. */ |
| 6 var refreshCrashListId = undefined; |
| 7 |
5 /** | 8 /** |
6 * Requests the list of crashes from the backend. | 9 * Requests the list of crashes from the backend. |
7 */ | 10 */ |
8 function requestCrashes() { | 11 function requestCrashes() { |
9 chrome.send('requestCrashList'); | 12 chrome.send('requestCrashList'); |
10 } | 13 } |
11 | 14 |
12 /** | 15 /** |
13 * Callback from backend with the list of crashes. Builds the UI. | 16 * Callback from backend with the list of crashes. Builds the UI. |
14 * @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. |
15 * @param {array} crashes The list of crashes. | 19 * @param {array} crashes The list of crashes. |
16 * @param {string} version The browser version. | 20 * @param {string} version The browser version. |
17 */ | 21 */ |
18 function updateCrashList(enabled, crashes, version) { | 22 function updateCrashList(enabled, dynamicBackend, crashes, version) { |
19 $('countBanner').textContent = loadTimeData.getStringF('crashCountFormat', | 23 $('countBanner').textContent = loadTimeData.getStringF('crashCountFormat', |
20 crashes.length); | 24 crashes.length); |
21 | 25 |
22 var crashSection = $('crashList'); | 26 var crashSection = $('crashList'); |
23 | 27 |
24 $('enabledMode').hidden = !enabled; | 28 $('enabledMode').hidden = !enabled; |
25 $('disabledMode').hidden = enabled; | 29 $('disabledMode').hidden = enabled; |
| 30 $('crashUploadStatus').hidden = !enabled || !dynamicBackend; |
26 | 31 |
27 if (!enabled) | 32 if (!enabled) |
28 return; | 33 return; |
29 | 34 |
30 // Clear any previous list. | 35 // Clear any previous list. |
31 crashSection.textContent = ''; | 36 crashSection.textContent = ''; |
32 | 37 |
33 for (var i = 0; i < crashes.length; i++) { | 38 for (var i = 0; i < crashes.length; i++) { |
34 var crash = crashes[i]; | 39 var crash = crashes[i]; |
35 | 40 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 link.target = '_blank'; | 81 link.target = '_blank'; |
77 link.textContent = loadTimeData.getString('bugLinkText'); | 82 link.textContent = loadTimeData.getString('bugLinkText'); |
78 linkBlock.appendChild(link); | 83 linkBlock.appendChild(link); |
79 crashBlock.appendChild(linkBlock); | 84 crashBlock.appendChild(linkBlock); |
80 crashSection.appendChild(crashBlock); | 85 crashSection.appendChild(crashBlock); |
81 } | 86 } |
82 | 87 |
83 $('noCrashes').hidden = crashes.length != 0; | 88 $('noCrashes').hidden = crashes.length != 0; |
84 } | 89 } |
85 | 90 |
86 document.addEventListener('DOMContentLoaded', requestCrashes); | 91 /** |
| 92 * Request crashes get uploaded in the background. |
| 93 */ |
| 94 function requestCrashUpload() { |
| 95 // Don't need locking with this call because the system crash reporter |
| 96 // has locking built into itself. |
| 97 chrome.send('requestCrashUpload'); |
| 98 |
| 99 // Trigger a refresh in 5 seconds. Clear any previous requests. |
| 100 clearTimeout(refreshCrashListId); |
| 101 refreshCrashListId = setTimeout(requestCrashes, 5000); |
| 102 } |
| 103 |
| 104 document.addEventListener('DOMContentLoaded', function() { |
| 105 $('uploadCrashes').onclick = requestCrashUpload; |
| 106 requestCrashes(); |
| 107 }); |
OLD | NEW |