| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview DevTools' implementation of the InspectorController API. | |
| 7 */ | |
| 8 goog.require('devtools.InspectorController'); | |
| 9 | |
| 10 goog.provide('devtools.InspectorControllerImpl'); | |
| 11 | |
| 12 devtools.InspectorControllerImpl = function() { | |
| 13 devtools.InspectorController.call(this); | |
| 14 this.frame_element_id_ = 1; | |
| 15 | |
| 16 this.installInspectorControllerDelegate_('clearMessages'); | |
| 17 this.installInspectorControllerDelegate_('copyNode'); | |
| 18 this.installInspectorControllerDelegate_('deleteCookie'); | |
| 19 this.installInspectorControllerDelegate_('disableResourceTracking'); | |
| 20 this.installInspectorControllerDelegate_('disableTimeline'); | |
| 21 this.installInspectorControllerDelegate_('enableResourceTracking'); | |
| 22 this.installInspectorControllerDelegate_('enableTimeline'); | |
| 23 this.installInspectorControllerDelegate_('getChildNodes'); | |
| 24 this.installInspectorControllerDelegate_('getCookies'); | |
| 25 this.installInspectorControllerDelegate_('getDatabaseTableNames'); | |
| 26 this.installInspectorControllerDelegate_('getDOMStorageEntries'); | |
| 27 this.installInspectorControllerDelegate_('getEventListenersForNode'); | |
| 28 this.installInspectorControllerDelegate_('highlightDOMNode'); | |
| 29 this.installInspectorControllerDelegate_('hideDOMNodeHighlight'); | |
| 30 this.installInspectorControllerDelegate_('releaseWrapperObjectGroup'); | |
| 31 this.installInspectorControllerDelegate_('removeAttribute'); | |
| 32 this.installInspectorControllerDelegate_('setAttribute'); | |
| 33 this.installInspectorControllerDelegate_('setSetting'); | |
| 34 this.installInspectorControllerDelegate_('setTextNodeValue'); | |
| 35 this.installInspectorControllerDelegate_('setting'); | |
| 36 this.installInspectorControllerDelegate_('storeLastActivePanel'); | |
| 37 }; | |
| 38 goog.inherits(devtools.InspectorControllerImpl, | |
| 39 devtools.InspectorController); | |
| 40 | |
| 41 | |
| 42 /** | |
| 43 * {@inheritDoc}. | |
| 44 */ | |
| 45 devtools.InspectorControllerImpl.prototype.platform = function() { | |
| 46 return DevToolsHost.getPlatform(); | |
| 47 }; | |
| 48 | |
| 49 | |
| 50 /** | |
| 51 * {@inheritDoc}. | |
| 52 */ | |
| 53 devtools.InspectorControllerImpl.prototype.closeWindow = function() { | |
| 54 DevToolsHost.closeWindow(); | |
| 55 }; | |
| 56 | |
| 57 | |
| 58 /** | |
| 59 * {@inheritDoc}. | |
| 60 */ | |
| 61 devtools.InspectorControllerImpl.prototype.attach = function() { | |
| 62 DevToolsHost.dockWindow(); | |
| 63 }; | |
| 64 | |
| 65 | |
| 66 /** | |
| 67 * {@inheritDoc}. | |
| 68 */ | |
| 69 devtools.InspectorControllerImpl.prototype.detach = function() { | |
| 70 DevToolsHost.undockWindow(); | |
| 71 }; | |
| 72 | |
| 73 | |
| 74 /** | |
| 75 * {@inheritDoc}. | |
| 76 */ | |
| 77 devtools.InspectorControllerImpl.prototype.hiddenPanels = function() { | |
| 78 return DevToolsHost.hiddenPanels(); | |
| 79 }; | |
| 80 | |
| 81 | |
| 82 /** | |
| 83 * {@inheritDoc}. | |
| 84 */ | |
| 85 devtools.InspectorControllerImpl.prototype.search = function(sourceRow, query) { | |
| 86 return DevToolsHost.search(sourceRow, query); | |
| 87 }; | |
| 88 | |
| 89 | |
| 90 /** | |
| 91 * {@inheritDoc}. | |
| 92 */ | |
| 93 devtools.InspectorControllerImpl.prototype.toggleNodeSearch = function() { | |
| 94 devtools.InspectorController.prototype.toggleNodeSearch.call(this); | |
| 95 DevToolsHost.toggleInspectElementMode(this.searchingForNode()); | |
| 96 }; | |
| 97 | |
| 98 | |
| 99 /** | |
| 100 * {@inheritDoc}. | |
| 101 */ | |
| 102 devtools.InspectorControllerImpl.prototype.localizedStringsURL = | |
| 103 function(opt_prefix) { | |
| 104 // l10n is turned off in test mode because delayed loading of strings | |
| 105 // causes test failures. | |
| 106 if (false) { | |
| 107 var locale = DevToolsHost.getApplicationLocale(); | |
| 108 locale = locale.replace('_', '-'); | |
| 109 return 'l10n/localizedStrings_' + locale + '.js'; | |
| 110 } else { | |
| 111 return undefined; | |
| 112 } | |
| 113 }; | |
| 114 | |
| 115 | |
| 116 /** | |
| 117 * {@inheritDoc}. | |
| 118 */ | |
| 119 devtools.InspectorControllerImpl.prototype.addSourceToFrame = | |
| 120 function(mimeType, source, element) { | |
| 121 return DevToolsHost.addSourceToFrame(mimeType, source, element); | |
| 122 }; | |
| 123 | |
| 124 | |
| 125 /** | |
| 126 * {@inheritDoc}. | |
| 127 */ | |
| 128 devtools.InspectorControllerImpl.prototype.addResourceSourceToFrame = | |
| 129 function(identifier, element) { | |
| 130 var resource = WebInspector.resources[identifier]; | |
| 131 if (!resource) { | |
| 132 return; | |
| 133 } | |
| 134 | |
| 135 // Temporary fix for http://crbug/23260. | |
| 136 var mimeType = resource.mimeType; | |
| 137 if (!mimeType && resource.url) { | |
| 138 if (resource.url.search('\.js$') != -1) { | |
| 139 mimeType = 'application/x-javascript'; | |
| 140 } else if (resource.url.search('\.html$') != -1) { | |
| 141 mimeType = 'text/html'; | |
| 142 } | |
| 143 } | |
| 144 | |
| 145 DevToolsHost.addResourceSourceToFrame(identifier, mimeType, element); | |
| 146 }; | |
| 147 | |
| 148 | |
| 149 /** | |
| 150 * {@inheritDoc}. | |
| 151 */ | |
| 152 devtools.InspectorControllerImpl.prototype.inspectedWindow = function() { | |
| 153 return null; | |
| 154 }; | |
| 155 | |
| 156 | |
| 157 /** | |
| 158 * @override | |
| 159 */ | |
| 160 devtools.InspectorControllerImpl.prototype.debuggerEnabled = function() { | |
| 161 return true; | |
| 162 }; | |
| 163 | |
| 164 | |
| 165 devtools.InspectorControllerImpl.prototype.addBreakpoint = function( | |
| 166 sourceID, line, condition) { | |
| 167 devtools.tools.getDebuggerAgent().addBreakpoint(sourceID, line, condition); | |
| 168 }; | |
| 169 | |
| 170 | |
| 171 devtools.InspectorControllerImpl.prototype.removeBreakpoint = function( | |
| 172 sourceID, line) { | |
| 173 devtools.tools.getDebuggerAgent().removeBreakpoint(sourceID, line); | |
| 174 }; | |
| 175 | |
| 176 devtools.InspectorControllerImpl.prototype.updateBreakpoint = function( | |
| 177 sourceID, line, condition) { | |
| 178 devtools.tools.getDebuggerAgent().updateBreakpoint( | |
| 179 sourceID, line, condition); | |
| 180 }; | |
| 181 | |
| 182 devtools.InspectorControllerImpl.prototype.pauseInDebugger = function() { | |
| 183 devtools.tools.getDebuggerAgent().pauseExecution(); | |
| 184 }; | |
| 185 | |
| 186 | |
| 187 devtools.InspectorControllerImpl.prototype.resumeDebugger = function() { | |
| 188 devtools.tools.getDebuggerAgent().resumeExecution(); | |
| 189 }; | |
| 190 | |
| 191 | |
| 192 devtools.InspectorControllerImpl.prototype.stepIntoStatementInDebugger = | |
| 193 function() { | |
| 194 devtools.tools.getDebuggerAgent().stepIntoStatement(); | |
| 195 }; | |
| 196 | |
| 197 | |
| 198 devtools.InspectorControllerImpl.prototype.stepOutOfFunctionInDebugger = | |
| 199 function() { | |
| 200 devtools.tools.getDebuggerAgent().stepOutOfFunction(); | |
| 201 }; | |
| 202 | |
| 203 | |
| 204 devtools.InspectorControllerImpl.prototype.stepOverStatementInDebugger = | |
| 205 function() { | |
| 206 devtools.tools.getDebuggerAgent().stepOverStatement(); | |
| 207 }; | |
| 208 | |
| 209 | |
| 210 /** | |
| 211 * @override | |
| 212 */ | |
| 213 devtools.InspectorControllerImpl.prototype.pauseOnExceptions = function() { | |
| 214 return devtools.tools.getDebuggerAgent().pauseOnExceptions(); | |
| 215 }; | |
| 216 | |
| 217 | |
| 218 /** | |
| 219 * @override | |
| 220 */ | |
| 221 devtools.InspectorControllerImpl.prototype.setPauseOnExceptions = function( | |
| 222 value) { | |
| 223 return devtools.tools.getDebuggerAgent().setPauseOnExceptions(value); | |
| 224 }; | |
| 225 | |
| 226 | |
| 227 /** | |
| 228 * @override | |
| 229 */ | |
| 230 devtools.InspectorControllerImpl.prototype.startProfiling = function() { | |
| 231 devtools.tools.getDebuggerAgent().startProfiling( | |
| 232 devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_CPU); | |
| 233 }; | |
| 234 | |
| 235 | |
| 236 /** | |
| 237 * @override | |
| 238 */ | |
| 239 devtools.InspectorControllerImpl.prototype.stopProfiling = function() { | |
| 240 devtools.tools.getDebuggerAgent().stopProfiling( | |
| 241 devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_CPU); | |
| 242 }; | |
| 243 | |
| 244 | |
| 245 /** | |
| 246 * @override | |
| 247 */ | |
| 248 devtools.InspectorControllerImpl.prototype.takeHeapSnapshot = function() { | |
| 249 devtools.tools.getDebuggerAgent().startProfiling( | |
| 250 devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_HEAP_SNAPSHOT | |
| 251 | devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_HEAP_STATS | |
| 252 | devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_JS_CONSTRUCTORS); | |
| 253 }; | |
| 254 | |
| 255 | |
| 256 /** | |
| 257 * @override | |
| 258 */ | |
| 259 devtools.InspectorControllerImpl.prototype.dispatchOnInjectedScript = function( | |
| 260 callId, methodName, argsString, async) { | |
| 261 var callback = function(result, isException) { | |
| 262 WebInspector.didDispatchOnInjectedScript(callId, result, isException); | |
| 263 }; | |
| 264 RemoteToolsAgent.DispatchOnInjectedScript( | |
| 265 WebInspector.Callback.wrap(callback), | |
| 266 async ? methodName + "_async" : methodName, | |
| 267 argsString); | |
| 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.installInspectorControllerDelegate_ | |
| 276 = function(methodName) { | |
| 277 this[methodName] = goog.bind(this.callInspectorController_, this, | |
| 278 methodName); | |
| 279 }; | |
| 280 | |
| 281 | |
| 282 /** | |
| 283 * Bound function with the installInjectedScriptDelegate_ actual | |
| 284 * implementation. | |
| 285 */ | |
| 286 devtools.InspectorControllerImpl.prototype.callInspectorController_ = | |
| 287 function(methodName, var_arg) { | |
| 288 var args = Array.prototype.slice.call(arguments, 1); | |
| 289 RemoteToolsAgent.DispatchOnInspectorController( | |
| 290 WebInspector.Callback.wrap(function(){}), | |
| 291 methodName, | |
| 292 JSON.stringify(args)); | |
| 293 }; | |
| 294 | |
| 295 | |
| 296 InspectorController = new devtools.InspectorControllerImpl(); | |
| OLD | NEW |