Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js b/third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js |
| index e4b472251a47a835ed2ad4274e4e5ef3ef347565..2652dd87aed788aa48336ff87c5594edd32ee064 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js |
| @@ -1101,24 +1101,50 @@ Network.NetworkLogView = class extends UI.VBox { |
| contextMenu.appendItem(Common.UIString.capitalize('Clear ^browser ^cache'), this._clearBrowserCache.bind(this)); |
| contextMenu.appendItem(Common.UIString.capitalize('Clear ^browser ^cookies'), this._clearBrowserCookies.bind(this)); |
| - var blockedSetting = Common.moduleSetting('blockedURLs'); |
| if (request && Runtime.experiments.isEnabled('requestBlocking')) { // Disabled until ready. |
| contextMenu.appendSeparator(); |
| + var blockedSetting = Common.moduleSetting('blockedURLs'); |
|
pfeldman
2017/02/11 01:34:59
Let's prefix this to be networkBlockedURLs now tha
allada
2017/02/11 02:29:17
Done.
|
| + var blockedSettingData = blockedSetting.get(); |
| + |
| + const maxBlockedURLLength = 20; |
| var urlWithoutScheme = request.parsedURL.urlWithoutScheme(); |
| - if (urlWithoutScheme && blockedSetting.get().indexOf(urlWithoutScheme) === -1) { |
| + var blockedURLIndex = blockedSettingData.indexOf(urlWithoutScheme); |
| + if (urlWithoutScheme && blockedURLIndex === -1) { |
| contextMenu.appendItem( |
| Common.UIString.capitalize('Block ^request URL'), addBlockedURL.bind(null, urlWithoutScheme)); |
| + } else { |
| + const croppedURL = blockedSettingData[blockedURLIndex].trimMiddle(maxBlockedURLLength); |
|
pfeldman
2017/02/11 01:34:59
What if there is no urlWithoutScheme? You fall int
allada
2017/02/11 02:29:17
Done.
|
| + contextMenu.appendItem( |
| + Common.UIString.capitalize('Unblock ' + croppedURL), removeBlockedURLIndex.bind(null, blockedURLIndex)); |
| } |
| var domain = request.parsedURL.domain(); |
| - if (domain && blockedSetting.get().indexOf(domain) === -1) |
| + var blockedDomainIndex = blockedSettingData.indexOf(domain); |
| + if (domain && blockedDomainIndex === -1) { |
| contextMenu.appendItem(Common.UIString.capitalize('Block ^request ^domain'), addBlockedURL.bind(null, domain)); |
| + } else { |
| + const croppedDomain = blockedSettingData[blockedDomainIndex].trimMiddle(maxBlockedURLLength); |
|
pfeldman
2017/02/11 01:34:59
ditto
allada
2017/02/11 02:29:17
Done.
|
| + contextMenu.appendItem( |
| + Common.UIString.capitalize('Unblock ' + croppedDomain), |
| + removeBlockedURLIndex.bind(null, blockedDomainIndex)); |
| + } |
| + /** |
| + * @param {string} url |
| + */ |
| function addBlockedURL(url) { |
| - var list = blockedSetting.get(); |
| - list.push(url); |
| - blockedSetting.set(list); |
| + blockedSettingData.push(url); |
| + blockedSetting.set(blockedSettingData); |
| + UI.viewManager.showView('network.blocked-urls'); |
| + } |
| + |
| + /** |
| + * @param {number} index |
| + */ |
| + function removeBlockedURLIndex(index) { |
| + blockedSettingData.splice(index, 1); |
| + blockedSetting.set(blockedSettingData); |
| UI.viewManager.showView('network.blocked-urls'); |
| } |
| } |