| 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 0e232079569493a51e38b4ecaba93d390644e210..495eb3aa41d3e7d18c8fbe1271ee0d1a79f3ada1 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('networkBlockedURLs');
|
| + 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 if (urlWithoutScheme) {
|
| + const croppedURL = blockedSettingData[blockedURLIndex].trimMiddle(maxBlockedURLLength);
|
| + 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 if (domain) {
|
| + const croppedDomain = blockedSettingData[blockedDomainIndex].trimMiddle(maxBlockedURLLength);
|
| + 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');
|
| SDK.multitargetNetworkManager.setRequestBlockingEnabled(true);
|
| }
|
|
|