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 Stub implementation of the InspectorController API. |
| 7 * This stub class is supposed to make front-end a standalone WebApp |
| 8 * that can be implemented/refactored in isolation from the Web browser |
| 9 * backend. Clients need to subclass it in order to wire calls to the |
| 10 * non-stub backends. |
| 11 */ |
| 12 goog.provide('devtools.InspectorController'); |
| 13 |
| 14 |
| 15 /** |
| 16 * Creates inspector controller stub instance. |
| 17 * @constructor. |
| 18 */ |
| 19 devtools.InspectorController = function() { |
| 20 /** |
| 21 * @type {boolean} |
| 22 */ |
| 23 this.searchingForNode_ = false; |
| 24 |
| 25 /** |
| 26 * @type {boolean} |
| 27 */ |
| 28 this.windowVisible_ = true; |
| 29 |
| 30 /** |
| 31 * @type {number} |
| 32 */ |
| 33 this.attachedWindowHeight_ = 0; |
| 34 |
| 35 /** |
| 36 * @type {boolean} |
| 37 */ |
| 38 this.debuggerEnabled_ = true; |
| 39 |
| 40 /** |
| 41 * @type {boolean} |
| 42 */ |
| 43 this.profilerEnabled_ = true; |
| 44 |
| 45 /** |
| 46 * @type {boolean} |
| 47 */ |
| 48 this.resourceTrackingEnabled_ = false; |
| 49 |
| 50 /** |
| 51 * @type {boolean} |
| 52 */ |
| 53 this.timelineEnabled_ = false; |
| 54 |
| 55 /** |
| 56 * @type {Object} |
| 57 */ |
| 58 this.settings_ = {}; |
| 59 }; |
| 60 |
| 61 |
| 62 /** |
| 63 * Wraps javascript callback. |
| 64 * @param {function():undefined} func The callback to wrap. |
| 65 * @return {function():undefined} Callback wrapper. |
| 66 */ |
| 67 devtools.InspectorController.prototype.wrapCallback = function f(func) { |
| 68 // Just return as is. |
| 69 return func; |
| 70 }; |
| 71 |
| 72 |
| 73 /** |
| 74 * @return {boolean} True iff inspector window is currently visible. |
| 75 */ |
| 76 devtools.InspectorController.prototype.isWindowVisible = function() { |
| 77 return this.windowVisible_; |
| 78 }; |
| 79 |
| 80 |
| 81 /** |
| 82 * @return {string} Platform identifier. |
| 83 */ |
| 84 devtools.InspectorController.prototype.platform = function() { |
| 85 return 'windows'; |
| 86 }; |
| 87 |
| 88 |
| 89 /** |
| 90 * Closes inspector window. |
| 91 */ |
| 92 devtools.InspectorController.prototype.closeWindow = function() { |
| 93 this.windowVisible_ = false; |
| 94 }; |
| 95 |
| 96 |
| 97 /** |
| 98 * Attaches frontend to the backend. |
| 99 */ |
| 100 devtools.InspectorController.prototype.attach = function() { |
| 101 }; |
| 102 |
| 103 |
| 104 /** |
| 105 * Detaches frontend from the backend. |
| 106 */ |
| 107 devtools.InspectorController.prototype.detach = function() { |
| 108 }; |
| 109 |
| 110 |
| 111 /** |
| 112 * Tell host that the active panel has changed. |
| 113 * @param {string} panel Panel name that was last active. |
| 114 */ |
| 115 devtools.InspectorController.prototype.storeLastActivePanel = function(panel) { |
| 116 }; |
| 117 |
| 118 |
| 119 /** |
| 120 * Clears console message log in the backend. |
| 121 */ |
| 122 devtools.InspectorController.prototype.clearMessages = function() { |
| 123 }; |
| 124 |
| 125 |
| 126 /** |
| 127 * Returns true iff browser is currently in the search for node mode. |
| 128 * @return {boolean} True is currently searching for a node. |
| 129 */ |
| 130 devtools.InspectorController.prototype.searchingForNode = function() { |
| 131 return this.searchingForNode_; |
| 132 }; |
| 133 |
| 134 |
| 135 /** |
| 136 * Initiates search for a given query starting on a given row. |
| 137 * @param {number} sourceRow Row to start searching from. |
| 138 * @param {string} query Query string for search for. |
| 139 */ |
| 140 devtools.InspectorController.prototype.search = function(sourceRow, query) { |
| 141 }; |
| 142 |
| 143 |
| 144 /** |
| 145 * Toggles node search mode on/off. |
| 146 */ |
| 147 devtools.InspectorController.prototype.toggleNodeSearch = function() { |
| 148 this.searchingForNode_ = !this.searchingForNode_; |
| 149 }; |
| 150 |
| 151 |
| 152 /** |
| 153 * Sets the inspector window height while in the attached mode. |
| 154 * @param {number} height Window height being set. |
| 155 */ |
| 156 devtools.InspectorController.prototype.setAttachedWindowHeight = |
| 157 function(height) { |
| 158 this.attachedWindowHeight_ = height; |
| 159 }; |
| 160 |
| 161 |
| 162 /** |
| 163 * Moves window by the given offset. |
| 164 * @param {number} x X offset. |
| 165 * @param {number} y Y offset. |
| 166 */ |
| 167 devtools.InspectorController.prototype.moveByUnrestricted = function(x, y) { |
| 168 }; |
| 169 |
| 170 |
| 171 /** |
| 172 * Adds resource with given identifier into the given iframe element. |
| 173 * @param {number} identifier Identifier of the resource to add into the frame. |
| 174 * @param {Element} element Element to add resource content to. |
| 175 */ |
| 176 devtools.InspectorController.prototype.addResourceSourceToFrame = |
| 177 function(identifier, element) { |
| 178 }; |
| 179 |
| 180 |
| 181 /** |
| 182 * Adds given source of a given mimeType into the given iframe element. |
| 183 * @param {string} mimeType MIME type of the content to be added. |
| 184 * @param {string} source String content to be added. |
| 185 * @param {Element} element Element to add resource content to. |
| 186 */ |
| 187 devtools.InspectorController.prototype.addSourceToFrame = |
| 188 function(mimeType, source, element) { |
| 189 return false; |
| 190 }; |
| 191 |
| 192 |
| 193 /** |
| 194 * Returns document node corresponding to the resource with given id. |
| 195 * @return {Node} Node containing the resource. |
| 196 */ |
| 197 devtools.InspectorController.prototype.getResourceDocumentNode = |
| 198 function(identifier) { |
| 199 return undefined; |
| 200 }; |
| 201 |
| 202 |
| 203 /** |
| 204 * Highlights the given node on the page. |
| 205 * @param {Node} node Node to highlight. |
| 206 */ |
| 207 devtools.InspectorController.prototype.highlightDOMNode = function(node) { |
| 208 // Does nothing in stub. |
| 209 }; |
| 210 |
| 211 |
| 212 /** |
| 213 * Clears current highlight. |
| 214 */ |
| 215 devtools.InspectorController.prototype.hideDOMNodeHighlight = function() { |
| 216 // Does nothing in stub. |
| 217 }; |
| 218 |
| 219 |
| 220 /** |
| 221 * @return {window} Inspectable window instance. |
| 222 */ |
| 223 devtools.InspectorController.prototype.inspectedWindow = function() { |
| 224 return window; |
| 225 }; |
| 226 |
| 227 |
| 228 /** |
| 229 * Notifies backend that the frontend has been successfully loaded. |
| 230 */ |
| 231 devtools.InspectorController.prototype.loaded = function() { |
| 232 // Does nothing in stub. |
| 233 }; |
| 234 |
| 235 |
| 236 /** |
| 237 * @return {string} Url of the i18n-ed strings map. |
| 238 */ |
| 239 devtools.InspectorController.prototype.localizedStringsURL = function() { |
| 240 return undefined; |
| 241 }; |
| 242 |
| 243 |
| 244 /** |
| 245 * @return {boolean} True iff window is currently unloading. |
| 246 */ |
| 247 devtools.InspectorController.prototype.windowUnloading = function() { |
| 248 return false; |
| 249 }; |
| 250 |
| 251 |
| 252 /** |
| 253 * @return {string} Identifiers of the panels that should be hidden. |
| 254 */ |
| 255 devtools.InspectorController.prototype.hiddenPanels = function() { |
| 256 return ''; |
| 257 }; |
| 258 |
| 259 |
| 260 /** |
| 261 * @return {boolean} True iff debugger is enabled. |
| 262 */ |
| 263 devtools.InspectorController.prototype.debuggerEnabled = function() { |
| 264 return this.debuggerEnabled_; |
| 265 }; |
| 266 |
| 267 |
| 268 /** |
| 269 * Enables resource tracking. |
| 270 */ |
| 271 devtools.InspectorController.prototype.enableResourceTracking = function() { |
| 272 this.resourceTrackingEnabled_ = true; |
| 273 WebInspector.resourceTrackingWasEnabled(); |
| 274 }; |
| 275 |
| 276 |
| 277 /** |
| 278 * Disables resource tracking. |
| 279 */ |
| 280 devtools.InspectorController.prototype.disableResourceTracking = function() { |
| 281 this.resourceTrackingEnabled_ = false; |
| 282 WebInspector.resourceTrackingWasDisabled(); |
| 283 }; |
| 284 |
| 285 |
| 286 /** |
| 287 * @return {boolean} True iff resource tracking is enabled. |
| 288 */ |
| 289 devtools.InspectorController.prototype.resourceTrackingEnabled = function() { |
| 290 return this.resourceTrackingEnabled_; |
| 291 }; |
| 292 |
| 293 |
| 294 /** |
| 295 * Enables timeline. |
| 296 */ |
| 297 devtools.InspectorController.prototype.enableTimeline = function() { |
| 298 this.timelineEnabled_ = true; |
| 299 WebInspector.timelineWasEnabled(); |
| 300 }; |
| 301 |
| 302 |
| 303 /** |
| 304 * Disables timeline. |
| 305 */ |
| 306 devtools.InspectorController.prototype.disableTimeline = function() { |
| 307 this.timelineEnabled_ = false; |
| 308 WebInspector.timelineWasDisabled(); |
| 309 }; |
| 310 |
| 311 /** |
| 312 * @return {boolean} True iff timeline is enabled. |
| 313 */ |
| 314 devtools.InspectorController.prototype.timelineEnabled = function() { |
| 315 return this.timelineEnabled_; |
| 316 }; |
| 317 |
| 318 |
| 319 /** |
| 320 * Enables debugger. |
| 321 */ |
| 322 devtools.InspectorController.prototype.enableDebugger = function() { |
| 323 this.debuggerEnabled_ = true; |
| 324 }; |
| 325 |
| 326 |
| 327 /** |
| 328 * Disables debugger. |
| 329 */ |
| 330 devtools.InspectorController.prototype.disableDebugger = function() { |
| 331 this.debuggerEnabled_ = false; |
| 332 }; |
| 333 |
| 334 |
| 335 /** |
| 336 * Adds breakpoint to the given line of the source with given ID. |
| 337 * @param {string} sourceID Source Id to add breakpoint to. |
| 338 * @param {number} line Line number to add breakpoint to. |
| 339 * @param {?string} condition The breakpoint condition. |
| 340 */ |
| 341 devtools.InspectorController.prototype.addBreakpoint = |
| 342 function(sourceID, line, condition) { |
| 343 }; |
| 344 |
| 345 |
| 346 /** |
| 347 * Removes breakpoint from the given line of the source with given ID. |
| 348 * @param {string} sourceID Source Id to remove breakpoint from. |
| 349 * @param {number} line Line number to remove breakpoint from. |
| 350 */ |
| 351 devtools.InspectorController.prototype.removeBreakpoint = |
| 352 function(sourceID, line) { |
| 353 }; |
| 354 |
| 355 |
| 356 /** |
| 357 * Sets a breakpoint condition given a line of the source and an ID. |
| 358 * @param {string} sourceID Source Id to remove breakpoint from. |
| 359 * @param {number} line Line number to remove breakpoint from. |
| 360 * @param {?string} condition New breakpoint condition. |
| 361 */ |
| 362 devtools.InspectorController.prototype.updateBreakpoint = |
| 363 function(sourceID, line, condition) { |
| 364 }; |
| 365 |
| 366 |
| 367 /** |
| 368 * Tells backend to pause in the debugger. |
| 369 */ |
| 370 devtools.InspectorController.prototype.pauseInDebugger = function() { |
| 371 // Does nothing in stub. |
| 372 }; |
| 373 |
| 374 |
| 375 /** |
| 376 * @return {boolean} True iff the debugger will pause execution on the |
| 377 * exceptions. |
| 378 */ |
| 379 devtools.InspectorController.prototype.pauseOnExceptions = function() { |
| 380 // Does nothing in stub. |
| 381 return false; |
| 382 }; |
| 383 |
| 384 |
| 385 /** |
| 386 * Tells whether to pause in the debugger on the exceptions or not. |
| 387 * @param {boolean} value True iff execution should be stopped in the debugger |
| 388 * on the exceptions. |
| 389 */ |
| 390 devtools.InspectorController.prototype.setPauseOnExceptions = function(value) { |
| 391 }; |
| 392 |
| 393 |
| 394 /** |
| 395 * Tells backend to resume execution. |
| 396 */ |
| 397 devtools.InspectorController.prototype.resumeDebugger = function() { |
| 398 }; |
| 399 |
| 400 |
| 401 /** |
| 402 * @return {boolean} True iff profiler is enabled. |
| 403 */ |
| 404 devtools.InspectorController.prototype.profilerEnabled = function() { |
| 405 return true; |
| 406 }; |
| 407 |
| 408 |
| 409 /** |
| 410 * Enables profiler. |
| 411 */ |
| 412 devtools.InspectorController.prototype.enableProfiler = function() { |
| 413 this.profilerEnabled_ = true; |
| 414 }; |
| 415 |
| 416 |
| 417 /** |
| 418 * Disables profiler. |
| 419 */ |
| 420 devtools.InspectorController.prototype.disableProfiler = function() { |
| 421 this.profilerEnabled_ = false; |
| 422 }; |
| 423 |
| 424 |
| 425 /** |
| 426 * Returns given callframe while on a debugger break. |
| 427 * @return {Object} Current call frame. |
| 428 */ |
| 429 devtools.InspectorController.prototype.currentCallFrame = function() { |
| 430 return undefined; |
| 431 }; |
| 432 |
| 433 |
| 434 /** |
| 435 * Tells backend to start collecting profiler data. |
| 436 */ |
| 437 devtools.InspectorController.prototype.startProfiling = function() { |
| 438 }; |
| 439 |
| 440 |
| 441 /** |
| 442 * Tells backend to stop collecting profiler data. |
| 443 */ |
| 444 devtools.InspectorController.prototype.stopProfiling = function() { |
| 445 }; |
| 446 |
| 447 |
| 448 /** |
| 449 * TODO(mnaganov): Remove after injected script change landing in WebKit. |
| 450 * @return {Array.<Object>} Profile snapshots array. |
| 451 */ |
| 452 devtools.InspectorController.prototype.profiles = function() { |
| 453 return []; |
| 454 }; |
| 455 |
| 456 |
| 457 /** |
| 458 * Async function for retrieving headers of existing profiles. |
| 459 */ |
| 460 devtools.InspectorController.prototype.getProfileHeaders = function(callId) { |
| 461 WebInspector.didGetProfileHeaders(callId, []); |
| 462 }; |
| 463 |
| 464 |
| 465 /** |
| 466 * Async function for lazy loading an existing profile. |
| 467 */ |
| 468 devtools.InspectorController.prototype.getProfile = function(callId, uid) { |
| 469 if (WebInspector.__fullProfiles && (uid in WebInspector.__fullProfiles)) { |
| 470 WebInspector.didGetProfile(callId, WebInspector.__fullProfiles[uid]); |
| 471 } |
| 472 }; |
| 473 |
| 474 |
| 475 /** |
| 476 * Tells backend to create a heap snapshot. |
| 477 */ |
| 478 devtools.InspectorController.prototype.takeHeapSnapshot = function() { |
| 479 }; |
| 480 |
| 481 |
| 482 /** |
| 483 * @return {Array.<string>} Database table names available offline. |
| 484 */ |
| 485 devtools.InspectorController.prototype.databaseTableNames = |
| 486 function(database) { |
| 487 return []; |
| 488 }; |
| 489 |
| 490 |
| 491 /** |
| 492 * Tells backend to step into the function in debugger. |
| 493 */ |
| 494 devtools.InspectorController.prototype.stepIntoStatementInDebugger = |
| 495 function() { |
| 496 }; |
| 497 |
| 498 |
| 499 /** |
| 500 * Tells backend to step out of the function in debugger. |
| 501 */ |
| 502 devtools.InspectorController.prototype.stepOutOfFunctionInDebugger = |
| 503 function() {}; |
| 504 |
| 505 |
| 506 /** |
| 507 * Tells backend to step over the statement in debugger. |
| 508 */ |
| 509 devtools.InspectorController.prototype.stepOverStatementInDebugger = |
| 510 function() { |
| 511 }; |
| 512 |
| 513 |
| 514 /** |
| 515 * Sets a setting value in backend. |
| 516 */ |
| 517 devtools.InspectorController.prototype.setSetting = |
| 518 function(setting, value) { |
| 519 this.settings_[setting] = value; |
| 520 }; |
| 521 |
| 522 |
| 523 /** |
| 524 * Retrieves a setting value stored in backend. |
| 525 */ |
| 526 devtools.InspectorController.prototype.setting = |
| 527 function(setting) { |
| 528 return this.settings_[setting]; |
| 529 }; |
| 530 |
| 531 |
| 532 var InspectorController = new devtools.InspectorController(); |
OLD | NEW |