|
1 /* |
|
2 * Copyright (C) 2010 Google Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions are |
|
6 * met: |
|
7 * |
|
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 |
|
13 * distribution. |
|
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. |
|
17 * |
|
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. |
|
29 */ |
|
30 |
|
31 /** |
|
32 * @fileoverview DevTools' implementation of the InspectorController API. |
|
33 */ |
|
34 |
|
35 if (!this.devtools) |
|
36 devtools = {}; |
|
37 |
|
38 devtools.InspectorBackendImpl = function() |
|
39 { |
|
40 WebInspector.InspectorBackendStub.call(this); |
|
41 this.installInspectorControllerDelegate_("addInspectedNode"); |
|
42 this.installInspectorControllerDelegate_("addScriptToEvaluateOnLoad"); |
|
43 this.installInspectorControllerDelegate_("changeTagName"); |
|
44 this.installInspectorControllerDelegate_("clearConsoleMessages"); |
|
45 this.installInspectorControllerDelegate_("copyNode"); |
|
46 this.installInspectorControllerDelegate_("deleteCookie"); |
|
47 this.installInspectorControllerDelegate_("didEvaluateForTestInFrontend"); |
|
48 this.installInspectorControllerDelegate_("disableMonitoringXHR"); |
|
49 this.installInspectorControllerDelegate_("disableResourceTracking"); |
|
50 this.installInspectorControllerDelegate_("disableSearchingForNode"); |
|
51 this.installInspectorControllerDelegate_("disableTimeline"); |
|
52 this.installInspectorControllerDelegate_("enableMonitoringXHR"); |
|
53 this.installInspectorControllerDelegate_("enableResourceTracking"); |
|
54 this.installInspectorControllerDelegate_("enableSearchingForNode"); |
|
55 this.installInspectorControllerDelegate_("enableTimeline"); |
|
56 this.installInspectorControllerDelegate_("getChildNodes"); |
|
57 this.installInspectorControllerDelegate_("getCookies"); |
|
58 this.installInspectorControllerDelegate_("getDatabaseTableNames"); |
|
59 this.installInspectorControllerDelegate_("getDOMStorageEntries"); |
|
60 this.installInspectorControllerDelegate_("getEventListenersForNode"); |
|
61 this.installInspectorControllerDelegate_("getOuterHTML"); |
|
62 this.installInspectorControllerDelegate_("getProfile"); |
|
63 this.installInspectorControllerDelegate_("getProfileHeaders"); |
|
64 this.installInspectorControllerDelegate_("removeProfile"); |
|
65 this.installInspectorControllerDelegate_("clearProfiles"); |
|
66 this.installInspectorControllerDelegate_("getResourceContent"); |
|
67 this.installInspectorControllerDelegate_("highlightDOMNode"); |
|
68 this.installInspectorControllerDelegate_("hideDOMNodeHighlight"); |
|
69 this.installInspectorControllerDelegate_("performSearch"); |
|
70 this.installInspectorControllerDelegate_("pushNodeByPathToFrontend"); |
|
71 this.installInspectorControllerDelegate_("releaseWrapperObjectGroup"); |
|
72 this.installInspectorControllerDelegate_("removeAllScriptsToEvaluateOnLoad"); |
|
73 this.installInspectorControllerDelegate_("reloadPage"); |
|
74 this.installInspectorControllerDelegate_("removeAttribute"); |
|
75 this.installInspectorControllerDelegate_("removeDOMStorageItem"); |
|
76 this.installInspectorControllerDelegate_("removeNode"); |
|
77 this.installInspectorControllerDelegate_("saveApplicationSettings"); |
|
78 this.installInspectorControllerDelegate_("saveSessionSettings"); |
|
79 this.installInspectorControllerDelegate_("searchCanceled"); |
|
80 this.installInspectorControllerDelegate_("setAttribute"); |
|
81 this.installInspectorControllerDelegate_("setDOMStorageItem"); |
|
82 this.installInspectorControllerDelegate_("setInjectedScriptSource"); |
|
83 this.installInspectorControllerDelegate_("setOuterHTML"); |
|
84 this.installInspectorControllerDelegate_("setTextNodeValue"); |
|
85 this.installInspectorControllerDelegate_("startProfiling"); |
|
86 this.installInspectorControllerDelegate_("startTimelineProfiler"); |
|
87 this.installInspectorControllerDelegate_("stopProfiling"); |
|
88 this.installInspectorControllerDelegate_("stopTimelineProfiler"); |
|
89 this.installInspectorControllerDelegate_("storeLastActivePanel"); |
|
90 this.installInspectorControllerDelegate_("takeHeapSnapshot"); |
|
91 |
|
92 this.installInspectorControllerDelegate_("getAllStyles"); |
|
93 this.installInspectorControllerDelegate_("getStyles"); |
|
94 this.installInspectorControllerDelegate_("getComputedStyle"); |
|
95 this.installInspectorControllerDelegate_("getInlineStyle"); |
|
96 this.installInspectorControllerDelegate_("getStyleSheet"); |
|
97 this.installInspectorControllerDelegate_("getRuleRangesForStyleSheetId"); |
|
98 this.installInspectorControllerDelegate_("applyStyleText"); |
|
99 this.installInspectorControllerDelegate_("setStyleText"); |
|
100 this.installInspectorControllerDelegate_("setStyleProperty"); |
|
101 this.installInspectorControllerDelegate_("toggleStyleEnabled"); |
|
102 this.installInspectorControllerDelegate_("setRuleSelector"); |
|
103 this.installInspectorControllerDelegate_("addRule"); |
|
104 |
|
105 this.installInspectorControllerDelegate_("disableDebugger"); |
|
106 this.installInspectorControllerDelegate_("editScriptSource"); |
|
107 this.installInspectorControllerDelegate_("getScriptSource"); |
|
108 this.installInspectorControllerDelegate_("enableDebugger"); |
|
109 this.installInspectorControllerDelegate_("setBreakpoint"); |
|
110 this.installInspectorControllerDelegate_("removeBreakpoint"); |
|
111 this.installInspectorControllerDelegate_("activateBreakpoints"); |
|
112 this.installInspectorControllerDelegate_("deactivateBreakpoints"); |
|
113 this.installInspectorControllerDelegate_("resume"); |
|
114 this.installInspectorControllerDelegate_("stepIntoStatement"); |
|
115 this.installInspectorControllerDelegate_("stepOutOfFunction"); |
|
116 this.installInspectorControllerDelegate_("stepOverStatement"); |
|
117 this.installInspectorControllerDelegate_("setPauseOnExceptionsState"); |
|
118 }; |
|
119 devtools.InspectorBackendImpl.prototype.__proto__ = WebInspector.InspectorBackendStub.prototype; |
|
120 |
|
121 |
|
122 devtools.InspectorBackendImpl.prototype.pause = function() |
|
123 { |
|
124 RemoteDebuggerCommandExecutor.DebuggerPauseScript(); |
|
125 }; |
|
126 |
|
127 |
|
128 /** |
|
129 * @override |
|
130 */ |
|
131 devtools.InspectorBackendImpl.prototype.dispatchOnInjectedScript = function(callId, injectedScriptId, methodName, argsString, async) |
|
132 { |
|
133 // Encode injectedScriptId into callId |
|
134 if (typeof injectedScriptId !== "number") |
|
135 injectedScriptId = 0; |
|
136 RemoteToolsAgent.dispatchOnInjectedScript(callId, injectedScriptId, methodName, argsString, async); |
|
137 }; |
|
138 |
|
139 |
|
140 /** |
|
141 * Installs delegating handler into the inspector controller. |
|
142 * @param {string} methodName Method to install delegating handler for. |
|
143 */ |
|
144 devtools.InspectorBackendImpl.prototype.installInspectorControllerDelegate_ = function(methodName) |
|
145 { |
|
146 this[methodName] = this.callInspectorController_.bind(this, methodName); |
|
147 }; |
|
148 |
|
149 |
|
150 /** |
|
151 * Bound function with the installInjectedScriptDelegate_ actual |
|
152 * implementation. |
|
153 */ |
|
154 devtools.InspectorBackendImpl.prototype.callInspectorController_ = function(methodName, var_arg) |
|
155 { |
|
156 var args = Array.prototype.slice.call(arguments, 1); |
|
157 RemoteToolsAgent.dispatchOnInspectorController(WebInspector.Callback.wrap(function(){}), methodName, JSON.stringify(args)); |
|
158 }; |
|
159 |
|
160 |
|
161 InspectorBackend = new devtools.InspectorBackendImpl(); |