2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
4 * Copyright (C) 2009 Joseph Pecoraro
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * @implements {InspectorAgent.Dispatcher}
35 WebInspector.Main = function()
37 var boundListener = windowLoaded.bind(this);
40 * @this {WebInspector.Main}
42 function windowLoaded()
45 window.removeEventListener("DOMContentLoaded", boundListener, false);
47 window.addEventListener("DOMContentLoaded", boundListener, false);
50 WebInspector.Main.prototype = {
51 _createGlobalStatusBarItems: function()
53 var extensions = self.runtime.extensions(WebInspector.StatusBarItem.Provider);
56 * @param {!Runtime.Extension} left
57 * @param {!Runtime.Extension} right
59 function orderComparator(left, right)
61 return left.descriptor()["order"] - right.descriptor()["order"];
63 extensions.sort(orderComparator);
64 extensions.forEach(function(extension) {
66 switch (extension.descriptor()["location"]) {
68 item = createItem(extension);
70 WebInspector.inspectorView.appendToLeftToolbar(item);
73 item = createItem(extension);
75 WebInspector.inspectorView.appendToRightToolbar(item);
78 if (item && extension.descriptor()["actionId"]) {
79 item.addEventListener("click", function() {
80 WebInspector.actionRegistry.execute(extension.descriptor()["actionId"]);
85 function createItem(extension)
87 var descriptor = extension.descriptor();
88 if (descriptor.className)
89 return extension.instance().item();
90 return new WebInspector.StatusBarButton(WebInspector.UIString(descriptor["title"]), descriptor["elementClass"]);
94 _calculateWorkerInspectorTitle: function()
96 var expression = "location.href";
97 if (WebInspector.queryParam("isSharedWorker"))
98 expression += " + (this.name ? ' (' + this.name + ')' : '')";
99 RuntimeAgent.invoke_evaluate({expression:expression, doNotPauseOnExceptionsAndMuteConsole:true, returnByValue: true}, evalCallback);
102 * @param {?Protocol.Error} error
103 * @param {!RuntimeAgent.RemoteObject} result
104 * @param {boolean=} wasThrown
106 function evalCallback(error, result, wasThrown)
108 if (error || wasThrown) {
109 console.error(error);
112 InspectorFrontendHost.inspectedURLChanged(String(result.value));
116 _loadCompletedForWorkers: function()
118 // Make sure script execution of dedicated worker or service worker is
119 // resumed and then paused on the first script statement in case we
120 // autoattached to it.
121 if (WebInspector.queryParam("workerPaused")) {
122 pauseAndResume.call(this);
124 RuntimeAgent.isRunRequired(isRunRequiredCallback.bind(this));
128 * @this {WebInspector.Main}
130 function isRunRequiredCallback(error, result)
133 pauseAndResume.call(this);
134 } else if (WebInspector.isWorkerFrontend()) {
135 calculateTitle.call(this);
140 * @this {WebInspector.Main}
142 function pauseAndResume()
144 DebuggerAgent.pause();
145 RuntimeAgent.run(calculateTitle.bind(this));
149 * @this {WebInspector.Main}
151 function calculateTitle()
153 this._calculateWorkerInspectorTitle();
159 console.timeStamp("Main._loaded");
161 // FIXME: Make toolbox a real app.
162 if (WebInspector.queryParam("toolbox"))
165 this._createSettings();
166 this._createModuleManager();
170 _createSettings: function()
172 WebInspector.settings = new WebInspector.Settings();
173 WebInspector.experimentsSettings = new WebInspector.ExperimentsSettings(WebInspector.queryParam("experiments") !== null);
174 // This setting is needed for backwards compatibility with Devtools CodeSchool extension. DO NOT REMOVE
175 WebInspector.settings.pauseOnExceptionStateString = new WebInspector.PauseOnExceptionStateSetting();
176 new WebInspector.VersionController().updateVersion();
179 _createModuleManager: function()
181 console.timeStamp("Main._createModuleManager");
182 self.runtime = new Runtime(allDescriptors);
184 // FIXME: define html-per-app, make configuration a part of the app.
185 var configuration = ["main", "elements", "network", "sources", "timeline", "profiler", "resources", "audits", "console", "source_frame", "extensions", "settings"];
186 if (WebInspector.experimentsSettings.layersPanel.isEnabled())
187 configuration.push("layers");
188 if (WebInspector.experimentsSettings.devicesPanel.isEnabled() && !!WebInspector.queryParam("can_dock"))
189 configuration.push("devices");
190 if (WebInspector.experimentsSettings.documentation.isEnabled())
191 configuration.push("documentation");
192 if (WebInspector.isWorkerFrontend())
193 configuration = ["main", "sources", "timeline", "profiler", "console", "source_frame", "extensions"];
194 self.runtime.registerModules(configuration);
197 _createAppUI: function()
199 console.timeStamp("Main._createApp");
201 WebInspector.installPortStyles();
202 if (WebInspector.queryParam("toolbarColor") && WebInspector.queryParam("textColor"))
203 WebInspector.setToolbarColors(WebInspector.queryParam("toolbarColor"), WebInspector.queryParam("textColor"));
204 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.SetToolbarColors, updateToolbarColors);
206 * @param {!WebInspector.Event} event
208 function updateToolbarColors(event)
210 WebInspector.setToolbarColors(/** @type {string} */ (event.data["backgroundColor"]), /** @type {string} */ (event.data["color"]));
213 var canDock = !!WebInspector.queryParam("can_dock");
214 WebInspector.zoomManager = new WebInspector.ZoomManager(InspectorFrontendHost);
215 WebInspector.inspectorView = new WebInspector.InspectorView();
216 WebInspector.ContextMenu.initialize();
217 WebInspector.dockController = new WebInspector.DockController(canDock);
218 WebInspector.overridesSupport = new WebInspector.OverridesSupport(canDock);
219 WebInspector.multitargetConsoleModel = new WebInspector.MultitargetConsoleModel();
221 WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen();
222 // set order of some sections explicitly
223 WebInspector.shortcutsScreen.section(WebInspector.UIString("Console"));
224 WebInspector.shortcutsScreen.section(WebInspector.UIString("Elements Panel"));
227 WebInspector.app = new WebInspector.AdvancedApp();
228 else if (WebInspector.queryParam("remoteFrontend"))
229 WebInspector.app = new WebInspector.ScreencastApp();
231 WebInspector.app = new WebInspector.SimpleApp();
233 // It is important to kick controller lifetime after apps are instantiated.
234 WebInspector.dockController.initialize();
235 WebInspector.app.createRootView();
237 // Give UI cycles to repaint, then proceed with creating connection.
238 setTimeout(this._createConnection.bind(this), 0);
241 _createConnection: function()
243 console.timeStamp("Main._createConnection");
244 InspectorBackend.loadFromJSONIfNeeded("../protocol.json");
246 var workerId = WebInspector.queryParam("dedicatedWorkerId");
248 this._connectionEstablished(new WebInspector.ExternalWorkerConnection(workerId));
252 if (WebInspector.queryParam("ws")) {
253 var ws = "ws://" + WebInspector.queryParam("ws");
254 InspectorBackendClass.WebSocketConnection.Create(ws, this._connectionEstablished.bind(this));
258 if (!InspectorFrontendHost.isHostedMode()) {
259 this._connectionEstablished(new InspectorBackendClass.MainConnection());
263 this._connectionEstablished(new InspectorBackendClass.StubConnection());
267 * @param {!InspectorBackendClass.Connection} connection
269 _connectionEstablished: function(connection)
271 console.timeStamp("Main._connectionEstablished");
272 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconnected, onDisconnected);
275 * @param {!WebInspector.Event} event
277 function onDisconnected(event)
279 if (WebInspector._disconnectedScreenWithReasonWasShown)
281 new WebInspector.RemoteDebuggingTerminatedScreen(event.data.reason).showModal();
284 InspectorBackend.setConnection(connection);
286 // Install styles and themes
287 WebInspector.installPortStyles();
289 if (WebInspector.queryParam("toolbarColor") && WebInspector.queryParam("textColor"))
290 WebInspector.setToolbarColors(WebInspector.queryParam("toolbarColor"), WebInspector.queryParam("textColor"));
291 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.SetToolbarColors, updateToolbarColors);
293 * @param {!WebInspector.Event} event
295 function updateToolbarColors(event)
297 WebInspector.setToolbarColors(/** @type {string} */ (event.data["backgroundColor"]), /** @type {string} */ (event.data["color"]));
299 WebInspector.ContextMenu.initialize();
300 WebInspector.targetManager.createTarget(WebInspector.UIString("Main"), connection, this._mainTargetCreated.bind(this));
301 WebInspector.isolatedFileSystemManager = new WebInspector.IsolatedFileSystemManager();
302 WebInspector.workspace = new WebInspector.Workspace(WebInspector.isolatedFileSystemManager.mapping());
303 WebInspector.networkWorkspaceBinding = new WebInspector.NetworkWorkspaceBinding(WebInspector.workspace);
304 new WebInspector.NetworkUISourceCodeProvider(WebInspector.networkWorkspaceBinding, WebInspector.workspace);
305 new WebInspector.PresentationConsoleMessageHelper(WebInspector.workspace);
306 WebInspector.cssWorkspaceBinding = new WebInspector.CSSWorkspaceBinding();
307 WebInspector.debuggerWorkspaceBinding = new WebInspector.DebuggerWorkspaceBinding(WebInspector.targetManager, WebInspector.workspace, WebInspector.networkWorkspaceBinding);
308 WebInspector.fileSystemWorkspaceBinding = new WebInspector.FileSystemWorkspaceBinding(WebInspector.isolatedFileSystemManager, WebInspector.workspace);
309 WebInspector.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, WebInspector.workspace, WebInspector.targetManager, WebInspector.debuggerWorkspaceBinding);
310 WebInspector.scriptSnippetModel = new WebInspector.ScriptSnippetModel(WebInspector.workspace);
311 this._executionContextSelector = new WebInspector.ExecutionContextSelector();
313 if (!WebInspector.isWorkerFrontend())
314 WebInspector.inspectElementModeController = new WebInspector.InspectElementModeController();
315 this._createGlobalStatusBarItems();
319 * @param {!WebInspector.Target} mainTarget
321 _mainTargetCreated: function(mainTarget)
323 console.timeStamp("Main._mainTargetCreated");
325 this._registerShortcuts();
327 WebInspector.workerTargetManager = new WebInspector.WorkerTargetManager(mainTarget, WebInspector.targetManager);
329 InspectorBackend.registerInspectorDispatcher(this);
331 if (WebInspector.isWorkerFrontend())
332 mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerDisconnected, onWorkerDisconnected);
334 function onWorkerDisconnected()
336 var screen = new WebInspector.WorkerTerminatedScreen();
337 var listener = hideScreen.bind(null, screen);
338 mainTarget.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, listener);
341 * @param {!WebInspector.WorkerTerminatedScreen} screen
343 function hideScreen(screen)
345 mainTarget.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, listener);
352 WebInspector.domBreakpointsSidebarPane = new WebInspector.DOMBreakpointsSidebarPane();
353 var autoselectPanel = WebInspector.UIString("a panel chosen automatically");
354 var openAnchorLocationSetting = WebInspector.settings.createSetting("openLinkHandler", autoselectPanel);
355 WebInspector.openAnchorLocationRegistry = new WebInspector.HandlerRegistry(openAnchorLocationSetting);
356 WebInspector.openAnchorLocationRegistry.registerHandler(autoselectPanel, function() { return false; });
357 WebInspector.Linkifier.setLinkHandler(new WebInspector.HandlerRegistry.LinkHandler());
358 new WebInspector.WorkspaceController(WebInspector.workspace);
359 new WebInspector.RenderingOptions();
360 new WebInspector.Main.PauseListener();
361 new WebInspector.Main.InspectedNodeRevealer();
363 this._addMainEventListeners(document);
365 WebInspector.extensionServerProxy.setFrontendReady();
367 InspectorAgent.enable(inspectorAgentEnableCallback);
369 function inspectorAgentEnableCallback()
371 console.timeStamp("Main.inspectorAgentEnableCallback");
372 WebInspector.app.presentUI(mainTarget);
373 console.timeStamp("Main.inspectorAgentEnableCallbackPresentUI");
374 WebInspector.notifications.dispatchEventToListeners(WebInspector.NotificationService.Events.InspectorUILoadedForTests);
377 WebInspector.actionRegistry = new WebInspector.ActionRegistry();
378 WebInspector.shortcutRegistry = new WebInspector.ShortcutRegistry(WebInspector.actionRegistry);
379 WebInspector.ShortcutsScreen.registerShortcuts();
380 this._registerForwardedShortcuts();
381 this._registerMessageSinkListener();
383 this._loadCompletedForWorkers();
384 InspectorFrontendAPI.loadCompleted();
387 _registerForwardedShortcuts: function()
389 /** @const */ var forwardedActions = ["main.reload", "main.hard-reload"];
390 var actionKeys = WebInspector.shortcutRegistry.keysForActions(forwardedActions).map(WebInspector.KeyboardShortcut.keyCodeAndModifiersFromKey);
392 actionKeys.push({keyCode: WebInspector.KeyboardShortcut.Keys.F8.code});
393 InspectorFrontendHost.setWhitelistedShortcuts(JSON.stringify(actionKeys));
396 _registerMessageSinkListener: function()
398 WebInspector.console.addEventListener(WebInspector.Console.Events.MessageAdded, messageAdded);
401 * @param {!WebInspector.Event} event
403 function messageAdded(event)
405 var message = /** @type {!WebInspector.Console.Message} */ (event.data);
407 WebInspector.console.show();
411 _documentClick: function(event)
413 var anchor = event.target.enclosingNodeOrSelfWithNodeName("a");
414 if (!anchor || !anchor.href)
417 // Prevent the link from navigating, since we don't do any navigation by following links normally.
420 if (anchor.target === "_blank") {
421 InspectorFrontendHost.openInNewTab(anchor.href);
425 function followLink()
427 if (WebInspector.isBeingEdited(event.target))
429 if (WebInspector.openAnchorLocationRegistry.dispatch({ url: anchor.href, lineNumber: anchor.lineNumber}))
432 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(anchor.href);
434 WebInspector.Revealer.reveal(uiSourceCode.uiLocation(anchor.lineNumber || 0, anchor.columnNumber || 0));
438 var resource = WebInspector.resourceForURL(anchor.href);
440 WebInspector.Revealer.reveal(resource);
444 var request = WebInspector.networkLog.requestForURL(anchor.href);
446 WebInspector.Revealer.reveal(request);
449 InspectorFrontendHost.openInNewTab(anchor.href);
452 if (WebInspector.followLinkTimeout)
453 clearTimeout(WebInspector.followLinkTimeout);
455 if (anchor.preventFollowOnDoubleClick) {
456 // Start a timeout if this is the first click, if the timeout is canceled
457 // before it fires, then a double clicked happened or another link was clicked.
458 if (event.detail === 1)
459 WebInspector.followLinkTimeout = setTimeout(followLink, 333);
466 _registerShortcuts: function()
468 var shortcut = WebInspector.KeyboardShortcut;
469 var section = WebInspector.shortcutsScreen.section(WebInspector.UIString("All Panels"));
471 shortcut.makeDescriptor("[", shortcut.Modifiers.CtrlOrMeta),
472 shortcut.makeDescriptor("]", shortcut.Modifiers.CtrlOrMeta)
474 section.addRelatedKeys(keys, WebInspector.UIString("Go to the panel to the left/right"));
477 shortcut.makeDescriptor("[", shortcut.Modifiers.CtrlOrMeta | shortcut.Modifiers.Alt),
478 shortcut.makeDescriptor("]", shortcut.Modifiers.CtrlOrMeta | shortcut.Modifiers.Alt)
480 section.addRelatedKeys(keys, WebInspector.UIString("Go back/forward in panel history"));
482 var toggleConsoleLabel = WebInspector.UIString("Show console");
483 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Tilde, shortcut.Modifiers.Ctrl), toggleConsoleLabel);
484 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Esc), WebInspector.UIString("Toggle drawer"));
485 if (WebInspector.overridesSupport.responsiveDesignAvailable())
486 section.addKey(shortcut.makeDescriptor("M", shortcut.Modifiers.CtrlOrMeta | shortcut.Modifiers.Shift), WebInspector.UIString("Toggle device mode"));
487 section.addKey(shortcut.makeDescriptor("f", shortcut.Modifiers.CtrlOrMeta), WebInspector.UIString("Search"));
489 var advancedSearchShortcutModifier = WebInspector.isMac()
490 ? WebInspector.KeyboardShortcut.Modifiers.Meta | WebInspector.KeyboardShortcut.Modifiers.Alt
491 : WebInspector.KeyboardShortcut.Modifiers.Ctrl | WebInspector.KeyboardShortcut.Modifiers.Shift;
492 var advancedSearchShortcut = shortcut.makeDescriptor("f", advancedSearchShortcutModifier);
493 section.addKey(advancedSearchShortcut, WebInspector.UIString("Search across all sources"));
495 var inspectElementModeShortcut = WebInspector.InspectElementModeController.createShortcut();
496 section.addKey(inspectElementModeShortcut, WebInspector.UIString("Select node to inspect"));
498 var openResourceShortcut = WebInspector.KeyboardShortcut.makeDescriptor("p", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta);
499 section.addKey(openResourceShortcut, WebInspector.UIString("Go to source"));
501 if (WebInspector.isMac()) {
503 shortcut.makeDescriptor("g", shortcut.Modifiers.Meta),
504 shortcut.makeDescriptor("g", shortcut.Modifiers.Meta | shortcut.Modifiers.Shift)
506 section.addRelatedKeys(keys, WebInspector.UIString("Find next/previous"));
510 _postDocumentKeyDown: function(event)
515 if (!WebInspector.Dialog.currentInstance() && WebInspector.inspectorView.currentPanel()) {
516 WebInspector.inspectorView.currentPanel().handleShortcut(event);
523 WebInspector.shortcutRegistry.handleShortcut(event);
526 _documentCanCopy: function(event)
528 var panel = WebInspector.inspectorView.currentPanel();
529 if (panel && panel["handleCopyEvent"])
530 event.preventDefault();
533 _documentCopy: function(event)
535 var panel = WebInspector.inspectorView.currentPanel();
536 if (panel && panel["handleCopyEvent"])
537 panel["handleCopyEvent"](event);
540 _documentCut: function(event)
542 var panel = WebInspector.inspectorView.currentPanel();
543 if (panel && panel["handleCutEvent"])
544 panel["handleCutEvent"](event);
547 _documentPaste: function(event)
549 var panel = WebInspector.inspectorView.currentPanel();
550 if (panel && panel["handlePasteEvent"])
551 panel["handlePasteEvent"](event);
554 _contextMenuEventFired: function(event)
556 if (event.handled || event.target.classList.contains("popup-glasspane"))
557 event.preventDefault();
560 _addMainEventListeners: function(doc)
562 doc.addEventListener("keydown", this._postDocumentKeyDown.bind(this), false);
563 doc.addEventListener("beforecopy", this._documentCanCopy.bind(this), true);
564 doc.addEventListener("copy", this._documentCopy.bind(this), false);
565 doc.addEventListener("cut", this._documentCut.bind(this), false);
566 doc.addEventListener("paste", this._documentPaste.bind(this), false);
567 doc.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true);
568 doc.addEventListener("click", this._documentClick.bind(this), false);
573 * @param {!RuntimeAgent.RemoteObject} payload
574 * @param {!Object=} hints
576 inspect: function(payload, hints)
578 var object = WebInspector.runtimeModel.createRemoteObject(payload);
579 if (object.isNode()) {
580 var nodeObjectInspector = runtime.instance(WebInspector.NodeRemoteObjectInspector, object);
581 if (nodeObjectInspector)
582 nodeObjectInspector.inspectNodeObject(object);
586 if (object.type === "function") {
587 object.functionDetails(didGetDetails);
592 * @param {?WebInspector.DebuggerModel.FunctionDetails} response
594 function didGetDetails(response)
598 if (!response || !response.location)
601 WebInspector.Revealer.reveal(WebInspector.debuggerWorkspaceBinding.rawLocationToUILocation(response.location));
604 if (hints.copyToClipboard)
605 InspectorFrontendHost.copyText(object.value);
611 * @param {string} reason
613 detached: function(reason)
615 WebInspector._disconnectedScreenWithReasonWasShown = true;
616 new WebInspector.RemoteDebuggingTerminatedScreen(reason).showModal();
622 targetCrashed: function()
624 (new WebInspector.HelpScreenUntilReload(
625 WebInspector.UIString("Inspected target crashed"),
626 WebInspector.UIString("Inspected target has crashed. Once it reloads we will attach to it automatically."))).showModal();
631 * @param {number} callId
632 * @param {string} script
634 evaluateForTestInFrontend: function(callId, script)
636 WebInspector.evaluateForTestInFrontend(callId, script);
640 WebInspector.reload = function()
642 InspectorAgent.reset();
643 window.location.reload();
648 * @implements {WebInspector.ActionDelegate}
650 WebInspector.Main.ReloadActionDelegate = function()
654 WebInspector.Main.ReloadActionDelegate.prototype = {
658 handleAction: function()
660 WebInspector.debuggerModel.skipAllPauses(true, true);
661 WebInspector.resourceTreeModel.reloadPage(false);
668 * @implements {WebInspector.ActionDelegate}
670 WebInspector.Main.HardReloadActionDelegate = function()
674 WebInspector.Main.HardReloadActionDelegate.prototype = {
678 handleAction: function()
680 WebInspector.debuggerModel.skipAllPauses(true, true);
681 WebInspector.resourceTreeModel.reloadPage(true);
688 * @implements {WebInspector.ActionDelegate}
690 WebInspector.Main.DebugReloadActionDelegate = function()
694 WebInspector.Main.DebugReloadActionDelegate.prototype = {
698 handleAction: function()
700 WebInspector.reload();
707 * @implements {WebInspector.ActionDelegate}
709 WebInspector.Main.ZoomInActionDelegate = function()
713 WebInspector.Main.ZoomInActionDelegate.prototype = {
717 handleAction: function()
719 if (InspectorFrontendHost.isHostedMode())
722 InspectorFrontendHost.zoomIn();
729 * @implements {WebInspector.ActionDelegate}
731 WebInspector.Main.ZoomOutActionDelegate = function()
735 WebInspector.Main.ZoomOutActionDelegate.prototype = {
739 handleAction: function()
741 if (InspectorFrontendHost.isHostedMode())
744 InspectorFrontendHost.zoomOut();
751 * @implements {WebInspector.ActionDelegate}
753 WebInspector.Main.ZoomResetActionDelegate = function()
757 WebInspector.Main.ZoomResetActionDelegate.prototype = {
761 handleAction: function()
763 if (InspectorFrontendHost.isHostedMode())
766 InspectorFrontendHost.resetZoom();
773 * @extends {WebInspector.UISettingDelegate}
775 WebInspector.Main.ShortcutPanelSwitchSettingDelegate = function()
777 WebInspector.UISettingDelegate.call(this);
780 WebInspector.Main.ShortcutPanelSwitchSettingDelegate.prototype = {
785 settingElement: function()
787 var modifier = WebInspector.platform() === "mac" ? "Cmd" : "Ctrl";
788 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Enable %s + 1-9 shortcut to switch panels", modifier), WebInspector.settings.shortcutPanelSwitch);
791 __proto__: WebInspector.UISettingDelegate.prototype
797 WebInspector.Main._addWebSocketTarget = function(ws)
800 * @param {!InspectorBackendClass.Connection} connection
802 function callback(connection)
804 WebInspector.targetManager.createTarget(ws, connection);
806 new InspectorBackendClass.WebSocketConnection(ws, callback);
809 new WebInspector.Main();
811 // These methods are added for backwards compatibility with Devtools CodeSchool extension.
814 WebInspector.__defineGetter__("inspectedPageURL", function()
816 return WebInspector.resourceTreeModel.inspectedPageURL();
820 * @param {string} name
821 * @return {?WebInspector.Panel}
823 WebInspector.panel = function(name)
825 return WebInspector.inspectorView.panel(name);
830 * @implements {WebInspector.StatusBarItem.Provider}
832 WebInspector.Main.WarningErrorCounter = function()
834 this._counter = new WebInspector.StatusBarCounter(["error-icon-small", "warning-icon-small"]);
835 this._counter.addEventListener("click", showConsole);
837 function showConsole()
839 WebInspector.console.show();
842 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._updateErrorAndWarningCounts, this);
843 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._updateErrorAndWarningCounts, this);
846 WebInspector.Main.WarningErrorCounter.prototype = {
847 _updateErrorAndWarningCounts: function()
851 var targets = WebInspector.targetManager.targets();
852 for (var i = 0; i < targets.length; ++i) {
853 errors = errors + targets[i].consoleModel.errors;
854 warnings = warnings + targets[i].consoleModel.warnings;
856 this._counter.setCounter("error-icon-small", errors, WebInspector.UIString(errors > 1 ? "%d errors" : "%d error", errors));
857 this._counter.setCounter("warning-icon-small", warnings, WebInspector.UIString(warnings > 1 ? "%d warnings" : "%d warning", warnings));
858 WebInspector.inspectorView.toolbarItemResized();
862 * @return {?WebInspector.StatusBarItem}
866 return this._counter;
873 WebInspector.Main.PauseListener = function()
875 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
878 WebInspector.Main.PauseListener.prototype = {
880 * @param {!WebInspector.Event} event
882 _debuggerPaused: function(event)
884 WebInspector.targetManager.removeModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
885 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.target);
886 WebInspector.context.setFlavor(WebInspector.Target, debuggerModel.target());
887 WebInspector.inspectorView.showPanel("sources");
894 WebInspector.Main.InspectedNodeRevealer = function()
896 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspector.DOMModel.Events.NodeInspected, this._inspectNode, this);
899 WebInspector.Main.InspectedNodeRevealer.prototype = {
901 * @param {!WebInspector.Event} event
903 _inspectNode: function(event)
905 WebInspector.Revealer.reveal(/** @type {!WebInspector.DOMNode} */ (event.data));