Chromium Code Reviews| Index: Source/devtools/front_end/main/Main.js |
| diff --git a/Source/devtools/front_end/main/Main.js b/Source/devtools/front_end/main/Main.js |
| index 44e480170a32f672ba88e5ef60439ab2f2db78c6..2c2ba1df82fa9350ae1d48318e1596f5267b9e15 100644 |
| --- a/Source/devtools/front_end/main/Main.js |
| +++ b/Source/devtools/front_end/main/Main.js |
| @@ -210,7 +210,7 @@ WebInspector.Main.prototype = { |
| WebInspector.debuggerWorkspaceBinding = new WebInspector.DebuggerWorkspaceBinding(WebInspector.targetManager, WebInspector.workspace, WebInspector.networkMapping); |
| WebInspector.fileSystemWorkspaceBinding = new WebInspector.FileSystemWorkspaceBinding(WebInspector.isolatedFileSystemManager, WebInspector.workspace, WebInspector.networkMapping); |
| WebInspector.breakpointManager = new WebInspector.BreakpointManager(null, WebInspector.workspace, WebInspector.networkMapping, WebInspector.targetManager, WebInspector.debuggerWorkspaceBinding); |
| - WebInspector.extensionServer = new WebInspector.ExtensionServer(); |
| + WebInspector.extensionServer = new WebInspector.ExtensionServer(new WebInspector.ExtensionServer.UIDelegateImpl()); |
| new WebInspector.OverlayController(); |
| new WebInspector.ContentScriptProjectDecorator(); |
| @@ -844,4 +844,104 @@ WebInspector.WorkerTerminatedScreen.prototype = { |
| __proto__: WebInspector.HelpScreen.prototype |
| } |
| +// TODO: Expose the 'sources' panel features more cleanly; files are |
|
pfeldman
2015/08/13 21:15:46
This needs to use runtime DI
wes
2015/08/14 00:55:05
It can also probably be moved out of Main and back
|
| +// opened via the `WebInspector.Revealer` construct (which does similar things |
| +// to the below) - we need something similar for each of these, probably. |
| +/** |
| + * @constructor |
| + * @implements {WebInspector.ExtensionServer.UIDelegate} |
| + */ |
| +WebInspector.ExtensionServer.UIDelegateImpl = function() {} |
| +WebInspector.ExtensionServer.UIDelegateImpl.prototype = { |
| + /** |
| + * @override |
| + * @param {!WebInspector.UISourceCode} code |
| + * @param {!Array<{kind: string, text: string, location: {startLine: number, startColumn: number, endLine: number, endColumn: number}}>} messages |
| + * @suppress {missingProperties} |
| + */ |
| + setResourceLineMessages: function(code, messages) { |
| + self.runtime.loadModulePromise("sources").then(function() { //sources isn't autoloaded, but it tracks line messages - load it |
|
pfeldman
2015/08/13 21:15:46
For example check out UISourceCode revealers (Reve
wes
2015/08/14 00:55:05
I actually mentioned that class in my TODO above.
pfeldman
2015/08/17 21:15:51
I think we need to introduce proper markers the UI
wes
2015/08/25 18:13:18
IMO, binding messages to lines is very limiting. I
|
| + var frame = WebInspector.SourcesPanel.instance().sourcesView().viewForFile(code); |
| + frame.setMessagesForSource(messages.map(function(m){ |
| + return new WebInspector.SourceFrameMessage(m.text, WebInspector.SourceFrameMessage.Level[m.kind], { |
| + line: m.location.startLine, |
| + column: m.location.startColumn |
| + }, { |
| + line: m.location.endLine, |
| + column: m.location.endColumn |
| + }); |
| + })); |
| + }); |
| + }, |
| + |
| + /** |
| + * @override |
| + * @param {!WebInspector.UISourceCode} code |
| + * @return {!Promise<!SourceFrameMessageGetter>} |
| + * @suppress {missingProperties} |
| + */ |
| + getResourceLineMessages: function(code) { |
|
wes
2015/08/14 00:55:05
We mentioned removing the `get` line messages (and
|
| + return self.runtime.loadModulePromise("sources").then(function() { |
| + var frame = WebInspector.SourcesPanel.instance().sourcesView().viewForFile(code); |
| + return /** @type {!SourceFrameMessageGetter} */ (frame.getMessagesFromSource()); |
| + }); |
| + }, |
| + |
| + /** |
| + * @override |
| + * @param {string} highlightText |
| + * @param {!Array<!SearchResultArray>} groupedResults |
| + * @suppress {missingProperties} |
| + */ |
| + displaySearchResults: function(highlightText, groupedResults) { |
| + //TODO: remove private refs, replace with (likely new) public ones |
| + self.runtime.loadModulePromise("sources").then(function() { //sources isn't autoloaded - ensure it exists since we're about to swap to it! |
| + var searchResultsPanel = WebInspector.AdvancedSearchView._instance; |
| + if (!searchResultsPanel) { |
| + searchResultsPanel = new WebInspector.AdvancedSearchView(); |
| + } |
| + |
| + searchResultsPanel._nothingFound(); |
| + searchResultsPanel._searchConfig = new WebInspector.SearchConfig(highlightText, true, false); //TODO: HACK - really should be able to highlight arbitrary spans |
| + searchResultsPanel._searchResultsPane = searchResultsPanel._searchScope.createSearchResultsPane(searchResultsPanel._searchConfig); |
| + searchResultsPanel._resetResults(); |
| + searchResultsPanel._searchResultsElement.appendChild(searchResultsPanel._searchResultsPane.element); |
| + |
| + |
| + WebInspector.inspectorView.setCurrentPanel(WebInspector.SourcesPanel.instance()); |
| + WebInspector.inspectorView.showViewInDrawer("sources.search"); |
| + |
| + groupedResults.map(function(sourceResult) { //map to file search result |
| + var code = WebInspector.networkMapping.uiSourceCodeFromURL(sourceResult.source); |
| + if (!code) { |
| + return; |
| + } |
| + return new WebInspector.FileBasedSearchResult( |
| + code, |
| + sourceResult.map(function(item){ |
| + return new WebInspector.ContentProvider.SearchMatch(item.line, item.lineContent); |
| + }) |
| + ); |
| + }).forEach(function(searchResult) { |
| + if (!searchResult) return; |
| + searchResultsPanel._addSearchResult(searchResult); |
| + searchResultsPanel._searchResultsPane.addSearchResult(searchResult); |
| + }); |
| + }); |
| + }, |
| + |
| + /** |
| + * @override |
| + * @param {!Array<string>} mimes |
| + * @param {?} mode |
| + */ |
| + addSimpleCodeMirrorMode: function(mimes, mode) { |
| + self.runtime.loadModulePromise("source_frame").then(function() { //also not autoloaded (Though TBH this could just add waiting ones on start, rather than loading it when we want to add one) |
| + for (var i=0; i<mimes.length; i++) { |
| + CodeMirror.defineSimpleMode(mimes[i], mode); |
| + } |
| + }); |
| + } |
| +} |
| + |
| new WebInspector.Main(); |