| 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() { |
| 12 refreshCrashListId = clearInterval(refreshCrashListId); |
| 9 chrome.send('requestCrashList'); | 13 chrome.send('requestCrashList'); |
| 10 } | 14 } |
| 11 | 15 |
| 12 /** | 16 /** |
| 13 * Callback from backend with the list of crashes. Builds the UI. | 17 * Callback from backend with the list of crashes. Builds the UI. |
| 14 * @param {boolean} enabled Whether or not crash reporting is enabled. | 18 * @param {boolean} enabled Whether or not crash reporting is enabled. |
| 19 * @param {boolean} dynamic_backend Whether the crash backend is dynamic. |
| 15 * @param {array} crashes The list of crashes. | 20 * @param {array} crashes The list of crashes. |
| 16 * @param {string} version The browser version. | 21 * @param {string} version The browser version. |
| 17 */ | 22 */ |
| 18 function updateCrashList(enabled, crashes, version) { | 23 function updateCrashList(enabled, dynamic_backend, crashes, version) { |
| 19 $('countBanner').textContent = loadTimeData.getStringF('crashCountFormat', | 24 $('countBanner').textContent = loadTimeData.getStringF('crashCountFormat', |
| 20 crashes.length); | 25 crashes.length); |
| 21 | 26 |
| 22 var crashSection = $('crashList'); | 27 var crashSection = $('crashList'); |
| 23 | 28 |
| 24 $('enabledMode').hidden = !enabled; | 29 $('enabledMode').hidden = !enabled; |
| 25 $('disabledMode').hidden = enabled; | 30 $('disabledMode').hidden = enabled; |
| 26 | 31 |
| 32 if (dynamic_backend) |
| 33 $('crashUploadStatus').hidden = !enabled; |
| 34 |
| 27 if (!enabled) | 35 if (!enabled) |
| 28 return; | 36 return; |
| 29 | 37 |
| 30 // Clear any previous list. | 38 // Clear any previous list. |
| 31 crashSection.textContent = ''; | 39 crashSection.textContent = ''; |
| 32 | 40 |
| 33 for (var i = 0; i < crashes.length; i++) { | 41 for (var i = 0; i < crashes.length; i++) { |
| 34 var crash = crashes[i]; | 42 var crash = crashes[i]; |
| 35 | 43 |
| 36 var crashBlock = document.createElement('div'); | 44 var crashBlock = document.createElement('div'); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 link.target = '_blank'; | 84 link.target = '_blank'; |
| 77 link.textContent = loadTimeData.getString('bugLinkText'); | 85 link.textContent = loadTimeData.getString('bugLinkText'); |
| 78 linkBlock.appendChild(link); | 86 linkBlock.appendChild(link); |
| 79 crashBlock.appendChild(linkBlock); | 87 crashBlock.appendChild(linkBlock); |
| 80 crashSection.appendChild(crashBlock); | 88 crashSection.appendChild(crashBlock); |
| 81 } | 89 } |
| 82 | 90 |
| 83 $('noCrashes').hidden = crashes.length != 0; | 91 $('noCrashes').hidden = crashes.length != 0; |
| 84 } | 92 } |
| 85 | 93 |
| 86 document.addEventListener('DOMContentLoaded', requestCrashes); | 94 /** |
| 95 * Request crashes get uploaded in the background. |
| 96 * @return {boolean} Always false to disable navigation to linked anchor. |
| 97 */ |
| 98 function requestCrashUpload() { |
| 99 chrome.send('requestCrashUpload'); |
| 100 |
| 101 // Trigger a refresh in 5 seconds. |
| 102 refreshCrashListId = setTimeout(requestCrashes, 5000); |
| 103 |
| 104 return false; |
| 105 } |
| 106 |
| 107 /** |
| 108 * Callback from backend when crash uploading has started. |
| 109 * @param {boolean} enabled Whether or not crash reporting is enabled. |
| 110 */ |
| 111 function updateCrashUploadStatus(enabled) { |
| 112 } |
| 113 |
| 114 document.addEventListener('DOMContentLoaded', function() { |
| 115 $('uploadCrashesLink').onclick = requestCrashUpload; |
| 116 requestCrashes(); |
| 117 }); |
| OLD | NEW |