Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> | 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> |
| 4 * Copyright (C) 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 if (request) { | 1242 if (request) { |
| 1243 contextMenu.appendApplicableItems(request); | 1243 contextMenu.appendApplicableItems(request); |
| 1244 if (request.requestHeadersText()) | 1244 if (request.requestHeadersText()) |
| 1245 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^r equest ^headers"), this._copyRequestHeaders.bind(this, request)); | 1245 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^r equest ^headers"), this._copyRequestHeaders.bind(this, request)); |
| 1246 if (request.responseHeadersText) | 1246 if (request.responseHeadersText) |
| 1247 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^r esponse ^headers"), this._copyResponseHeaders.bind(this, request)); | 1247 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^r esponse ^headers"), this._copyResponseHeaders.bind(this, request)); |
| 1248 if (request.finished) | 1248 if (request.finished) |
| 1249 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^r esponse"), this._copyResponse.bind(this, request)); | 1249 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^r esponse"), this._copyResponse.bind(this, request)); |
| 1250 contextMenu.appendItem(WebInspector.UIString("Copy as cURL"), this._ copyCurlCommand.bind(this, request)); | 1250 |
| 1251 if (WebInspector.isWin()) { | |
| 1252 contextMenu.appendItem(WebInspector.UIString("Copy as cURL (cmd) "), this._copyCurlCommand.bind(this, request, "win")); | |
| 1253 contextMenu.appendItem(WebInspector.UIString("Copy as cURL (bash )"), this._copyCurlCommand.bind(this, request, "unix")); | |
| 1254 } else { | |
| 1255 contextMenu.appendItem(WebInspector.UIString("Copy as cURL"), th is._copyCurlCommand.bind(this, request, "unix")); | |
| 1256 } | |
| 1251 } | 1257 } |
| 1252 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^all as HA R"), this._copyAll.bind(this)); | 1258 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^all as HA R"), this._copyAll.bind(this)); |
| 1253 | 1259 |
| 1254 contextMenu.appendSeparator(); | 1260 contextMenu.appendSeparator(); |
| 1255 contextMenu.appendItem(WebInspector.UIString.capitalize("Save as HAR wit h ^content"), this._exportAll.bind(this)); | 1261 contextMenu.appendItem(WebInspector.UIString.capitalize("Save as HAR wit h ^content"), this._exportAll.bind(this)); |
| 1256 | 1262 |
| 1257 contextMenu.appendSeparator(); | 1263 contextMenu.appendSeparator(); |
| 1258 contextMenu.appendItem(WebInspector.UIString.capitalize("Clear ^browser ^cache"), this._clearBrowserCache.bind(this)); | 1264 contextMenu.appendItem(WebInspector.UIString.capitalize("Clear ^browser ^cache"), this._clearBrowserCache.bind(this)); |
| 1259 contextMenu.appendItem(WebInspector.UIString.capitalize("Clear ^browser ^cookies"), this._clearBrowserCookies.bind(this)); | 1265 contextMenu.appendItem(WebInspector.UIString.capitalize("Clear ^browser ^cookies"), this._clearBrowserCookies.bind(this)); |
| 1260 | 1266 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1310 /** | 1316 /** |
| 1311 * @param {!WebInspector.NetworkRequest} request | 1317 * @param {!WebInspector.NetworkRequest} request |
| 1312 */ | 1318 */ |
| 1313 _copyResponseHeaders: function(request) | 1319 _copyResponseHeaders: function(request) |
| 1314 { | 1320 { |
| 1315 InspectorFrontendHost.copyText(request.responseHeadersText); | 1321 InspectorFrontendHost.copyText(request.responseHeadersText); |
| 1316 }, | 1322 }, |
| 1317 | 1323 |
| 1318 /** | 1324 /** |
| 1319 * @param {!WebInspector.NetworkRequest} request | 1325 * @param {!WebInspector.NetworkRequest} request |
| 1326 * @param {string} platform | |
| 1320 */ | 1327 */ |
| 1321 _copyCurlCommand: function(request) | 1328 _copyCurlCommand: function(request, platform) |
| 1322 { | 1329 { |
| 1323 InspectorFrontendHost.copyText(this._generateCurlCommand(request)); | 1330 InspectorFrontendHost.copyText(this._generateCurlCommand(request, platfo rm)); |
| 1324 }, | 1331 }, |
| 1325 | 1332 |
| 1326 _exportAll: function() | 1333 _exportAll: function() |
| 1327 { | 1334 { |
| 1328 var filename = WebInspector.targetManager.inspectedPageDomain() + ".har" ; | 1335 var filename = WebInspector.targetManager.inspectedPageDomain() + ".har" ; |
| 1329 var stream = new WebInspector.FileOutputStream(); | 1336 var stream = new WebInspector.FileOutputStream(); |
| 1330 stream.open(filename, openCallback.bind(this)); | 1337 stream.open(filename, openCallback.bind(this)); |
| 1331 | 1338 |
| 1332 /** | 1339 /** |
| 1333 * @param {boolean} accepted | 1340 * @param {boolean} accepted |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1702 * @param {!WebInspector.NetworkDataGridNode} node | 1709 * @param {!WebInspector.NetworkDataGridNode} node |
| 1703 */ | 1710 */ |
| 1704 _highlightNode: function(node) | 1711 _highlightNode: function(node) |
| 1705 { | 1712 { |
| 1706 WebInspector.runCSSAnimationOnce(node.element(), "highlighted-row"); | 1713 WebInspector.runCSSAnimationOnce(node.element(), "highlighted-row"); |
| 1707 this._highlightedNode = node; | 1714 this._highlightedNode = node; |
| 1708 }, | 1715 }, |
| 1709 | 1716 |
| 1710 /** | 1717 /** |
| 1711 * @param {!WebInspector.NetworkRequest} request | 1718 * @param {!WebInspector.NetworkRequest} request |
| 1719 * @param {string} platform | |
| 1712 * @return {string} | 1720 * @return {string} |
| 1713 */ | 1721 */ |
| 1714 _generateCurlCommand: function(request) | 1722 _generateCurlCommand: function(request, platform) |
| 1715 { | 1723 { |
| 1716 var command = ["curl"]; | 1724 var command = ["curl"]; |
| 1717 // These headers are derived from URL (except "version") and would be ad ded by cURL anyway. | 1725 // These headers are derived from URL (except "version") and would be ad ded by cURL anyway. |
| 1718 var ignoredHeaders = {"host": 1, "method": 1, "path": 1, "scheme": 1, "v ersion": 1}; | 1726 var ignoredHeaders = {"host": 1, "method": 1, "path": 1, "scheme": 1, "v ersion": 1}; |
| 1719 | 1727 |
| 1720 function escapeStringWin(str) | 1728 function escapeStringWin(str) |
| 1721 { | 1729 { |
| 1722 /* Replace quote by double quote (but not by \") because it is | 1730 /* Replace quote by double quote (but not by \") because it is |
| 1723 recognized by both cmd.exe and MS Crt arguments parser. | 1731 recognized by both cmd.exe and MS Crt arguments parser. |
| 1724 | 1732 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1760 .replace(/\r/g, "\\r") | 1768 .replace(/\r/g, "\\r") |
| 1761 .replace(/[^\x20-\x7E]/g, escapeCharacter) + " '"; | 1769 .replace(/[^\x20-\x7E]/g, escapeCharacter) + " '"; |
| 1762 } else { | 1770 } else { |
| 1763 // Use single quote syntax. | 1771 // Use single quote syntax. |
| 1764 return "'" + str + "'"; | 1772 return "'" + str + "'"; |
| 1765 } | 1773 } |
| 1766 } | 1774 } |
| 1767 | 1775 |
| 1768 // cURL command expected to run on the same platform that DevTools run | 1776 // cURL command expected to run on the same platform that DevTools run |
| 1769 // (it may be different from the inspected page platform). | 1777 // (it may be different from the inspected page platform). |
| 1770 var escapeString = WebInspector.isWin() ? escapeStringWin : escapeString Posix; | 1778 var escapeString = platform == "win" ? escapeStringWin : escapeStringPos ix; |
|
alph
2015/06/03 19:01:16
please use === for comparison.
| |
| 1771 | 1779 |
| 1772 command.push(escapeString(request.url).replace(/[[{}\]]/g, "\\$&")); | 1780 command.push(escapeString(request.url).replace(/[[{}\]]/g, "\\$&")); |
| 1773 | 1781 |
| 1774 var inferredMethod = "GET"; | 1782 var inferredMethod = "GET"; |
| 1775 var data = []; | 1783 var data = []; |
| 1776 var requestContentType = request.requestContentType(); | 1784 var requestContentType = request.requestContentType(); |
| 1777 if (requestContentType && requestContentType.startsWith("application/x-w ww-form-urlencoded") && request.requestFormData) { | 1785 if (requestContentType && requestContentType.startsWith("application/x-w ww-form-urlencoded") && request.requestFormData) { |
| 1778 data.push("--data"); | 1786 data.push("--data"); |
| 1779 data.push(escapeString(request.requestFormData)); | 1787 data.push(escapeString(request.requestFormData)); |
| 1780 ignoredHeaders["content-length"] = true; | 1788 ignoredHeaders["content-length"] = true; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2019 if (request.endTime !== -1 && request.endTime < windowStart) | 2027 if (request.endTime !== -1 && request.endTime < windowStart) |
| 2020 return false; | 2028 return false; |
| 2021 return true; | 2029 return true; |
| 2022 } | 2030 } |
| 2023 | 2031 |
| 2024 WebInspector.NetworkLogView.EventTypes = { | 2032 WebInspector.NetworkLogView.EventTypes = { |
| 2025 RequestSelected: "RequestSelected", | 2033 RequestSelected: "RequestSelected", |
| 2026 SearchCountUpdated: "SearchCountUpdated", | 2034 SearchCountUpdated: "SearchCountUpdated", |
| 2027 SearchIndexUpdated: "SearchIndexUpdated" | 2035 SearchIndexUpdated: "SearchIndexUpdated" |
| 2028 }; | 2036 }; |
| OLD | NEW |