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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/BlockedURLsPane.js

Issue 2814563004: [DevTools] Handle blocked urls disabled state better in UI (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/network/blockedURLsPane.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * @implements {UI.ListWidget.Delegate} 5 * @implements {UI.ListWidget.Delegate}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 Network.BlockedURLsPane = class extends UI.VBox { 8 Network.BlockedURLsPane = class extends UI.VBox {
9 constructor() { 9 constructor() {
10 super(true); 10 super(true);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 addLink.addEventListener('click', this._addButtonClicked.bind(this), false); 54 addLink.addEventListener('click', this._addButtonClicked.bind(this), false);
55 return element; 55 return element;
56 } 56 }
57 57
58 static reset() { 58 static reset() {
59 if (Network.BlockedURLsPane._instance) 59 if (Network.BlockedURLsPane._instance)
60 Network.BlockedURLsPane._instance.reset(); 60 Network.BlockedURLsPane._instance.reset();
61 } 61 }
62 62
63 _addButtonClicked() { 63 _addButtonClicked() {
64 this._manager.setBlockingEnabled(true);
64 this._list.addNewItem(0, {url: '', enabled: true}); 65 this._list.addNewItem(0, {url: '', enabled: true});
65 } 66 }
66 67
67 /** 68 /**
68 * @override 69 * @override
69 * @param {*} item 70 * @param {*} item
70 * @param {boolean} editable 71 * @param {boolean} editable
71 * @return {!Element} 72 * @return {!Element}
72 */ 73 */
73 renderItem(item, editable) { 74 renderItem(item, editable) {
74 var pattern = /** @type {!SDK.NetworkManager.BlockedPattern} */ (item); 75 var pattern = /** @type {!SDK.NetworkManager.BlockedPattern} */ (item);
75 var count = this._blockedRequestsCount(pattern.url); 76 var count = this._blockedRequestsCount(pattern.url);
76 var element = createElementWithClass('div', 'blocked-url'); 77 var element = createElementWithClass('div', 'blocked-url');
77 var checkbox = element.createChild('input', 'blocked-url-checkbox'); 78 var checkbox = element.createChild('input', 'blocked-url-checkbox');
78 checkbox.type = 'checkbox'; 79 checkbox.type = 'checkbox';
79 checkbox.checked = pattern.enabled; 80 checkbox.checked = pattern.enabled;
81 checkbox.disabled = !this._manager.blockingEnabled();
80 element.createChild('div', 'blocked-url-label').textContent = pattern.url; 82 element.createChild('div', 'blocked-url-label').textContent = pattern.url;
81 element.createChild('div', 'blocked-url-count').textContent = Common.UIStrin g('%d blocked', count); 83 element.createChild('div', 'blocked-url-count').textContent = Common.UIStrin g('%d blocked', count);
82 element.addEventListener('click', event => this._togglePattern(pattern, even t), false); 84 element.addEventListener('click', event => this._togglePattern(pattern, even t), false);
83 checkbox.addEventListener('click', event => this._togglePattern(pattern, eve nt), false); 85 checkbox.addEventListener('click', event => this._togglePattern(pattern, eve nt), false);
84 return element; 86 return element;
85 } 87 }
86 88
87 /** 89 /**
88 * @param {!SDK.NetworkManager.BlockedPattern} pattern 90 * @param {!SDK.NetworkManager.BlockedPattern} pattern
89 * @param {!Event} event 91 * @param {!Event} event
90 */ 92 */
91 _togglePattern(pattern, event) { 93 _togglePattern(pattern, event) {
92 event.consume(true); 94 event.consume(true);
93 var patterns = this._manager.blockedPatterns(); 95 var patterns = this._manager.blockedPatterns();
94 patterns.splice(patterns.indexOf(pattern), 1, {enabled: !pattern.enabled, ur l: pattern.url}); 96 patterns.splice(patterns.indexOf(pattern), 1, {enabled: !pattern.enabled, ur l: pattern.url});
95 this._manager.setBlockedPatterns(patterns); 97 this._manager.setBlockedPatterns(patterns);
96 } 98 }
97 99
98 _toggleEnabled() { 100 _toggleEnabled() {
99 this._manager.setBlockingEnabled(!this._manager.blockingEnabled()); 101 this._manager.setBlockingEnabled(!this._manager.blockingEnabled());
102 this._update();
100 } 103 }
101 104
102 /** 105 /**
103 * @override 106 * @override
104 * @param {*} item 107 * @param {*} item
105 * @param {number} index 108 * @param {number} index
106 */ 109 */
107 removeItemRequested(item, index) { 110 removeItemRequested(item, index) {
108 var patterns = this._manager.blockedPatterns(); 111 var patterns = this._manager.blockedPatterns();
109 patterns.splice(index, 1); 112 patterns.splice(index, 1);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 167 }
165 168
166 _removeAll() { 169 _removeAll() {
167 this._manager.setBlockedPatterns([]); 170 this._manager.setBlockedPatterns([]);
168 } 171 }
169 172
170 /** 173 /**
171 * @return {!Promise<?>} 174 * @return {!Promise<?>}
172 */ 175 */
173 _update() { 176 _update() {
174 this._enabledCheckbox.setChecked(this._manager.blockingEnabled()); 177 var enabled = this._manager.blockingEnabled();
178 this._list.element.classList.toggle('blocking-disabled', !enabled);
179 this._enabledCheckbox.setChecked(enabled);
175 this._list.clear(); 180 this._list.clear();
176 for (var pattern of this._manager.blockedPatterns()) 181 for (var pattern of this._manager.blockedPatterns())
177 this._list.appendItem(pattern, true); 182 this._list.appendItem(pattern, true);
178 return Promise.resolve(); 183 return Promise.resolve();
179 } 184 }
180 185
181 /** 186 /**
182 * @param {string} url 187 * @param {string} url
183 * @return {number} 188 * @return {number}
184 */ 189 */
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (request.wasBlocked()) { 232 if (request.wasBlocked()) {
228 var count = this._blockedCountForUrl.get(request.url()) || 0; 233 var count = this._blockedCountForUrl.get(request.url()) || 0;
229 this._blockedCountForUrl.set(request.url(), count + 1); 234 this._blockedCountForUrl.set(request.url(), count + 1);
230 this._updateThrottler.schedule(this._update.bind(this)); 235 this._updateThrottler.schedule(this._update.bind(this));
231 } 236 }
232 } 237 }
233 }; 238 };
234 239
235 /** @type {?Network.BlockedURLsPane} */ 240 /** @type {?Network.BlockedURLsPane} */
236 Network.BlockedURLsPane._instance = null; 241 Network.BlockedURLsPane._instance = null;
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/network/blockedURLsPane.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698