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

Side by Side Diff: chrome/browser/resources/net_internals/source_row.js

Issue 13725016: about:net-internals: Add support for negative text filters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 var SourceRow = (function() { 5 var SourceRow = (function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * A SourceRow represents the row corresponding to a single SourceEntry 9 * A SourceRow represents the row corresponding to a single SourceEntry
10 * displayed by the EventsView. 10 * displayed by the EventsView.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 onSourceUpdated: function() { 84 onSourceUpdated: function() {
85 if (this.sourceEntry_.isInactive() != this.isInactive_ || 85 if (this.sourceEntry_.isInactive() != this.isInactive_ ||
86 this.sourceEntry_.isError() != this.isError_) { 86 this.sourceEntry_.isError() != this.isError_) {
87 this.updateClass_(); 87 this.updateClass_();
88 } 88 }
89 89
90 if (this.description_ != this.sourceEntry_.getDescription()) 90 if (this.description_ != this.sourceEntry_.getDescription())
91 this.updateDescription_(); 91 this.updateDescription_();
92 92
93 // Update filters. 93 // Update filters.
94 var matchesFilter = this.matchesFilter(this.parentView_.currentFilter_); 94 var matchesFilter = this.parentView_.currentFilter_(this.sourceEntry_);
95 this.setIsMatchedByFilter(matchesFilter); 95 this.setIsMatchedByFilter(matchesFilter);
96 }, 96 },
97 97
98 /** 98 /**
99 * Changes |row_|'s class based on currently set flags. Clears any previous 99 * Changes |row_|'s class based on currently set flags. Clears any previous
100 * class set by this method. This method is needed so that some styles 100 * class set by this method. This method is needed so that some styles
101 * override others. 101 * override others.
102 */ 102 */
103 updateClass_: function() { 103 updateClass_: function() {
104 this.isInactive_ = this.sourceEntry_.isInactive(); 104 this.isInactive_ = this.sourceEntry_.isInactive();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 setFilterStyles: function(isMatchedByFilter) { 159 setFilterStyles: function(isMatchedByFilter) {
160 // Hide rows which have been filtered away. 160 // Hide rows which have been filtered away.
161 if (isMatchedByFilter) { 161 if (isMatchedByFilter) {
162 this.row_.style.display = ''; 162 this.row_.style.display = '';
163 } else { 163 } else {
164 this.row_.style.display = 'none'; 164 this.row_.style.display = 'none';
165 } 165 }
166 }, 166 },
167 167
168 matchesFilter: function(filter) {
169 if (filter.isActive && this.isInactive_)
170 return false;
171 if (filter.isInactive && !this.isInactive_)
172 return false;
173 if (filter.isError && !this.isError_)
174 return false;
175 if (filter.isNotError && this.isError_)
176 return false;
177
178 // Check source type, if needed.
179 if (filter.type) {
180 var i;
181 var sourceType = this.sourceEntry_.getSourceTypeString().toLowerCase();
182 for (i = 0; i < filter.type.length; ++i) {
183 if (sourceType.search(filter.type[i]) != -1)
184 break;
185 }
186 if (i == filter.type.length)
187 return false;
188 }
189
190 // Check source ID, if needed.
191 if (filter.id) {
192 if (filter.id.indexOf(this.getSourceId() + '') == -1)
193 return false;
194 }
195
196 if (!filter.textFilters)
197 return true;
198
199 // Used for searching for input strings. Lazily initialized.
200 var tablePrinter = null;
201
202 for (var i = 0; i < filter.textFilters.length; ++i) {
203 // The description is not always contained in one of the log entries.
204 if (this.description_.toLowerCase().indexOf(
205 filter.textFilters[i]) != -1) {
206 continue;
207 }
208
209 // Allow specifying source types by name.
210 var sourceType = this.sourceEntry_.getSourceTypeString();
211 if (sourceType.toLowerCase().indexOf(filter.textFilters[i]) != -1)
212 continue;
213
214 if (!tablePrinter) {
215 tablePrinter = createLogEntryTablePrinter(
216 this.sourceEntry_.getLogEntries(),
217 SourceTracker.getInstance().getPrivacyStripping());
218 }
219 if (!tablePrinter.search(filter.textFilters[i]))
220 return false;
221 }
222 return true;
223 },
224
225 isSelected: function() { 168 isSelected: function() {
226 return this.isSelected_; 169 return this.isSelected_;
227 }, 170 },
228 171
229 setSelected: function(isSelected) { 172 setSelected: function(isSelected) {
230 if (isSelected == this.isSelected()) 173 if (isSelected == this.isSelected())
231 return; 174 return;
232 175
233 this.isSelected_ = isSelected; 176 this.isSelected_ = isSelected;
234 177
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 /** 258 /**
316 * Moves current object's row after |entry|'s row. 259 * Moves current object's row after |entry|'s row.
317 */ 260 */
318 moveAfter: function(entry) { 261 moveAfter: function(entry) {
319 this.row_.parentNode.insertBefore(this.row_, entry.row_.nextSibling); 262 this.row_.parentNode.insertBefore(this.row_, entry.row_.nextSibling);
320 } 263 }
321 }; 264 };
322 265
323 return SourceRow; 266 return SourceRow;
324 })(); 267 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_internals/source_filter_parser.js ('k') | chrome/test/data/webui/net_internals/events_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698