2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * @extends {WebInspector.Panel}
30 * @implements {WebInspector.ContextMenu.Provider}
31 * @implements {WebInspector.TargetManager.Observer}
32 * @param {!WebInspector.Workspace=} workspaceForTest
34 WebInspector.SourcesPanel = function(workspaceForTest)
36 WebInspector.Panel.call(this, "sources");
37 this.registerRequiredCSS("sourcesPanel.css");
38 new WebInspector.UpgradeFileSystemDropTarget(this.element);
40 this._workspace = workspaceForTest || WebInspector.workspace;
42 this.debugToolbar = this._createDebugToolbar();
43 this._debugToolbarDrawer = this._createDebugToolbarDrawer();
45 const initialDebugSidebarWidth = 225;
46 this._splitView = new WebInspector.SplitView(true, true, "sourcesPanelSplitViewState", initialDebugSidebarWidth);
47 this._splitView.enableShowModeSaving();
48 this._splitView.show(this.element);
50 // Create scripts navigator
51 const initialNavigatorWidth = 225;
52 this.editorView = new WebInspector.SplitView(true, false, "sourcesPanelNavigatorSplitViewState", initialNavigatorWidth);
53 this.editorView.enableShowModeSaving();
54 this.editorView.element.id = "scripts-editor-split-view";
55 this.editorView.element.tabIndex = 0;
56 this.editorView.show(this._splitView.mainElement());
58 this._navigator = new WebInspector.SourcesNavigator(this._workspace);
59 this._navigator.view.setMinimumSize(100, 25);
60 this._navigator.view.show(this.editorView.sidebarElement());
61 this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceSelected, this._sourceSelected, this);
62 this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceRenamed, this._sourceRenamed, this);
64 this._sourcesView = new WebInspector.SourcesView(this._workspace, this);
65 this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSelected, this._editorSelected.bind(this));
66 this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorClosed, this._editorClosed.bind(this));
67 this._sourcesView.registerShortcuts(this.registerShortcuts.bind(this));
68 this._sourcesView.show(this.editorView.mainElement());
70 this._debugSidebarResizeWidgetElement = document.createElementWithClass("div", "resizer-widget");
71 this._debugSidebarResizeWidgetElement.id = "scripts-debug-sidebar-resizer-widget";
72 this._splitView.addEventListener(WebInspector.SplitView.Events.ShowModeChanged, this._updateDebugSidebarResizeWidget, this);
73 this._updateDebugSidebarResizeWidget();
74 this._splitView.installResizer(this._debugSidebarResizeWidgetElement);
76 // FIXME: This is a temporary solution which should be removed as soon as the documentation module is released from experiment.
77 if (Runtime.experiments.isEnabled("documentation"))
78 self.runtime.loadModule("documentation");
80 this.sidebarPanes = {};
81 this.sidebarPanes.threads = new WebInspector.ThreadsSidebarPane();
82 this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSidebarPane();
83 this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane();
84 this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPane.Events.CallFrameSelected, this._callFrameSelectedInSidebar.bind(this));
85 this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(this));
87 this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane();
88 this.sidebarPanes.jsBreakpoints = new WebInspector.JavaScriptBreakpointsSidebarPane(WebInspector.breakpointManager, this.showUISourceCode.bind(this));
89 this.sidebarPanes.domBreakpoints = WebInspector.domBreakpointsSidebarPane.createProxy(this);
90 this.sidebarPanes.xhrBreakpoints = new WebInspector.XHRBreakpointsSidebarPane();
91 this.sidebarPanes.eventListenerBreakpoints = new WebInspector.EventListenerBreakpointsSidebarPane();
93 this._extensionSidebarPanes = [];
94 this._installDebuggerSidebarController();
96 WebInspector.dockController.addEventListener(WebInspector.DockController.Events.DockSideChanged, this._dockSideChanged.bind(this));
97 WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(this._dockSideChanged.bind(this));
98 this._dockSideChanged();
100 this._updateDebuggerButtons();
101 this._pauseOnExceptionEnabledChanged();
102 WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseOnExceptionEnabledChanged, this);
103 this._setTarget(WebInspector.context.flavor(WebInspector.Target));
104 WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this);
105 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._onCurrentTargetChanged, this);
106 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerWasEnabled, this._debuggerWasEnabled, this);
107 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerReset, this);
108 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
109 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this);
110 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.CallFrameSelected, this._callFrameSelected, this);
111 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame, this._consoleCommandEvaluatedInSelectedCallFrame, this);
112 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
113 WebInspector.targetManager.observeTargets(this);
116 WebInspector.SourcesPanel.minToolbarWidth = 215;
118 WebInspector.SourcesPanel._infobarSymbol = Symbol("infobar");
120 WebInspector.SourcesPanel.prototype = {
122 * @param {?WebInspector.Target} target
124 _setTarget: function(target)
129 if (target.debuggerModel.isPaused()) {
130 this._showDebuggerPausedDetails(/** @type {!WebInspector.DebuggerPausedDetails} */ (target.debuggerModel.debuggerPausedDetails()));
131 var callFrame = target.debuggerModel.selectedCallFrame();
133 this._selectCallFrame(callFrame);
135 this._paused = false;
136 this._clearInterface();
137 this._toggleDebuggerSidebarButton.setEnabled(true);
142 * @param {!WebInspector.Event} event
144 _onCurrentTargetChanged: function(event)
146 var target = /** @type {?WebInspector.Target} */ (event.data);
147 this._setTarget(target);
153 defaultFocusedElement: function()
155 return this._sourcesView.defaultFocusedElement();
168 WebInspector.context.setFlavor(WebInspector.SourcesPanel, this);
169 WebInspector.Panel.prototype.wasShown.call(this);
174 WebInspector.Panel.prototype.willHide.call(this);
175 WebInspector.context.setFlavor(WebInspector.SourcesPanel, null);
179 * @return {!WebInspector.SearchableView}
181 searchableView: function()
183 return this._sourcesView.searchableView();
186 _consoleCommandEvaluatedInSelectedCallFrame: function(event)
188 var target = /** @type {!WebInspector.Target} */ (event.target.target());
189 if (WebInspector.context.flavor(WebInspector.Target) !== target)
191 this.sidebarPanes.scopechain.update(target.debuggerModel.selectedCallFrame());
195 * @param {!WebInspector.Event} event
197 _debuggerPaused: function(event)
199 var details = /** @type {!WebInspector.DebuggerPausedDetails} */ (event.data);
201 WebInspector.inspectorView.setCurrentPanel(this);
203 if (WebInspector.context.flavor(WebInspector.Target) === details.target())
204 this._showDebuggerPausedDetails(details);
205 else if (!this._paused)
206 WebInspector.context.setFlavor(WebInspector.Target, details.target());
210 * @param {!WebInspector.DebuggerPausedDetails} details
212 _showDebuggerPausedDetails: function(details)
215 this._updateDebuggerButtons();
217 this.sidebarPanes.callstack.update(details);
220 * @param {!Element} element
221 * @this {WebInspector.SourcesPanel}
223 function didCreateBreakpointHitStatusMessage(element)
225 this.sidebarPanes.callstack.setStatus(element);
229 * @param {!WebInspector.UILocation} uiLocation
230 * @this {WebInspector.SourcesPanel}
232 function didGetUILocation(uiLocation)
234 var breakpoint = WebInspector.breakpointManager.findBreakpointOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
237 this.sidebarPanes.jsBreakpoints.highlightBreakpoint(breakpoint);
238 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a JavaScript breakpoint."));
241 if (details.reason === WebInspector.DebuggerModel.BreakReason.DOM) {
242 WebInspector.domBreakpointsSidebarPane.highlightBreakpoint(details.auxData);
243 WebInspector.domBreakpointsSidebarPane.createBreakpointHitStatusMessage(details, didCreateBreakpointHitStatusMessage.bind(this));
244 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.EventListener) {
245 var eventName = details.auxData["eventName"];
246 var targetName = details.auxData["targetName"];
247 this.sidebarPanes.eventListenerBreakpoints.highlightBreakpoint(eventName, targetName);
248 var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName, details.auxData);
249 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a \"%s\" Event Listener.", eventNameForUI));
250 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR) {
251 this.sidebarPanes.xhrBreakpoints.highlightBreakpoint(details.auxData["breakpointURL"]);
252 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a XMLHttpRequest."));
253 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exception)
254 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.", details.auxData["description"]));
255 else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert)
256 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion."));
257 else if (details.reason === WebInspector.DebuggerModel.BreakReason.CSPViolation)
258 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a script blocked due to Content Security Policy directive: \"%s\".", details.auxData["directiveText"]));
259 else if (details.reason === WebInspector.DebuggerModel.BreakReason.DebugCommand)
260 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a debugged function"));
262 if (details.callFrames.length)
263 WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(details.callFrames[0], didGetUILocation.bind(this));
265 console.warn("ScriptsPanel paused, but callFrames.length is zero."); // TODO remove this once we understand this case better
268 this._splitView.showBoth(true);
269 this._toggleDebuggerSidebarButton.setEnabled(false);
271 InspectorFrontendHost.bringToFront();
275 * @param {!WebInspector.Event} event
277 _debuggerResumed: function(event)
279 var target = /** @type {!WebInspector.Target} */ (event.target.target());
280 if (WebInspector.context.flavor(WebInspector.Target) !== target)
282 this._paused = false;
283 this._clearInterface();
284 this._toggleDebuggerSidebarButton.setEnabled(true);
288 * @param {!WebInspector.Event} event
290 _debuggerWasEnabled: function(event)
292 var target = /** @type {!WebInspector.Target} */ (event.target.target());
293 if (WebInspector.context.flavor(WebInspector.Target) !== target)
296 this._updateDebuggerButtons();
300 * @param {!WebInspector.Event} event
302 _debuggerReset: function(event)
304 this._debuggerResumed(event);
308 * @return {!WebInspector.View}
312 return this._sourcesView.visibleView();
316 * @param {!WebInspector.UISourceCode} uiSourceCode
317 * @param {number=} lineNumber 0-based
318 * @param {number=} columnNumber
319 * @param {boolean=} forceShowInPanel
321 showUISourceCode: function(uiSourceCode, lineNumber, columnNumber, forceShowInPanel)
323 this._showEditor(forceShowInPanel);
324 this._sourcesView.showSourceLocation(uiSourceCode, lineNumber, columnNumber);
327 _showEditor: function(forceShowInPanel)
329 WebInspector.inspectorView.showPanel("sources");
333 * @param {!WebInspector.UILocation} uiLocation
334 * @param {boolean=} forceShowInPanel
336 showUILocation: function(uiLocation, forceShowInPanel)
338 this.showUISourceCode(uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber, forceShowInPanel);
342 * @param {!WebInspector.UISourceCode} uiSourceCode
344 _revealInNavigator: function(uiSourceCode)
346 this._navigator.revealUISourceCode(uiSourceCode);
350 * @param {boolean} ignoreExecutionLineEvents
352 setIgnoreExecutionLineEvents: function(ignoreExecutionLineEvents)
354 this._ignoreExecutionLineEvents = ignoreExecutionLineEvents;
357 _executionLineChanged: function(uiLocation)
359 this._sourcesView.clearCurrentExecutionLine();
360 this._sourcesView.setExecutionLine(uiLocation);
361 if (this._ignoreExecutionLineEvents)
363 this._sourcesView.showSourceLocation(uiLocation.uiSourceCode, uiLocation.lineNumber, 0, undefined, true);
367 * @param {!WebInspector.Event} event
369 _callFrameSelected: function(event)
371 var callFrame = /** @type {?WebInspector.DebuggerModel.CallFrame} */ (event.data);
373 if (!callFrame || callFrame.target() !== WebInspector.context.flavor(WebInspector.Target))
376 this._selectCallFrame(callFrame);
380 * @param {!WebInspector.DebuggerModel.CallFrame} callFrame
382 _selectCallFrame: function(callFrame)
384 this.sidebarPanes.scopechain.update(callFrame);
385 this.sidebarPanes.watchExpressions.refreshExpressions();
386 this.sidebarPanes.callstack.setSelectedCallFrame(callFrame);
387 WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(callFrame, this._executionLineChanged.bind(this));
391 * @param {!WebInspector.Event} event
393 _sourceSelected: function(event)
395 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data.uiSourceCode);
396 this._sourcesView.showSourceLocation(uiSourceCode, undefined, undefined, !event.data.focusSource)
400 * @param {!WebInspector.Event} event
402 _sourceRenamed: function(event)
404 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
405 this._sourcesView.sourceRenamed(uiSourceCode);
408 _pauseOnExceptionEnabledChanged: function()
410 var enabled = WebInspector.settings.pauseOnExceptionEnabled.get();
411 this._pauseOnExceptionButton.toggled = enabled;
412 this._pauseOnExceptionButton.title = WebInspector.UIString(enabled ? "Don't pause on exceptions." : "Pause on exceptions.");
413 this._debugToolbarDrawer.classList.toggle("expanded", enabled);
416 _updateDebuggerButtons: function()
418 var currentTarget = WebInspector.context.flavor(WebInspector.Target);
423 this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Resume script execution (%s)."))
424 this._pauseButton.state = true;
425 this._pauseButton.setLongClickOptionsEnabled((function() { return [ this._longResumeButton ] }).bind(this));
427 this._pauseButton.setEnabled(true);
428 this._stepOverButton.setEnabled(true);
429 this._stepIntoButton.setEnabled(true);
430 this._stepOutButton.setEnabled(true);
432 this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Pause script execution (%s)."))
433 this._pauseButton.state = false;
434 this._pauseButton.setLongClickOptionsEnabled(null);
436 this._pauseButton.setEnabled(!currentTarget.debuggerModel.isPausing());
437 this._stepOverButton.setEnabled(false);
438 this._stepIntoButton.setEnabled(false);
439 this._stepOutButton.setEnabled(false);
443 _clearInterface: function()
445 this.sidebarPanes.callstack.update(null);
446 this.sidebarPanes.scopechain.update(null);
447 this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight();
448 WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight();
449 this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight();
450 this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight();
452 this._sourcesView.clearCurrentExecutionLine();
453 this._updateDebuggerButtons();
456 _togglePauseOnExceptions: function()
458 WebInspector.settings.pauseOnExceptionEnabled.set(!this._pauseOnExceptionButton.toggled);
464 _runSnippet: function()
466 var uiSourceCode = this._sourcesView.currentUISourceCode();
467 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets)
470 var currentExecutionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
471 if (!currentExecutionContext)
474 WebInspector.scriptSnippetModel.evaluateScriptSnippet(currentExecutionContext, uiSourceCode);
479 * @param {!WebInspector.Event} event
481 _editorSelected: function(event)
483 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
484 this._editorChanged(uiSourceCode);
485 if (Runtime.experiments.isEnabled("suggestUsingWorkspace")) {
486 if (this._editorSelectedTimer)
487 clearTimeout(this._editorSelectedTimer);
488 this._editorSelectedTimer = setTimeout(this._updateSuggestedMappingInfobar.bind(this, uiSourceCode), 3000);
493 * @param {!WebInspector.UISourceCode} uiSourceCode
495 _updateSuggestedMappingInfobar: function(uiSourceCode)
497 if (!this.isShowing())
499 if (uiSourceCode[WebInspector.SourcesPanel._infobarSymbol])
502 // First try mapping filesystem -> network.
503 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode);
504 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem) {
505 var hasMappings = !!uiSourceCode.url;
509 var targets = WebInspector.targetManager.targets();
510 for (var i = 0; i < targets.length; ++i)
511 targets[i].resourceTreeModel.forAllResources(matchResource.bind(this));
515 * @param {!WebInspector.Resource} resource
517 * @this {WebInspector.SourcesPanel}
519 function matchResource(resource)
521 if (resource.contentURL().endsWith(uiSourceCode.name())) {
522 createMappingInfobar.call(this, false);
528 // Then map network -> filesystem.
529 if (uiSourceCode.project().type() === WebInspector.projectTypes.Network || uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) {
530 if (this._workspace.uiSourceCodeForURL(uiSourceCode.url) !== uiSourceCode)
533 var filesystemProjects = this._workspace.projectsForType(WebInspector.projectTypes.FileSystem);
534 for (var i = 0; i < filesystemProjects.length; ++i) {
535 var name = uiSourceCode.name();
536 var fsUiSourceCodes = filesystemProjects[i].uiSourceCodes();
537 for (var j = 0; j < fsUiSourceCodes.length; ++j) {
538 if (fsUiSourceCodes[j].name() === name) {
539 createMappingInfobar.call(this, true);
545 // There are no matching filesystems. Suggest adding a filesystem in case of localhost.
546 var originURL = uiSourceCode.originURL().asParsedURL();
547 if (originURL && originURL.host === "localhost")
548 createWorkspaceInfobar();
552 * @param {boolean} isNetwork
553 * @this {WebInspector.SourcesPanel}
555 function createMappingInfobar(isNetwork)
559 title = WebInspector.UIString("Map network resource '%s' to workspace?", uiSourceCode.originURL());
561 title = WebInspector.UIString("Map workspace resource '%s' to network?", uiSourceCode.path());
563 var infobar = new WebInspector.UISourceCodeFrame.Infobar(WebInspector.UISourceCodeFrame.Infobar.Level.Info, title);
564 infobar.createDetailsRowMessage(WebInspector.UIString("You can map files in your workspace to the ones loaded over the network. As a result, changes made in DevTools will be persisted to disk."));
565 infobar.createDetailsRowMessage(WebInspector.UIString("Use context menu to establish the mapping at any time."));
566 var actionLink = infobar.createDetailsRowMessage("").createChild("a");
567 actionLink.href = "";
568 actionLink.onclick = establishTheMapping.bind(this);
569 actionLink.textContent = WebInspector.UIString("Establish the mapping now...");
570 appendInfobar(infobar);
574 * @param {?Event} event
575 * @this {WebInspector.SourcesPanel}
577 function establishTheMapping(event)
580 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem)
581 this._mapFileSystemToNetwork(uiSourceCode);
583 this._mapNetworkToFileSystem(uiSourceCode);
586 function createWorkspaceInfobar()
588 var infobar = new WebInspector.UISourceCodeFrame.Infobar(WebInspector.UISourceCodeFrame.Infobar.Level.Info, WebInspector.UIString("Serving from the file system? Add your files into the workspace."));
589 infobar.createDetailsRowMessage(WebInspector.UIString("If you add files into your DevTools workspace, your changes will be persisted to disk."));
590 infobar.createDetailsRowMessage(WebInspector.UIString("To add a folder into the workspace, drag and drop it into the Sources panel."));
591 appendInfobar(infobar);
595 * @param {!WebInspector.UISourceCodeFrame.Infobar} infobar
597 function appendInfobar(infobar)
599 infobar.createDetailsRowMessage("").createChild("br");
600 var rowElement = infobar.createDetailsRowMessage(WebInspector.UIString("For more information on workspaces, refer to the "));
601 var a = rowElement.createChild("a");
602 a.textContent = "workspaces documentation";
603 a.href = "https://developer.chrome.com/devtools/docs/workspaces";
604 rowElement.createTextChild(".");
605 uiSourceCode[WebInspector.SourcesPanel._infobarSymbol] = infobar;
606 uiSourceCodeFrame.attachInfobars([infobar]);
611 * @param {!WebInspector.Event} event
613 _editorClosed: function(event)
615 var wasSelected = /** @type {boolean} */ (event.data.wasSelected);
617 this._editorChanged(null);
621 * @param {?WebInspector.UISourceCode} uiSourceCode
623 _editorChanged: function(uiSourceCode)
625 var isSnippet = uiSourceCode && uiSourceCode.project().type() === WebInspector.projectTypes.Snippets;
626 this._runSnippetButton.element.classList.toggle("hidden", !isSnippet);
632 togglePause: function()
634 var target = WebInspector.context.flavor(WebInspector.Target);
639 this._paused = false;
640 target.debuggerModel.resume();
642 // Make sure pauses didn't stick skipped.
643 target.debuggerModel.pause();
646 this._clearInterface();
651 * @return {?WebInspector.DebuggerModel}
653 _prepareToResume: function()
658 this._paused = false;
660 this._clearInterface();
661 var target = WebInspector.context.flavor(WebInspector.Target);
662 return target ? target.debuggerModel : null;
668 _longResume: function()
670 var debuggerModel = this._prepareToResume();
674 debuggerModel.skipAllPausesUntilReloadOrTimeout(500);
675 debuggerModel.resume();
682 _stepOverClicked: function()
684 var debuggerModel = this._prepareToResume();
688 debuggerModel.stepOver();
695 _stepIntoClicked: function()
697 var debuggerModel = this._prepareToResume();
701 debuggerModel.stepInto();
708 _stepOutClicked: function()
710 var debuggerModel = this._prepareToResume();
714 debuggerModel.stepOut();
719 * @param {!WebInspector.Event} event
721 _callFrameSelectedInSidebar: function(event)
723 var callFrame = /** @type {!WebInspector.DebuggerModel.CallFrame} */ (event.data);
724 callFrame.target().debuggerModel.setSelectedCallFrame(callFrame);
728 * @param {!WebInspector.DebuggerModel.Location} rawLocation
730 continueToLocation: function(rawLocation)
732 if (!this._prepareToResume())
735 rawLocation.continueToLocation();
738 _toggleBreakpointsClicked: function(event)
740 WebInspector.breakpointManager.setBreakpointsActive(!WebInspector.breakpointManager.breakpointsActive());
743 _breakpointsActiveStateChanged: function(event)
745 var active = event.data;
746 this._toggleBreakpointsButton.toggled = !active;
747 this.sidebarPanes.jsBreakpoints.listElement.classList.toggle("breakpoints-list-deactivated", !active);
748 this._sourcesView.toggleBreakpointsActiveState(active);
750 this._toggleBreakpointsButton.title = WebInspector.UIString("Deactivate breakpoints.");
752 this._toggleBreakpointsButton.title = WebInspector.UIString("Activate breakpoints.");
755 _createDebugToolbar: function()
757 var debugToolbar = document.createElementWithClass("div", "scripts-debug-toolbar");
760 var platformSpecificModifier = WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta;
763 title = WebInspector.UIString("Run snippet (%s).");
764 handler = this._runSnippet.bind(this);
765 this._runSnippetButton = this._createButtonAndRegisterShortcuts("scripts-run-snippet", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.RunSnippet);
766 debugToolbar.appendChild(this._runSnippetButton.element);
767 this._runSnippetButton.element.classList.add("hidden");
770 this._pauseButton = this._createButtonAndRegisterShortcutsForAction("scripts-pause", "", "debugger.toggle-pause");
771 debugToolbar.appendChild(this._pauseButton.element);
774 title = WebInspector.UIString("Resume with all pauses blocked for 500 ms");
775 this._longResumeButton = new WebInspector.StatusBarButton(title, "scripts-long-resume");
776 this._longResumeButton.addEventListener("click", this._longResume.bind(this), this);
779 title = WebInspector.UIString("Step over next function call (%s).");
780 handler = this._stepOverClicked.bind(this);
781 this._stepOverButton = this._createButtonAndRegisterShortcuts("scripts-step-over", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepOver);
782 debugToolbar.appendChild(this._stepOverButton.element);
785 title = WebInspector.UIString("Step into next function call (%s).");
786 handler = this._stepIntoClicked.bind(this);
787 this._stepIntoButton = this._createButtonAndRegisterShortcuts("scripts-step-into", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepInto);
788 debugToolbar.appendChild(this._stepIntoButton.element);
791 title = WebInspector.UIString("Step out of current function (%s).");
792 handler = this._stepOutClicked.bind(this);
793 this._stepOutButton = this._createButtonAndRegisterShortcuts("scripts-step-out", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepOut);
794 debugToolbar.appendChild(this._stepOutButton.element);
796 // Toggle Breakpoints
797 this._toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Deactivate breakpoints."), "scripts-toggle-breakpoints");
798 this._toggleBreakpointsButton.toggled = false;
799 this._toggleBreakpointsButton.addEventListener("click", this._toggleBreakpointsClicked, this);
800 debugToolbar.appendChild(this._toggleBreakpointsButton.element);
802 // Pause on Exception
803 this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scripts-pause-on-exceptions-status-bar-item");
804 this._pauseOnExceptionButton.addEventListener("click", this._togglePauseOnExceptions, this);
805 debugToolbar.appendChild(this._pauseOnExceptionButton.element);
810 _createDebugToolbarDrawer: function()
812 var debugToolbarDrawer = document.createElementWithClass("div", "scripts-debug-toolbar-drawer");
814 var label = WebInspector.UIString("Pause On Caught Exceptions");
815 var setting = WebInspector.settings.pauseOnCaughtException;
816 debugToolbarDrawer.appendChild(WebInspector.SettingsUI.createSettingCheckbox(label, setting, true));
818 return debugToolbarDrawer;
822 * @param {!WebInspector.StatusBarButton} button
823 * @param {string} buttonTitle
825 _updateButtonTitle: function(button, buttonTitle)
827 var hasShortcuts = button.shortcuts && button.shortcuts.length;
829 button.title = String.vsprintf(buttonTitle, [button.shortcuts[0].name]);
831 button.title = buttonTitle;
835 * @param {string} buttonId
836 * @param {string} buttonTitle
837 * @param {function(!Event=):boolean} handler
838 * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} shortcuts
839 * @return {!WebInspector.StatusBarButton}
841 _createButtonAndRegisterShortcuts: function(buttonId, buttonTitle, handler, shortcuts)
843 var button = new WebInspector.StatusBarButton(buttonTitle, buttonId);
844 button.element.addEventListener("click", handler, false);
845 button.shortcuts = shortcuts;
846 this._updateButtonTitle(button, buttonTitle);
847 this.registerShortcuts(shortcuts, handler);
852 * @param {string} buttonId
853 * @param {string} buttonTitle
854 * @param {string} actionId
855 * @return {!WebInspector.StatusBarButton}
857 _createButtonAndRegisterShortcutsForAction: function(buttonId, buttonTitle, actionId)
864 return WebInspector.actionRegistry.execute(actionId);
866 var shortcuts = WebInspector.shortcutRegistry.shortcutDescriptorsForAction(actionId);
867 return this._createButtonAndRegisterShortcuts(buttonId, buttonTitle, handler, shortcuts);
870 addToWatch: function(expression)
872 this.sidebarPanes.watchExpressions.addExpression(expression);
875 _installDebuggerSidebarController: function()
877 this._toggleNavigatorSidebarButton = this.editorView.createShowHideSidebarButton("navigator", "scripts-navigator-show-hide-button");
878 this.editorView.mainElement().appendChild(this._toggleNavigatorSidebarButton.element);
880 this._toggleDebuggerSidebarButton = this._splitView.createShowHideSidebarButton("debugger", "scripts-debugger-show-hide-button");
882 this._splitView.mainElement().appendChild(this._toggleDebuggerSidebarButton.element);
883 this._splitView.mainElement().appendChild(this._debugSidebarResizeWidgetElement);
886 _updateDebugSidebarResizeWidget: function()
888 this._debugSidebarResizeWidgetElement.classList.toggle("hidden", this._splitView.showMode() !== WebInspector.SplitView.ShowMode.Both);
892 * @param {!WebInspector.UISourceCode} uiSourceCode
894 _showLocalHistory: function(uiSourceCode)
896 WebInspector.RevisionHistoryView.showHistory(uiSourceCode);
900 * @param {!Event} event
901 * @param {!WebInspector.ContextMenu} contextMenu
902 * @param {!Object} target
904 appendApplicableItems: function(event, contextMenu, target)
906 this._appendUISourceCodeItems(event, contextMenu, target);
907 this._appendRemoteObjectItems(contextMenu, target);
910 _suggestReload: function()
912 if (window.confirm(WebInspector.UIString("It is recommended to restart inspector after making these changes. Would you like to restart it?")))
913 WebInspector.reload();
917 * @param {!WebInspector.UISourceCode} uiSourceCode
919 _mapFileSystemToNetwork: function(uiSourceCode)
921 WebInspector.SelectUISourceCodeForProjectTypesDialog.show(uiSourceCode.name(), [WebInspector.projectTypes.Network, WebInspector.projectTypes.ContentScripts], mapFileSystemToNetwork.bind(this), this.editorView.mainElement())
924 * @param {!WebInspector.UISourceCode} networkUISourceCode
925 * @this {WebInspector.SourcesPanel}
927 function mapFileSystemToNetwork(networkUISourceCode)
929 this._workspace.addMapping(networkUISourceCode, uiSourceCode, WebInspector.fileSystemWorkspaceBinding);
930 this._suggestReload();
935 * @param {!WebInspector.UISourceCode} uiSourceCode
937 _removeNetworkMapping: function(uiSourceCode)
939 if (confirm(WebInspector.UIString("Are you sure you want to remove network mapping?"))) {
940 this._workspace.removeMapping(uiSourceCode);
941 this._suggestReload();
946 * @param {!WebInspector.UISourceCode} networkUISourceCode
948 _mapNetworkToFileSystem: function(networkUISourceCode)
950 WebInspector.SelectUISourceCodeForProjectTypesDialog.show(networkUISourceCode.name(), [WebInspector.projectTypes.FileSystem], mapNetworkToFileSystem.bind(this), this.editorView.mainElement())
953 * @param {!WebInspector.UISourceCode} uiSourceCode
954 * @this {WebInspector.SourcesPanel}
956 function mapNetworkToFileSystem(uiSourceCode)
958 this._workspace.addMapping(networkUISourceCode, uiSourceCode, WebInspector.fileSystemWorkspaceBinding);
959 this._suggestReload();
964 * @param {!WebInspector.ContextMenu} contextMenu
965 * @param {!WebInspector.UISourceCode} uiSourceCode
967 _appendUISourceCodeMappingItems: function(contextMenu, uiSourceCode)
969 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem) {
970 var hasMappings = !!uiSourceCode.url;
972 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Map to network resource\u2026" : "Map to Network Resource\u2026"), this._mapFileSystemToNetwork.bind(this, uiSourceCode));
974 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove network mapping" : "Remove Network Mapping"), this._removeNetworkMapping.bind(this, uiSourceCode));
978 * @param {!WebInspector.Project} project
980 function filterProject(project)
982 return project.type() === WebInspector.projectTypes.FileSystem;
985 if (uiSourceCode.project().type() === WebInspector.projectTypes.Network || uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) {
986 if (!this._workspace.projects().filter(filterProject).length)
988 if (this._workspace.uiSourceCodeForURL(uiSourceCode.url) === uiSourceCode)
989 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Map to file system resource\u2026" : "Map to File System Resource\u2026"), this._mapNetworkToFileSystem.bind(this, uiSourceCode));
994 * @param {!Event} event
995 * @param {!WebInspector.ContextMenu} contextMenu
996 * @param {!Object} target
998 _appendUISourceCodeItems: function(event, contextMenu, target)
1000 if (!(target instanceof WebInspector.UISourceCode))
1003 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (target);
1004 var projectType = uiSourceCode.project().type();
1005 if (projectType !== WebInspector.projectTypes.FileSystem)
1006 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Local modifications\u2026" : "Local Modifications\u2026"), this._showLocalHistory.bind(this, uiSourceCode));
1007 this._appendUISourceCodeMappingItems(contextMenu, uiSourceCode);
1009 var contentType = uiSourceCode.contentType();
1010 if ((contentType === WebInspector.resourceTypes.Script || contentType === WebInspector.resourceTypes.Document) && projectType !== WebInspector.projectTypes.Snippets)
1011 this.sidebarPanes.callstack.appendBlackboxURLContextMenuItems(contextMenu, uiSourceCode.url, projectType === WebInspector.projectTypes.ContentScripts);
1013 if (!event.target.isSelfOrDescendant(this.editorView.sidebarElement())) {
1014 contextMenu.appendSeparator();
1015 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Reveal in navigator" : "Reveal in Navigator"), this._handleContextMenuReveal.bind(this, uiSourceCode));
1020 * @param {!WebInspector.UISourceCode} uiSourceCode
1022 _handleContextMenuReveal: function(uiSourceCode)
1024 this.editorView.showBoth();
1025 this._revealInNavigator(uiSourceCode);
1029 * @param {!WebInspector.ContextMenu} contextMenu
1030 * @param {!Object} target
1032 _appendRemoteObjectItems: function(contextMenu, target)
1034 if (!(target instanceof WebInspector.RemoteObject))
1036 var remoteObject = /** @type {!WebInspector.RemoteObject} */ (target);
1037 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Store as global variable" : "Store as Global Variable"), this._saveToTempVariable.bind(this, remoteObject));
1038 if (remoteObject.type === "function")
1039 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Show function definition" : "Show Function Definition"), this._showFunctionDefinition.bind(this, remoteObject));
1043 * @param {!WebInspector.RemoteObject} remoteObject
1045 _saveToTempVariable: function(remoteObject)
1047 var currentExecutionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
1048 if (!currentExecutionContext)
1051 currentExecutionContext.evaluate("this", "", false, true, false, false, didGetGlobalObject.bind(null, currentExecutionContext.target()));
1053 * @param {!WebInspector.Target} target
1054 * @param {?WebInspector.RemoteObject} global
1055 * @param {boolean=} wasThrown
1057 function didGetGlobalObject(target, global, wasThrown)
1060 * @suppressReceiverCheck
1063 function remoteFunction(value)
1065 var prefix = "temp";
1067 while ((prefix + index) in this)
1069 var name = prefix + index;
1074 if (wasThrown || !global)
1075 failedToSave(target, global);
1077 global.callFunction(remoteFunction, [WebInspector.RemoteObject.toCallArgument(remoteObject)], didSave.bind(null, global));
1081 * @param {!WebInspector.RemoteObject} global
1082 * @param {?WebInspector.RemoteObject} result
1083 * @param {boolean=} wasThrown
1085 function didSave(global, result, wasThrown)
1087 var currentExecutionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
1089 if (!currentExecutionContext || wasThrown || !result || result.type !== "string")
1090 failedToSave(global.target(), result);
1092 WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionContext, result.value);
1096 * @param {!WebInspector.Target} target
1097 * @param {?WebInspector.RemoteObject} result
1099 function failedToSave(target, result)
1101 var message = WebInspector.UIString("Failed to save to temp variable.");
1103 message += " " + result.description;
1106 WebInspector.console.error(message);
1111 * @param {!WebInspector.RemoteObject} remoteObject
1113 _showFunctionDefinition: function(remoteObject)
1115 var debuggerModel = remoteObject.target().debuggerModel;
1118 * @param {?WebInspector.DebuggerModel.FunctionDetails} response
1119 * @this {WebInspector.SourcesPanel}
1121 function didGetFunctionDetails(response)
1123 if (!response || !response.location)
1126 var location = response.location;
1130 var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationToUILocation(location);
1132 this.showUILocation(uiLocation, true);
1134 debuggerModel.functionDetails(remoteObject, didGetFunctionDetails.bind(this));
1137 showGoToSourceDialog: function()
1139 this._sourcesView.showOpenResourceDialog();
1142 _dockSideChanged: function()
1144 var vertically = WebInspector.dockController.isVertical() && WebInspector.settings.splitVerticallyWhenDockedToRight.get();
1145 this._splitVertically(vertically);
1149 * @param {boolean} vertically
1151 _splitVertically: function(vertically)
1153 if (this.sidebarPaneView && vertically === !this._splitView.isVertical())
1156 if (this.sidebarPaneView)
1157 this.sidebarPaneView.detach();
1159 this._splitView.setVertical(!vertically);
1162 this._splitView.uninstallResizer(this._sourcesView.statusBarContainerElement());
1164 this._splitView.installResizer(this._sourcesView.statusBarContainerElement());
1166 // Create vertical box with stack.
1167 var vbox = new WebInspector.VBox();
1168 vbox.element.appendChild(this._debugToolbarDrawer);
1169 vbox.element.appendChild(this.debugToolbar);
1170 vbox.setMinimumAndPreferredSizes(25, 25, WebInspector.SourcesPanel.minToolbarWidth, 100);
1171 var sidebarPaneStack = new WebInspector.SidebarPaneStack();
1172 sidebarPaneStack.element.classList.add("flex-auto");
1173 sidebarPaneStack.show(vbox.element);
1176 // Populate the only stack.
1177 for (var pane in this.sidebarPanes)
1178 sidebarPaneStack.addPane(this.sidebarPanes[pane]);
1179 this._extensionSidebarPanesContainer = sidebarPaneStack;
1180 this.sidebarPaneView = vbox;
1182 var splitView = new WebInspector.SplitView(true, true, "sourcesPanelDebuggerSidebarSplitViewState", 0.5);
1183 vbox.show(splitView.mainElement());
1185 // Populate the left stack.
1186 sidebarPaneStack.addPane(this.sidebarPanes.threads);
1187 sidebarPaneStack.addPane(this.sidebarPanes.callstack);
1188 sidebarPaneStack.addPane(this.sidebarPanes.jsBreakpoints);
1189 sidebarPaneStack.addPane(this.sidebarPanes.domBreakpoints);
1190 sidebarPaneStack.addPane(this.sidebarPanes.xhrBreakpoints);
1191 sidebarPaneStack.addPane(this.sidebarPanes.eventListenerBreakpoints);
1193 var tabbedPane = new WebInspector.SidebarTabbedPane();
1194 tabbedPane.show(splitView.sidebarElement());
1195 tabbedPane.addPane(this.sidebarPanes.scopechain);
1196 tabbedPane.addPane(this.sidebarPanes.watchExpressions);
1197 this._extensionSidebarPanesContainer = tabbedPane;
1199 this.sidebarPaneView = splitView;
1201 for (var i = 0; i < this._extensionSidebarPanes.length; ++i)
1202 this._extensionSidebarPanesContainer.addPane(this._extensionSidebarPanes[i]);
1204 this.sidebarPaneView.show(this._splitView.sidebarElement());
1205 this.sidebarPanes.threads.expand();
1206 this.sidebarPanes.scopechain.expand();
1207 this.sidebarPanes.jsBreakpoints.expand();
1208 this.sidebarPanes.callstack.expand();
1209 this._sidebarPaneStack = sidebarPaneStack;
1210 this._updateTargetsSidebarVisibility();
1211 if (WebInspector.settings.watchExpressions.get().length > 0)
1212 this.sidebarPanes.watchExpressions.expand();
1216 * @param {string} id
1217 * @param {!WebInspector.SidebarPane} pane
1219 addExtensionSidebarPane: function(id, pane)
1221 this._extensionSidebarPanes.push(pane);
1222 this._extensionSidebarPanesContainer.addPane(pane);
1223 this.setHideOnDetach();
1227 * @return {!WebInspector.SourcesView}
1229 sourcesView: function()
1231 return this._sourcesView;
1235 * @param {!WebInspector.Target} target
1237 targetAdded: function(target)
1239 this._updateTargetsSidebarVisibility();
1243 * @param {!WebInspector.Target} target
1245 targetRemoved: function(target)
1247 this._updateTargetsSidebarVisibility();
1250 _updateTargetsSidebarVisibility: function()
1252 if (!this._sidebarPaneStack)
1254 this._sidebarPaneStack.togglePaneHidden(this.sidebarPanes.threads, WebInspector.targetManager.targets().length < 2);
1257 __proto__: WebInspector.Panel.prototype
1262 * @param {!Element} element
1264 WebInspector.UpgradeFileSystemDropTarget = function(element)
1266 element.addEventListener("dragenter", this._onDragEnter.bind(this), true);
1267 element.addEventListener("dragover", this._onDragOver.bind(this), true);
1268 this._element = element;
1271 WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType = "Files";
1273 WebInspector.UpgradeFileSystemDropTarget.prototype = {
1274 _onDragEnter: function (event)
1276 if (event.dataTransfer.types.indexOf(WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType) === -1)
1278 event.consume(true);
1281 _onDragOver: function (event)
1283 if (event.dataTransfer.types.indexOf(WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType) === -1)
1285 event.dataTransfer.dropEffect = "copy";
1286 event.consume(true);
1287 if (this._dragMaskElement)
1289 this._dragMaskElement = this._element.createChild("div", "fill drag-mask");
1290 this._dragMaskElement.createChild("div", "fill drag-mask-inner").textContent = WebInspector.UIString("Drop workspace folder here");
1291 this._dragMaskElement.addEventListener("drop", this._onDrop.bind(this), true);
1292 this._dragMaskElement.addEventListener("dragleave", this._onDragLeave.bind(this), true);
1295 _onDrop: function (event)
1297 event.consume(true);
1299 var items = /** @type {!Array.<!DataTransferItem>} */ (event.dataTransfer.items);
1302 var entry = items[0].webkitGetAsEntry();
1303 if (!entry.isDirectory)
1305 InspectorFrontendHost.upgradeDraggedFileSystemPermissions(entry.filesystem);
1308 _onDragLeave: function (event)
1310 event.consume(true);
1314 _removeMask: function ()
1316 this._dragMaskElement.remove();
1317 delete this._dragMaskElement;
1323 * @implements {WebInspector.ContextMenu.Provider}
1325 WebInspector.SourcesPanel.ContextMenuProvider = function()
1329 WebInspector.SourcesPanel.ContextMenuProvider.prototype = {
1331 * @param {!Event} event
1332 * @param {!WebInspector.ContextMenu} contextMenu
1333 * @param {!Object} target
1335 appendApplicableItems: function(event, contextMenu, target)
1337 WebInspector.inspectorView.panel("sources").appendApplicableItems(event, contextMenu, target);
1343 * @implements {WebInspector.Revealer}
1345 WebInspector.SourcesPanel.UILocationRevealer = function()
1349 WebInspector.SourcesPanel.UILocationRevealer.prototype = {
1351 * @param {!Object} uiLocation
1353 reveal: function(uiLocation)
1355 if (uiLocation instanceof WebInspector.UILocation)
1356 /** @type {!WebInspector.SourcesPanel} */ (WebInspector.inspectorView.panel("sources")).showUILocation(uiLocation);
1362 * @implements {WebInspector.Revealer}
1364 WebInspector.SourcesPanel.UISourceCodeRevealer = function()
1368 WebInspector.SourcesPanel.UISourceCodeRevealer.prototype = {
1370 * @param {!Object} uiSourceCode
1372 reveal: function(uiSourceCode)
1374 if (uiSourceCode instanceof WebInspector.UISourceCode)
1375 /** @type {!WebInspector.SourcesPanel} */ (WebInspector.inspectorView.panel("sources")).showUISourceCode(uiSourceCode);
1381 * @implements {WebInspector.ActionDelegate}
1383 WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate = function() {}
1385 WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate.prototype = {
1389 handleAction: function()
1391 var panel = /** @type {?WebInspector.SourcesPanel} */ (WebInspector.inspectorView.showPanel("sources"));
1394 panel.showGoToSourceDialog();
1401 * @extends {WebInspector.UISettingDelegate}
1403 WebInspector.SourcesPanel.DisableJavaScriptSettingDelegate = function()
1405 WebInspector.UISettingDelegate.call(this);
1408 WebInspector.SourcesPanel.DisableJavaScriptSettingDelegate.prototype = {
1411 * @return {!Element}
1413 settingElement: function()
1415 var disableJSElement = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Disable JavaScript"), WebInspector.settings.javaScriptDisabled);
1416 this._disableJSCheckbox = disableJSElement.getElementsByTagName("input")[0];
1417 WebInspector.settings.javaScriptDisabled.addChangeListener(this._settingChanged, this);
1418 var disableJSInfoParent = this._disableJSCheckbox.parentElement.createChild("span", "monospace");
1419 this._disableJSInfo = disableJSInfoParent.createChild("span", "object-info-state-note hidden");
1420 this._disableJSInfo.title = WebInspector.UIString("JavaScript is blocked on the inspected page (may be disabled in browser settings).");
1422 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.MainFrameNavigated, this._updateScriptDisabledCheckbox, this);
1423 this._updateScriptDisabledCheckbox();
1424 return disableJSElement;
1428 * @param {!WebInspector.Event} event
1430 _settingChanged: function(event)
1432 PageAgent.setScriptExecutionDisabled(event.data, this._updateScriptDisabledCheckbox.bind(this));
1435 _updateScriptDisabledCheckbox: function()
1437 PageAgent.getScriptExecutionStatus(executionStatusCallback.bind(this));
1440 * @param {?Protocol.Error} error
1441 * @param {string} status
1442 * @this {WebInspector.SourcesPanel.DisableJavaScriptSettingDelegate}
1444 function executionStatusCallback(error, status)
1446 if (error || !status)
1449 var forbidden = (status === "forbidden");
1450 var disabled = forbidden || (status === "disabled");
1452 this._disableJSInfo.classList.toggle("hidden", !forbidden);
1453 this._disableJSCheckbox.checked = disabled;
1454 this._disableJSCheckbox.disabled = forbidden;
1458 __proto__: WebInspector.UISettingDelegate.prototype
1463 * @implements {WebInspector.ActionDelegate}
1465 WebInspector.SourcesPanel.TogglePauseActionDelegate = function()
1469 WebInspector.SourcesPanel.TogglePauseActionDelegate.prototype = {
1473 handleAction: function()
1475 var panel = /** @type {?WebInspector.SourcesPanel} */ (WebInspector.inspectorView.showPanel("sources"));
1478 panel.togglePause();