Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Unified Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js

Issue 2688983002: [Devtools] Added context menus for removing request blocking in network (Closed)
Patch Set: changes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..792c6d4ece410ebbdd47a826ba6ba0dcc3c8f932 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);
luoe 2017/02/13 06:45:30 nit: ... = urlWithoutScheme.trimMiddle(...)?
allada 2017/02/13 16:29:24 These are not the same. urlWithoutScheme is the re
+ 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);
luoe 2017/02/13 06:45:30 ditto, ... = domain.trimMiddle(...)?
allada 2017/02/13 16:29:24 same as above.
+ 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');
}
}

Powered by Google App Engine
This is Rietveld 408576698