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

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);
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return a.columnNumber - b.columnNumber; 151 return a.columnNumber - b.columnNumber;
148 } 152 }
149 }, 153 },
150 154
151 _sourceMapLoadedForTest: function() 155 _sourceMapLoadedForTest: function()
152 { 156 {
153 // This method is sniffed in tests. 157 // This method is sniffed in tests.
154 }, 158 },
155 159
156 /** 160 /**
161 * @override
162 * @param {!WebInspector.Target} target
163 */
164 targetAdded: function(target)
165 {
166 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
167 if (debuggerModel)
168 this._setBlackboxPatterns(debuggerModel);
169 },
170
171 /**
172 * @override
173 * @param {!WebInspector.Target} target
174 */
175 targetRemoved: function(target)
176 {
177 },
178
179 /**
180 * @param {!WebInspector.DebuggerModel} debuggerModel
181 * @return {!Promise<boolean>}
182 */
183 _setBlackboxPatterns: function(debuggerModel)
184 {
185 var regexPatterns = WebInspector.moduleSetting("skipStackFramesPattern") .getAsArray()
186 .filter(item => !item.disabled)
pfeldman 2016/03/03 01:25:39 Did closure compiler resolve item type?
187 .map(item => ({ type: "RegExp", value: item.pattern }));
188 return debuggerModel.setBlackboxPatterns(regexPatterns);
pfeldman 2016/03/03 01:25:39 It could not possibly resolve this type, so it is
kozy 2016/03/03 20:14:18 Rewrited without awesome filter and map with array
189 },
190
191 /**
157 * @param {!WebInspector.UISourceCode} uiSourceCode 192 * @param {!WebInspector.UISourceCode} uiSourceCode
158 * @return {?string} 193 * @return {?string}
159 */ 194 */
160 _uiSourceCodeURL: function(uiSourceCode) 195 _uiSourceCodeURL: function(uiSourceCode)
161 { 196 {
162 var networkURL = this._networkMapping.networkURL(uiSourceCode); 197 var networkURL = this._networkMapping.networkURL(uiSourceCode);
163 var projectType = uiSourceCode.project().type(); 198 var projectType = uiSourceCode.project().type();
164 if (projectType === WebInspector.projectTypes.Debugger) 199 if (projectType === WebInspector.projectTypes.Debugger)
165 return null; 200 return null;
166 var url = projectType === WebInspector.projectTypes.Formatter ? uiSource Code.url() : networkURL; 201 var url = projectType === WebInspector.projectTypes.Formatter ? uiSource Code.url() : networkURL;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 { 295 {
261 this._isBlackboxedURLCache.clear(); 296 this._isBlackboxedURLCache.clear();
262 297
263 var promises = []; 298 var promises = [];
264 for (var debuggerModel of WebInspector.DebuggerModel.instances()) { 299 for (var debuggerModel of WebInspector.DebuggerModel.instances()) {
265 for (var scriptId in debuggerModel.scripts) { 300 for (var scriptId in debuggerModel.scripts) {
266 var script = debuggerModel.scripts[scriptId]; 301 var script = debuggerModel.scripts[scriptId];
267 promises.push(this._addScript(script) 302 promises.push(this._addScript(script)
268 .then(loadSourceMap.bind(this, script))); 303 .then(loadSourceMap.bind(this, script)));
269 } 304 }
305 promises.push(this._setBlackboxPatterns(debuggerModel));
270 } 306 }
271 Promise.all(promises).then(this._patternChangeFinishedForTests); 307 Promise.all(promises).then(this._patternChangeFinishedForTests);
272 308
273 /** 309 /**
274 * @param {!WebInspector.Script} script 310 * @param {!WebInspector.Script} script
275 * @return {!Promise<undefined>} 311 * @return {!Promise<undefined>}
276 * @this {WebInspector.BlackboxManager} 312 * @this {WebInspector.BlackboxManager}
277 */ 313 */
278 function loadSourceMap(script) 314 function loadSourceMap(script)
279 { 315 {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 hasChanged = previousScriptState.length !== positions.length; 396 hasChanged = previousScriptState.length !== positions.length;
361 for (var i = 0; !hasChanged && i < positions.length; ++i) 397 for (var i = 0; !hasChanged && i < positions.length; ++i)
362 hasChanged = positions[i].line !== previousScriptState[i].line | | positions[i].column !== previousScriptState[i].column; 398 hasChanged = positions[i].line !== previousScriptState[i].line | | positions[i].column !== previousScriptState[i].column;
363 if (!hasChanged) 399 if (!hasChanged)
364 return Promise.resolve(); 400 return Promise.resolve();
365 } else { 401 } else {
366 if (positions.length === 0) 402 if (positions.length === 0)
367 return Promise.resolve().then(updateState.bind(this, false)); 403 return Promise.resolve().then(updateState.bind(this, false));
368 } 404 }
369 405
370 return script.setBlackboxedRanges(positions).then(updateState.bind(this) ); 406 return script.setBlackboxRanges(positions).then(updateState.bind(this));
371 407
372 /** 408 /**
373 * @param {boolean} success 409 * @param {boolean} success
374 * @this {WebInspector.BlackboxManager} 410 * @this {WebInspector.BlackboxManager}
375 */ 411 */
376 function updateState(success) 412 function updateState(success)
377 { 413 {
378 if (success) { 414 if (success) {
379 this._setScriptPositions(script, positions); 415 this._setScriptPositions(script, positions);
380 this._debuggerWorkspaceBinding.updateLocations(script); 416 this._debuggerWorkspaceBinding.updateLocations(script);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 if (scheme === "chrome-extension") 452 if (scheme === "chrome-extension")
417 prefix += parsedURL.host + "\\b"; 453 prefix += parsedURL.host + "\\b";
418 prefix += ".*"; 454 prefix += ".*";
419 } 455 }
420 return prefix + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\ b"); 456 return prefix + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\ b");
421 } 457 }
422 } 458 }
423 459
424 /** @type {!WebInspector.BlackboxManager} */ 460 /** @type {!WebInspector.BlackboxManager} */
425 WebInspector.blackboxManager; 461 WebInspector.blackboxManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698