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 // Constants. | 5 // Constants. |
6 /** @const */ var FEEDBACK_LANDING_PAGE = | 6 /** @const */ var FEEDBACK_LANDING_PAGE = |
7 'https://www.google.com/support/chrome/go/feedback_confirmation'; | 7 'https://www.google.com/support/chrome/go/feedback_confirmation'; |
8 /** @const */ var MAX_ATTACH_FILE_SIZE = 3 * 1024 * 1024; | 8 /** @const */ var MAX_ATTACH_FILE_SIZE = 3 * 1024 * 1024; |
9 | 9 |
10 var selectedThumbnailDivId = ''; | 10 var selectedThumbnailDivId = ''; |
11 var selectedThumbnailId = ''; | 11 var selectedThumbnailId = ''; |
12 var selectedImageUrl; | 12 var selectedImageUrl; |
13 | 13 |
14 var savedThumbnailIds = []; | 14 var savedThumbnailIds = []; |
15 savedThumbnailIds['current-screenshots'] = ''; | 15 savedThumbnailIds['current-screenshots'] = ''; |
16 savedThumbnailIds['saved-screenshots'] = ''; | 16 savedThumbnailIds['saved-screenshots'] = ''; |
17 | 17 |
18 var categoryTag = ''; | 18 var categoryTag = ''; |
19 var filePath = ''; | 19 var filePath = ''; |
20 var forceDisableScreenshots = false; | 20 var forceDisableScreenshots = false; |
| 21 var traceId = 0; |
21 | 22 |
22 // Globals to manage reading data from the attach a file option. | 23 // Globals to manage reading data from the attach a file option. |
23 var attachFileBinaryData = ''; | 24 var attachFileBinaryData = ''; |
24 var lastReader = null; | 25 var lastReader = null; |
25 | 26 |
26 /** | 27 /** |
27 * Returns the base filename for a given path. Handles only Unix style paths. | 28 * Returns the base filename for a given path. Handles only Unix style paths. |
28 * @param {string} path The path to return the basename for. | 29 * @param {string} path The path to return the basename for. |
29 * @return {string} Basename for the path. | 30 * @return {string} Basename for the path. |
30 */ | 31 */ |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 178 |
178 var reportArray = [pageUrl, | 179 var reportArray = [pageUrl, |
179 categoryTag, | 180 categoryTag, |
180 $('description-text').value, | 181 $('description-text').value, |
181 userEmail, | 182 userEmail, |
182 imagePath]; | 183 imagePath]; |
183 | 184 |
184 // Add chromeos data if it exists. | 185 // Add chromeos data if it exists. |
185 if ($('sys-info-checkbox')) { | 186 if ($('sys-info-checkbox')) { |
186 reportArray = reportArray.concat([String($('sys-info-checkbox').checked)]); | 187 reportArray = reportArray.concat([String($('sys-info-checkbox').checked)]); |
| 188 if (!$('performance-info-checkbox').checked) { |
| 189 traceId = 0; |
| 190 } |
| 191 reportArray = reportArray.concat([String(traceId)]); |
187 } | 192 } |
188 | 193 |
189 if ($('attach-file-checkbox') && | 194 if ($('attach-file-checkbox') && |
190 $('attach-file-checkbox').checked) { | 195 $('attach-file-checkbox').checked) { |
191 if (attachFileBinaryData) { | 196 if (attachFileBinaryData) { |
192 reportArray = reportArray.concat( | 197 reportArray = reportArray.concat( |
193 [$('attach-file').files[0].name, btoa(attachFileBinaryData)]); | 198 [$('attach-file').files[0].name, btoa(attachFileBinaryData)]); |
194 } | 199 } |
195 } else if ($('attach-file-custom-checkbox') && | 200 } else if ($('attach-file-custom-checkbox') && |
196 $('attach-file-custom-checkbox').checked) { | 201 $('attach-file-custom-checkbox').checked) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 $('screenshot-label-current').hidden = false; | 272 $('screenshot-label-current').hidden = false; |
268 $('screenshot-label-saved').hidden = true; | 273 $('screenshot-label-saved').hidden = true; |
269 | 274 |
270 // Change the link to say "go to saved" | 275 // Change the link to say "go to saved" |
271 $('screenshot-link-tosaved').hidden = false; | 276 $('screenshot-link-tosaved').hidden = false; |
272 $('screenshot-link-tocurrent').hidden = true; | 277 $('screenshot-link-tocurrent').hidden = true; |
273 | 278 |
274 currentSelected(); | 279 currentSelected(); |
275 } | 280 } |
276 | 281 |
| 282 <if expr="pp_ifdef('chromeos')"> |
| 283 /** |
| 284 * Update the page when performance feedback state is changed. |
| 285 */ |
| 286 function performanceFeedbackChanged() { |
| 287 if ($('performance-info-checkbox').checked) { |
| 288 $('attach-file-checkbox').disabled = true; |
| 289 $('attach-file-checkbox').checked = false; |
| 290 |
| 291 $('screenshot-checkbox').disabled = true; |
| 292 $('screenshot-checkbox').checked = false; |
| 293 } else { |
| 294 $('attach-file-checkbox').disabled = false; |
| 295 $('screenshot-checkbox').disabled = false; |
| 296 } |
| 297 } |
| 298 </if> |
| 299 |
277 /////////////////////////////////////////////////////////////////////////////// | 300 /////////////////////////////////////////////////////////////////////////////// |
278 // Document Functions: | 301 // Document Functions: |
279 /** | 302 /** |
280 * Window onload handler, sets up the page. | 303 * Window onload handler, sets up the page. |
281 */ | 304 */ |
282 function load() { | 305 function load() { |
283 cr.ui.FocusOutlineManager.forDocument(document); | 306 cr.ui.FocusOutlineManager.forDocument(document); |
284 if ($('attach-file')) | 307 if ($('attach-file')) |
285 $('attach-file').addEventListener('change', onFileSelected); | 308 $('attach-file').addEventListener('change', onFileSelected); |
286 | 309 |
287 if ($('sysinfo-url')) { | 310 if ($('sysinfo-url')) { |
288 $('sysinfo-url').onclick = function(event) { | 311 $('sysinfo-url').onclick = function(event) { |
289 chrome.send('openSystemTab'); | 312 chrome.send('openSystemTab'); |
290 }; | 313 }; |
291 } | 314 } |
292 | 315 |
293 <if expr="pp_ifdef('chromeos')"> | 316 <if expr="pp_ifdef('chromeos')"> |
294 $('screenshot-link-tosaved').onclick = changeToSaved; | 317 $('screenshot-link-tosaved').onclick = changeToSaved; |
295 $('screenshot-link-tocurrent').onclick = changeToCurrent; | 318 $('screenshot-link-tocurrent').onclick = changeToCurrent; |
| 319 |
| 320 $('performance-info-checkbox').addEventListener( |
| 321 'change', performanceFeedbackChanged); |
296 </if> | 322 </if> |
297 $('send-report-button').onclick = sendReport; | 323 $('send-report-button').onclick = sendReport; |
298 $('cancel-button').onclick = cancel; | 324 $('cancel-button').onclick = cancel; |
299 | 325 |
300 // Set default values for the possible parameters, and then parse the actual | 326 // Set default values for the possible parameters, and then parse the actual |
301 // values from the URL href. | 327 // values from the URL href. |
302 var parameters = { | 328 var parameters = { |
303 'description': '', | 329 'description': '', |
304 'categoryTag': '', | 330 'categoryTag': '', |
305 'customPageUrl': '', | 331 'customPageUrl': '', |
306 'filePath': '', | 332 'filePath': '', |
| 333 'traceId': 0, |
307 }; | 334 }; |
308 | 335 |
309 var loc = window.location; | 336 var loc = window.location; |
310 // Split the query string into an array of parameters. | 337 // Split the query string into an array of parameters. |
311 var query = loc.search.substr(1).split('&'); | 338 var query = loc.search.substr(1).split('&'); |
312 // If we have a query in the hash. | 339 // If we have a query in the hash. |
313 if (loc.hash.indexOf('?') >= 0) { | 340 if (loc.hash.indexOf('?') >= 0) { |
314 // Remove the hash and split this query into parameters too. | 341 // Remove the hash and split this query into parameters too. |
315 query = query.concat(loc.hash.substr(loc.hash.indexOf('?') + 1).split('&')); | 342 query = query.concat(loc.hash.substr(loc.hash.indexOf('?') + 1).split('&')); |
316 } | 343 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 $('attach-file-custom-container').hidden = false; | 377 $('attach-file-custom-container').hidden = false; |
351 // No screenshots if we're being invoked by an extension - screenshot was | 378 // No screenshots if we're being invoked by an extension - screenshot was |
352 // never taken. | 379 // never taken. |
353 $('screenshot-checkbox').checked = false; | 380 $('screenshot-checkbox').checked = false; |
354 forceDisableScreenshots = true; | 381 forceDisableScreenshots = true; |
355 } else { | 382 } else { |
356 filePath = ''; | 383 filePath = ''; |
357 } | 384 } |
358 } | 385 } |
359 | 386 |
| 387 traceId = parameters['traceId']; |
| 388 if (traceId != 0 && ($('performance-info-area'))) { |
| 389 $('performance-info-area').hidden = false; |
| 390 $('performance-info-checkbox').checked = true; |
| 391 performanceFeedbackChanged(); |
| 392 } |
| 393 |
360 chrome.send('getDialogDefaults'); | 394 chrome.send('getDialogDefaults'); |
361 chrome.send('refreshCurrentScreenshot'); | 395 chrome.send('refreshCurrentScreenshot'); |
362 } | 396 } |
363 | 397 |
364 function setupCurrentScreenshot(screenshot) { | 398 function setupCurrentScreenshot(screenshot) { |
365 addScreenshot('current-screenshots', screenshot); | 399 addScreenshot('current-screenshots', screenshot); |
366 } | 400 } |
367 | 401 |
368 function setupSavedScreenshots(screenshots) { | 402 function setupSavedScreenshots(screenshots) { |
369 if (screenshots.length == 0) { | 403 if (screenshots.length == 0) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 438 |
405 if (!defaults.disableScreenshots) | 439 if (!defaults.disableScreenshots) |
406 enableScreenshots(); | 440 enableScreenshots(); |
407 | 441 |
408 if (defaults.useSaved) { | 442 if (defaults.useSaved) { |
409 $('screenshot-link-tosaved').hidden = false; | 443 $('screenshot-link-tosaved').hidden = false; |
410 } | 444 } |
411 } | 445 } |
412 | 446 |
413 window.addEventListener('DOMContentLoaded', load); | 447 window.addEventListener('DOMContentLoaded', load); |
OLD | NEW |