2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * FIXME: change field naming style to use trailing underscore.
33 * @fileoverview Tools is a main class that wires all components of the
34 * DevTools frontend together. It is also responsible for overriding existing
35 * WebInspector functionality while it is getting upstreamed into WebCore.
38 var context = {}; // Used by WebCore's inspector routines.
41 Preferences.ignoreWhitespace = false;
42 Preferences.samplingCPUProfiler = true;
43 Preferences.heapProfilerPresent = true;
44 Preferences.debuggerAlwaysEnabled = true;
45 Preferences.profilerAlwaysEnabled = true;
46 Preferences.canEditScriptSource = true;
47 Preferences.onlineDetectionEnabled = false;
48 Preferences.nativeInstrumentationEnabled = true;
49 Preferences.fileSystemEnabled = false;
52 var devtools = devtools || {};
54 devtools.domContentLoaded = function()
56 WebInspector.setAttachedWindow(WebInspector.queryParamsObject.docked === "true");
57 if (WebInspector.queryParamsObject.toolbar_color && WebInspector.queryParamsObject.text_color)
58 WebInspector.setToolbarColors(WebInspector.queryParamsObject.toolbar_color, WebInspector.queryParamsObject.text_color);
60 document.addEventListener("DOMContentLoaded", devtools.domContentLoaded, false);
63 // FIXME: This needs to be upstreamed.
64 (function InterceptProfilesPanelEvents()
66 var oldShow = WebInspector.ProfilesPanel.prototype.show;
67 WebInspector.ProfilesPanel.prototype.show = function()
69 this.enableToggleButton.visible = false;
71 // Show is called on every show event of a panel, so
72 // we only need to intercept it once.
73 WebInspector.ProfilesPanel.prototype.show = oldShow;
80 * TODO(mnaganov): Restore l10n when it will be agreed that it is needed.
82 WebInspector.UIString = function(string)
84 return String.vsprintf(string, Array.prototype.slice.call(arguments, 1));
88 /** Pending WebKit upstream by apavlov). Fixes iframe vs drag problem. */
91 var originalDragStart = WebInspector.elementDragStart;
92 WebInspector.elementDragStart = function(element)
95 var glassPane = document.createElement("div");
96 glassPane.style.cssText = "position:absolute;width:100%;height:100%;opacity:0;z-index:1";
97 glassPane.id = "glass-pane-for-drag";
98 element.parentElement.appendChild(glassPane);
101 originalDragStart.apply(this, arguments);
104 var originalDragEnd = WebInspector.elementDragEnd;
105 WebInspector.elementDragEnd = function()
107 originalDragEnd.apply(this, arguments);
109 var glassPane = document.getElementById("glass-pane-for-drag");
111 glassPane.parentElement.removeChild(glassPane);
117 ///////////////////////////////////////////
118 // Chromium layout test harness support. //
119 ///////////////////////////////////////////
121 WebInspector.runAfterPendingDispatchesQueue = [];
123 WebInspector.TestController.prototype.runAfterPendingDispatches = function(callback)
125 WebInspector.runAfterPendingDispatchesQueue.push(callback);
128 WebInspector.queuesAreEmpty = function()
130 var copy = this.runAfterPendingDispatchesQueue.slice();
131 this.runAfterPendingDispatchesQueue = [];
132 for (var i = 0; i < copy.length; ++i)
137 /////////////////////////////
138 // Chromium theme support. //
139 /////////////////////////////
141 WebInspector.setToolbarColors = function(backgroundColor, color)
143 if (!WebInspector._themeStyleElement) {
144 WebInspector._themeStyleElement = document.createElement("style");
145 document.head.appendChild(WebInspector._themeStyleElement);
147 WebInspector._themeStyleElement.textContent =
149 background-image: none !important;\
150 background-color: " + backgroundColor + " !important;\
154 color: " + color + " !important;\
159 WebInspector.resetToolbarColors = function()
161 if (WebInspector._themeStyleElement)
162 WebInspector._themeStyleElement.textContent = "";
166 ////////////////////////////////////////////////////////
167 // Platform-specific WebInspector extensions support. //
168 ////////////////////////////////////////////////////////
170 WebInspector.platformExtensionAPI = function(tabId)
176 webInspector.inspectedWindow.__proto__.__defineGetter__("tabId", getTabId);
179 WebInspector.buildPlatformExtensionAPI = function()
181 return "(" + WebInspector.platformExtensionAPI + ")(" + WebInspector._inspectedTabId + ");";
184 WebInspector.setInspectedTabId = function(tabId)
186 WebInspector._inspectedTabId = tabId;