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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 } | 1094 } |
1095 copyMenu.appendItem(Common.UIString.capitalize('Copy ^all as HAR'), this._co
pyAll.bind(this)); | 1095 copyMenu.appendItem(Common.UIString.capitalize('Copy ^all as HAR'), this._co
pyAll.bind(this)); |
1096 | 1096 |
1097 contextMenu.appendSeparator(); | 1097 contextMenu.appendSeparator(); |
1098 contextMenu.appendItem(Common.UIString.capitalize('Save as HAR with ^content
'), this._exportAll.bind(this)); | 1098 contextMenu.appendItem(Common.UIString.capitalize('Save as HAR with ^content
'), this._exportAll.bind(this)); |
1099 | 1099 |
1100 contextMenu.appendSeparator(); | 1100 contextMenu.appendSeparator(); |
1101 contextMenu.appendItem(Common.UIString.capitalize('Clear ^browser ^cache'),
this._clearBrowserCache.bind(this)); | 1101 contextMenu.appendItem(Common.UIString.capitalize('Clear ^browser ^cache'),
this._clearBrowserCache.bind(this)); |
1102 contextMenu.appendItem(Common.UIString.capitalize('Clear ^browser ^cookies')
, this._clearBrowserCookies.bind(this)); | 1102 contextMenu.appendItem(Common.UIString.capitalize('Clear ^browser ^cookies')
, this._clearBrowserCookies.bind(this)); |
1103 | 1103 |
1104 var blockedSetting = Common.moduleSetting('blockedURLs'); | |
1105 if (request && Runtime.experiments.isEnabled('requestBlocking')) { // Disab
led until ready. | 1104 if (request && Runtime.experiments.isEnabled('requestBlocking')) { // Disab
led until ready. |
1106 contextMenu.appendSeparator(); | 1105 contextMenu.appendSeparator(); |
1107 | 1106 |
| 1107 var blockedSetting = Common.moduleSetting('networkBlockedURLs'); |
| 1108 var blockedSettingData = blockedSetting.get(); |
| 1109 |
| 1110 const maxBlockedURLLength = 20; |
1108 var urlWithoutScheme = request.parsedURL.urlWithoutScheme(); | 1111 var urlWithoutScheme = request.parsedURL.urlWithoutScheme(); |
1109 if (urlWithoutScheme && blockedSetting.get().indexOf(urlWithoutScheme) ===
-1) { | 1112 var blockedURLIndex = blockedSettingData.indexOf(urlWithoutScheme); |
| 1113 if (urlWithoutScheme && blockedURLIndex === -1) { |
1110 contextMenu.appendItem( | 1114 contextMenu.appendItem( |
1111 Common.UIString.capitalize('Block ^request URL'), addBlockedURL.bind
(null, urlWithoutScheme)); | 1115 Common.UIString.capitalize('Block ^request URL'), addBlockedURL.bind
(null, urlWithoutScheme)); |
| 1116 } else if (urlWithoutScheme) { |
| 1117 const croppedURL = blockedSettingData[blockedURLIndex].trimMiddle(maxBlo
ckedURLLength); |
| 1118 contextMenu.appendItem( |
| 1119 Common.UIString.capitalize('Unblock ' + croppedURL), removeBlockedUR
LIndex.bind(null, blockedURLIndex)); |
1112 } | 1120 } |
1113 | 1121 |
1114 var domain = request.parsedURL.domain(); | 1122 var domain = request.parsedURL.domain(); |
1115 if (domain && blockedSetting.get().indexOf(domain) === -1) | 1123 var blockedDomainIndex = blockedSettingData.indexOf(domain); |
| 1124 if (domain && blockedDomainIndex === -1) { |
1116 contextMenu.appendItem(Common.UIString.capitalize('Block ^request ^domai
n'), addBlockedURL.bind(null, domain)); | 1125 contextMenu.appendItem(Common.UIString.capitalize('Block ^request ^domai
n'), addBlockedURL.bind(null, domain)); |
| 1126 } else if (domain) { |
| 1127 const croppedDomain = blockedSettingData[blockedDomainIndex].trimMiddle(
maxBlockedURLLength); |
| 1128 contextMenu.appendItem( |
| 1129 Common.UIString.capitalize('Unblock ' + croppedDomain), |
| 1130 removeBlockedURLIndex.bind(null, blockedDomainIndex)); |
| 1131 } |
1117 | 1132 |
| 1133 /** |
| 1134 * @param {string} url |
| 1135 */ |
1118 function addBlockedURL(url) { | 1136 function addBlockedURL(url) { |
1119 var list = blockedSetting.get(); | 1137 blockedSettingData.push(url); |
1120 list.push(url); | 1138 blockedSetting.set(blockedSettingData); |
1121 blockedSetting.set(list); | 1139 UI.viewManager.showView('network.blocked-urls'); |
| 1140 } |
| 1141 |
| 1142 /** |
| 1143 * @param {number} index |
| 1144 */ |
| 1145 function removeBlockedURLIndex(index) { |
| 1146 blockedSettingData.splice(index, 1); |
| 1147 blockedSetting.set(blockedSettingData); |
1122 UI.viewManager.showView('network.blocked-urls'); | 1148 UI.viewManager.showView('network.blocked-urls'); |
1123 SDK.multitargetNetworkManager.setRequestBlockingEnabled(true); | 1149 SDK.multitargetNetworkManager.setRequestBlockingEnabled(true); |
1124 } | 1150 } |
1125 } | 1151 } |
1126 | 1152 |
1127 if (request && request.resourceType() === Common.resourceTypes.XHR) { | 1153 if (request && request.resourceType() === Common.resourceTypes.XHR) { |
1128 contextMenu.appendSeparator(); | 1154 contextMenu.appendSeparator(); |
1129 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi
nd(request)); | 1155 contextMenu.appendItem(Common.UIString('Replay XHR'), request.replayXHR.bi
nd(request)); |
1130 contextMenu.appendSeparator(); | 1156 contextMenu.appendSeparator(); |
1131 } | 1157 } |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 Running: 'running', | 1776 Running: 'running', |
1751 FromCache: 'from-cache' | 1777 FromCache: 'from-cache' |
1752 }; | 1778 }; |
1753 | 1779 |
1754 /** @type {!Array<string>} */ | 1780 /** @type {!Array<string>} */ |
1755 Network.NetworkLogView._searchKeys = | 1781 Network.NetworkLogView._searchKeys = |
1756 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog
View.FilterType[key]); | 1782 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog
View.FilterType[key]); |
1757 | 1783 |
1758 /** @typedef {function(!SDK.NetworkRequest): boolean} */ | 1784 /** @typedef {function(!SDK.NetworkRequest): boolean} */ |
1759 Network.NetworkLogView.Filter; | 1785 Network.NetworkLogView.Filter; |
OLD | NEW |