| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 /** | 5 /** |
| 6 * This view displays options for importing/exporting the captured data. Its | 6 * This view displays options for importing/exporting the captured data. Its |
| 7 * primarily usefulness is to allow users to copy-paste their data in an easy | 7 * primarily usefulness is to allow users to copy-paste their data in an easy |
| 8 * to read format for bug reports. | 8 * to read format for bug reports. |
| 9 * | 9 * |
| 10 * - Has a button to generate a text report. | 10 * - Has a button to generate a text report. |
| 11 * | 11 * |
| 12 * - Shows how many events have been captured. | 12 * - Shows how many events have been captured. |
| 13 * @constructor | 13 * @constructor |
| 14 */ | 14 */ |
| 15 function DataView(mainBoxId, | 15 function DataView(mainBoxId, |
| 16 outputTextBoxId, | 16 outputTextBoxId, |
| 17 exportTextButtonId, | 17 exportTextButtonId, |
| 18 securityStrippingCheckboxId, | 18 securityStrippingCheckboxId, |
| 19 byteLoggingCheckboxId, | 19 byteLoggingCheckboxId, |
| 20 passivelyCapturedCountId, | 20 passivelyCapturedCountId, |
| 21 activelyCapturedCountId, | 21 activelyCapturedCountId, |
| 22 deleteAllId) { | 22 deleteAllId, |
| 23 dumpDataDivId, |
| 24 loadDataDivId, |
| 25 loadLogFileId, |
| 26 capturingTextSpanId, |
| 27 loggingTextSpanId) { |
| 23 DivView.call(this, mainBoxId); | 28 DivView.call(this, mainBoxId); |
| 24 | 29 |
| 25 this.textPre_ = document.getElementById(outputTextBoxId); | 30 this.textPre_ = document.getElementById(outputTextBoxId); |
| 26 this.securityStrippingCheckbox_ = | 31 this.securityStrippingCheckbox_ = |
| 27 document.getElementById(securityStrippingCheckboxId); | 32 document.getElementById(securityStrippingCheckboxId); |
| 28 | 33 |
| 29 var byteLoggingCheckbox = document.getElementById(byteLoggingCheckboxId); | 34 var byteLoggingCheckbox = document.getElementById(byteLoggingCheckboxId); |
| 30 byteLoggingCheckbox.onclick = | 35 byteLoggingCheckbox.onclick = |
| 31 this.onSetByteLogging_.bind(this, byteLoggingCheckbox); | 36 this.onSetByteLogging_.bind(this, byteLoggingCheckbox); |
| 32 | 37 |
| 33 var exportTextButton = document.getElementById(exportTextButtonId); | 38 var exportTextButton = document.getElementById(exportTextButtonId); |
| 34 exportTextButton.onclick = this.onExportToText_.bind(this); | 39 exportTextButton.onclick = this.onExportToText_.bind(this); |
| 35 | 40 |
| 36 this.activelyCapturedCountBox_ = | 41 this.activelyCapturedCountBox_ = |
| 37 document.getElementById(activelyCapturedCountId); | 42 document.getElementById(activelyCapturedCountId); |
| 38 this.passivelyCapturedCountBox_ = | 43 this.passivelyCapturedCountBox_ = |
| 39 document.getElementById(passivelyCapturedCountId); | 44 document.getElementById(passivelyCapturedCountId); |
| 40 document.getElementById(deleteAllId).onclick = | 45 document.getElementById(deleteAllId).onclick = |
| 41 g_browser.deleteAllEvents.bind(g_browser); | 46 g_browser.deleteAllEvents.bind(g_browser); |
| 42 | 47 |
| 48 this.dumpDataDiv_ = document.getElementById(dumpDataDivId); |
| 49 this.loadDataDiv_ = document.getElementById(loadDataDivId); |
| 50 this.capturingTextSpan_ = document.getElementById(capturingTextSpanId); |
| 51 this.loggingTextSpan_ = document.getElementById(loggingTextSpanId); |
| 52 |
| 53 document.getElementById(loadLogFileId).onclick = |
| 54 g_browser.loadLogFile.bind(g_browser); |
| 55 |
| 43 this.updateEventCounts_(); | 56 this.updateEventCounts_(); |
| 44 this.waitingForUpdate_ = false; | 57 this.waitingForUpdate_ = false; |
| 45 | 58 |
| 46 g_browser.addLogObserver(this); | 59 g_browser.addLogObserver(this); |
| 47 } | 60 } |
| 48 | 61 |
| 49 inherits(DataView, DivView); | 62 inherits(DataView, DivView); |
| 50 | 63 |
| 51 /** | 64 /** |
| 52 * Called whenever a new event is received. | 65 * Called whenever a new event is received. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 }; | 77 }; |
| 65 | 78 |
| 66 /** | 79 /** |
| 67 * Called whenever all log events are deleted. | 80 * Called whenever all log events are deleted. |
| 68 */ | 81 */ |
| 69 DataView.prototype.onAllLogEntriesDeleted = function() { | 82 DataView.prototype.onAllLogEntriesDeleted = function() { |
| 70 this.updateEventCounts_(); | 83 this.updateEventCounts_(); |
| 71 }; | 84 }; |
| 72 | 85 |
| 73 /** | 86 /** |
| 87 * Called when either a log file is loaded or when going back to actively |
| 88 * logging events. In either case, called after clearing the old entries, |
| 89 * but before getting any new ones. |
| 90 */ |
| 91 DataView.prototype.onSetIsViewingLogFile = function(isViewingLogFile) { |
| 92 setNodeDisplay(this.dumpDataDiv_, !isViewingLogFile); |
| 93 setNodeDisplay(this.capturingTextSpan_, !isViewingLogFile); |
| 94 setNodeDisplay(this.loggingTextSpan_, isViewingLogFile); |
| 95 this.setText_(''); |
| 96 }; |
| 97 |
| 98 /** |
| 74 * Updates the counters showing how many events have been captured. | 99 * Updates the counters showing how many events have been captured. |
| 75 */ | 100 */ |
| 76 DataView.prototype.updateEventCounts_ = function() { | 101 DataView.prototype.updateEventCounts_ = function() { |
| 77 this.activelyCapturedCountBox_.innerText = | 102 this.activelyCapturedCountBox_.innerText = |
| 78 g_browser.getNumActivelyCapturedEvents() | 103 g_browser.getNumActivelyCapturedEvents() |
| 79 this.passivelyCapturedCountBox_.innerText = | 104 this.passivelyCapturedCountBox_.innerText = |
| 80 g_browser.getNumPassivelyCapturedEvents(); | 105 g_browser.getNumPassivelyCapturedEvents(); |
| 81 }; | 106 }; |
| 82 | 107 |
| 83 /** | 108 /** |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 * Select all text from log dump. | 416 * Select all text from log dump. |
| 392 */ | 417 */ |
| 393 DataView.prototype.selectText_ = function() { | 418 DataView.prototype.selectText_ = function() { |
| 394 var selection = window.getSelection(); | 419 var selection = window.getSelection(); |
| 395 selection.removeAllRanges(); | 420 selection.removeAllRanges(); |
| 396 | 421 |
| 397 var range = document.createRange(); | 422 var range = document.createRange(); |
| 398 range.selectNodeContents(this.textPre_); | 423 range.selectNodeContents(this.textPre_); |
| 399 selection.addRange(range); | 424 selection.addRange(range); |
| 400 }; | 425 }; |
| OLD | NEW |