Chromium Code Reviews| 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} |