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")) {
163 new WebInspector.Toolbox();
167 this._createSettings();
168 this._createModuleManager();
172 _createSettings: function()
174 WebInspector.settings = new WebInspector.Settings();
175 WebInspector.experimentsSettings = new WebInspector.ExperimentsSettings(WebInspector.queryParam("experiments") !== null);
176 // This setting is needed for backwards compatibility with Devtools CodeSchool extension. DO NOT REMOVE
177 WebInspector.settings.pauseOnExceptionStateString = new WebInspector.PauseOnExceptionStateSetting();
178 new WebInspector.VersionController().updateVersion();
181 _createModuleManager: function()
183 console.timeStamp("Main._createModuleManager");
184 self.runtime = new Runtime(allDescriptors);
186 // FIXME: define html-per-app, make configuration a part of the app.
187 var configuration = ["main", "elements", "network", "sources", "timeline", "profiler", "resources", "audits", "console", "source_frame", "extensions", "settings"];
188 if (WebInspector.experimentsSettings.layersPanel.isEnabled())
189 configuration.push("layers");
190 if (WebInspector.experimentsSettings.devicesPanel.isEnabled() && !!WebInspector.queryParam("can_dock"))
191 configuration.push("devices");
192 if (WebInspector.experimentsSettings.documentation.isEnabled())
193 configuration.push("documentation");
194 if (WebInspector.isWorkerFrontend())
195 configuration = ["main", "sources", "timeline", "profiler", "console", "source_frame", "extensions"];
196 self.runtime.registerModules(configuration);
199 _createAppUI: function()
201 console.timeStamp("Main._createApp");
203 WebInspector.installPortStyles();
204 if (WebInspector.queryParam("toolbarColor") && WebInspector.queryParam("textColor"))
205 WebInspector.setToolbarColors(WebInspector.queryParam("toolbarColor"), WebInspector.queryParam("textColor"));
206 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.SetToolbarColors, updateToolbarColors);
208 * @param {!WebInspector.Event} event
210 function updateToolbarColors(event)
212 WebInspector.setToolbarColors(/** @type {string} */ (event.data["backgroundColor"]), /** @type {string} */ (event.data["color"]));
215 var canDock = !!WebInspector.queryParam("can_dock");
216 WebInspector.zoomManager = new WebInspector.ZoomManager(InspectorFrontendHost);
217 WebInspector.inspectorView = new WebInspector.InspectorView();
218 WebInspector.ContextMenu.initialize();
219 WebInspector.dockController = new WebInspector.DockController(canDock);
220 WebInspector.overridesSupport = new WebInspector.OverridesSupport(canDock);
221 WebInspector.multitargetConsoleModel = new WebInspector.MultitargetConsoleModel();
223 WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen();
224 // set order of some sections explicitly
225 WebInspector.shortcutsScreen.section(WebInspector.UIString("Console"));
226 WebInspector.shortcutsScreen.section(WebInspector.UIString("Elements Panel"));
229 WebInspector.app = new WebInspector.AdvancedApp();
230 else if (WebInspector.queryParam("remoteFrontend"))
231 WebInspector.app = new WebInspector.ScreencastApp();
233 WebInspector.app = new WebInspector.SimpleApp();
235 // It is important to kick controller lifetime after apps are instantiated.
236 WebInspector.dockController.initialize();
237 WebInspector.app.createRootView();
239 // Give UI cycles to repaint, then proceed with creating connection.
240 setTimeout(this._createConnection.bind(this), 0);
243 _createConnection: function()
245 console.timeStamp("Main._createConnection");
246 InspectorBackend.loadFromJSONIfNeeded("../protocol.json");
248 var workerId = WebInspector.queryParam("dedicatedWorkerId");
250 this._connectionEstablished(new WebInspector.ExternalWorkerConnection(workerId));
254 if (WebInspector.queryParam("ws")) {
255 var ws = "ws://" + WebInspector.queryParam("ws");
256 InspectorBackendClass.WebSocketConnection.Create(ws, this._connectionEstablished.bind(this));
260 if (!InspectorFrontendHost.isHostedMode()) {
261 this._connectionEstablished(new InspectorBackendClass.MainConnection());
265 this._connectionEstablished(new InspectorBackendClass.StubConnection());
269 * @param {!InspectorBackendClass.Connection} connection
271 _connectionEstablished: function(connection)
273 console.timeStamp("Main._connectionEstablished");
274 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconnected, onDisconnected);
277 * @param {!WebInspector.Event} event
279 function onDisconnected(event)
281 if (WebInspector._disconnectedScreenWithReasonWasShown)
283 new WebInspector.RemoteDebuggingTerminatedScreen(event.data.reason).showModal();
286 InspectorBackend.setConnection(connection);
288 // Install styles and themes
289 WebInspector.installPortStyles();
291 if (WebInspector.queryParam("toolbarColor") && WebInspector.queryParam("textColor"))
292 WebInspector.setToolbarColors(WebInspector.queryParam("toolbarColor"), WebInspector.queryParam("textColor"));
293 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.SetToolbarColors, updateToolbarColors);
295 * @param {!WebInspector.Event} event
297 function updateToolbarColors(event)
299 WebInspector.setToolbarColors(/** @type {string} */ (event.data["backgroundColor"]), /** @type {string} */ (event.data["color"]));
301 WebInspector.ContextMenu.initialize();
302 WebInspector.targetManager.createTarget(WebInspector.UIString("Main"), connection, this._mainTargetCreated.bind(this));
303 WebInspector.isolatedFileSystemManager = new WebInspector.IsolatedFileSystemManager();
304 WebInspector.workspace = new WebInspector.Workspace(WebInspector.isolatedFileSystemManager.mapping());
305 WebInspector.networkWorkspaceBinding = new WebInspector.NetworkWorkspaceBinding(WebInspector.workspace);
306 new WebInspector.NetworkUISourceCodeProvider(WebInspector.networkWorkspaceBinding, WebInspector.workspace);
307 new WebInspector.PresentationConsoleMessageHelper(WebInspector.workspace);
308 WebInspector.cssWorkspaceBinding = new WebInspector.CSSWorkspaceBinding();
309 WebInspector.debuggerWorkspaceBinding = new WebInspector.DebuggerWorkspaceBinding(WebInspector.targetManager, WebInspector.workspace, WebInspector.networkWorkspaceBinding);
310 WebInspector.fileSystemWorkspaceBinding = new WebInspector.FileSystemWorkspaceBinding(WebInspector.isolatedFileSystemManager, WebInspector.workspace);
311 WebInspector.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, WebInspector.workspace, WebInspector.targetManager, WebInspector.debuggerWorkspaceBinding);
312 WebInspector.scriptSnippetModel = new WebInspector.ScriptSnippetModel(WebInspector.workspace);
313 this._executionContextSelector = new WebInspector.ExecutionContextSelector();
315 if (!WebInspector.isWorkerFrontend())
316 WebInspector.inspectElementModeController = new WebInspector.InspectElementModeController();
317 this._createGlobalStatusBarItems();
321 * @param {!WebInspector.Target} mainTarget
323 _mainTargetCreated: function(mainTarget)
325 console.timeStamp("Main._mainTargetCreated");
327 this._registerShortcuts();
329 WebInspector.workerTargetManager = new WebInspector.WorkerTargetManager(mainTarget, WebInspector.targetManager);
331 InspectorBackend.registerInspectorDispatcher(this);
333 if (WebInspector.isWorkerFrontend())
334 mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerDisconnected, onWorkerDisconnected);
336 function onWorkerDisconnected()
338 var screen = new WebInspector.WorkerTerminatedScreen();
339 var listener = hideScreen.bind(null, screen);
340 mainTarget.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, listener);
343 * @param {!WebInspector.WorkerTerminatedScreen} screen
345 function hideScreen(screen)
347 mainTarget.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, listener);
354 WebInspector.domBreakpointsSidebarPane = new WebInspector.DOMBreakpointsSidebarPane();
355 var autoselectPanel = WebInspector.UIString("a panel chosen automatically");
356 var openAnchorLocationSetting = WebInspector.settings.createSetting("openLinkHandler", autoselectPanel);
357 WebInspector.openAnchorLocationRegistry = new WebInspector.HandlerRegistry(openAnchorLocationSetting);
358 WebInspector.openAnchorLocationRegistry.registerHandler(autoselectPanel, function() { return false; });
359 WebInspector.Linkifier.setLinkHandler(new WebInspector.HandlerRegistry.LinkHandler());
360 new WebInspector.WorkspaceController(WebInspector.workspace);
361 new WebInspector.RenderingOptions();
362 new WebInspector.Main.PauseListener();
363 new WebInspector.Main.InspectedNodeRevealer();
365 this._addMainEventListeners(document);
367 WebInspector.extensionServerProxy.setFrontendReady();
369 InspectorAgent.enable(inspectorAgentEnableCallback);
371 function inspectorAgentEnableCallback()
373 console.timeStamp("Main.inspectorAgentEnableCallback");
374 WebInspector.app.presentUI(mainTarget);
375 console.timeStamp("Main.inspectorAgentEnableCallbackPresentUI");
376 WebInspector.notifications.dispatchEventToListeners(WebInspector.NotificationService.Events.InspectorUILoadedForTests);
379 WebInspector.actionRegistry = new WebInspector.ActionRegistry();
380 WebInspector.shortcutRegistry = new WebInspector.ShortcutRegistry(WebInspector.actionRegistry);
381 WebInspector.ShortcutsScreen.registerShortcuts();
382 this._registerForwardedShortcuts();
383 this._registerMessageSinkListener();
385 this._loadCompletedForWorkers();
386 InspectorFrontendAPI.loadCompleted();
389 _registerForwardedShortcuts: function()
391 /** @const */ var forwardedActions = ["main.reload", "main.hard-reload"];
392 var actionKeys = WebInspector.shortcutRegistry.keysForActions(forwardedActions).map(WebInspector.KeyboardShortcut.keyCodeAndModifiersFromKey);
394 actionKeys.push({keyCode: WebInspector.KeyboardShortcut.Keys.F8.code});
395 InspectorFrontendHost.setWhitelistedShortcuts(JSON.stringify(actionKeys));
398 _registerMessageSinkListener: function()
400 WebInspector.console.addEventListener(WebInspector.Console.Events.MessageAdded, messageAdded);
403 * @param {!WebInspector.Event} event
405 function messageAdded(event)
407 var message = /** @type {!WebInspector.Console.Message} */ (event.data);
409 WebInspector.console.show();
413 _documentClick: function(event)
415 var anchor = event.target.enclosingNodeOrSelfWithNodeName("a");
416 if (!anchor || !anchor.href)
419 // Prevent the link from navigating, since we don't do any navigation by following links normally.
422 if (anchor.target === "_blank") {
423 InspectorFrontendHost.openInNewTab(anchor.href);
427 function followLink()
429 if (WebInspector.isBeingEdited(event.target))
431 if (WebInspector.openAnchorLocationRegistry.dispatch({ url: anchor.href, lineNumber: anchor.lineNumber}))
434 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(anchor.href);
436 WebInspector.Revealer.reveal(uiSourceCode.uiLocation(anchor.lineNumber || 0, anchor.columnNumber || 0));
440 var resource = WebInspector.resourceForURL(anchor.href);
442 WebInspector.Revealer.reveal(resource);
446 var request = WebInspector.networkLog.requestForURL(anchor.href);
448 WebInspector.Revealer.reveal(request);
451 InspectorFrontendHost.openInNewTab(anchor.href);
454 if (WebInspector.followLinkTimeout)
455 clearTimeout(WebInspector.followLinkTimeout);
457 if (anchor.preventFollowOnDoubleClick) {
458 // Start a timeout if this is the first click, if the timeout is canceled
459 // before it fires, then a double clicked happened or another link was clicked.
460 if (event.detail === 1)
461 WebInspector.followLinkTimeout = setTimeout(followLink, 333);
468 _registerShortcuts: function()
470 var shortcut = WebInspector.KeyboardShortcut;
471 var section = WebInspector.shortcutsScreen.section(WebInspector.UIString("All Panels"));
473 shortcut.makeDescriptor("[", shortcut.Modifiers.CtrlOrMeta),
474 shortcut.makeDescriptor("]", shortcut.Modifiers.CtrlOrMeta)
476 section.addRelatedKeys(keys, WebInspector.UIString("Go to the panel to the left/right"));
479 shortcut.makeDescriptor("[", shortcut.Modifiers.CtrlOrMeta | shortcut.Modifiers.Alt),
480 shortcut.makeDescriptor("]", shortcut.Modifiers.CtrlOrMeta | shortcut.Modifiers.Alt)
482 section.addRelatedKeys(keys, WebInspector.UIString("Go back/forward in panel history"));
484 var toggleConsoleLabel = WebInspector.UIString("Show console");
485 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Tilde, shortcut.Modifiers.Ctrl), toggleConsoleLabel);
486 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Esc), WebInspector.UIString("Toggle drawer"));
487 if (WebInspector.overridesSupport.responsiveDesignAvailable())
488 section.addKey(shortcut.makeDescriptor("M", shortcut.Modifiers.CtrlOrMeta | shortcut.Modifiers.Shift), WebInspector.UIString("Toggle device mode"));
489 section.addKey(shortcut.makeDescriptor("f", shortcut.Modifiers.CtrlOrMeta), WebInspector.UIString("Search"));
491 var advancedSearchShortcutModifier = WebInspector.isMac()
492 ? WebInspector.KeyboardShortcut.Modifiers.Meta | WebInspector.KeyboardShortcut.Modifiers.Alt
493 : WebInspector.KeyboardShortcut.Modifiers.Ctrl | WebInspector.KeyboardShortcut.Modifiers.Shift;
494 var advancedSearchShortcut = shortcut.makeDescriptor("f", advancedSearchShortcutModifier);
495 section.addKey(advancedSearchShortcut, WebInspector.UIString("Search across all sources"));
497 var inspectElementModeShortcut = WebInspector.InspectElementModeController.createShortcut();
498 section.addKey(inspectElementModeShortcut, WebInspector.UIString("Select node to inspect"));
500 var openResourceShortcut = WebInspector.KeyboardShortcut.makeDescriptor("p", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta);
501 section.addKey(openResourceShortcut, WebInspector.UIString("Go to source"));
503 if (WebInspector.isMac()) {
505 shortcut.makeDescriptor("g", shortcut.Modifiers.Meta),
506 shortcut.makeDescriptor("g", shortcut.Modifiers.Meta | shortcut.Modifiers.Shift)
508 section.addRelatedKeys(keys, WebInspector.UIString("Find next/previous"));
512 _postDocumentKeyDown: function(event)
517 if (!WebInspector.Dialog.currentInstance() && WebInspector.inspectorView.currentPanel()) {
518 WebInspector.inspectorView.currentPanel().handleShortcut(event);
525 WebInspector.shortcutRegistry.handleShortcut(event);
528 _documentCanCopy: function(event)
530 var panel = WebInspector.inspectorView.currentPanel();
531 if (panel && panel["handleCopyEvent"])
532 event.preventDefault();
535 _documentCopy: function(event)
537 var panel = WebInspector.inspectorView.currentPanel();
538 if (panel && panel["handleCopyEvent"])
539 panel["handleCopyEvent"](event);
542 _documentCut: function(event)
544 var panel = WebInspector.inspectorView.currentPanel();
545 if (panel && panel["handleCutEvent"])
546 panel["handleCutEvent"](event);
549 _documentPaste: function(event)
551 var panel = WebInspector.inspectorView.currentPanel();
552 if (panel && panel["handlePasteEvent"])
553 panel["handlePasteEvent"](event);
556 _contextMenuEventFired: function(event)
558 if (event.handled || event.target.classList.contains("popup-glasspane"))
559 event.preventDefault();
562 _addMainEventListeners: function(doc)
564 doc.addEventListener("keydown", this._postDocumentKeyDown.bind(this), false);
565 doc.addEventListener("beforecopy", this._documentCanCopy.bind(this), true);
566 doc.addEventListener("copy", this._documentCopy.bind(this), false);
567 doc.addEventListener("cut", this._documentCut.bind(this), false);
568 doc.addEventListener("paste", this._documentPaste.bind(this), false);
569 doc.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true);
570 doc.addEventListener("click", this._documentClick.bind(this), false);
575 * @param {!RuntimeAgent.RemoteObject} payload
576 * @param {!Object=} hints
578 inspect: function(payload, hints)
580 var object = WebInspector.runtimeModel.createRemoteObject(payload);
581 if (object.isNode()) {
582 var nodeObjectInspector = runtime.instance(WebInspector.NodeRemoteObjectInspector, object);
583 if (nodeObjectInspector)
584 nodeObjectInspector.inspectNodeObject(object);
588 if (object.type === "function") {
589 object.functionDetails(didGetDetails);
594 * @param {?WebInspector.DebuggerModel.FunctionDetails} response
596 function didGetDetails(response)
600 if (!response || !response.location)
603 WebInspector.Revealer.reveal(WebInspector.debuggerWorkspaceBinding.rawLocationToUILocation(response.location));
606 if (hints.copyToClipboard)
607 InspectorFrontendHost.copyText(object.value);
613 * @param {string} reason
615 detached: function(reason)
617 WebInspector._disconnectedScreenWithReasonWasShown = true;
618 new WebInspector.RemoteDebuggingTerminatedScreen(reason).showModal();
624 targetCrashed: function()
626 (new WebInspector.HelpScreenUntilReload(
627 WebInspector.UIString("Inspected target crashed"),
628 WebInspector.UIString("Inspected target has crashed. Once it reloads we will attach to it automatically."))).showModal();
633 * @param {number} callId
634 * @param {string} script
636 evaluateForTestInFrontend: function(callId, script)
638 WebInspector.evaluateForTestInFrontend(callId, script);
642 WebInspector.reload = function()
644 InspectorAgent.reset();
645 window.location.reload();
650 * @implements {WebInspector.ActionDelegate}
652 WebInspector.Main.ReloadActionDelegate = function()
656 WebInspector.Main.ReloadActionDelegate.prototype = {
660 handleAction: function()
662 WebInspector.debuggerModel.skipAllPauses(true, true);
663 WebInspector.resourceTreeModel.reloadPage(false);
670 * @implements {WebInspector.ActionDelegate}
672 WebInspector.Main.HardReloadActionDelegate = function()
676 WebInspector.Main.HardReloadActionDelegate.prototype = {
680 handleAction: function()
682 WebInspector.debuggerModel.skipAllPauses(true, true);
683 WebInspector.resourceTreeModel.reloadPage(true);
690 * @implements {WebInspector.ActionDelegate}
692 WebInspector.Main.DebugReloadActionDelegate = function()
696 WebInspector.Main.DebugReloadActionDelegate.prototype = {
700 handleAction: function()
702 WebInspector.reload();
709 * @implements {WebInspector.ActionDelegate}
711 WebInspector.Main.ZoomInActionDelegate = function()
715 WebInspector.Main.ZoomInActionDelegate.prototype = {
719 handleAction: function()
721 if (InspectorFrontendHost.isHostedMode())
724 InspectorFrontendHost.zoomIn();
731 * @implements {WebInspector.ActionDelegate}
733 WebInspector.Main.ZoomOutActionDelegate = function()
737 WebInspector.Main.ZoomOutActionDelegate.prototype = {
741 handleAction: function()
743 if (InspectorFrontendHost.isHostedMode())
746 InspectorFrontendHost.zoomOut();
753 * @implements {WebInspector.ActionDelegate}
755 WebInspector.Main.ZoomResetActionDelegate = function()
759 WebInspector.Main.ZoomResetActionDelegate.prototype = {
763 handleAction: function()
765 if (InspectorFrontendHost.isHostedMode())
768 InspectorFrontendHost.resetZoom();
775 * @extends {WebInspector.UISettingDelegate}
777 WebInspector.Main.ShortcutPanelSwitchSettingDelegate = function()
779 WebInspector.UISettingDelegate.call(this);
782 WebInspector.Main.ShortcutPanelSwitchSettingDelegate.prototype = {
787 settingElement: function()
789 var modifier = WebInspector.platform() === "mac" ? "Cmd" : "Ctrl";
790 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Enable %s + 1-9 shortcut to switch panels", modifier), WebInspector.settings.shortcutPanelSwitch);
793 __proto__: WebInspector.UISettingDelegate.prototype
799 WebInspector.Main._addWebSocketTarget = function(ws)
802 * @param {!InspectorBackendClass.Connection} connection
804 function callback(connection)
806 WebInspector.targetManager.createTarget(ws, connection);
808 new InspectorBackendClass.WebSocketConnection(ws, callback);
811 new WebInspector.Main();
813 // These methods are added for backwards compatibility with Devtools CodeSchool extension.
816 WebInspector.__defineGetter__("inspectedPageURL", function()
818 return WebInspector.resourceTreeModel.inspectedPageURL();
822 * @param {string} name
823 * @return {?WebInspector.Panel}
825 WebInspector.panel = function(name)
827 return WebInspector.inspectorView.panel(name);
832 * @implements {WebInspector.StatusBarItem.Provider}
834 WebInspector.Main.WarningErrorCounter = function()
836 this._counter = new WebInspector.StatusBarCounter(["error-icon-small", "warning-icon-small"]);
837 this._counter.addEventListener("click", showConsole);
839 function showConsole()
841 WebInspector.console.show();
844 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._updateErrorAndWarningCounts, this);
845 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._updateErrorAndWarningCounts, this);
848 WebInspector.Main.WarningErrorCounter.prototype = {
849 _updateErrorAndWarningCounts: function()
853 var targets = WebInspector.targetManager.targets();
854 for (var i = 0; i < targets.length; ++i) {
855 errors = errors + targets[i].consoleModel.errors;
856 warnings = warnings + targets[i].consoleModel.warnings;
858 this._counter.setCounter("error-icon-small", errors, WebInspector.UIString(errors > 1 ? "%d errors" : "%d error", errors));
859 this._counter.setCounter("warning-icon-small", warnings, WebInspector.UIString(warnings > 1 ? "%d warnings" : "%d warning", warnings));
860 WebInspector.inspectorView.toolbarItemResized();
864 * @return {?WebInspector.StatusBarItem}
868 return this._counter;
875 WebInspector.Main.PauseListener = function()
877 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
880 WebInspector.Main.PauseListener.prototype = {
882 * @param {!WebInspector.Event} event
884 _debuggerPaused: function(event)
886 WebInspector.targetManager.removeModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
887 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.target);
888 WebInspector.context.setFlavor(WebInspector.Target, debuggerModel.target());
889 WebInspector.inspectorView.showPanel("sources");
896 WebInspector.Main.InspectedNodeRevealer = function()
898 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspector.DOMModel.Events.NodeInspected, this._inspectNode, this);
901 WebInspector.Main.InspectedNodeRevealer.prototype = {
903 * @param {!WebInspector.Event} event
905 _inspectNode: function(event)
907 WebInspector.Revealer.reveal(/** @type {!WebInspector.DOMNode} */ (event.data));