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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/BlackboxManager.js

Issue 1754483002: [DevTools] Added setBlackboxPatterns method to protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@provide-hash-for-anonymous-scripts
Patch Set: Created 4 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding 7 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding
8 * @param {!WebInspector.NetworkMapping} networkMapping 8 * @param {!WebInspector.NetworkMapping} networkMapping
9 * @implements {WebInspector.TargetManager.Observer}
9 */ 10 */
10 WebInspector.BlackboxManager = function(debuggerWorkspaceBinding, networkMapping ) 11 WebInspector.BlackboxManager = function(debuggerWorkspaceBinding, networkMapping )
11 { 12 {
13 WebInspector.targetManager.observeTargets(this);
dgozman 2016/03/07 17:26:13 Better do this at the end, after all fields have b
kozy 2016/03/08 02:33:20 Done.
14
12 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; 15 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding;
13 this._networkMapping = networkMapping; 16 this._networkMapping = networkMapping;
14 17
15 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this ); 18 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this );
16 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.GlobalObjectCleared, this._globalObjectCleared, th is); 19 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.GlobalObjectCleared, this._globalObjectCleared, th is);
17 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this. _patternChanged.bind(this)); 20 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this. _patternChanged.bind(this));
18 WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._pat ternChanged.bind(this)); 21 WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._pat ternChanged.bind(this));
19 22
23
20 /** @type {!Map<!WebInspector.DebuggerModel, !Map<string, !Array<!DebuggerAg ent.ScriptPosition>>>} */ 24 /** @type {!Map<!WebInspector.DebuggerModel, !Map<string, !Array<!DebuggerAg ent.ScriptPosition>>>} */
21 this._debuggerModelData = new Map(); 25 this._debuggerModelData = new Map();
22 /** @type {!Map<string, boolean>} */ 26 /** @type {!Map<string, boolean>} */
23 this._isBlackboxedURLCache = new Map(); 27 this._isBlackboxedURLCache = new Map();
24 } 28 }
25 29
26 WebInspector.BlackboxManager.prototype = { 30 WebInspector.BlackboxManager.prototype = {
27 /** 31 /**
28 * @param {function(!WebInspector.Event)} listener 32 * @param {function(!WebInspector.Event)} listener
29 * @param {!Object=} thisObject 33 * @param {!Object=} thisObject
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 */ 146 */
143 function mappingComparator(a, b) 147 function mappingComparator(a, b)
144 { 148 {
145 if (a.lineNumber !== b.lineNumber) 149 if (a.lineNumber !== b.lineNumber)
146 return a.lineNumber - b.lineNumber; 150 return a.lineNumber - b.lineNumber;
147 return a.columnNumber - b.columnNumber; 151 return a.columnNumber - b.columnNumber;
148 } 152 }
149 }, 153 },
150 154
151 /** 155 /**
156 * @override
157 * @param {!WebInspector.Target} target
158 */
159 targetAdded: function(target)
160 {
161 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
162 if (debuggerModel)
163 this._addBlackboxPatterns(debuggerModel);
164 },
165
166 /**
167 * @override
168 * @param {!WebInspector.Target} target
169 */
170 targetRemoved: function(target)
171 {
172 },
173
174 /**
175 * @param {!WebInspector.DebuggerModel} debuggerModel
176 * @return {!Promise<boolean>}
177 */
178 _addBlackboxPatterns: function(debuggerModel)
179 {
180 var regexPatterns = WebInspector.moduleSetting("skipStackFramesPattern") .getAsArray();
181 var patterns = /** @type {!Array<!DebuggerAgent.BlackboxPattern>} */([]) ;
182 for (var item of regexPatterns) {
183 if (!item.disabled && item.pattern)
184 patterns.push({ regexp: item.pattern });
185 }
186 return debuggerModel.addBlackboxPatterns(patterns);
187 },
188
189 /**
152 * @param {!WebInspector.UISourceCode} uiSourceCode 190 * @param {!WebInspector.UISourceCode} uiSourceCode
153 * @return {?string} 191 * @return {?string}
154 */ 192 */
155 _uiSourceCodeURL: function(uiSourceCode) 193 _uiSourceCodeURL: function(uiSourceCode)
156 { 194 {
157 var networkURL = this._networkMapping.networkURL(uiSourceCode); 195 var networkURL = this._networkMapping.networkURL(uiSourceCode);
158 var projectType = uiSourceCode.project().type(); 196 var projectType = uiSourceCode.project().type();
159 if (projectType === WebInspector.projectTypes.Debugger) 197 if (projectType === WebInspector.projectTypes.Debugger)
160 return null; 198 return null;
161 var url = projectType === WebInspector.projectTypes.Formatter ? uiSource Code.url() : networkURL; 199 var url = projectType === WebInspector.projectTypes.Formatter ? uiSource Code.url() : networkURL;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 { 293 {
256 this._isBlackboxedURLCache.clear(); 294 this._isBlackboxedURLCache.clear();
257 295
258 var promises = []; 296 var promises = [];
259 for (var debuggerModel of WebInspector.DebuggerModel.instances()) { 297 for (var debuggerModel of WebInspector.DebuggerModel.instances()) {
260 for (var scriptId in debuggerModel.scripts) { 298 for (var scriptId in debuggerModel.scripts) {
261 var script = debuggerModel.scripts[scriptId]; 299 var script = debuggerModel.scripts[scriptId];
262 promises.push(this._addScript(script) 300 promises.push(this._addScript(script)
263 .then(loadSourceMap.bind(this, script))); 301 .then(loadSourceMap.bind(this, script)));
264 } 302 }
303 promises.push(this._addBlackboxPatterns(debuggerModel));
dgozman 2016/03/07 17:26:13 Clear patterns before adding them again.
kozy 2016/03/08 02:33:20 Done.
265 } 304 }
266 Promise.all(promises).then(this._patternChangeFinishedForTests.bind(this )); 305 Promise.all(promises).then(this._patternChangeFinishedForTests.bind(this ));
267 306
268 /** 307 /**
269 * @param {!WebInspector.Script} script 308 * @param {!WebInspector.Script} script
270 * @return {!Promise<undefined>} 309 * @return {!Promise<undefined>}
271 * @this {WebInspector.BlackboxManager} 310 * @this {WebInspector.BlackboxManager}
272 */ 311 */
273 function loadSourceMap(script) 312 function loadSourceMap(script)
274 { 313 {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 hasChanged = previousScriptState.length !== positions.length; 394 hasChanged = previousScriptState.length !== positions.length;
356 for (var i = 0; !hasChanged && i < positions.length; ++i) 395 for (var i = 0; !hasChanged && i < positions.length; ++i)
357 hasChanged = positions[i].line !== previousScriptState[i].line | | positions[i].column !== previousScriptState[i].column; 396 hasChanged = positions[i].line !== previousScriptState[i].line | | positions[i].column !== previousScriptState[i].column;
358 if (!hasChanged) 397 if (!hasChanged)
359 return Promise.resolve(); 398 return Promise.resolve();
360 } else { 399 } else {
361 if (positions.length === 0) 400 if (positions.length === 0)
362 return Promise.resolve().then(updateState.bind(this, false)); 401 return Promise.resolve().then(updateState.bind(this, false));
363 } 402 }
364 403
365 return script.setBlackboxedRanges(positions).then(updateState.bind(this) ); 404 return script.addBlackboxPattern(positions).then(updateState.bind(this)) ;
366 405
367 /** 406 /**
368 * @param {boolean} success 407 * @param {boolean} success
369 * @this {WebInspector.BlackboxManager} 408 * @this {WebInspector.BlackboxManager}
370 */ 409 */
371 function updateState(success) 410 function updateState(success)
372 { 411 {
373 if (success) { 412 if (success) {
374 this._setScriptPositions(script, positions); 413 this._setScriptPositions(script, positions);
375 this._debuggerWorkspaceBinding.updateLocations(script); 414 this._debuggerWorkspaceBinding.updateLocations(script);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (scheme === "chrome-extension") 450 if (scheme === "chrome-extension")
412 prefix += parsedURL.host + "\\b"; 451 prefix += parsedURL.host + "\\b";
413 prefix += ".*"; 452 prefix += ".*";
414 } 453 }
415 return prefix + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\ b"); 454 return prefix + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\ b");
416 } 455 }
417 } 456 }
418 457
419 /** @type {!WebInspector.BlackboxManager} */ 458 /** @type {!WebInspector.BlackboxManager} */
420 WebInspector.blackboxManager; 459 WebInspector.blackboxManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698