Skip to content

Commit

Permalink
[DevTools] Replace (un)blackboxURL methods with (un)blackboxUISourceCode
Browse files Browse the repository at this point in the history
It's preparation step for anonymous script blackboxing.

BUG=583193
[email protected]

Review URL: https://codereview.chromium.org/1742463003

Cr-Commit-Position: refs/heads/master@{#377794}
  • Loading branch information
alexkozy authored and Commit bot committed Feb 26, 2016
1 parent 336beef commit 8c6c1b4
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 59 deletions.
64 changes: 52 additions & 12 deletions front_end/bindings/BlackboxManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ WebInspector.BlackboxManager.prototype = {
var isContentScript = projectType === WebInspector.projectTypes.ContentScripts;
if (isContentScript && WebInspector.moduleSetting("skipContentScripts").get())
return true;
var networkURL = this._networkMapping.networkURL(uiSourceCode);
var url = projectType === WebInspector.projectTypes.Formatter ? uiSourceCode.url() : networkURL;
return this.isBlackboxedURL(url);
var url = this._uiSourceCodeURL(uiSourceCode);
return url ? this.isBlackboxedURL(url) : false;
},

/**
Expand Down Expand Up @@ -155,18 +154,63 @@ WebInspector.BlackboxManager.prototype = {
},

/**
* @param {string} url
* @param {!WebInspector.UISourceCode} uiSourceCode
* @return {?string}
*/
_uiSourceCodeURL: function(uiSourceCode)
{
var networkURL = this._networkMapping.networkURL(uiSourceCode);
var projectType = uiSourceCode.project().type();
if (projectType === WebInspector.projectTypes.Debugger)
return null;
var url = projectType === WebInspector.projectTypes.Formatter ? uiSourceCode.url() : networkURL;
return url ? url : null;
},

/**
* @param {!WebInspector.UISourceCode} uiSourceCode
* @return {boolean}
*/
canBlackboxURL: function(url)
canBlackboxUISourceCode: function(uiSourceCode)
{
var url = this._uiSourceCodeURL(uiSourceCode);
return url ? !!this._urlToRegExpString(url) : false;
},

/**
* @param {!WebInspector.UISourceCode} uiSourceCode
*/
blackboxUISourceCode: function(uiSourceCode)
{
var url = this._uiSourceCodeURL(uiSourceCode);
if (url)
this._blackboxURL(url);
},

/**
* @param {!WebInspector.UISourceCode} uiSourceCode
*/
unblackboxUISourceCode: function(uiSourceCode)
{
var url = this._uiSourceCodeURL(uiSourceCode);
if (url)
this._unblackboxURL(url);
},

blackboxContentScripts: function()
{
return !!this._urlToRegExpString(url);
WebInspector.moduleSetting("skipContentScripts").set(true);
},

unblackboxContentScripts: function()
{
WebInspector.moduleSetting("skipContentScripts").set(false);
},

/**
* @param {string} url
*/
blackboxURL: function(url)
_blackboxURL: function(url)
{
var regexPatterns = WebInspector.moduleSetting("skipStackFramesPattern").getAsArray();
var regexValue = this._urlToRegExpString(url);
Expand All @@ -188,13 +232,9 @@ WebInspector.BlackboxManager.prototype = {

/**
* @param {string} url
* @param {boolean} isContentScript
*/
unblackbox: function(url, isContentScript)
_unblackboxURL: function(url)
{
if (isContentScript)
WebInspector.moduleSetting("skipContentScripts").set(false);

var regexPatterns = WebInspector.moduleSetting("skipStackFramesPattern").getAsArray();
var regexValue = WebInspector.blackboxManager._urlToRegExpString(url);
if (!regexValue)
Expand Down
51 changes: 18 additions & 33 deletions front_end/sources/CallStackSidebarPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ WebInspector.CallStackSidebarPane.prototype = {

contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^stack ^trace"), this._copyStackTrace.bind(this));

var isBlackboxed = WebInspector.blackboxManager.isBlackboxedRawLocation(callFrame._callFrame.location());
var script = callFrame._callFrame.script;
this.appendBlackboxURLContextMenuItems(contextMenu, script.sourceURL, script.isContentScript(), isBlackboxed);
var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationToUILocation(callFrame._callFrame.location());
this.appendBlackboxURLContextMenuItems(contextMenu, uiLocation.uiSourceCode);

contextMenu.show();
},
Expand All @@ -193,40 +192,26 @@ WebInspector.CallStackSidebarPane.prototype = {

/**
* @param {!WebInspector.ContextMenu} contextMenu
* @param {string} url
* @param {boolean} isContentScript
* @param {boolean} isBlackboxed
* @param {!WebInspector.UISourceCode} uiSourceCode
*/
appendBlackboxURLContextMenuItems: function(contextMenu, url, isContentScript, isBlackboxed)
appendBlackboxURLContextMenuItems: function(contextMenu, uiSourceCode)
{
var canBlackBox = WebInspector.blackboxManager.canBlackboxURL(url);
if (!isBlackboxed && !isContentScript && !canBlackBox)
return;

if (isBlackboxed) {
contextMenu.appendItem(WebInspector.UIString.capitalize("Stop ^blackboxing"), this._handleContextMenuBlackboxURL.bind(this, url, isContentScript, false));
} else {
if (canBlackBox)
contextMenu.appendItem(WebInspector.UIString.capitalize("Blackbox ^script"), this._handleContextMenuBlackboxURL.bind(this, url, false, true));
if (isContentScript)
contextMenu.appendItem(WebInspector.UIString.capitalize("Blackbox ^all ^content ^scripts"), this._handleContextMenuBlackboxURL.bind(this, url, true, true));
var canBlackbox = WebInspector.blackboxManager.canBlackboxUISourceCode(uiSourceCode);
var isBlackboxed = WebInspector.blackboxManager.isBlackboxedUISourceCode(uiSourceCode);
var isContentScript = uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts;

var manager = WebInspector.blackboxManager;
if (canBlackbox) {
if (isBlackboxed)
contextMenu.appendItem(WebInspector.UIString.capitalize("Stop ^blackboxing"), manager.unblackboxUISourceCode.bind(manager, uiSourceCode));
else
contextMenu.appendItem(WebInspector.UIString.capitalize("Blackbox ^script"), manager.blackboxUISourceCode.bind(manager, uiSourceCode));
}
},

/**
* @param {string} url
* @param {boolean} isContentScript
* @param {boolean} blackbox
*/
_handleContextMenuBlackboxURL: function(url, isContentScript, blackbox)
{
if (blackbox) {
if (isContentScript)
WebInspector.moduleSetting("skipContentScripts").set(true);
if (isContentScript) {
if (isBlackboxed)
contextMenu.appendItem(WebInspector.UIString.capitalize("Stop blackboxing ^all ^content ^scripts"), manager.blackboxContentScripts.bind(manager));
else
WebInspector.blackboxManager.blackboxURL(url);
} else {
WebInspector.blackboxManager.unblackbox(url, isContentScript);
contextMenu.appendItem(WebInspector.UIString.capitalize("Blackbox ^all ^content ^scripts"), manager.unblackboxContentScripts.bind(manager));
}
},

Expand Down
19 changes: 11 additions & 8 deletions front_end/sources/JavaScriptSourceFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,16 @@ WebInspector.JavaScriptSourceFrame.prototype = {

_showBlackboxInfobarIfNeeded: function()
{
if (!this.uiSourceCode().contentType().hasScripts())
var uiSourceCode = this.uiSourceCode();
if (!uiSourceCode.contentType().hasScripts())
return;
var projectType = this.uiSourceCode().project().type();
var projectType = uiSourceCode.project().type();
if (projectType === WebInspector.projectTypes.Snippets)
return;
var networkURL = WebInspector.networkMapping.networkURL(this.uiSourceCode());
var url = projectType === WebInspector.projectTypes.Formatter ? this.uiSourceCode().url() : networkURL;
var networkURL = WebInspector.networkMapping.networkURL(uiSourceCode);
var url = projectType === WebInspector.projectTypes.Formatter ? uiSourceCode.url() : networkURL;
var isContentScript = projectType === WebInspector.projectTypes.ContentScripts;
if (!WebInspector.blackboxManager.isBlackboxedUISourceCode(this.uiSourceCode())) {
if (!WebInspector.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) {
this._hideBlackboxInfobar();
return;
}
Expand All @@ -163,8 +164,8 @@ WebInspector.JavaScriptSourceFrame.prototype = {

infobar.createDetailsRowMessage(WebInspector.UIString("Debugger will skip stepping through this script, and will not stop on exceptions"));

var scriptFile = this._scriptFileForTarget.valuesArray()[0];
if (scriptFile.hasSourceMapURL())
var scriptFile = this._scriptFileForTarget.size ? this._scriptFileForTarget.valuesArray()[0] : null;
if (scriptFile && scriptFile.hasSourceMapURL())
infobar.createDetailsRowMessage(WebInspector.UIString("Source map found, but ignored for blackboxed file."));
infobar.createDetailsRowMessage();
infobar.createDetailsRowMessage(WebInspector.UIString("Possible ways to cancel this behavior are:"));
Expand All @@ -176,7 +177,9 @@ WebInspector.JavaScriptSourceFrame.prototype = {

function unblackbox()
{
WebInspector.blackboxManager.unblackbox(url, isContentScript);
WebInspector.blackboxManager.unblackboxUISourceCode(uiSourceCode);
if (projectType === WebInspector.projectTypes.ContentScripts)
WebInspector.blackboxManager.unblackboxContentScripts();
}

this._updateInfobars();
Expand Down
8 changes: 2 additions & 6 deletions front_end/sources/SourcesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,12 +931,8 @@ WebInspector.SourcesPanel.prototype = {
contextMenu.appendItem(WebInspector.UIString.capitalize("Continue to ^here"), this._continueToLocation.bind(this, uiLocation));
}

if (contentType.hasScripts() && projectType !== WebInspector.projectTypes.Snippets) {
var networkURL = this._networkMapping.networkURL(uiSourceCode);
var url = projectType === WebInspector.projectTypes.Formatter ? uiSourceCode.url() : networkURL;
var isBlackboxed = WebInspector.blackboxManager.isBlackboxedUISourceCode(uiSourceCode);
this.sidebarPanes.callstack.appendBlackboxURLContextMenuItems(contextMenu, url, projectType === WebInspector.projectTypes.ContentScripts, isBlackboxed);
}
if (contentType.hasScripts() && projectType !== WebInspector.projectTypes.Snippets)
this.sidebarPanes.callstack.appendBlackboxURLContextMenuItems(contextMenu, uiSourceCode);
},

/**
Expand Down

0 comments on commit 8c6c1b4

Please sign in to comment.