OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 /** | 4 /** |
5 * @unrestricted | 5 * @unrestricted |
6 */ | 6 */ |
7 Network.BlockedURLsPane = class extends UI.VBox { | 7 Network.BlockedURLsPane = class extends UI.VBox { |
8 constructor() { | 8 constructor() { |
9 super(true); | 9 super(true); |
10 this.registerRequiredCSS('network/blockedURLsPane.css'); | 10 this.registerRequiredCSS('network/blockedURLsPane.css'); |
11 this.contentElement.classList.add('blocked-urls-pane'); | 11 this.contentElement.classList.add('blocked-urls-pane'); |
12 | 12 |
13 Network.BlockedURLsPane._instance = this; | 13 Network.BlockedURLsPane._instance = this; |
14 | 14 |
15 this._blockedURLsSetting = Common.moduleSetting('networkBlockedURLs'); | 15 this._blockedURLsSetting = Common.moduleSetting('networkBlockedURLs'); |
16 this._blockedURLsSetting.addChangeListener(this._update, this); | 16 this._blockedURLsSetting.addChangeListener(this._update, this); |
17 | 17 |
18 this._toolbar = new UI.Toolbar('', this.contentElement); | 18 this._toolbar = new UI.Toolbar('', this.contentElement); |
19 this._toolbar.element.addEventListener('click', (e) => e.consume()); | 19 this._toolbar.element.addEventListener('click', (e) => e.consume()); |
20 var addButton = new UI.ToolbarButton(Common.UIString('Add pattern'), 'largei
con-add'); | 20 var addButton = new UI.ToolbarButton(Common.UIString('Add pattern'), 'largei
con-add'); |
21 addButton.addEventListener(UI.ToolbarButton.Events.Click, this._addButtonCli
cked, this); | 21 addButton.addEventListener(UI.ToolbarButton.Events.Click, this._addButtonCli
cked, this); |
22 this._toolbar.appendToolbarItem(addButton); | 22 this._toolbar.appendToolbarItem(addButton); |
23 var clearButton = new UI.ToolbarButton(Common.UIString('Remove all'), 'large
icon-clear'); | 23 var clearButton = new UI.ToolbarButton(Common.UIString('Remove all'), 'large
icon-clear'); |
24 clearButton.addEventListener(UI.ToolbarButton.Events.Click, this._removeAll,
this); | 24 clearButton.addEventListener(UI.ToolbarButton.Events.Click, this._removeAll,
this); |
25 this._toolbar.appendToolbarItem(clearButton); | 25 this._toolbar.appendToolbarItem(clearButton); |
26 | 26 |
| 27 var enableRequestBlockingCheckbox = new UI.ToolbarCheckbox( |
| 28 Common.UIString('Enable Request Blocking'), Common.UIString('Enables req
uest blocking'), undefined, |
| 29 enableRequestBlockingChecked); |
| 30 SDK.multitargetNetworkManager.on( |
| 31 SDK.MultitargetNetworkManager.RequestBlockingEnabledChangedEvent, |
| 32 event => enableRequestBlockingCheckbox.setChecked(event.enabled)); |
| 33 this._toolbar.appendToolbarItem(enableRequestBlockingCheckbox); |
| 34 |
27 this._emptyElement = this.contentElement.createChild('div', 'no-blocked-urls
'); | 35 this._emptyElement = this.contentElement.createChild('div', 'no-blocked-urls
'); |
28 this._emptyElement.createChild('span').textContent = Common.UIString('Reques
ts are not blocked. '); | 36 this._emptyElement.createChild('span').textContent = Common.UIString('Reques
ts are not blocked. '); |
29 var addLink = this._emptyElement.createChild('span', 'link'); | 37 var addLink = this._emptyElement.createChild('span', 'link'); |
30 addLink.textContent = Common.UIString('Add pattern.'); | 38 addLink.textContent = Common.UIString('Add pattern.'); |
31 addLink.href = ''; | 39 addLink.href = ''; |
32 addLink.addEventListener('click', this._addButtonClicked.bind(this), false); | 40 addLink.addEventListener('click', this._addButtonClicked.bind(this), false); |
33 this._emptyElement.addEventListener('contextmenu', this._emptyElementContext
Menu.bind(this), true); | 41 this._emptyElement.addEventListener('contextmenu', this._emptyElementContext
Menu.bind(this), true); |
34 | 42 |
35 this._listElement = this.contentElement.createChild('div', 'blocked-urls-lis
t'); | 43 this._listElement = this.contentElement.createChild('div', 'blocked-urls-lis
t'); |
36 | 44 |
37 /** @type {!Map<string, number>} */ | 45 /** @type {!Map<string, number>} */ |
38 this._blockedCountForUrl = new Map(); | 46 this._blockedCountForUrl = new Map(); |
39 SDK.targetManager.addModelListener( | 47 SDK.targetManager.addModelListener( |
40 SDK.NetworkManager, SDK.NetworkManager.Events.RequestFinished, this._onR
equestFinished, this); | 48 SDK.NetworkManager, SDK.NetworkManager.Events.RequestFinished, this._onR
equestFinished, this); |
41 | 49 |
42 this._updateThrottler = new Common.Throttler(200); | 50 this._updateThrottler = new Common.Throttler(200); |
43 | 51 |
44 this._update(); | 52 this._update(); |
| 53 |
| 54 function enableRequestBlockingChecked() { |
| 55 SDK.multitargetNetworkManager.setRequestBlockingEnabled(enableRequestBlock
ingCheckbox.checked()); |
| 56 } |
45 } | 57 } |
46 | 58 |
47 static reset() { | 59 static reset() { |
48 if (Network.BlockedURLsPane._instance) | 60 if (Network.BlockedURLsPane._instance) |
49 Network.BlockedURLsPane._instance.reset(); | 61 Network.BlockedURLsPane._instance.reset(); |
50 } | 62 } |
51 | 63 |
52 /** | 64 /** |
53 * @param {!Event} event | 65 * @param {!Event} event |
54 */ | 66 */ |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 * @override | 289 * @override |
278 * @param {!UI.Context} context | 290 * @param {!UI.Context} context |
279 * @param {string} actionId | 291 * @param {string} actionId |
280 * @return {boolean} | 292 * @return {boolean} |
281 */ | 293 */ |
282 handleAction(context, actionId) { | 294 handleAction(context, actionId) { |
283 UI.viewManager.showView('network.blocked-urls'); | 295 UI.viewManager.showView('network.blocked-urls'); |
284 return true; | 296 return true; |
285 } | 297 } |
286 }; | 298 }; |
OLD | NEW |