OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview DevTools' implementation of the InspectorController API. | 6 * @fileoverview DevTools' implementation of the InspectorController API. |
7 */ | 7 */ |
8 goog.require('devtools.InspectorController'); | 8 goog.require('devtools.InspectorController'); |
9 | 9 |
10 goog.provide('devtools.InspectorControllerImpl'); | 10 goog.provide('devtools.InspectorControllerImpl'); |
11 | 11 |
12 devtools.InspectorControllerImpl = function() { | 12 devtools.InspectorControllerImpl = function() { |
13 devtools.InspectorController.call(this); | 13 devtools.InspectorController.call(this); |
14 this.frame_element_id_ = 1; | 14 this.frame_element_id_ = 1; |
| 15 |
| 16 this.installInspectorControllerDelegate_('clearMessages'); |
| 17 this.installInspectorControllerDelegate_('storeLastActivePanel'); |
| 18 this.installInspectorControllerDelegate_('highlightDOMNode'); |
| 19 this.installInspectorControllerDelegate_('hideDOMNodeHighlight'); |
| 20 this.installInspectorControllerDelegate_('getChildNodes'); |
| 21 this.installInspectorControllerDelegate_('setAttribute'); |
| 22 this.installInspectorControllerDelegate_('removeAttribute'); |
| 23 this.installInspectorControllerDelegate_('setTextNodeValue'); |
| 24 this.installInspectorControllerDelegate_('enableResourceTracking'); |
| 25 this.installInspectorControllerDelegate_('disableResourceTracking'); |
| 26 |
| 27 this.installInjectedScriptDelegate_('getStyles'); |
| 28 this.installInjectedScriptDelegate_('getComputedStyle'); |
| 29 this.installInjectedScriptDelegate_('getInlineStyle'); |
| 30 this.installInjectedScriptDelegate_('applyStyleText'); |
| 31 this.installInjectedScriptDelegate_('setStyleText'); |
| 32 this.installInjectedScriptDelegate_('toggleStyleEnabled'); |
| 33 this.installInjectedScriptDelegate_('applyStyleRuleText'); |
| 34 this.installInjectedScriptDelegate_('addStyleSelector'); |
| 35 this.installInjectedScriptDelegate_('setStyleProperty'); |
| 36 this.installInjectedScriptDelegate_('getPrototypes'); |
| 37 this.installInjectedScriptDelegate_('setPropertyValue'); |
| 38 this.installInjectedScriptDelegate_('evaluate'); |
| 39 this.installInjectedScriptDelegate_('addInspectedNode'); |
| 40 this.installInjectedScriptDelegate_('pushNodeToFrontend'); |
| 41 this.installInjectedScriptDelegate_('performSearch'); |
| 42 this.installInjectedScriptDelegate_('searchCanceled'); |
15 }; | 43 }; |
16 goog.inherits(devtools.InspectorControllerImpl, | 44 goog.inherits(devtools.InspectorControllerImpl, |
17 devtools.InspectorController); | 45 devtools.InspectorController); |
18 | 46 |
19 | 47 |
20 /** | 48 /** |
21 * {@inheritDoc}. | 49 * {@inheritDoc}. |
22 */ | 50 */ |
23 devtools.InspectorController.prototype.clearMessages = function() { | 51 devtools.InspectorControllerImpl.prototype.platform = function() { |
24 RemoteToolsAgent.ClearConsoleMessages(); | 52 return DevToolsHost.getPlatform(); |
25 }; | 53 }; |
26 | 54 |
27 | 55 |
| 56 /** |
| 57 * {@inheritDoc}. |
| 58 */ |
| 59 devtools.InspectorControllerImpl.prototype.closeWindow = function() { |
| 60 DevToolsHost.closeWindow(); |
| 61 }; |
| 62 |
| 63 |
| 64 /** |
| 65 * {@inheritDoc}. |
| 66 */ |
| 67 devtools.InspectorControllerImpl.prototype.attach = function() { |
| 68 DevToolsHost.dockWindow(); |
| 69 }; |
| 70 |
| 71 |
| 72 /** |
| 73 * {@inheritDoc}. |
| 74 */ |
| 75 devtools.InspectorControllerImpl.prototype.detach = function() { |
| 76 DevToolsHost.undockWindow(); |
| 77 }; |
| 78 |
| 79 |
28 /** | 80 /** |
29 * {@inheritDoc}. | 81 * {@inheritDoc}. |
30 */ | 82 */ |
31 devtools.InspectorControllerImpl.prototype.hiddenPanels = function() { | 83 devtools.InspectorControllerImpl.prototype.hiddenPanels = function() { |
32 return 'profiles,databases'; | 84 return 'databases'; |
33 }; | 85 }; |
34 | 86 |
35 | 87 |
36 /** | 88 /** |
37 * {@inheritDoc}. | 89 * {@inheritDoc}. |
38 */ | 90 */ |
39 devtools.InspectorController.prototype.search = function(sourceRow, query) { | 91 devtools.InspectorControllerImpl.prototype.search = function(sourceRow, query) { |
40 return DevToolsHost.search(sourceRow, query); | 92 return DevToolsHost.search(sourceRow, query); |
41 }; | 93 }; |
42 | 94 |
43 | 95 |
44 /** | 96 /** |
45 * {@inheritDoc}. | 97 * {@inheritDoc}. |
46 */ | 98 */ |
| 99 devtools.InspectorControllerImpl.prototype.toggleNodeSearch = function() { |
| 100 devtools.InspectorController.prototype.toggleNodeSearch.call(this); |
| 101 DevToolsHost.toggleInspectElementMode(this.searchingForNode()); |
| 102 }; |
| 103 |
| 104 |
| 105 /** |
| 106 * {@inheritDoc}. |
| 107 */ |
| 108 devtools.InspectorControllerImpl.prototype.localizedStringsURL = |
| 109 function(opt_prefix) { |
| 110 // l10n is turned off in test mode because delayed loading of strings |
| 111 // causes test failures. |
| 112 if (false) { |
| 113 var locale = DevToolsHost.getApplicationLocale(); |
| 114 locale = locale.replace('_', '-'); |
| 115 return 'l10n/localizedStrings_' + locale + '.js'; |
| 116 } else { |
| 117 return undefined; |
| 118 } |
| 119 }; |
| 120 |
| 121 |
| 122 /** |
| 123 * {@inheritDoc}. |
| 124 */ |
47 devtools.InspectorControllerImpl.prototype.addSourceToFrame = | 125 devtools.InspectorControllerImpl.prototype.addSourceToFrame = |
48 function(mimeType, source, element) { | 126 function(mimeType, source, element) { |
49 return DevToolsHost.addSourceToFrame(mimeType, source, element); | 127 return DevToolsHost.addSourceToFrame(mimeType, source, element); |
50 }; | 128 }; |
51 | 129 |
52 | 130 |
53 /** | 131 /** |
54 * {@inheritDoc}. | 132 * {@inheritDoc}. |
55 */ | 133 */ |
56 devtools.InspectorControllerImpl.prototype.hideDOMNodeHighlight = function() { | 134 devtools.InspectorControllerImpl.prototype.addResourceSourceToFrame = |
57 RemoteToolsAgent.HideDOMNodeHighlight(); | 135 function(identifier, element) { |
| 136 var resource = WebInspector.resources[identifier]; |
| 137 if (!resource) { |
| 138 return; |
| 139 } |
| 140 DevToolsHost.addResourceSourceToFrame(identifier, resource.mimeType, element); |
58 }; | 141 }; |
59 | 142 |
60 | 143 |
61 /** | |
62 * {@inheritDoc}. | |
63 */ | |
64 devtools.InspectorControllerImpl.prototype.highlightDOMNode = | |
65 function(hoveredNode) { | |
66 RemoteToolsAgent.HighlightDOMNode(hoveredNode.id_); | |
67 }; | |
68 | |
69 | |
70 /** | 144 /** |
71 * {@inheritDoc}. | 145 * {@inheritDoc}. |
72 */ | 146 */ |
73 devtools.InspectorControllerImpl.prototype.inspectedWindow = function() { | 147 devtools.InspectorControllerImpl.prototype.inspectedWindow = function() { |
74 return devtools.tools.getDomAgent().getWindow(); | 148 return null; |
75 }; | 149 }; |
76 | 150 |
77 | 151 |
78 /** | 152 /** |
79 * @override | 153 * @override |
80 */ | 154 */ |
81 devtools.InspectorControllerImpl.prototype.debuggerEnabled = function() { | 155 devtools.InspectorControllerImpl.prototype.debuggerEnabled = function() { |
82 return true; | 156 return true; |
83 }; | 157 }; |
84 | 158 |
85 | 159 |
86 devtools.InspectorControllerImpl.prototype.currentCallFrame = function() { | |
87 return devtools.tools.getDebuggerAgent().getCurrentCallFrame(); | |
88 }; | |
89 | |
90 | |
91 devtools.InspectorControllerImpl.prototype.addBreakpoint = function( | 160 devtools.InspectorControllerImpl.prototype.addBreakpoint = function( |
92 sourceID, line) { | 161 sourceID, line) { |
93 devtools.tools.getDebuggerAgent().addBreakpoint(sourceID, line); | 162 devtools.tools.getDebuggerAgent().addBreakpoint(sourceID, line); |
94 }; | 163 }; |
95 | 164 |
96 | 165 |
97 devtools.InspectorControllerImpl.prototype.removeBreakpoint = function( | 166 devtools.InspectorControllerImpl.prototype.removeBreakpoint = function( |
98 sourceID, line) { | 167 sourceID, line) { |
99 devtools.tools.getDebuggerAgent().removeBreakpoint(sourceID, line); | 168 devtools.tools.getDebuggerAgent().removeBreakpoint(sourceID, line); |
100 }; | 169 }; |
101 | 170 |
102 | 171 |
103 devtools.InspectorController.prototype.pauseInDebugger = function() { | 172 devtools.InspectorControllerImpl.prototype.pauseInDebugger = function() { |
104 devtools.tools.getDebuggerAgent().pauseExecution(); | 173 devtools.tools.getDebuggerAgent().pauseExecution(); |
105 }; | 174 }; |
106 | 175 |
107 | 176 |
108 devtools.InspectorControllerImpl.prototype.resumeDebugger = function() { | 177 devtools.InspectorControllerImpl.prototype.resumeDebugger = function() { |
109 devtools.tools.getDebuggerAgent().resumeExecution(); | 178 devtools.tools.getDebuggerAgent().resumeExecution(); |
110 }; | 179 }; |
111 | 180 |
112 | 181 |
113 devtools.InspectorControllerImpl.prototype.stepIntoStatementInDebugger = | 182 devtools.InspectorControllerImpl.prototype.stepIntoStatementInDebugger = |
(...skipping 10 matching lines...) Expand all Loading... |
124 | 193 |
125 devtools.InspectorControllerImpl.prototype.stepOverStatementInDebugger = | 194 devtools.InspectorControllerImpl.prototype.stepOverStatementInDebugger = |
126 function() { | 195 function() { |
127 devtools.tools.getDebuggerAgent().stepOverStatement(); | 196 devtools.tools.getDebuggerAgent().stepOverStatement(); |
128 }; | 197 }; |
129 | 198 |
130 | 199 |
131 /** | 200 /** |
132 * @override | 201 * @override |
133 */ | 202 */ |
134 devtools.InspectorControllerImpl.prototype.pauseOnExceptions = function() { | 203 devtools.InspectorControllerImpl.prototype.pauseOnExceptions = function() { |
135 return devtools.tools.getDebuggerAgent().pauseOnExceptions(); | 204 return devtools.tools.getDebuggerAgent().pauseOnExceptions(); |
136 }; | 205 }; |
137 | 206 |
138 | 207 |
139 /** | 208 /** |
140 * @override | 209 * @override |
141 */ | 210 */ |
142 devtools.InspectorControllerImpl.prototype.setPauseOnExceptions = function( | 211 devtools.InspectorControllerImpl.prototype.setPauseOnExceptions = function( |
143 value) { | 212 value) { |
144 return devtools.tools.getDebuggerAgent().setPauseOnExceptions(value); | 213 return devtools.tools.getDebuggerAgent().setPauseOnExceptions(value); |
145 }; | 214 }; |
146 | 215 |
147 | 216 |
148 /** | 217 /** |
149 * @override | 218 * @override |
150 */ | 219 */ |
151 devtools.InspectorControllerImpl.prototype.startProfiling = function() { | 220 devtools.InspectorControllerImpl.prototype.startProfiling = function() { |
152 devtools.tools.getDebuggerAgent().startProfiling(); | 221 devtools.tools.getDebuggerAgent().startProfiling( |
| 222 devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_CPU); |
153 }; | 223 }; |
154 | 224 |
155 | 225 |
156 /** | 226 /** |
157 * @override | 227 * @override |
158 */ | 228 */ |
159 devtools.InspectorControllerImpl.prototype.stopProfiling = function() { | 229 devtools.InspectorControllerImpl.prototype.stopProfiling = function() { |
160 devtools.tools.getDebuggerAgent().stopProfiling(); | 230 devtools.tools.getDebuggerAgent().stopProfiling( |
| 231 devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_CPU); |
161 }; | 232 }; |
162 | 233 |
163 | 234 |
164 var InspectorController = new devtools.InspectorControllerImpl(); | 235 /** |
| 236 * @override |
| 237 */ |
| 238 devtools.InspectorControllerImpl.prototype.getCallFrames = function(callback) { |
| 239 callback(devtools.tools.getDebuggerAgent().getCallFrames()); |
| 240 }; |
| 241 |
| 242 |
| 243 /** |
| 244 * @override |
| 245 */ |
| 246 devtools.InspectorControllerImpl.prototype.evaluateInCallFrame = |
| 247 function(callFrameId, code, callback) { |
| 248 devtools.tools.getDebuggerAgent().evaluateInCallFrame(callFrameId, code, |
| 249 callback); |
| 250 }; |
| 251 |
| 252 |
| 253 /** |
| 254 * @override |
| 255 */ |
| 256 devtools.InspectorControllerImpl.prototype.getProperties = function( |
| 257 objectProxy, ignoreHasOwnProperty, callback) { |
| 258 if (objectProxy.isScope) { |
| 259 devtools.tools.getDebuggerAgent().resolveScope(objectProxy.objectId, |
| 260 callback); |
| 261 } else if (objectProxy.isV8Ref) { |
| 262 devtools.tools.getDebuggerAgent().resolveChildren(objectProxy.objectId, |
| 263 callback, true); |
| 264 } else { |
| 265 this.callInjectedScript_('getProperties', objectProxy, |
| 266 ignoreHasOwnProperty, callback); |
| 267 } |
| 268 }; |
| 269 |
| 270 |
| 271 /** |
| 272 * Installs delegating handler into the inspector controller. |
| 273 * @param {string} methodName Method to install delegating handler for. |
| 274 */ |
| 275 devtools.InspectorControllerImpl.prototype.installInjectedScriptDelegate_ = |
| 276 function(methodName) { |
| 277 this[methodName] = goog.bind(this.callInjectedScript_, this, |
| 278 methodName); |
| 279 }; |
| 280 |
| 281 |
| 282 /** |
| 283 * Bound function with the installInjectedScriptDelegate_ actual |
| 284 * implementation. |
| 285 */ |
| 286 devtools.InspectorControllerImpl.prototype.callInjectedScript_ = |
| 287 function(methodName, var_arg) { |
| 288 var allArgs = Array.prototype.slice.call(arguments); |
| 289 var callback = allArgs[allArgs.length - 1]; |
| 290 var args = Array.prototype.slice.call(allArgs, 0, allArgs.length - 1); |
| 291 RemoteToolsAgent.ExecuteUtilityFunction( |
| 292 devtools.InspectorControllerImpl.parseWrap_(callback), |
| 293 'InjectedScript', JSON.stringify(args)); |
| 294 }; |
| 295 |
| 296 |
| 297 /** |
| 298 * Installs delegating handler into the inspector controller. |
| 299 * @param {string} methodName Method to install delegating handler for. |
| 300 */ |
| 301 devtools.InspectorControllerImpl.prototype.installInspectorControllerDelegate_ |
| 302 = function(methodName) { |
| 303 this[methodName] = goog.bind(this.callInspectorController_, this, |
| 304 methodName); |
| 305 }; |
| 306 |
| 307 |
| 308 /** |
| 309 * Bound function with the installInjectedScriptDelegate_ actual |
| 310 * implementation. |
| 311 */ |
| 312 devtools.InspectorControllerImpl.prototype.callInspectorController_ = |
| 313 function(methodName, var_arg) { |
| 314 var args = Array.prototype.slice.call(arguments); |
| 315 RemoteToolsAgent.ExecuteUtilityFunction( |
| 316 devtools.Callback.wrap(function(){}), |
| 317 'InspectorController', JSON.stringify(args)); |
| 318 }; |
| 319 |
| 320 |
| 321 devtools.InspectorControllerImpl.parseWrap_ = function(callback) { |
| 322 return devtools.Callback.wrap( |
| 323 function(data) { |
| 324 callback.call(this, JSON.parse(data)); |
| 325 }); |
| 326 }; |
| 327 |
| 328 |
| 329 InspectorController = new devtools.InspectorControllerImpl(); |
OLD | NEW |