| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 * TODO(eroman): This needs better presentation, and cleaner code. This | 6 * TODO(eroman): This needs better presentation, and cleaner code. This |
| 7 * implementation is more of a transitionary step as | 7 * implementation is more of a transitionary step as |
| 8 * the old net-internals is replaced. | 8 * the old net-internals is replaced. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 // TODO(eroman): these functions should use lower-case names. | 11 // TODO(eroman): these functions should use lower-case names. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 36 addTextNode(nobr, sourceEntry.getDescription()); | 36 addTextNode(nobr, sourceEntry.getDescription()); |
| 37 | 37 |
| 38 var p2 = addNode(div, 'p'); | 38 var p2 = addNode(div, 'p'); |
| 39 var nobr2 = addNode(p2, 'nobr'); | 39 var nobr2 = addNode(p2, 'nobr'); |
| 40 | 40 |
| 41 var logEntries = sourceEntry.getLogEntries(); | 41 var logEntries = sourceEntry.getLogEntries(); |
| 42 var startDate = g_browser.convertTimeTicksToDate(logEntries[0].time); | 42 var startDate = g_browser.convertTimeTicksToDate(logEntries[0].time); |
| 43 addTextNode(nobr2, 'Start Time: ' + startDate.toLocaleString()); | 43 addTextNode(nobr2, 'Start Time: ' + startDate.toLocaleString()); |
| 44 | 44 |
| 45 var pre = addNode(div, 'pre'); | 45 var pre = addNode(div, 'pre'); |
| 46 addTextNode(pre, PrintSourceEntriesAsText(logEntries, false)); | 46 addTextNode(pre, PrintSourceEntriesAsText(logEntries)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 function canCollapseBeginWithEnd(beginEntry) { | 49 function canCollapseBeginWithEnd(beginEntry) { |
| 50 return beginEntry && | 50 return beginEntry && |
| 51 beginEntry.isBegin() && | 51 beginEntry.isBegin() && |
| 52 beginEntry.end && | 52 beginEntry.end && |
| 53 beginEntry.end.index == beginEntry.index + 1 && | 53 beginEntry.end.index == beginEntry.index + 1 && |
| 54 (!beginEntry.orig.params || !beginEntry.end.orig.params) && | 54 (!beginEntry.orig.params || !beginEntry.end.orig.params) && |
| 55 beginEntry.orig.wasPassivelyCaptured == | 55 beginEntry.orig.wasPassivelyCaptured == |
| 56 beginEntry.end.orig.wasPassivelyCaptured; | 56 beginEntry.end.orig.wasPassivelyCaptured; |
| 57 } | 57 } |
| 58 | 58 |
| 59 PrintSourceEntriesAsText = function(sourceEntries, doSecurityStripping) { | 59 PrintSourceEntriesAsText = function(sourceEntries) { |
| 60 var entries = LogGroupEntry.createArrayFrom(sourceEntries); | 60 var entries = LogGroupEntry.createArrayFrom(sourceEntries); |
| 61 if (entries.length == 0) | 61 if (entries.length == 0) |
| 62 return ''; | 62 return ''; |
| 63 | 63 |
| 64 var startDate = g_browser.convertTimeTicksToDate(entries[0].orig.time); | 64 var startDate = g_browser.convertTimeTicksToDate(entries[0].orig.time); |
| 65 var startTime = startDate.getTime(); | 65 var startTime = startDate.getTime(); |
| 66 | 66 |
| 67 var tablePrinter = new TablePrinter(); | 67 var tablePrinter = new TablePrinter(); |
| 68 | 68 |
| 69 for (var i = 0; i < entries.length; ++i) { | 69 for (var i = 0; i < entries.length; ++i) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 tablePrinter.addCell(']'); | 105 tablePrinter.addCell(']'); |
| 106 } else { | 106 } else { |
| 107 mainCell.allowOverflow = true; | 107 mainCell.allowOverflow = true; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Output the extra parameters. | 111 // Output the extra parameters. |
| 112 if (entry.orig.params != undefined) { | 112 if (entry.orig.params != undefined) { |
| 113 // Add a continuation row for each line of text from the extra parameters. | 113 // Add a continuation row for each line of text from the extra parameters. |
| 114 var extraParamsText = getTextForExtraParams(entry.orig, | 114 var extraParamsText = getTextForExtraParams( |
| 115 doSecurityStripping); | 115 entry.orig, |
| 116 g_browser.getSecurityStripping()); |
| 116 var extraParamsTextLines = extraParamsText.split('\n'); | 117 var extraParamsTextLines = extraParamsText.split('\n'); |
| 117 | 118 |
| 118 for (var j = 0; j < extraParamsTextLines.length; ++j) { | 119 for (var j = 0; j < extraParamsTextLines.length; ++j) { |
| 119 tablePrinter.addRow(); | 120 tablePrinter.addRow(); |
| 120 tablePrinter.addCell(''); // Empty passive annotation. | 121 tablePrinter.addCell(''); // Empty passive annotation. |
| 121 tablePrinter.addCell(''); // No t=. | 122 tablePrinter.addCell(''); // No t=. |
| 122 tablePrinter.addCell(''); | 123 tablePrinter.addCell(''); |
| 123 tablePrinter.addCell(''); // No st=. | 124 tablePrinter.addCell(''); // No st=. |
| 124 tablePrinter.addCell(''); | 125 tablePrinter.addCell(''); |
| 125 tablePrinter.addCell(' '); | 126 tablePrinter.addCell(' '); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 170 } |
| 170 | 171 |
| 171 // Max sure the ASCII text on last line of output lines up with previous | 172 // Max sure the ASCII text on last line of output lines up with previous |
| 172 // lines. | 173 // lines. |
| 173 hexLine += makeRepeatedString(' ', 3 * asciiCharsPerLine - hexLine.length); | 174 hexLine += makeRepeatedString(' ', 3 * asciiCharsPerLine - hexLine.length); |
| 174 out.push(' ' + hexLine + ' ' + asciiLine); | 175 out.push(' ' + hexLine + ' ' + asciiLine); |
| 175 } | 176 } |
| 176 return out.join('\n'); | 177 return out.join('\n'); |
| 177 } | 178 } |
| 178 | 179 |
| 179 function getTextForExtraParams(entry, doSecurityStripping) { | 180 function getTextForExtraParams(entry, enableSecurityStripping) { |
| 180 // Format the extra parameters (use a custom formatter for certain types, | 181 // Format the extra parameters (use a custom formatter for certain types, |
| 181 // but default to displaying as JSON). | 182 // but default to displaying as JSON). |
| 182 switch (entry.type) { | 183 switch (entry.type) { |
| 183 case LogEventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS: | 184 case LogEventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS: |
| 184 case LogEventType.HTTP_TRANSACTION_SEND_TUNNEL_HEADERS: | 185 case LogEventType.HTTP_TRANSACTION_SEND_TUNNEL_HEADERS: |
| 185 return getTextForRequestHeadersExtraParam(entry, doSecurityStripping); | 186 return getTextForRequestHeadersExtraParam(entry, enableSecurityStripping); |
| 186 | 187 |
| 187 case LogEventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS: | 188 case LogEventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS: |
| 188 case LogEventType.HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS: | 189 case LogEventType.HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS: |
| 189 return getTextForResponseHeadersExtraParam(entry, doSecurityStripping); | 190 return getTextForResponseHeadersExtraParam(entry, |
| 191 enableSecurityStripping); |
| 190 | 192 |
| 191 case LogEventType.PROXY_CONFIG_CHANGED: | 193 case LogEventType.PROXY_CONFIG_CHANGED: |
| 192 return getTextForProxyConfigChangedExtraParam(entry); | 194 return getTextForProxyConfigChangedExtraParam(entry); |
| 193 | 195 |
| 194 default: | 196 default: |
| 195 var out = []; | 197 var out = []; |
| 196 for (var k in entry.params) { | 198 for (var k in entry.params) { |
| 197 if (k == 'headers' && entry.params[k] instanceof Array) { | 199 if (k == 'headers' && entry.params[k] instanceof Array) { |
| 198 out.push(getTextForResponseHeadersExtraParam(entry, | 200 out.push( |
| 199 doSecurityStripping)); | 201 getTextForResponseHeadersExtraParam(entry, |
| 202 enableSecurityStripping)); |
| 200 continue; | 203 continue; |
| 201 } | 204 } |
| 202 var value = entry.params[k]; | 205 var value = entry.params[k]; |
| 203 // For transferred bytes, display the bytes in hex and ASCII. | 206 // For transferred bytes, display the bytes in hex and ASCII. |
| 204 if (k == 'hex_encoded_bytes') { | 207 if (k == 'hex_encoded_bytes') { |
| 205 out.push(' --> ' + k + ' ='); | 208 out.push(' --> ' + k + ' ='); |
| 206 out.push(formatHexString(value, 20)); | 209 out.push(formatHexString(value, 20)); |
| 207 continue; | 210 continue; |
| 208 } | 211 } |
| 209 | 212 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 297 } |
| 295 | 298 |
| 296 /** | 299 /** |
| 297 * Removes all cookie and unencrypted login text from a list of HTTP | 300 * Removes all cookie and unencrypted login text from a list of HTTP |
| 298 * header lines. | 301 * header lines. |
| 299 */ | 302 */ |
| 300 function stripCookiesAndLoginInfo(headers) { | 303 function stripCookiesAndLoginInfo(headers) { |
| 301 return headers.map(stripCookieOrLoginInfo); | 304 return headers.map(stripCookieOrLoginInfo); |
| 302 } | 305 } |
| 303 | 306 |
| 304 function getTextForRequestHeadersExtraParam(entry, doSecurityStripping) { | 307 function getTextForRequestHeadersExtraParam(entry, enableSecurityStripping) { |
| 305 var params = entry.params; | 308 var params = entry.params; |
| 306 | 309 |
| 307 // Strip the trailing CRLF that params.line contains. | 310 // Strip the trailing CRLF that params.line contains. |
| 308 var lineWithoutCRLF = params.line.replace(/\r\n$/g, ''); | 311 var lineWithoutCRLF = params.line.replace(/\r\n$/g, ''); |
| 309 | 312 |
| 310 var headers = params.headers; | 313 var headers = params.headers; |
| 311 if (doSecurityStripping) | 314 if (enableSecurityStripping) |
| 312 headers = stripCookiesAndLoginInfo(headers); | 315 headers = stripCookiesAndLoginInfo(headers); |
| 313 | 316 |
| 314 return indentLines(' --> ', [lineWithoutCRLF].concat(headers)); | 317 return indentLines(' --> ', [lineWithoutCRLF].concat(headers)); |
| 315 } | 318 } |
| 316 | 319 |
| 317 function getTextForResponseHeadersExtraParam(entry, doSecurityStripping) { | 320 function getTextForResponseHeadersExtraParam(entry, enableSecurityStripping) { |
| 318 var headers = entry.params.headers; | 321 var headers = entry.params.headers; |
| 319 if (doSecurityStripping) | 322 if (enableSecurityStripping) |
| 320 headers = stripCookiesAndLoginInfo(headers); | 323 headers = stripCookiesAndLoginInfo(headers); |
| 321 return indentLines(' --> ', headers); | 324 return indentLines(' --> ', headers); |
| 322 } | 325 } |
| 323 | 326 |
| 324 function getTextForProxyConfigChangedExtraParam(entry) { | 327 function getTextForProxyConfigChangedExtraParam(entry) { |
| 325 var params = entry.params; | 328 var params = entry.params; |
| 326 var out = ''; | 329 var out = ''; |
| 327 var indentation = ' '; | 330 var indentation = ' '; |
| 328 | 331 |
| 329 if (params.old_config) { | 332 if (params.old_config) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 var result = []; | 425 var result = []; |
| 423 for (var i = 0; i < modes.length; ++i) | 426 for (var i = 0; i < modes.length; ++i) |
| 424 result.push(indentLines('(' + (i + 1) + ') ', modes[i])); | 427 result.push(indentLines('(' + (i + 1) + ') ', modes[i])); |
| 425 | 428 |
| 426 return result.join('\n'); | 429 return result.join('\n'); |
| 427 }; | 430 }; |
| 428 | 431 |
| 429 // End of anonymous namespace. | 432 // End of anonymous namespace. |
| 430 })(); | 433 })(); |
| 431 | 434 |
| OLD | NEW |