Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** @type {string} | 5 /** @type {string} |
| 6 * @const | 6 * @const |
| 7 */ | 7 */ |
| 8 var FEEDBACK_LANDING_PAGE = | 8 var FEEDBACK_LANDING_PAGE = |
| 9 'https://www.google.com/support/chrome/go/feedback_confirmation'; | 9 'https://www.google.com/support/chrome/go/feedback_confirmation'; |
| 10 /** @type {number} | 10 /** @type {number} |
| 11 * @const | 11 * @const |
| 12 */ | 12 */ |
| 13 var MAX_ATTACH_FILE_SIZE = 3 * 1024 * 1024; | 13 var MAX_ATTACH_FILE_SIZE = 3 * 1024 * 1024; |
| 14 | 14 |
| 15 var attachedFileBlob = null; | 15 var attachedFileBlob = null; |
| 16 var lastReader = null; | 16 var lastReader = null; |
| 17 | 17 |
| 18 var feedbackInfo = null; | 18 var feedbackInfo = null; |
| 19 var systemInfo = null; | 19 var systemInfo = null; |
| 20 | 20 |
| 21 var systemInfoWindowId = 0; | 21 var systemInfoWindowId = 0; |
| 22 var histogramsWindowId = 0; | |
| 22 | 23 |
| 23 /** | 24 /** |
| 24 * Reads the selected file when the user selects a file. | 25 * Reads the selected file when the user selects a file. |
| 25 * @param {Event} fileSelectedEvent The onChanged event for the file input box. | 26 * @param {Event} fileSelectedEvent The onChanged event for the file input box. |
| 26 */ | 27 */ |
| 27 function onFileSelected(fileSelectedEvent) { | 28 function onFileSelected(fileSelectedEvent) { |
| 28 $('attach-error').hidden = true; | 29 $('attach-error').hidden = true; |
| 29 var file = fileSelectedEvent.target.files[0]; | 30 var file = fileSelectedEvent.target.files[0]; |
| 30 if (!file) { | 31 if (!file) { |
| 31 // User canceled file selection. | 32 // User canceled file selection. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 chrome.windows.create({url: 'chrome://system'}, function(win) { | 66 chrome.windows.create({url: 'chrome://system'}, function(win) { |
| 66 systemInfoWindowId = win.id; | 67 systemInfoWindowId = win.id; |
| 67 chrome.app.window.current().show(); | 68 chrome.app.window.current().show(); |
| 68 }); | 69 }); |
| 69 } else { | 70 } else { |
| 70 chrome.windows.update(systemInfoWindowId, {drawAttention: true}); | 71 chrome.windows.update(systemInfoWindowId, {drawAttention: true}); |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 /** | 75 /** |
| 76 * Opens a new window with chrome://histograms, showing the histogram metrics. | |
| 77 */ | |
| 78 function openHistogramsWindow() { | |
|
rkc
2013/11/01 19:57:39
Move this code to a common function which both ope
michaelpg
2013/11/01 22:14:50
How about this, or is it too much?
rkc
2013/11/01 22:28:32
LG.
| |
| 79 if (histogramsWindowId == 0) { | |
| 80 chrome.windows.create({url: 'chrome://histograms'}, function(win) { | |
| 81 histogramsWindowId = win.id; | |
| 82 chrome.app.window.current().show(); | |
| 83 }); | |
| 84 } else { | |
| 85 chrome.windows.update(histogramsWindowId, {drawAttention: true}); | |
| 86 } | |
| 87 } | |
| 88 | |
| 89 /** | |
| 75 * Opens a new window with chrome://slow_trace, downloading performance data. | 90 * Opens a new window with chrome://slow_trace, downloading performance data. |
| 76 */ | 91 */ |
| 77 function openSlowTraceWindow() { | 92 function openSlowTraceWindow() { |
| 78 chrome.windows.create( | 93 chrome.windows.create( |
| 79 {url: 'chrome://slow_trace/tracing.zip#' + feedbackInfo.traceId}, | 94 {url: 'chrome://slow_trace/tracing.zip#' + feedbackInfo.traceId}, |
| 80 function(win) {}); | 95 function(win) {}); |
| 81 } | 96 } |
| 82 | 97 |
| 83 /** | 98 /** |
| 84 * Sends the report; after the report is sent, we need to be redirected to | 99 * Sends the report; after the report is sent, we need to be redirected to |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 100 if (!feedbackInfo.attachedFile && attachedFileBlob) { | 115 if (!feedbackInfo.attachedFile && attachedFileBlob) { |
| 101 feedbackInfo.attachedFile = { name: $('attach-file').value, | 116 feedbackInfo.attachedFile = { name: $('attach-file').value, |
| 102 data: attachedFileBlob }; | 117 data: attachedFileBlob }; |
| 103 } | 118 } |
| 104 | 119 |
| 105 feedbackInfo.description = $('description-text').value; | 120 feedbackInfo.description = $('description-text').value; |
| 106 feedbackInfo.pageUrl = $('page-url-text').value; | 121 feedbackInfo.pageUrl = $('page-url-text').value; |
| 107 feedbackInfo.email = $('user-email-text').value; | 122 feedbackInfo.email = $('user-email-text').value; |
| 108 | 123 |
| 109 var useSystemInfo = false; | 124 var useSystemInfo = false; |
| 125 var useHistograms = false; | |
| 110 // On ChromeOS, since we gather System info, check if the user has given his | 126 // On ChromeOS, since we gather System info, check if the user has given his |
| 111 // permission for us to send system info. | 127 // permission for us to send system info. |
| 112 <if expr="pp_ifdef('chromeos')"> | 128 <if expr="pp_ifdef('chromeos')"> |
| 113 if ($('sys-info-checkbox') != null && | 129 if ($('sys-info-checkbox') != null && |
| 114 $('sys-info-checkbox').checked && | 130 $('sys-info-checkbox').checked && |
| 115 systemInfo != null) { | 131 systemInfo != null) { |
| 116 useSystemInfo = true; | 132 // Send histograms along with system info. |
| 133 useSystemInfo = useHistograms = true; | |
| 117 } | 134 } |
| 118 if ($('performance-info-checkbox') == null || | 135 if ($('performance-info-checkbox') == null || |
| 119 !($('performance-info-checkbox').checked)) { | 136 !($('performance-info-checkbox').checked)) { |
| 120 feedbackInfo.traceId = null; | 137 feedbackInfo.traceId = null; |
| 121 } | 138 } |
| 122 </if> | 139 </if> |
| 123 | 140 |
| 124 // On NonChromeOS, we don't have any system information gathered except the | 141 // On NonChromeOS, we don't have any system information gathered except the |
| 125 // Chrome version and the OS version. Hence for Chrome, pass the system info | 142 // Chrome version and the OS version. Hence for Chrome, pass the system info |
| 126 // through. | 143 // through. |
| 127 <if expr="not pp_ifdef('chromeos')"> | 144 <if expr="not pp_ifdef('chromeos')"> |
| 128 if (systemInfo != null) | 145 if (systemInfo != null) |
| 129 useSystemInfo = true; | 146 useSystemInfo = true; |
| 130 </if> | 147 </if> |
| 131 | 148 |
| 132 if (useSystemInfo) { | 149 if (useSystemInfo) { |
| 133 if (feedbackInfo.systemInformation != null) { | 150 if (feedbackInfo.systemInformation != null) { |
| 134 // Concatenate sysinfo if we had any initial system information | 151 // Concatenate sysinfo if we had any initial system information |
| 135 // sent with the feedback request event. | 152 // sent with the feedback request event. |
| 136 feedbackInfo.systemInformation = | 153 feedbackInfo.systemInformation = |
| 137 feedbackInfo.systemInformation.concat(systemInfo); | 154 feedbackInfo.systemInformation.concat(systemInfo); |
| 138 } else { | 155 } else { |
| 139 feedbackInfo.systemInformation = systemInfo; | 156 feedbackInfo.systemInformation = systemInfo; |
| 140 } | 157 } |
| 141 } | 158 } |
| 142 | 159 |
| 160 feedbackInfo.sendHistograms = useHistograms; | |
|
rkc
2013/11/01 19:57:39
See my comment on the idl.
| |
| 161 | |
| 143 // If the user doesn't want to send the screenshot. | 162 // If the user doesn't want to send the screenshot. |
| 144 if (!$('screenshot-checkbox').checked) | 163 if (!$('screenshot-checkbox').checked) |
| 145 feedbackInfo.screenshot = null; | 164 feedbackInfo.screenshot = null; |
| 146 | 165 |
| 147 chrome.feedbackPrivate.sendFeedback(feedbackInfo, function(result) { | 166 chrome.feedbackPrivate.sendFeedback(feedbackInfo, function(result) { |
| 148 window.open(FEEDBACK_LANDING_PAGE, '_blank'); | 167 window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
| 149 window.close(); | 168 window.close(); |
| 150 }); | 169 }); |
| 151 | 170 |
| 152 return true; | 171 return true; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 $('performance-info-area').hidden = false; | 272 $('performance-info-area').hidden = false; |
| 254 $('performance-info-checkbox').checked = true; | 273 $('performance-info-checkbox').checked = true; |
| 255 performanceFeedbackChanged(); | 274 performanceFeedbackChanged(); |
| 256 $('performance-info-link').onclick = openSlowTraceWindow; | 275 $('performance-info-link').onclick = openSlowTraceWindow; |
| 257 } | 276 } |
| 258 </if> | 277 </if> |
| 259 | 278 |
| 260 chrome.feedbackPrivate.getStrings(function(strings) { | 279 chrome.feedbackPrivate.getStrings(function(strings) { |
| 261 loadTimeData.data = strings; | 280 loadTimeData.data = strings; |
| 262 i18nTemplate.process(document, loadTimeData); | 281 i18nTemplate.process(document, loadTimeData); |
| 282 | |
| 283 if ($('sys-info-url')) { | |
| 284 $('sys-info-url').onclick = openSystemInfoWindow; | |
| 285 } | |
| 286 if ($('histograms-url')) { | |
| 287 $('histograms-url').onclick = openHistogramsWindow; | |
| 288 } | |
| 263 }); | 289 }); |
| 264 } | 290 } |
| 265 }); | 291 }); |
| 266 | 292 |
| 267 window.addEventListener('DOMContentLoaded', function() { | 293 window.addEventListener('DOMContentLoaded', function() { |
| 268 // TODO(rkc): Remove logging once crbug.com/284662 is closed. | 294 // TODO(rkc): Remove logging once crbug.com/284662 is closed. |
| 269 console.log('FEEDBACK_DEBUG: feedback.js: DOMContentLoaded'); | 295 console.log('FEEDBACK_DEBUG: feedback.js: DOMContentLoaded'); |
| 270 // Ready to receive the feedback object. | 296 // Ready to receive the feedback object. |
| 271 chrome.runtime.sendMessage({ready: true}); | 297 chrome.runtime.sendMessage({ready: true}); |
| 272 | 298 |
| 273 // Setup our event handlers. | 299 // Setup our event handlers. |
| 274 $('attach-file').addEventListener('change', onFileSelected); | 300 $('attach-file').addEventListener('change', onFileSelected); |
| 275 $('send-report-button').onclick = sendReport; | 301 $('send-report-button').onclick = sendReport; |
| 276 $('cancel-button').onclick = cancel; | 302 $('cancel-button').onclick = cancel; |
| 277 $('remove-attached-file').onclick = clearAttachedFile; | 303 $('remove-attached-file').onclick = clearAttachedFile; |
| 278 <if expr="pp_ifdef('chromeos')"> | 304 <if expr="pp_ifdef('chromeos')"> |
| 279 $('performance-info-checkbox').addEventListener( | 305 $('performance-info-checkbox').addEventListener( |
| 280 'change', performanceFeedbackChanged); | 306 'change', performanceFeedbackChanged); |
| 281 </if> | 307 </if> |
| 282 | 308 |
| 283 chrome.windows.onRemoved.addListener(function(windowId, removeInfo) { | 309 chrome.windows.onRemoved.addListener(function(windowId, removeInfo) { |
| 284 if (windowId == systemInfoWindowId) | 310 if (windowId == systemInfoWindowId) |
| 285 systemInfoWindowId = 0; | 311 systemInfoWindowId = 0; |
| 312 else if (windowId == histogramsWindowId) | |
| 313 histogramsWindowId = 0; | |
| 286 }); | 314 }); |
| 287 if ($('sysinfo-url')) { | |
| 288 $('sysinfo-url').onclick = openSystemInfoWindow; | |
| 289 } | |
| 290 }); | 315 }); |
| 291 } | 316 } |
| 292 | 317 |
| 293 initialize(); | 318 initialize(); |
| OLD | NEW |