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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js

Issue 2692653003: [Devtools] Added Enable/Disable for request blocking in network (Closed)
Patch Set: Merge branch 'BLOCK_REQUEST_REMOVE_CONTEXT_MENU' into ADD_ENABLE_DISABLE_REQUEST_BLOCKINg 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/sdk/NetworkManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js
index 2a0ae0afd4149360d1dcff2bce1142dccdb4c1b1..e7b6c37bc0f0a199d844edee69e25a6f609e92dc 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js
@@ -693,6 +693,7 @@ SDK.MultitargetNetworkManager = class extends Common.Object {
this._updateBlockedURLs();
this._userAgentOverride = '';
+ this._isRequestBlockingEnabled = false;
/** @type {!Set<!Protocol.NetworkAgent>} */
this._agents = new Set();
/** @type {!SDK.NetworkManager.Conditions} */
@@ -852,6 +853,8 @@ SDK.MultitargetNetworkManager = class extends Common.Object {
*/
_addBlockedURL(url) {
this._blockedURLs.add(url);
+ if (!this._isRequestBlockingEnabled)
+ return;
for (var agent of this._agents)
agent.addBlockedURL(url);
}
@@ -861,10 +864,33 @@ SDK.MultitargetNetworkManager = class extends Common.Object {
*/
_removeBlockedURL(url) {
this._blockedURLs.delete(url);
+ if (!this._isRequestBlockingEnabled)
+ return;
for (var agent of this._agents)
agent.removeBlockedURL(url);
}
+ /**
+ * @param {boolean} enabled
+ */
+ setRequestBlockingEnabled(enabled) {
+ if (this._isRequestBlockingEnabled === enabled)
+ return;
+ this._isRequestBlockingEnabled = enabled;
+ if (enabled) {
+ for (var agent of this._agents)
+ this._blockedURLs.forEach(url => agent.addBlockedURL(url));
pfeldman 2017/02/13 18:24:26 Let's follow up immediately with converting add/re
allada 2017/02/16 21:42:03 Done. see: https://codereview.chromium.org/2703603
+ } else {
+ for (var agent of this._agents)
+ this._blockedURLs.forEach(url => agent.removeBlockedURL(url));
+ }
+ this.emit(new SDK.MultitargetNetworkManager.RequestBlockingEnabledChangedEvent(enabled));
+ }
+
+ isRequestBlockingEnabled() {
+ return this._isRequestBlockingEnabled;
+ }
+
clearBrowserCache() {
for (var agent of this._agents)
agent.clearBrowserCache();
@@ -916,6 +942,15 @@ SDK.MultitargetNetworkManager.Events = {
UserAgentChanged: Symbol('UserAgentChanged')
};
+/** @implements {Common.Emittable} */
+SDK.MultitargetNetworkManager.RequestBlockingEnabledChangedEvent = class {
pfeldman 2017/02/13 18:24:26 Seems like a lot of boilerplate for a simple liste
allada 2017/02/16 21:42:03 How about this as a compromise.
+ /**
+ * @param {boolean} enabled
+ */
+ constructor(enabled) {
+ this.enabled = enabled;
+ }
+};
/**
* @type {!SDK.MultitargetNetworkManager}

Powered by Google App Engine
This is Rietveld 408576698