1 // Copyright (c) 2011 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.
7 #include "InspectorBackendDispatcher.h"
8 #include <wtf/text/WTFString.h>
9 #include <wtf/text/CString.h>
13 #include "InspectorAgent.h"
14 #include "InspectorValues.h"
15 #include "InspectorFrontendChannel.h"
16 #include <wtf/text/WTFString.h>
17 #include "InspectorApplicationCacheAgent.h"
18 #include "InspectorCSSAgent.h"
19 #include "InspectorConsoleAgent.h"
20 #include "InspectorDOMAgent.h"
21 #include "InspectorDOMDebuggerAgent.h"
22 #include "InspectorDOMStorageAgent.h"
23 #include "InspectorDatabaseAgent.h"
24 #include "InspectorDebuggerAgent.h"
25 #include "InspectorFileSystemAgent.h"
26 #include "InspectorAgent.h"
27 #include "InspectorMetaAgent.h"
28 #include "InspectorResourceAgent.h"
29 #include "InspectorPageAgent.h"
30 #include "InspectorProfilerAgent.h"
31 #include "InspectorRuntimeAgent.h"
32 #include "InspectorTimelineAgent.h"
33 #include "InspectorWorkerAgent.h"
37 const char* InspectorBackendDispatcher::commandNames[] = {
40 "Meta.getCapabilities",
43 "Page.addScriptToEvaluateOnLoad",
44 "Page.removeScriptToEvaluateOnLoad",
49 "Page.getResourceTree",
50 "Page.getResourceContent",
51 "Page.searchInResource",
52 "Page.searchInResources",
54 "Runtime.callFunctionOn",
55 "Runtime.getProperties",
56 "Runtime.releaseObject",
57 "Runtime.releaseObjectGroup",
61 "Console.clearMessages",
62 "Console.setMonitoringXHREnabled",
63 "Console.addInspectedNode",
66 "Network.setUserAgentOverride",
67 "Network.setExtraHTTPHeaders",
68 "Network.getResponseBody",
69 "Network.clearBrowserCache",
70 "Network.clearBrowserCookies",
71 "Network.setCacheDisabled",
74 "Database.getDatabaseTableNames",
75 "Database.executeSQL",
78 "DOMStorage.getDOMStorageEntries",
79 "DOMStorage.setDOMStorageItem",
80 "DOMStorage.removeDOMStorageItem",
81 "ApplicationCache.getFramesWithManifests",
82 "ApplicationCache.enable",
83 "ApplicationCache.getManifestForFrame",
84 "ApplicationCache.getApplicationCacheForFrame",
88 "DOM.requestChildNodes",
90 "DOM.querySelectorAll",
94 "DOM.setAttributeValue",
95 "DOM.setAttributesAsText",
96 "DOM.removeAttribute",
97 "DOM.getEventListenersForNode",
102 "DOM.getSearchResults",
103 "DOM.discardSearchResults",
105 "DOM.setInspectModeEnabled",
109 "DOM.highlightFrame",
110 "DOM.pushNodeByPathToFrontend",
114 "CSS.getMatchedStylesForNode",
115 "CSS.getInlineStylesForNode",
116 "CSS.getComputedStyleForNode",
117 "CSS.getAllStyleSheets",
119 "CSS.getStyleSheetText",
120 "CSS.setStyleSheetText",
121 "CSS.setPropertyText",
122 "CSS.toggleProperty",
123 "CSS.setRuleSelector",
125 "CSS.getSupportedCSSProperties",
130 "Debugger.setBreakpointsActive",
131 "Debugger.setBreakpointByUrl",
132 "Debugger.setBreakpoint",
133 "Debugger.removeBreakpoint",
134 "Debugger.continueToLocation",
140 "Debugger.searchInContent",
141 "Debugger.setScriptSource",
142 "Debugger.getScriptSource",
143 "Debugger.getFunctionLocation",
144 "Debugger.setPauseOnExceptions",
145 "Debugger.evaluateOnCallFrame",
146 "DOMDebugger.setDOMBreakpoint",
147 "DOMDebugger.removeDOMBreakpoint",
148 "DOMDebugger.setEventListenerBreakpoint",
149 "DOMDebugger.removeEventListenerBreakpoint",
150 "DOMDebugger.setXHRBreakpoint",
151 "DOMDebugger.removeXHRBreakpoint",
154 "Profiler.isEnabled",
157 "Profiler.getProfileHeaders",
158 "Profiler.getProfile",
159 "Profiler.removeProfile",
160 "Profiler.clearProfiles",
161 "Profiler.takeHeapSnapshot",
162 "Profiler.collectGarbage",
163 "Profiler.getObjectByHeapObjectId",
164 "Worker.setWorkerInspectionEnabled",
165 "Worker.sendMessageToWorker",
166 "Worker.connectToWorker",
167 "Worker.disconnectFromWorker",
168 "Worker.setAutoconnectToWorkers",
172 void InspectorBackendDispatcher::Inspector_enable(long callId, InspectorObject*)
174 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
176 if (!m_inspectorAgent)
177 protocolErrors->pushString("Inspector handler is not available.");
181 if (!protocolErrors->length())
182 m_inspectorAgent->enable(&error);
184 RefPtr<InspectorObject> result = InspectorObject::create();
185 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Inspector.enable"), protocolErrors, error);
188 void InspectorBackendDispatcher::Inspector_disable(long callId, InspectorObject*)
190 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
192 if (!m_inspectorAgent)
193 protocolErrors->pushString("Inspector handler is not available.");
197 if (!protocolErrors->length())
198 m_inspectorAgent->disable(&error);
200 RefPtr<InspectorObject> result = InspectorObject::create();
201 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Inspector.disable"), protocolErrors, error);
204 void InspectorBackendDispatcher::Meta_getCapabilities(long callId, InspectorObject* requestMessageObject)
206 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
209 protocolErrors->pushString("Meta handler is not available.");
211 RefPtr<InspectorArray> out_capabilities = InspectorArray::create();
215 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
216 InspectorObject* paramsContainerPtr = paramsContainer.get();
217 InspectorArray* protocolErrorsPtr = protocolErrors.get();
218 RefPtr<InspectorArray> in_domainNames = getArray(paramsContainerPtr, "domainNames", 0, protocolErrorsPtr);
220 if (!protocolErrors->length())
221 m_metaAgent->getCapabilities(&error, in_domainNames, &out_capabilities);
223 RefPtr<InspectorObject> result = InspectorObject::create();
224 if (!protocolErrors->length() && !error.length()) {
225 result->setArray("capabilities", out_capabilities);
227 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Meta.getCapabilities"), protocolErrors, error);
230 void InspectorBackendDispatcher::Page_enable(long callId, InspectorObject*)
232 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
235 protocolErrors->pushString("Page handler is not available.");
239 if (!protocolErrors->length())
240 m_pageAgent->enable(&error);
242 RefPtr<InspectorObject> result = InspectorObject::create();
243 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.enable"), protocolErrors, error);
246 void InspectorBackendDispatcher::Page_disable(long callId, InspectorObject*)
248 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
251 protocolErrors->pushString("Page handler is not available.");
255 if (!protocolErrors->length())
256 m_pageAgent->disable(&error);
258 RefPtr<InspectorObject> result = InspectorObject::create();
259 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.disable"), protocolErrors, error);
262 void InspectorBackendDispatcher::Page_addScriptToEvaluateOnLoad(long callId, InspectorObject* requestMessageObject)
264 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
267 protocolErrors->pushString("Page handler is not available.");
269 String out_identifier = "";
273 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
274 InspectorObject* paramsContainerPtr = paramsContainer.get();
275 InspectorArray* protocolErrorsPtr = protocolErrors.get();
276 String in_scriptSource = getString(paramsContainerPtr, "scriptSource", 0, protocolErrorsPtr);
278 if (!protocolErrors->length())
279 m_pageAgent->addScriptToEvaluateOnLoad(&error, in_scriptSource, &out_identifier);
281 RefPtr<InspectorObject> result = InspectorObject::create();
282 if (!protocolErrors->length() && !error.length()) {
283 result->setString("identifier", out_identifier);
285 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.addScriptToEvaluateOnLoad"), protocolErrors, error);
288 void InspectorBackendDispatcher::Page_removeScriptToEvaluateOnLoad(long callId, InspectorObject* requestMessageObject)
290 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
293 protocolErrors->pushString("Page handler is not available.");
297 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
298 InspectorObject* paramsContainerPtr = paramsContainer.get();
299 InspectorArray* protocolErrorsPtr = protocolErrors.get();
300 String in_identifier = getString(paramsContainerPtr, "identifier", 0, protocolErrorsPtr);
302 if (!protocolErrors->length())
303 m_pageAgent->removeScriptToEvaluateOnLoad(&error, in_identifier);
305 RefPtr<InspectorObject> result = InspectorObject::create();
306 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.removeScriptToEvaluateOnLoad"), protocolErrors, error);
309 void InspectorBackendDispatcher::Page_reload(long callId, InspectorObject* requestMessageObject)
311 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
314 protocolErrors->pushString("Page handler is not available.");
318 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
319 InspectorObject* paramsContainerPtr = paramsContainer.get();
320 InspectorArray* protocolErrorsPtr = protocolErrors.get();
321 bool ignoreCache_valueFound = false;
322 bool in_ignoreCache = getBoolean(paramsContainerPtr, "ignoreCache", &ignoreCache_valueFound, protocolErrorsPtr);
323 bool scriptToEvaluateOnLoad_valueFound = false;
324 String in_scriptToEvaluateOnLoad = getString(paramsContainerPtr, "scriptToEvaluateOnLoad", &scriptToEvaluateOnLoad_valueFound, protocolErrorsPtr);
326 if (!protocolErrors->length())
327 m_pageAgent->reload(&error, ignoreCache_valueFound ? &in_ignoreCache : 0, scriptToEvaluateOnLoad_valueFound ? &in_scriptToEvaluateOnLoad : 0);
329 RefPtr<InspectorObject> result = InspectorObject::create();
330 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.reload"), protocolErrors, error);
333 void InspectorBackendDispatcher::Page_open(long callId, InspectorObject* requestMessageObject)
335 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
338 protocolErrors->pushString("Page handler is not available.");
342 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
343 InspectorObject* paramsContainerPtr = paramsContainer.get();
344 InspectorArray* protocolErrorsPtr = protocolErrors.get();
345 String in_url = getString(paramsContainerPtr, "url", 0, protocolErrorsPtr);
346 bool newWindow_valueFound = false;
347 bool in_newWindow = getBoolean(paramsContainerPtr, "newWindow", &newWindow_valueFound, protocolErrorsPtr);
349 if (!protocolErrors->length())
350 m_pageAgent->open(&error, in_url, newWindow_valueFound ? &in_newWindow : 0);
352 RefPtr<InspectorObject> result = InspectorObject::create();
353 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.open"), protocolErrors, error);
356 void InspectorBackendDispatcher::Page_getCookies(long callId, InspectorObject*)
358 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
361 protocolErrors->pushString("Page handler is not available.");
363 RefPtr<InspectorArray> out_cookies = InspectorArray::create();
364 String out_cookiesString = "";
368 if (!protocolErrors->length())
369 m_pageAgent->getCookies(&error, &out_cookies, &out_cookiesString);
371 RefPtr<InspectorObject> result = InspectorObject::create();
372 if (!protocolErrors->length() && !error.length()) {
373 result->setArray("cookies", out_cookies);
374 result->setString("cookiesString", out_cookiesString);
376 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.getCookies"), protocolErrors, error);
379 void InspectorBackendDispatcher::Page_deleteCookie(long callId, InspectorObject* requestMessageObject)
381 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
384 protocolErrors->pushString("Page handler is not available.");
388 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
389 InspectorObject* paramsContainerPtr = paramsContainer.get();
390 InspectorArray* protocolErrorsPtr = protocolErrors.get();
391 String in_cookieName = getString(paramsContainerPtr, "cookieName", 0, protocolErrorsPtr);
392 String in_domain = getString(paramsContainerPtr, "domain", 0, protocolErrorsPtr);
394 if (!protocolErrors->length())
395 m_pageAgent->deleteCookie(&error, in_cookieName, in_domain);
397 RefPtr<InspectorObject> result = InspectorObject::create();
398 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.deleteCookie"), protocolErrors, error);
401 void InspectorBackendDispatcher::Page_getResourceTree(long callId, InspectorObject*)
403 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
406 protocolErrors->pushString("Page handler is not available.");
408 RefPtr<InspectorObject> out_frameTree = InspectorObject::create();
412 if (!protocolErrors->length())
413 m_pageAgent->getResourceTree(&error, &out_frameTree);
415 RefPtr<InspectorObject> result = InspectorObject::create();
416 if (!protocolErrors->length() && !error.length()) {
417 result->setObject("frameTree", out_frameTree);
419 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.getResourceTree"), protocolErrors, error);
422 void InspectorBackendDispatcher::Page_getResourceContent(long callId, InspectorObject* requestMessageObject)
424 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
427 protocolErrors->pushString("Page handler is not available.");
429 String out_content = "";
430 bool out_base64Encoded = false;
434 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
435 InspectorObject* paramsContainerPtr = paramsContainer.get();
436 InspectorArray* protocolErrorsPtr = protocolErrors.get();
437 String in_frameId = getString(paramsContainerPtr, "frameId", 0, protocolErrorsPtr);
438 String in_url = getString(paramsContainerPtr, "url", 0, protocolErrorsPtr);
440 if (!protocolErrors->length())
441 m_pageAgent->getResourceContent(&error, in_frameId, in_url, &out_content, &out_base64Encoded);
443 RefPtr<InspectorObject> result = InspectorObject::create();
444 if (!protocolErrors->length() && !error.length()) {
445 result->setString("content", out_content);
446 result->setBoolean("base64Encoded", out_base64Encoded);
448 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.getResourceContent"), protocolErrors, error);
451 void InspectorBackendDispatcher::Page_searchInResource(long callId, InspectorObject* requestMessageObject)
453 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
456 protocolErrors->pushString("Page handler is not available.");
458 RefPtr<InspectorArray> out_result = InspectorArray::create();
462 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
463 InspectorObject* paramsContainerPtr = paramsContainer.get();
464 InspectorArray* protocolErrorsPtr = protocolErrors.get();
465 String in_frameId = getString(paramsContainerPtr, "frameId", 0, protocolErrorsPtr);
466 String in_url = getString(paramsContainerPtr, "url", 0, protocolErrorsPtr);
467 String in_query = getString(paramsContainerPtr, "query", 0, protocolErrorsPtr);
468 bool caseSensitive_valueFound = false;
469 bool in_caseSensitive = getBoolean(paramsContainerPtr, "caseSensitive", &caseSensitive_valueFound, protocolErrorsPtr);
470 bool isRegex_valueFound = false;
471 bool in_isRegex = getBoolean(paramsContainerPtr, "isRegex", &isRegex_valueFound, protocolErrorsPtr);
473 if (!protocolErrors->length())
474 m_pageAgent->searchInResource(&error, in_frameId, in_url, in_query, caseSensitive_valueFound ? &in_caseSensitive : 0, isRegex_valueFound ? &in_isRegex : 0, &out_result);
476 RefPtr<InspectorObject> result = InspectorObject::create();
477 if (!protocolErrors->length() && !error.length()) {
478 result->setArray("result", out_result);
480 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.searchInResource"), protocolErrors, error);
483 void InspectorBackendDispatcher::Page_searchInResources(long callId, InspectorObject* requestMessageObject)
485 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
488 protocolErrors->pushString("Page handler is not available.");
490 RefPtr<InspectorArray> out_result = InspectorArray::create();
494 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
495 InspectorObject* paramsContainerPtr = paramsContainer.get();
496 InspectorArray* protocolErrorsPtr = protocolErrors.get();
497 String in_text = getString(paramsContainerPtr, "text", 0, protocolErrorsPtr);
498 bool caseSensitive_valueFound = false;
499 bool in_caseSensitive = getBoolean(paramsContainerPtr, "caseSensitive", &caseSensitive_valueFound, protocolErrorsPtr);
500 bool isRegex_valueFound = false;
501 bool in_isRegex = getBoolean(paramsContainerPtr, "isRegex", &isRegex_valueFound, protocolErrorsPtr);
503 if (!protocolErrors->length())
504 m_pageAgent->searchInResources(&error, in_text, caseSensitive_valueFound ? &in_caseSensitive : 0, isRegex_valueFound ? &in_isRegex : 0, &out_result);
506 RefPtr<InspectorObject> result = InspectorObject::create();
507 if (!protocolErrors->length() && !error.length()) {
508 result->setArray("result", out_result);
510 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.searchInResources"), protocolErrors, error);
513 void InspectorBackendDispatcher::Runtime_evaluate(long callId, InspectorObject* requestMessageObject)
515 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
518 protocolErrors->pushString("Runtime handler is not available.");
520 RefPtr<InspectorObject> out_result = InspectorObject::create();
521 bool out_wasThrown = false;
525 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
526 InspectorObject* paramsContainerPtr = paramsContainer.get();
527 InspectorArray* protocolErrorsPtr = protocolErrors.get();
528 String in_expression = getString(paramsContainerPtr, "expression", 0, protocolErrorsPtr);
529 bool objectGroup_valueFound = false;
530 String in_objectGroup = getString(paramsContainerPtr, "objectGroup", &objectGroup_valueFound, protocolErrorsPtr);
531 bool includeCommandLineAPI_valueFound = false;
532 bool in_includeCommandLineAPI = getBoolean(paramsContainerPtr, "includeCommandLineAPI", &includeCommandLineAPI_valueFound, protocolErrorsPtr);
533 bool doNotPauseOnExceptions_valueFound = false;
534 bool in_doNotPauseOnExceptions = getBoolean(paramsContainerPtr, "doNotPauseOnExceptions", &doNotPauseOnExceptions_valueFound, protocolErrorsPtr);
535 bool frameId_valueFound = false;
536 String in_frameId = getString(paramsContainerPtr, "frameId", &frameId_valueFound, protocolErrorsPtr);
537 bool returnByValue_valueFound = false;
538 bool in_returnByValue = getBoolean(paramsContainerPtr, "returnByValue", &returnByValue_valueFound, protocolErrorsPtr);
540 if (!protocolErrors->length())
541 m_runtimeAgent->evaluate(&error, in_expression, objectGroup_valueFound ? &in_objectGroup : 0, includeCommandLineAPI_valueFound ? &in_includeCommandLineAPI : 0, doNotPauseOnExceptions_valueFound ? &in_doNotPauseOnExceptions : 0, frameId_valueFound ? &in_frameId : 0, returnByValue_valueFound ? &in_returnByValue : 0, &out_result, &out_wasThrown);
543 RefPtr<InspectorObject> result = InspectorObject::create();
544 if (!protocolErrors->length() && !error.length()) {
545 result->setObject("result", out_result);
547 result->setBoolean("wasThrown", out_wasThrown);
549 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.evaluate"), protocolErrors, error);
552 void InspectorBackendDispatcher::Runtime_callFunctionOn(long callId, InspectorObject* requestMessageObject)
554 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
557 protocolErrors->pushString("Runtime handler is not available.");
559 RefPtr<InspectorObject> out_result = InspectorObject::create();
560 bool out_wasThrown = false;
564 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
565 InspectorObject* paramsContainerPtr = paramsContainer.get();
566 InspectorArray* protocolErrorsPtr = protocolErrors.get();
567 String in_objectId = getString(paramsContainerPtr, "objectId", 0, protocolErrorsPtr);
568 String in_functionDeclaration = getString(paramsContainerPtr, "functionDeclaration", 0, protocolErrorsPtr);
569 bool arguments_valueFound = false;
570 RefPtr<InspectorArray> in_arguments = getArray(paramsContainerPtr, "arguments", &arguments_valueFound, protocolErrorsPtr);
571 bool returnByValue_valueFound = false;
572 bool in_returnByValue = getBoolean(paramsContainerPtr, "returnByValue", &returnByValue_valueFound, protocolErrorsPtr);
574 if (!protocolErrors->length())
575 m_runtimeAgent->callFunctionOn(&error, in_objectId, in_functionDeclaration, arguments_valueFound ? &in_arguments : 0, returnByValue_valueFound ? &in_returnByValue : 0, &out_result, &out_wasThrown);
577 RefPtr<InspectorObject> result = InspectorObject::create();
578 if (!protocolErrors->length() && !error.length()) {
579 result->setObject("result", out_result);
581 result->setBoolean("wasThrown", out_wasThrown);
583 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.callFunctionOn"), protocolErrors, error);
586 void InspectorBackendDispatcher::Runtime_getProperties(long callId, InspectorObject* requestMessageObject)
588 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
591 protocolErrors->pushString("Runtime handler is not available.");
593 RefPtr<InspectorArray> out_result = InspectorArray::create();
597 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
598 InspectorObject* paramsContainerPtr = paramsContainer.get();
599 InspectorArray* protocolErrorsPtr = protocolErrors.get();
600 String in_objectId = getString(paramsContainerPtr, "objectId", 0, protocolErrorsPtr);
601 bool ownProperties_valueFound = false;
602 bool in_ownProperties = getBoolean(paramsContainerPtr, "ownProperties", &ownProperties_valueFound, protocolErrorsPtr);
604 if (!protocolErrors->length())
605 m_runtimeAgent->getProperties(&error, in_objectId, ownProperties_valueFound ? &in_ownProperties : 0, &out_result);
607 RefPtr<InspectorObject> result = InspectorObject::create();
608 if (!protocolErrors->length() && !error.length()) {
609 result->setArray("result", out_result);
611 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.getProperties"), protocolErrors, error);
614 void InspectorBackendDispatcher::Runtime_releaseObject(long callId, InspectorObject* requestMessageObject)
616 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
619 protocolErrors->pushString("Runtime handler is not available.");
623 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
624 InspectorObject* paramsContainerPtr = paramsContainer.get();
625 InspectorArray* protocolErrorsPtr = protocolErrors.get();
626 String in_objectId = getString(paramsContainerPtr, "objectId", 0, protocolErrorsPtr);
628 if (!protocolErrors->length())
629 m_runtimeAgent->releaseObject(&error, in_objectId);
631 RefPtr<InspectorObject> result = InspectorObject::create();
632 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.releaseObject"), protocolErrors, error);
635 void InspectorBackendDispatcher::Runtime_releaseObjectGroup(long callId, InspectorObject* requestMessageObject)
637 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
640 protocolErrors->pushString("Runtime handler is not available.");
644 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
645 InspectorObject* paramsContainerPtr = paramsContainer.get();
646 InspectorArray* protocolErrorsPtr = protocolErrors.get();
647 String in_objectGroup = getString(paramsContainerPtr, "objectGroup", 0, protocolErrorsPtr);
649 if (!protocolErrors->length())
650 m_runtimeAgent->releaseObjectGroup(&error, in_objectGroup);
652 RefPtr<InspectorObject> result = InspectorObject::create();
653 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.releaseObjectGroup"), protocolErrors, error);
656 void InspectorBackendDispatcher::Runtime_run(long callId, InspectorObject*)
658 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
661 protocolErrors->pushString("Runtime handler is not available.");
665 if (!protocolErrors->length())
666 m_runtimeAgent->run(&error);
668 RefPtr<InspectorObject> result = InspectorObject::create();
669 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.run"), protocolErrors, error);
672 void InspectorBackendDispatcher::Console_enable(long callId, InspectorObject*)
674 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
677 protocolErrors->pushString("Console handler is not available.");
681 if (!protocolErrors->length())
682 m_consoleAgent->enable(&error);
684 RefPtr<InspectorObject> result = InspectorObject::create();
685 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Console.enable"), protocolErrors, error);
688 void InspectorBackendDispatcher::Console_disable(long callId, InspectorObject*)
690 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
693 protocolErrors->pushString("Console handler is not available.");
697 if (!protocolErrors->length())
698 m_consoleAgent->disable(&error);
700 RefPtr<InspectorObject> result = InspectorObject::create();
701 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Console.disable"), protocolErrors, error);
704 void InspectorBackendDispatcher::Console_clearMessages(long callId, InspectorObject*)
706 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
709 protocolErrors->pushString("Console handler is not available.");
713 if (!protocolErrors->length())
714 m_consoleAgent->clearMessages(&error);
716 RefPtr<InspectorObject> result = InspectorObject::create();
717 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Console.clearMessages"), protocolErrors, error);
720 void InspectorBackendDispatcher::Console_setMonitoringXHREnabled(long callId, InspectorObject* requestMessageObject)
722 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
725 protocolErrors->pushString("Console handler is not available.");
729 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
730 InspectorObject* paramsContainerPtr = paramsContainer.get();
731 InspectorArray* protocolErrorsPtr = protocolErrors.get();
732 bool in_enabled = getBoolean(paramsContainerPtr, "enabled", 0, protocolErrorsPtr);
734 if (!protocolErrors->length())
735 m_consoleAgent->setMonitoringXHREnabled(&error, in_enabled);
737 RefPtr<InspectorObject> result = InspectorObject::create();
738 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Console.setMonitoringXHREnabled"), protocolErrors, error);
741 void InspectorBackendDispatcher::Console_addInspectedNode(long callId, InspectorObject* requestMessageObject)
743 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
746 protocolErrors->pushString("Console handler is not available.");
750 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
751 InspectorObject* paramsContainerPtr = paramsContainer.get();
752 InspectorArray* protocolErrorsPtr = protocolErrors.get();
753 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
755 if (!protocolErrors->length())
756 m_consoleAgent->addInspectedNode(&error, in_nodeId);
758 RefPtr<InspectorObject> result = InspectorObject::create();
759 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Console.addInspectedNode"), protocolErrors, error);
762 void InspectorBackendDispatcher::Network_enable(long callId, InspectorObject*)
764 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
767 protocolErrors->pushString("Network handler is not available.");
771 if (!protocolErrors->length())
772 m_networkAgent->enable(&error);
774 RefPtr<InspectorObject> result = InspectorObject::create();
775 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.enable"), protocolErrors, error);
778 void InspectorBackendDispatcher::Network_disable(long callId, InspectorObject*)
780 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
783 protocolErrors->pushString("Network handler is not available.");
787 if (!protocolErrors->length())
788 m_networkAgent->disable(&error);
790 RefPtr<InspectorObject> result = InspectorObject::create();
791 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.disable"), protocolErrors, error);
794 void InspectorBackendDispatcher::Network_setUserAgentOverride(long callId, InspectorObject* requestMessageObject)
796 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
799 protocolErrors->pushString("Network handler is not available.");
803 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
804 InspectorObject* paramsContainerPtr = paramsContainer.get();
805 InspectorArray* protocolErrorsPtr = protocolErrors.get();
806 String in_userAgent = getString(paramsContainerPtr, "userAgent", 0, protocolErrorsPtr);
808 if (!protocolErrors->length())
809 m_networkAgent->setUserAgentOverride(&error, in_userAgent);
811 RefPtr<InspectorObject> result = InspectorObject::create();
812 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.setUserAgentOverride"), protocolErrors, error);
815 void InspectorBackendDispatcher::Network_setExtraHTTPHeaders(long callId, InspectorObject* requestMessageObject)
817 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
820 protocolErrors->pushString("Network handler is not available.");
824 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
825 InspectorObject* paramsContainerPtr = paramsContainer.get();
826 InspectorArray* protocolErrorsPtr = protocolErrors.get();
827 RefPtr<InspectorObject> in_headers = getObject(paramsContainerPtr, "headers", 0, protocolErrorsPtr);
829 if (!protocolErrors->length())
830 m_networkAgent->setExtraHTTPHeaders(&error, in_headers);
832 RefPtr<InspectorObject> result = InspectorObject::create();
833 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.setExtraHTTPHeaders"), protocolErrors, error);
836 void InspectorBackendDispatcher::Network_getResponseBody(long callId, InspectorObject* requestMessageObject)
838 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
841 protocolErrors->pushString("Network handler is not available.");
843 String out_body = "";
844 bool out_base64Encoded = false;
848 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
849 InspectorObject* paramsContainerPtr = paramsContainer.get();
850 InspectorArray* protocolErrorsPtr = protocolErrors.get();
851 String in_requestId = getString(paramsContainerPtr, "requestId", 0, protocolErrorsPtr);
853 if (!protocolErrors->length())
854 m_networkAgent->getResponseBody(&error, in_requestId, &out_body, &out_base64Encoded);
856 RefPtr<InspectorObject> result = InspectorObject::create();
857 if (!protocolErrors->length() && !error.length()) {
858 result->setString("body", out_body);
859 result->setBoolean("base64Encoded", out_base64Encoded);
861 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.getResponseBody"), protocolErrors, error);
864 void InspectorBackendDispatcher::Network_clearBrowserCache(long callId, InspectorObject*)
866 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
869 protocolErrors->pushString("Network handler is not available.");
873 if (!protocolErrors->length())
874 m_networkAgent->clearBrowserCache(&error);
876 RefPtr<InspectorObject> result = InspectorObject::create();
877 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.clearBrowserCache"), protocolErrors, error);
880 void InspectorBackendDispatcher::Network_clearBrowserCookies(long callId, InspectorObject*)
882 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
885 protocolErrors->pushString("Network handler is not available.");
889 if (!protocolErrors->length())
890 m_networkAgent->clearBrowserCookies(&error);
892 RefPtr<InspectorObject> result = InspectorObject::create();
893 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.clearBrowserCookies"), protocolErrors, error);
896 void InspectorBackendDispatcher::Network_setCacheDisabled(long callId, InspectorObject* requestMessageObject)
898 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
901 protocolErrors->pushString("Network handler is not available.");
905 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
906 InspectorObject* paramsContainerPtr = paramsContainer.get();
907 InspectorArray* protocolErrorsPtr = protocolErrors.get();
908 bool in_cacheDisabled = getBoolean(paramsContainerPtr, "cacheDisabled", 0, protocolErrorsPtr);
910 if (!protocolErrors->length())
911 m_networkAgent->setCacheDisabled(&error, in_cacheDisabled);
913 RefPtr<InspectorObject> result = InspectorObject::create();
914 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.setCacheDisabled"), protocolErrors, error);
917 void InspectorBackendDispatcher::Database_enable(long callId, InspectorObject*)
919 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
921 if (!m_databaseAgent)
922 protocolErrors->pushString("Database handler is not available.");
926 if (!protocolErrors->length())
927 m_databaseAgent->enable(&error);
929 RefPtr<InspectorObject> result = InspectorObject::create();
930 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Database.enable"), protocolErrors, error);
933 void InspectorBackendDispatcher::Database_disable(long callId, InspectorObject*)
935 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
937 if (!m_databaseAgent)
938 protocolErrors->pushString("Database handler is not available.");
942 if (!protocolErrors->length())
943 m_databaseAgent->disable(&error);
945 RefPtr<InspectorObject> result = InspectorObject::create();
946 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Database.disable"), protocolErrors, error);
949 void InspectorBackendDispatcher::Database_getDatabaseTableNames(long callId, InspectorObject* requestMessageObject)
951 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
953 if (!m_databaseAgent)
954 protocolErrors->pushString("Database handler is not available.");
956 RefPtr<InspectorArray> out_tableNames = InspectorArray::create();
960 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
961 InspectorObject* paramsContainerPtr = paramsContainer.get();
962 InspectorArray* protocolErrorsPtr = protocolErrors.get();
963 int in_databaseId = getInt(paramsContainerPtr, "databaseId", 0, protocolErrorsPtr);
965 if (!protocolErrors->length())
966 m_databaseAgent->getDatabaseTableNames(&error, in_databaseId, &out_tableNames);
968 RefPtr<InspectorObject> result = InspectorObject::create();
969 if (!protocolErrors->length() && !error.length()) {
970 result->setArray("tableNames", out_tableNames);
972 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Database.getDatabaseTableNames"), protocolErrors, error);
975 void InspectorBackendDispatcher::Database_executeSQL(long callId, InspectorObject* requestMessageObject)
977 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
979 if (!m_databaseAgent)
980 protocolErrors->pushString("Database handler is not available.");
982 bool out_success = false;
983 int out_transactionId = 0;
987 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
988 InspectorObject* paramsContainerPtr = paramsContainer.get();
989 InspectorArray* protocolErrorsPtr = protocolErrors.get();
990 int in_databaseId = getInt(paramsContainerPtr, "databaseId", 0, protocolErrorsPtr);
991 String in_query = getString(paramsContainerPtr, "query", 0, protocolErrorsPtr);
993 if (!protocolErrors->length())
994 m_databaseAgent->executeSQL(&error, in_databaseId, in_query, &out_success, &out_transactionId);
996 RefPtr<InspectorObject> result = InspectorObject::create();
997 if (!protocolErrors->length() && !error.length()) {
998 result->setBoolean("success", out_success);
999 result->setNumber("transactionId", out_transactionId);
1001 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQL"), protocolErrors, error);
1004 void InspectorBackendDispatcher::DOMStorage_enable(long callId, InspectorObject*)
1006 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1008 if (!m_domStorageAgent)
1009 protocolErrors->pushString("DOMStorage handler is not available.");
1013 if (!protocolErrors->length())
1014 m_domStorageAgent->enable(&error);
1016 RefPtr<InspectorObject> result = InspectorObject::create();
1017 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMStorage.enable"), protocolErrors, error);
1020 void InspectorBackendDispatcher::DOMStorage_disable(long callId, InspectorObject*)
1022 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1024 if (!m_domStorageAgent)
1025 protocolErrors->pushString("DOMStorage handler is not available.");
1029 if (!protocolErrors->length())
1030 m_domStorageAgent->disable(&error);
1032 RefPtr<InspectorObject> result = InspectorObject::create();
1033 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMStorage.disable"), protocolErrors, error);
1036 void InspectorBackendDispatcher::DOMStorage_getDOMStorageEntries(long callId, InspectorObject* requestMessageObject)
1038 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1040 if (!m_domStorageAgent)
1041 protocolErrors->pushString("DOMStorage handler is not available.");
1043 RefPtr<InspectorArray> out_entries = InspectorArray::create();
1047 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1048 InspectorObject* paramsContainerPtr = paramsContainer.get();
1049 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1050 int in_storageId = getInt(paramsContainerPtr, "storageId", 0, protocolErrorsPtr);
1052 if (!protocolErrors->length())
1053 m_domStorageAgent->getDOMStorageEntries(&error, in_storageId, &out_entries);
1055 RefPtr<InspectorObject> result = InspectorObject::create();
1056 if (!protocolErrors->length() && !error.length()) {
1057 result->setArray("entries", out_entries);
1059 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMStorage.getDOMStorageEntries"), protocolErrors, error);
1062 void InspectorBackendDispatcher::DOMStorage_setDOMStorageItem(long callId, InspectorObject* requestMessageObject)
1064 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1066 if (!m_domStorageAgent)
1067 protocolErrors->pushString("DOMStorage handler is not available.");
1069 bool out_success = false;
1073 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1074 InspectorObject* paramsContainerPtr = paramsContainer.get();
1075 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1076 int in_storageId = getInt(paramsContainerPtr, "storageId", 0, protocolErrorsPtr);
1077 String in_key = getString(paramsContainerPtr, "key", 0, protocolErrorsPtr);
1078 String in_value = getString(paramsContainerPtr, "value", 0, protocolErrorsPtr);
1080 if (!protocolErrors->length())
1081 m_domStorageAgent->setDOMStorageItem(&error, in_storageId, in_key, in_value, &out_success);
1083 RefPtr<InspectorObject> result = InspectorObject::create();
1084 if (!protocolErrors->length() && !error.length()) {
1085 result->setBoolean("success", out_success);
1087 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMStorage.setDOMStorageItem"), protocolErrors, error);
1090 void InspectorBackendDispatcher::DOMStorage_removeDOMStorageItem(long callId, InspectorObject* requestMessageObject)
1092 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1094 if (!m_domStorageAgent)
1095 protocolErrors->pushString("DOMStorage handler is not available.");
1097 bool out_success = false;
1101 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1102 InspectorObject* paramsContainerPtr = paramsContainer.get();
1103 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1104 int in_storageId = getInt(paramsContainerPtr, "storageId", 0, protocolErrorsPtr);
1105 String in_key = getString(paramsContainerPtr, "key", 0, protocolErrorsPtr);
1107 if (!protocolErrors->length())
1108 m_domStorageAgent->removeDOMStorageItem(&error, in_storageId, in_key, &out_success);
1110 RefPtr<InspectorObject> result = InspectorObject::create();
1111 if (!protocolErrors->length() && !error.length()) {
1112 result->setBoolean("success", out_success);
1114 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMStorage.removeDOMStorageItem"), protocolErrors, error);
1117 void InspectorBackendDispatcher::ApplicationCache_getFramesWithManifests(long callId, InspectorObject*)
1119 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1121 if (!m_applicationCacheAgent)
1122 protocolErrors->pushString("ApplicationCache handler is not available.");
1124 RefPtr<InspectorArray> out_frameIds = InspectorArray::create();
1128 if (!protocolErrors->length())
1129 m_applicationCacheAgent->getFramesWithManifests(&error, &out_frameIds);
1131 RefPtr<InspectorObject> result = InspectorObject::create();
1132 if (!protocolErrors->length() && !error.length()) {
1133 result->setArray("frameIds", out_frameIds);
1135 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "ApplicationCache.getFramesWithManifests"), protocolErrors, error);
1138 void InspectorBackendDispatcher::ApplicationCache_enable(long callId, InspectorObject*)
1140 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1142 if (!m_applicationCacheAgent)
1143 protocolErrors->pushString("ApplicationCache handler is not available.");
1147 if (!protocolErrors->length())
1148 m_applicationCacheAgent->enable(&error);
1150 RefPtr<InspectorObject> result = InspectorObject::create();
1151 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "ApplicationCache.enable"), protocolErrors, error);
1154 void InspectorBackendDispatcher::ApplicationCache_getManifestForFrame(long callId, InspectorObject* requestMessageObject)
1156 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1158 if (!m_applicationCacheAgent)
1159 protocolErrors->pushString("ApplicationCache handler is not available.");
1161 String out_manifestURL = "";
1165 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1166 InspectorObject* paramsContainerPtr = paramsContainer.get();
1167 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1168 String in_frameId = getString(paramsContainerPtr, "frameId", 0, protocolErrorsPtr);
1170 if (!protocolErrors->length())
1171 m_applicationCacheAgent->getManifestForFrame(&error, in_frameId, &out_manifestURL);
1173 RefPtr<InspectorObject> result = InspectorObject::create();
1174 if (!protocolErrors->length() && !error.length()) {
1175 result->setString("manifestURL", out_manifestURL);
1177 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "ApplicationCache.getManifestForFrame"), protocolErrors, error);
1180 void InspectorBackendDispatcher::ApplicationCache_getApplicationCacheForFrame(long callId, InspectorObject* requestMessageObject)
1182 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1184 if (!m_applicationCacheAgent)
1185 protocolErrors->pushString("ApplicationCache handler is not available.");
1187 RefPtr<InspectorObject> out_applicationCache = InspectorObject::create();
1191 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1192 InspectorObject* paramsContainerPtr = paramsContainer.get();
1193 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1194 String in_frameId = getString(paramsContainerPtr, "frameId", 0, protocolErrorsPtr);
1196 if (!protocolErrors->length())
1197 m_applicationCacheAgent->getApplicationCacheForFrame(&error, in_frameId, &out_applicationCache);
1199 RefPtr<InspectorObject> result = InspectorObject::create();
1200 if (!protocolErrors->length() && !error.length()) {
1201 result->setObject("applicationCache", out_applicationCache);
1203 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "ApplicationCache.getApplicationCacheForFrame"), protocolErrors, error);
1206 void InspectorBackendDispatcher::FileSystem_enable(long callId, InspectorObject*)
1208 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1210 if (!m_fileSystemAgent)
1211 protocolErrors->pushString("FileSystem handler is not available.");
1215 if (!protocolErrors->length())
1216 m_fileSystemAgent->enable(&error);
1218 RefPtr<InspectorObject> result = InspectorObject::create();
1219 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "FileSystem.enable"), protocolErrors, error);
1222 void InspectorBackendDispatcher::FileSystem_disable(long callId, InspectorObject*)
1224 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1226 if (!m_fileSystemAgent)
1227 protocolErrors->pushString("FileSystem handler is not available.");
1231 if (!protocolErrors->length())
1232 m_fileSystemAgent->disable(&error);
1234 RefPtr<InspectorObject> result = InspectorObject::create();
1235 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "FileSystem.disable"), protocolErrors, error);
1238 void InspectorBackendDispatcher::DOM_getDocument(long callId, InspectorObject*)
1240 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1243 protocolErrors->pushString("DOM handler is not available.");
1245 RefPtr<InspectorObject> out_root = InspectorObject::create();
1249 if (!protocolErrors->length())
1250 m_domAgent->getDocument(&error, &out_root);
1252 RefPtr<InspectorObject> result = InspectorObject::create();
1253 if (!protocolErrors->length() && !error.length()) {
1254 result->setObject("root", out_root);
1256 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getDocument"), protocolErrors, error);
1259 void InspectorBackendDispatcher::DOM_requestChildNodes(long callId, InspectorObject* requestMessageObject)
1261 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1264 protocolErrors->pushString("DOM handler is not available.");
1268 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1269 InspectorObject* paramsContainerPtr = paramsContainer.get();
1270 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1271 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1273 if (!protocolErrors->length())
1274 m_domAgent->requestChildNodes(&error, in_nodeId);
1276 RefPtr<InspectorObject> result = InspectorObject::create();
1277 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.requestChildNodes"), protocolErrors, error);
1280 void InspectorBackendDispatcher::DOM_querySelector(long callId, InspectorObject* requestMessageObject)
1282 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1285 protocolErrors->pushString("DOM handler is not available.");
1291 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1292 InspectorObject* paramsContainerPtr = paramsContainer.get();
1293 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1294 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1295 String in_selector = getString(paramsContainerPtr, "selector", 0, protocolErrorsPtr);
1297 if (!protocolErrors->length())
1298 m_domAgent->querySelector(&error, in_nodeId, in_selector, &out_nodeId);
1300 RefPtr<InspectorObject> result = InspectorObject::create();
1301 if (!protocolErrors->length() && !error.length()) {
1302 result->setNumber("nodeId", out_nodeId);
1304 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.querySelector"), protocolErrors, error);
1307 void InspectorBackendDispatcher::DOM_querySelectorAll(long callId, InspectorObject* requestMessageObject)
1309 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1312 protocolErrors->pushString("DOM handler is not available.");
1314 RefPtr<InspectorArray> out_nodeIds = InspectorArray::create();
1318 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1319 InspectorObject* paramsContainerPtr = paramsContainer.get();
1320 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1321 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1322 String in_selector = getString(paramsContainerPtr, "selector", 0, protocolErrorsPtr);
1324 if (!protocolErrors->length())
1325 m_domAgent->querySelectorAll(&error, in_nodeId, in_selector, &out_nodeIds);
1327 RefPtr<InspectorObject> result = InspectorObject::create();
1328 if (!protocolErrors->length() && !error.length()) {
1329 result->setArray("nodeIds", out_nodeIds);
1331 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.querySelectorAll"), protocolErrors, error);
1334 void InspectorBackendDispatcher::DOM_setNodeName(long callId, InspectorObject* requestMessageObject)
1336 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1339 protocolErrors->pushString("DOM handler is not available.");
1345 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1346 InspectorObject* paramsContainerPtr = paramsContainer.get();
1347 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1348 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1349 String in_name = getString(paramsContainerPtr, "name", 0, protocolErrorsPtr);
1351 if (!protocolErrors->length())
1352 m_domAgent->setNodeName(&error, in_nodeId, in_name, &out_nodeId);
1354 RefPtr<InspectorObject> result = InspectorObject::create();
1355 if (!protocolErrors->length() && !error.length()) {
1356 result->setNumber("nodeId", out_nodeId);
1358 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.setNodeName"), protocolErrors, error);
1361 void InspectorBackendDispatcher::DOM_setNodeValue(long callId, InspectorObject* requestMessageObject)
1363 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1366 protocolErrors->pushString("DOM handler is not available.");
1370 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1371 InspectorObject* paramsContainerPtr = paramsContainer.get();
1372 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1373 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1374 String in_value = getString(paramsContainerPtr, "value", 0, protocolErrorsPtr);
1376 if (!protocolErrors->length())
1377 m_domAgent->setNodeValue(&error, in_nodeId, in_value);
1379 RefPtr<InspectorObject> result = InspectorObject::create();
1380 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.setNodeValue"), protocolErrors, error);
1383 void InspectorBackendDispatcher::DOM_removeNode(long callId, InspectorObject* requestMessageObject)
1385 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1388 protocolErrors->pushString("DOM handler is not available.");
1392 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1393 InspectorObject* paramsContainerPtr = paramsContainer.get();
1394 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1395 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1397 if (!protocolErrors->length())
1398 m_domAgent->removeNode(&error, in_nodeId);
1400 RefPtr<InspectorObject> result = InspectorObject::create();
1401 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.removeNode"), protocolErrors, error);
1404 void InspectorBackendDispatcher::DOM_setAttributeValue(long callId, InspectorObject* requestMessageObject)
1406 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1409 protocolErrors->pushString("DOM handler is not available.");
1413 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1414 InspectorObject* paramsContainerPtr = paramsContainer.get();
1415 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1416 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1417 String in_name = getString(paramsContainerPtr, "name", 0, protocolErrorsPtr);
1418 String in_value = getString(paramsContainerPtr, "value", 0, protocolErrorsPtr);
1420 if (!protocolErrors->length())
1421 m_domAgent->setAttributeValue(&error, in_nodeId, in_name, in_value);
1423 RefPtr<InspectorObject> result = InspectorObject::create();
1424 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.setAttributeValue"), protocolErrors, error);
1427 void InspectorBackendDispatcher::DOM_setAttributesAsText(long callId, InspectorObject* requestMessageObject)
1429 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1432 protocolErrors->pushString("DOM handler is not available.");
1436 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1437 InspectorObject* paramsContainerPtr = paramsContainer.get();
1438 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1439 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1440 String in_text = getString(paramsContainerPtr, "text", 0, protocolErrorsPtr);
1441 bool name_valueFound = false;
1442 String in_name = getString(paramsContainerPtr, "name", &name_valueFound, protocolErrorsPtr);
1444 if (!protocolErrors->length())
1445 m_domAgent->setAttributesAsText(&error, in_nodeId, in_text, name_valueFound ? &in_name : 0);
1447 RefPtr<InspectorObject> result = InspectorObject::create();
1448 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.setAttributesAsText"), protocolErrors, error);
1451 void InspectorBackendDispatcher::DOM_removeAttribute(long callId, InspectorObject* requestMessageObject)
1453 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1456 protocolErrors->pushString("DOM handler is not available.");
1460 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1461 InspectorObject* paramsContainerPtr = paramsContainer.get();
1462 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1463 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1464 String in_name = getString(paramsContainerPtr, "name", 0, protocolErrorsPtr);
1466 if (!protocolErrors->length())
1467 m_domAgent->removeAttribute(&error, in_nodeId, in_name);
1469 RefPtr<InspectorObject> result = InspectorObject::create();
1470 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.removeAttribute"), protocolErrors, error);
1473 void InspectorBackendDispatcher::DOM_getEventListenersForNode(long callId, InspectorObject* requestMessageObject)
1475 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1478 protocolErrors->pushString("DOM handler is not available.");
1480 RefPtr<InspectorArray> out_listeners = InspectorArray::create();
1484 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1485 InspectorObject* paramsContainerPtr = paramsContainer.get();
1486 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1487 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1489 if (!protocolErrors->length())
1490 m_domAgent->getEventListenersForNode(&error, in_nodeId, &out_listeners);
1492 RefPtr<InspectorObject> result = InspectorObject::create();
1493 if (!protocolErrors->length() && !error.length()) {
1494 result->setArray("listeners", out_listeners);
1496 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getEventListenersForNode"), protocolErrors, error);
1499 void InspectorBackendDispatcher::DOM_copyNode(long callId, InspectorObject* requestMessageObject)
1501 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1504 protocolErrors->pushString("DOM handler is not available.");
1508 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1509 InspectorObject* paramsContainerPtr = paramsContainer.get();
1510 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1511 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1513 if (!protocolErrors->length())
1514 m_domAgent->copyNode(&error, in_nodeId);
1516 RefPtr<InspectorObject> result = InspectorObject::create();
1517 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.copyNode"), protocolErrors, error);
1520 void InspectorBackendDispatcher::DOM_getOuterHTML(long callId, InspectorObject* requestMessageObject)
1522 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1525 protocolErrors->pushString("DOM handler is not available.");
1527 String out_outerHTML = "";
1531 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1532 InspectorObject* paramsContainerPtr = paramsContainer.get();
1533 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1534 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1536 if (!protocolErrors->length())
1537 m_domAgent->getOuterHTML(&error, in_nodeId, &out_outerHTML);
1539 RefPtr<InspectorObject> result = InspectorObject::create();
1540 if (!protocolErrors->length() && !error.length()) {
1541 result->setString("outerHTML", out_outerHTML);
1543 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getOuterHTML"), protocolErrors, error);
1546 void InspectorBackendDispatcher::DOM_setOuterHTML(long callId, InspectorObject* requestMessageObject)
1548 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1551 protocolErrors->pushString("DOM handler is not available.");
1557 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1558 InspectorObject* paramsContainerPtr = paramsContainer.get();
1559 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1560 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1561 String in_outerHTML = getString(paramsContainerPtr, "outerHTML", 0, protocolErrorsPtr);
1563 if (!protocolErrors->length())
1564 m_domAgent->setOuterHTML(&error, in_nodeId, in_outerHTML, &out_nodeId);
1566 RefPtr<InspectorObject> result = InspectorObject::create();
1567 if (!protocolErrors->length() && !error.length()) {
1568 result->setNumber("nodeId", out_nodeId);
1570 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.setOuterHTML"), protocolErrors, error);
1573 void InspectorBackendDispatcher::DOM_performSearch(long callId, InspectorObject* requestMessageObject)
1575 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1578 protocolErrors->pushString("DOM handler is not available.");
1580 String out_searchId = "";
1581 int out_resultCount = 0;
1585 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1586 InspectorObject* paramsContainerPtr = paramsContainer.get();
1587 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1588 String in_query = getString(paramsContainerPtr, "query", 0, protocolErrorsPtr);
1590 if (!protocolErrors->length())
1591 m_domAgent->performSearch(&error, in_query, &out_searchId, &out_resultCount);
1593 RefPtr<InspectorObject> result = InspectorObject::create();
1594 if (!protocolErrors->length() && !error.length()) {
1595 result->setString("searchId", out_searchId);
1596 result->setNumber("resultCount", out_resultCount);
1598 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.performSearch"), protocolErrors, error);
1601 void InspectorBackendDispatcher::DOM_getSearchResults(long callId, InspectorObject* requestMessageObject)
1603 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1606 protocolErrors->pushString("DOM handler is not available.");
1608 RefPtr<InspectorArray> out_nodeIds = InspectorArray::create();
1612 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1613 InspectorObject* paramsContainerPtr = paramsContainer.get();
1614 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1615 String in_searchId = getString(paramsContainerPtr, "searchId", 0, protocolErrorsPtr);
1616 int in_fromIndex = getInt(paramsContainerPtr, "fromIndex", 0, protocolErrorsPtr);
1617 int in_toIndex = getInt(paramsContainerPtr, "toIndex", 0, protocolErrorsPtr);
1619 if (!protocolErrors->length())
1620 m_domAgent->getSearchResults(&error, in_searchId, in_fromIndex, in_toIndex, &out_nodeIds);
1622 RefPtr<InspectorObject> result = InspectorObject::create();
1623 if (!protocolErrors->length() && !error.length()) {
1624 result->setArray("nodeIds", out_nodeIds);
1626 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getSearchResults"), protocolErrors, error);
1629 void InspectorBackendDispatcher::DOM_discardSearchResults(long callId, InspectorObject* requestMessageObject)
1631 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1634 protocolErrors->pushString("DOM handler is not available.");
1638 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1639 InspectorObject* paramsContainerPtr = paramsContainer.get();
1640 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1641 String in_searchId = getString(paramsContainerPtr, "searchId", 0, protocolErrorsPtr);
1643 if (!protocolErrors->length())
1644 m_domAgent->discardSearchResults(&error, in_searchId);
1646 RefPtr<InspectorObject> result = InspectorObject::create();
1647 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.discardSearchResults"), protocolErrors, error);
1650 void InspectorBackendDispatcher::DOM_requestNode(long callId, InspectorObject* requestMessageObject)
1652 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1655 protocolErrors->pushString("DOM handler is not available.");
1661 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1662 InspectorObject* paramsContainerPtr = paramsContainer.get();
1663 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1664 String in_objectId = getString(paramsContainerPtr, "objectId", 0, protocolErrorsPtr);
1666 if (!protocolErrors->length())
1667 m_domAgent->requestNode(&error, in_objectId, &out_nodeId);
1669 RefPtr<InspectorObject> result = InspectorObject::create();
1670 if (!protocolErrors->length() && !error.length()) {
1671 result->setNumber("nodeId", out_nodeId);
1673 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.requestNode"), protocolErrors, error);
1676 void InspectorBackendDispatcher::DOM_setInspectModeEnabled(long callId, InspectorObject* requestMessageObject)
1678 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1681 protocolErrors->pushString("DOM handler is not available.");
1685 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1686 InspectorObject* paramsContainerPtr = paramsContainer.get();
1687 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1688 bool in_enabled = getBoolean(paramsContainerPtr, "enabled", 0, protocolErrorsPtr);
1689 bool highlightConfig_valueFound = false;
1690 RefPtr<InspectorObject> in_highlightConfig = getObject(paramsContainerPtr, "highlightConfig", &highlightConfig_valueFound, protocolErrorsPtr);
1692 if (!protocolErrors->length())
1693 m_domAgent->setInspectModeEnabled(&error, in_enabled, highlightConfig_valueFound ? &in_highlightConfig : 0);
1695 RefPtr<InspectorObject> result = InspectorObject::create();
1696 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.setInspectModeEnabled"), protocolErrors, error);
1699 void InspectorBackendDispatcher::DOM_highlightRect(long callId, InspectorObject* requestMessageObject)
1701 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1704 protocolErrors->pushString("DOM handler is not available.");
1708 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1709 InspectorObject* paramsContainerPtr = paramsContainer.get();
1710 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1711 int in_x = getInt(paramsContainerPtr, "x", 0, protocolErrorsPtr);
1712 int in_y = getInt(paramsContainerPtr, "y", 0, protocolErrorsPtr);
1713 int in_width = getInt(paramsContainerPtr, "width", 0, protocolErrorsPtr);
1714 int in_height = getInt(paramsContainerPtr, "height", 0, protocolErrorsPtr);
1715 bool color_valueFound = false;
1716 RefPtr<InspectorObject> in_color = getObject(paramsContainerPtr, "color", &color_valueFound, protocolErrorsPtr);
1717 bool outlineColor_valueFound = false;
1718 RefPtr<InspectorObject> in_outlineColor = getObject(paramsContainerPtr, "outlineColor", &outlineColor_valueFound, protocolErrorsPtr);
1720 if (!protocolErrors->length())
1721 m_domAgent->highlightRect(&error, in_x, in_y, in_width, in_height, color_valueFound ? &in_color : 0, outlineColor_valueFound ? &in_outlineColor : 0);
1723 RefPtr<InspectorObject> result = InspectorObject::create();
1724 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.highlightRect"), protocolErrors, error);
1727 void InspectorBackendDispatcher::DOM_highlightNode(long callId, InspectorObject* requestMessageObject)
1729 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1732 protocolErrors->pushString("DOM handler is not available.");
1736 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1737 InspectorObject* paramsContainerPtr = paramsContainer.get();
1738 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1739 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1740 RefPtr<InspectorObject> in_highlightConfig = getObject(paramsContainerPtr, "highlightConfig", 0, protocolErrorsPtr);
1742 if (!protocolErrors->length())
1743 m_domAgent->highlightNode(&error, in_nodeId, in_highlightConfig);
1745 RefPtr<InspectorObject> result = InspectorObject::create();
1746 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.highlightNode"), protocolErrors, error);
1749 void InspectorBackendDispatcher::DOM_hideHighlight(long callId, InspectorObject*)
1751 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1754 protocolErrors->pushString("DOM handler is not available.");
1758 if (!protocolErrors->length())
1759 m_domAgent->hideHighlight(&error);
1761 RefPtr<InspectorObject> result = InspectorObject::create();
1762 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.hideHighlight"), protocolErrors, error);
1765 void InspectorBackendDispatcher::DOM_highlightFrame(long callId, InspectorObject* requestMessageObject)
1767 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1770 protocolErrors->pushString("DOM handler is not available.");
1774 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1775 InspectorObject* paramsContainerPtr = paramsContainer.get();
1776 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1777 String in_frameId = getString(paramsContainerPtr, "frameId", 0, protocolErrorsPtr);
1778 bool contentColor_valueFound = false;
1779 RefPtr<InspectorObject> in_contentColor = getObject(paramsContainerPtr, "contentColor", &contentColor_valueFound, protocolErrorsPtr);
1780 bool contentOutlineColor_valueFound = false;
1781 RefPtr<InspectorObject> in_contentOutlineColor = getObject(paramsContainerPtr, "contentOutlineColor", &contentOutlineColor_valueFound, protocolErrorsPtr);
1783 if (!protocolErrors->length())
1784 m_domAgent->highlightFrame(&error, in_frameId, contentColor_valueFound ? &in_contentColor : 0, contentOutlineColor_valueFound ? &in_contentOutlineColor : 0);
1786 RefPtr<InspectorObject> result = InspectorObject::create();
1787 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.highlightFrame"), protocolErrors, error);
1790 void InspectorBackendDispatcher::DOM_pushNodeByPathToFrontend(long callId, InspectorObject* requestMessageObject)
1792 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1795 protocolErrors->pushString("DOM handler is not available.");
1801 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1802 InspectorObject* paramsContainerPtr = paramsContainer.get();
1803 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1804 String in_path = getString(paramsContainerPtr, "path", 0, protocolErrorsPtr);
1806 if (!protocolErrors->length())
1807 m_domAgent->pushNodeByPathToFrontend(&error, in_path, &out_nodeId);
1809 RefPtr<InspectorObject> result = InspectorObject::create();
1810 if (!protocolErrors->length() && !error.length()) {
1811 result->setNumber("nodeId", out_nodeId);
1813 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.pushNodeByPathToFrontend"), protocolErrors, error);
1816 void InspectorBackendDispatcher::DOM_resolveNode(long callId, InspectorObject* requestMessageObject)
1818 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1821 protocolErrors->pushString("DOM handler is not available.");
1823 RefPtr<InspectorObject> out_object = InspectorObject::create();
1827 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1828 InspectorObject* paramsContainerPtr = paramsContainer.get();
1829 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1830 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1831 bool objectGroup_valueFound = false;
1832 String in_objectGroup = getString(paramsContainerPtr, "objectGroup", &objectGroup_valueFound, protocolErrorsPtr);
1834 if (!protocolErrors->length())
1835 m_domAgent->resolveNode(&error, in_nodeId, objectGroup_valueFound ? &in_objectGroup : 0, &out_object);
1837 RefPtr<InspectorObject> result = InspectorObject::create();
1838 if (!protocolErrors->length() && !error.length()) {
1839 result->setObject("object", out_object);
1841 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.resolveNode"), protocolErrors, error);
1844 void InspectorBackendDispatcher::DOM_getAttributes(long callId, InspectorObject* requestMessageObject)
1846 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1849 protocolErrors->pushString("DOM handler is not available.");
1851 RefPtr<InspectorArray> out_attributes = InspectorArray::create();
1855 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1856 InspectorObject* paramsContainerPtr = paramsContainer.get();
1857 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1858 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1860 if (!protocolErrors->length())
1861 m_domAgent->getAttributes(&error, in_nodeId, &out_attributes);
1863 RefPtr<InspectorObject> result = InspectorObject::create();
1864 if (!protocolErrors->length() && !error.length()) {
1865 result->setArray("attributes", out_attributes);
1867 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getAttributes"), protocolErrors, error);
1870 void InspectorBackendDispatcher::DOM_moveTo(long callId, InspectorObject* requestMessageObject)
1872 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1875 protocolErrors->pushString("DOM handler is not available.");
1881 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1882 InspectorObject* paramsContainerPtr = paramsContainer.get();
1883 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1884 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1885 int in_targetNodeId = getInt(paramsContainerPtr, "targetNodeId", 0, protocolErrorsPtr);
1886 bool insertBeforeNodeId_valueFound = false;
1887 int in_insertBeforeNodeId = getInt(paramsContainerPtr, "insertBeforeNodeId", &insertBeforeNodeId_valueFound, protocolErrorsPtr);
1889 if (!protocolErrors->length())
1890 m_domAgent->moveTo(&error, in_nodeId, in_targetNodeId, insertBeforeNodeId_valueFound ? &in_insertBeforeNodeId : 0, &out_nodeId);
1892 RefPtr<InspectorObject> result = InspectorObject::create();
1893 if (!protocolErrors->length() && !error.length()) {
1894 result->setNumber("nodeId", out_nodeId);
1896 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.moveTo"), protocolErrors, error);
1899 void InspectorBackendDispatcher::CSS_getMatchedStylesForNode(long callId, InspectorObject* requestMessageObject)
1901 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1904 protocolErrors->pushString("CSS handler is not available.");
1906 RefPtr<InspectorArray> out_matchedCSSRules = InspectorArray::create();
1907 RefPtr<InspectorArray> out_pseudoElements = InspectorArray::create();
1908 RefPtr<InspectorArray> out_inherited = InspectorArray::create();
1912 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1913 InspectorObject* paramsContainerPtr = paramsContainer.get();
1914 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1915 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1916 bool forcedPseudoClasses_valueFound = false;
1917 RefPtr<InspectorArray> in_forcedPseudoClasses = getArray(paramsContainerPtr, "forcedPseudoClasses", &forcedPseudoClasses_valueFound, protocolErrorsPtr);
1918 bool includePseudo_valueFound = false;
1919 bool in_includePseudo = getBoolean(paramsContainerPtr, "includePseudo", &includePseudo_valueFound, protocolErrorsPtr);
1920 bool includeInherited_valueFound = false;
1921 bool in_includeInherited = getBoolean(paramsContainerPtr, "includeInherited", &includeInherited_valueFound, protocolErrorsPtr);
1923 if (!protocolErrors->length())
1924 m_cssAgent->getMatchedStylesForNode(&error, in_nodeId, forcedPseudoClasses_valueFound ? &in_forcedPseudoClasses : 0, includePseudo_valueFound ? &in_includePseudo : 0, includeInherited_valueFound ? &in_includeInherited : 0, &out_matchedCSSRules, &out_pseudoElements, &out_inherited);
1926 RefPtr<InspectorObject> result = InspectorObject::create();
1927 if (!protocolErrors->length() && !error.length()) {
1928 result->setArray("matchedCSSRules", out_matchedCSSRules);
1929 result->setArray("pseudoElements", out_pseudoElements);
1930 result->setArray("inherited", out_inherited);
1932 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getMatchedStylesForNode"), protocolErrors, error);
1935 void InspectorBackendDispatcher::CSS_getInlineStylesForNode(long callId, InspectorObject* requestMessageObject)
1937 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1940 protocolErrors->pushString("CSS handler is not available.");
1942 RefPtr<InspectorObject> out_inlineStyle = InspectorObject::create();
1943 RefPtr<InspectorArray> out_styleAttributes = InspectorArray::create();
1947 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1948 InspectorObject* paramsContainerPtr = paramsContainer.get();
1949 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1950 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1952 if (!protocolErrors->length())
1953 m_cssAgent->getInlineStylesForNode(&error, in_nodeId, &out_inlineStyle, &out_styleAttributes);
1955 RefPtr<InspectorObject> result = InspectorObject::create();
1956 if (!protocolErrors->length() && !error.length()) {
1957 result->setObject("inlineStyle", out_inlineStyle);
1958 result->setArray("styleAttributes", out_styleAttributes);
1960 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getInlineStylesForNode"), protocolErrors, error);
1963 void InspectorBackendDispatcher::CSS_getComputedStyleForNode(long callId, InspectorObject* requestMessageObject)
1965 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1968 protocolErrors->pushString("CSS handler is not available.");
1970 RefPtr<InspectorArray> out_computedStyle = InspectorArray::create();
1974 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
1975 InspectorObject* paramsContainerPtr = paramsContainer.get();
1976 InspectorArray* protocolErrorsPtr = protocolErrors.get();
1977 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
1978 bool forcedPseudoClasses_valueFound = false;
1979 RefPtr<InspectorArray> in_forcedPseudoClasses = getArray(paramsContainerPtr, "forcedPseudoClasses", &forcedPseudoClasses_valueFound, protocolErrorsPtr);
1981 if (!protocolErrors->length())
1982 m_cssAgent->getComputedStyleForNode(&error, in_nodeId, forcedPseudoClasses_valueFound ? &in_forcedPseudoClasses : 0, &out_computedStyle);
1984 RefPtr<InspectorObject> result = InspectorObject::create();
1985 if (!protocolErrors->length() && !error.length()) {
1986 result->setArray("computedStyle", out_computedStyle);
1988 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getComputedStyleForNode"), protocolErrors, error);
1991 void InspectorBackendDispatcher::CSS_getAllStyleSheets(long callId, InspectorObject*)
1993 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1996 protocolErrors->pushString("CSS handler is not available.");
1998 RefPtr<InspectorArray> out_headers = InspectorArray::create();
2002 if (!protocolErrors->length())
2003 m_cssAgent->getAllStyleSheets(&error, &out_headers);
2005 RefPtr<InspectorObject> result = InspectorObject::create();
2006 if (!protocolErrors->length() && !error.length()) {
2007 result->setArray("headers", out_headers);
2009 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getAllStyleSheets"), protocolErrors, error);
2012 void InspectorBackendDispatcher::CSS_getStyleSheet(long callId, InspectorObject* requestMessageObject)
2014 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2017 protocolErrors->pushString("CSS handler is not available.");
2019 RefPtr<InspectorObject> out_styleSheet = InspectorObject::create();
2023 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2024 InspectorObject* paramsContainerPtr = paramsContainer.get();
2025 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2026 String in_styleSheetId = getString(paramsContainerPtr, "styleSheetId", 0, protocolErrorsPtr);
2028 if (!protocolErrors->length())
2029 m_cssAgent->getStyleSheet(&error, in_styleSheetId, &out_styleSheet);
2031 RefPtr<InspectorObject> result = InspectorObject::create();
2032 if (!protocolErrors->length() && !error.length()) {
2033 result->setObject("styleSheet", out_styleSheet);
2035 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getStyleSheet"), protocolErrors, error);
2038 void InspectorBackendDispatcher::CSS_getStyleSheetText(long callId, InspectorObject* requestMessageObject)
2040 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2043 protocolErrors->pushString("CSS handler is not available.");
2045 String out_text = "";
2049 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2050 InspectorObject* paramsContainerPtr = paramsContainer.get();
2051 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2052 String in_styleSheetId = getString(paramsContainerPtr, "styleSheetId", 0, protocolErrorsPtr);
2054 if (!protocolErrors->length())
2055 m_cssAgent->getStyleSheetText(&error, in_styleSheetId, &out_text);
2057 RefPtr<InspectorObject> result = InspectorObject::create();
2058 if (!protocolErrors->length() && !error.length()) {
2059 result->setString("text", out_text);
2061 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getStyleSheetText"), protocolErrors, error);
2064 void InspectorBackendDispatcher::CSS_setStyleSheetText(long callId, InspectorObject* requestMessageObject)
2066 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2069 protocolErrors->pushString("CSS handler is not available.");
2073 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2074 InspectorObject* paramsContainerPtr = paramsContainer.get();
2075 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2076 String in_styleSheetId = getString(paramsContainerPtr, "styleSheetId", 0, protocolErrorsPtr);
2077 String in_text = getString(paramsContainerPtr, "text", 0, protocolErrorsPtr);
2079 if (!protocolErrors->length())
2080 m_cssAgent->setStyleSheetText(&error, in_styleSheetId, in_text);
2082 RefPtr<InspectorObject> result = InspectorObject::create();
2083 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.setStyleSheetText"), protocolErrors, error);
2086 void InspectorBackendDispatcher::CSS_setPropertyText(long callId, InspectorObject* requestMessageObject)
2088 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2091 protocolErrors->pushString("CSS handler is not available.");
2093 RefPtr<InspectorObject> out_style = InspectorObject::create();
2097 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2098 InspectorObject* paramsContainerPtr = paramsContainer.get();
2099 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2100 RefPtr<InspectorObject> in_styleId = getObject(paramsContainerPtr, "styleId", 0, protocolErrorsPtr);
2101 int in_propertyIndex = getInt(paramsContainerPtr, "propertyIndex", 0, protocolErrorsPtr);
2102 String in_text = getString(paramsContainerPtr, "text", 0, protocolErrorsPtr);
2103 bool in_overwrite = getBoolean(paramsContainerPtr, "overwrite", 0, protocolErrorsPtr);
2105 if (!protocolErrors->length())
2106 m_cssAgent->setPropertyText(&error, in_styleId, in_propertyIndex, in_text, in_overwrite, &out_style);
2108 RefPtr<InspectorObject> result = InspectorObject::create();
2109 if (!protocolErrors->length() && !error.length()) {
2110 result->setObject("style", out_style);
2112 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.setPropertyText"), protocolErrors, error);
2115 void InspectorBackendDispatcher::CSS_toggleProperty(long callId, InspectorObject* requestMessageObject)
2117 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2120 protocolErrors->pushString("CSS handler is not available.");
2122 RefPtr<InspectorObject> out_style = InspectorObject::create();
2126 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2127 InspectorObject* paramsContainerPtr = paramsContainer.get();
2128 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2129 RefPtr<InspectorObject> in_styleId = getObject(paramsContainerPtr, "styleId", 0, protocolErrorsPtr);
2130 int in_propertyIndex = getInt(paramsContainerPtr, "propertyIndex", 0, protocolErrorsPtr);
2131 bool in_disable = getBoolean(paramsContainerPtr, "disable", 0, protocolErrorsPtr);
2133 if (!protocolErrors->length())
2134 m_cssAgent->toggleProperty(&error, in_styleId, in_propertyIndex, in_disable, &out_style);
2136 RefPtr<InspectorObject> result = InspectorObject::create();
2137 if (!protocolErrors->length() && !error.length()) {
2138 result->setObject("style", out_style);
2140 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.toggleProperty"), protocolErrors, error);
2143 void InspectorBackendDispatcher::CSS_setRuleSelector(long callId, InspectorObject* requestMessageObject)
2145 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2148 protocolErrors->pushString("CSS handler is not available.");
2150 RefPtr<InspectorObject> out_rule = InspectorObject::create();
2154 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2155 InspectorObject* paramsContainerPtr = paramsContainer.get();
2156 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2157 RefPtr<InspectorObject> in_ruleId = getObject(paramsContainerPtr, "ruleId", 0, protocolErrorsPtr);
2158 String in_selector = getString(paramsContainerPtr, "selector", 0, protocolErrorsPtr);
2160 if (!protocolErrors->length())
2161 m_cssAgent->setRuleSelector(&error, in_ruleId, in_selector, &out_rule);
2163 RefPtr<InspectorObject> result = InspectorObject::create();
2164 if (!protocolErrors->length() && !error.length()) {
2165 result->setObject("rule", out_rule);
2167 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.setRuleSelector"), protocolErrors, error);
2170 void InspectorBackendDispatcher::CSS_addRule(long callId, InspectorObject* requestMessageObject)
2172 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2175 protocolErrors->pushString("CSS handler is not available.");
2177 RefPtr<InspectorObject> out_rule = InspectorObject::create();
2181 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2182 InspectorObject* paramsContainerPtr = paramsContainer.get();
2183 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2184 int in_contextNodeId = getInt(paramsContainerPtr, "contextNodeId", 0, protocolErrorsPtr);
2185 String in_selector = getString(paramsContainerPtr, "selector", 0, protocolErrorsPtr);
2187 if (!protocolErrors->length())
2188 m_cssAgent->addRule(&error, in_contextNodeId, in_selector, &out_rule);
2190 RefPtr<InspectorObject> result = InspectorObject::create();
2191 if (!protocolErrors->length() && !error.length()) {
2192 result->setObject("rule", out_rule);
2194 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.addRule"), protocolErrors, error);
2197 void InspectorBackendDispatcher::CSS_getSupportedCSSProperties(long callId, InspectorObject*)
2199 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2202 protocolErrors->pushString("CSS handler is not available.");
2204 RefPtr<InspectorArray> out_cssProperties = InspectorArray::create();
2208 if (!protocolErrors->length())
2209 m_cssAgent->getSupportedCSSProperties(&error, &out_cssProperties);
2211 RefPtr<InspectorObject> result = InspectorObject::create();
2212 if (!protocolErrors->length() && !error.length()) {
2213 result->setArray("cssProperties", out_cssProperties);
2215 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getSupportedCSSProperties"), protocolErrors, error);
2218 void InspectorBackendDispatcher::Timeline_start(long callId, InspectorObject* requestMessageObject)
2220 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2222 if (!m_timelineAgent)
2223 protocolErrors->pushString("Timeline handler is not available.");
2227 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2228 InspectorObject* paramsContainerPtr = paramsContainer.get();
2229 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2230 bool maxCallStackDepth_valueFound = false;
2231 int in_maxCallStackDepth = getInt(paramsContainerPtr, "maxCallStackDepth", &maxCallStackDepth_valueFound, protocolErrorsPtr);
2233 if (!protocolErrors->length())
2234 m_timelineAgent->start(&error, maxCallStackDepth_valueFound ? &in_maxCallStackDepth : 0);
2236 RefPtr<InspectorObject> result = InspectorObject::create();
2237 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Timeline.start"), protocolErrors, error);
2240 void InspectorBackendDispatcher::Timeline_stop(long callId, InspectorObject*)
2242 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2244 if (!m_timelineAgent)
2245 protocolErrors->pushString("Timeline handler is not available.");
2249 if (!protocolErrors->length())
2250 m_timelineAgent->stop(&error);
2252 RefPtr<InspectorObject> result = InspectorObject::create();
2253 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Timeline.stop"), protocolErrors, error);
2256 void InspectorBackendDispatcher::Debugger_enable(long callId, InspectorObject*)
2258 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2260 if (!m_debuggerAgent)
2261 protocolErrors->pushString("Debugger handler is not available.");
2265 if (!protocolErrors->length())
2266 m_debuggerAgent->enable(&error);
2268 RefPtr<InspectorObject> result = InspectorObject::create();
2269 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.enable"), protocolErrors, error);
2272 void InspectorBackendDispatcher::Debugger_disable(long callId, InspectorObject*)
2274 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2276 if (!m_debuggerAgent)
2277 protocolErrors->pushString("Debugger handler is not available.");
2281 if (!protocolErrors->length())
2282 m_debuggerAgent->disable(&error);
2284 RefPtr<InspectorObject> result = InspectorObject::create();
2285 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.disable"), protocolErrors, error);
2288 void InspectorBackendDispatcher::Debugger_setBreakpointsActive(long callId, InspectorObject* requestMessageObject)
2290 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2292 if (!m_debuggerAgent)
2293 protocolErrors->pushString("Debugger handler is not available.");
2297 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2298 InspectorObject* paramsContainerPtr = paramsContainer.get();
2299 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2300 bool in_active = getBoolean(paramsContainerPtr, "active", 0, protocolErrorsPtr);
2302 if (!protocolErrors->length())
2303 m_debuggerAgent->setBreakpointsActive(&error, in_active);
2305 RefPtr<InspectorObject> result = InspectorObject::create();
2306 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.setBreakpointsActive"), protocolErrors, error);
2309 void InspectorBackendDispatcher::Debugger_setBreakpointByUrl(long callId, InspectorObject* requestMessageObject)
2311 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2313 if (!m_debuggerAgent)
2314 protocolErrors->pushString("Debugger handler is not available.");
2316 String out_breakpointId = "";
2317 RefPtr<InspectorArray> out_locations = InspectorArray::create();
2321 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2322 InspectorObject* paramsContainerPtr = paramsContainer.get();
2323 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2324 int in_lineNumber = getInt(paramsContainerPtr, "lineNumber", 0, protocolErrorsPtr);
2325 bool url_valueFound = false;
2326 String in_url = getString(paramsContainerPtr, "url", &url_valueFound, protocolErrorsPtr);
2327 bool urlRegex_valueFound = false;
2328 String in_urlRegex = getString(paramsContainerPtr, "urlRegex", &urlRegex_valueFound, protocolErrorsPtr);
2329 bool columnNumber_valueFound = false;
2330 int in_columnNumber = getInt(paramsContainerPtr, "columnNumber", &columnNumber_valueFound, protocolErrorsPtr);
2331 bool condition_valueFound = false;
2332 String in_condition = getString(paramsContainerPtr, "condition", &condition_valueFound, protocolErrorsPtr);
2334 if (!protocolErrors->length())
2335 m_debuggerAgent->setBreakpointByUrl(&error, in_lineNumber, url_valueFound ? &in_url : 0, urlRegex_valueFound ? &in_urlRegex : 0, columnNumber_valueFound ? &in_columnNumber : 0, condition_valueFound ? &in_condition : 0, &out_breakpointId, &out_locations);
2337 RefPtr<InspectorObject> result = InspectorObject::create();
2338 if (!protocolErrors->length() && !error.length()) {
2339 result->setString("breakpointId", out_breakpointId);
2340 result->setArray("locations", out_locations);
2342 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.setBreakpointByUrl"), protocolErrors, error);
2345 void InspectorBackendDispatcher::Debugger_setBreakpoint(long callId, InspectorObject* requestMessageObject)
2347 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2349 if (!m_debuggerAgent)
2350 protocolErrors->pushString("Debugger handler is not available.");
2352 String out_breakpointId = "";
2353 RefPtr<InspectorObject> out_actualLocation = InspectorObject::create();
2357 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2358 InspectorObject* paramsContainerPtr = paramsContainer.get();
2359 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2360 RefPtr<InspectorObject> in_location = getObject(paramsContainerPtr, "location", 0, protocolErrorsPtr);
2361 bool condition_valueFound = false;
2362 String in_condition = getString(paramsContainerPtr, "condition", &condition_valueFound, protocolErrorsPtr);
2364 if (!protocolErrors->length())
2365 m_debuggerAgent->setBreakpoint(&error, in_location, condition_valueFound ? &in_condition : 0, &out_breakpointId, &out_actualLocation);
2367 RefPtr<InspectorObject> result = InspectorObject::create();
2368 if (!protocolErrors->length() && !error.length()) {
2369 result->setString("breakpointId", out_breakpointId);
2370 result->setObject("actualLocation", out_actualLocation);
2372 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.setBreakpoint"), protocolErrors, error);
2375 void InspectorBackendDispatcher::Debugger_removeBreakpoint(long callId, InspectorObject* requestMessageObject)
2377 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2379 if (!m_debuggerAgent)
2380 protocolErrors->pushString("Debugger handler is not available.");
2384 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2385 InspectorObject* paramsContainerPtr = paramsContainer.get();
2386 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2387 String in_breakpointId = getString(paramsContainerPtr, "breakpointId", 0, protocolErrorsPtr);
2389 if (!protocolErrors->length())
2390 m_debuggerAgent->removeBreakpoint(&error, in_breakpointId);
2392 RefPtr<InspectorObject> result = InspectorObject::create();
2393 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.removeBreakpoint"), protocolErrors, error);
2396 void InspectorBackendDispatcher::Debugger_continueToLocation(long callId, InspectorObject* requestMessageObject)
2398 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2400 if (!m_debuggerAgent)
2401 protocolErrors->pushString("Debugger handler is not available.");
2405 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2406 InspectorObject* paramsContainerPtr = paramsContainer.get();
2407 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2408 RefPtr<InspectorObject> in_location = getObject(paramsContainerPtr, "location", 0, protocolErrorsPtr);
2410 if (!protocolErrors->length())
2411 m_debuggerAgent->continueToLocation(&error, in_location);
2413 RefPtr<InspectorObject> result = InspectorObject::create();
2414 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.continueToLocation"), protocolErrors, error);
2417 void InspectorBackendDispatcher::Debugger_stepOver(long callId, InspectorObject*)
2419 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2421 if (!m_debuggerAgent)
2422 protocolErrors->pushString("Debugger handler is not available.");
2426 if (!protocolErrors->length())
2427 m_debuggerAgent->stepOver(&error);
2429 RefPtr<InspectorObject> result = InspectorObject::create();
2430 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.stepOver"), protocolErrors, error);
2433 void InspectorBackendDispatcher::Debugger_stepInto(long callId, InspectorObject*)
2435 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2437 if (!m_debuggerAgent)
2438 protocolErrors->pushString("Debugger handler is not available.");
2442 if (!protocolErrors->length())
2443 m_debuggerAgent->stepInto(&error);
2445 RefPtr<InspectorObject> result = InspectorObject::create();
2446 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.stepInto"), protocolErrors, error);
2449 void InspectorBackendDispatcher::Debugger_stepOut(long callId, InspectorObject*)
2451 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2453 if (!m_debuggerAgent)
2454 protocolErrors->pushString("Debugger handler is not available.");
2458 if (!protocolErrors->length())
2459 m_debuggerAgent->stepOut(&error);
2461 RefPtr<InspectorObject> result = InspectorObject::create();
2462 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.stepOut"), protocolErrors, error);
2465 void InspectorBackendDispatcher::Debugger_pause(long callId, InspectorObject*)
2467 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2469 if (!m_debuggerAgent)
2470 protocolErrors->pushString("Debugger handler is not available.");
2474 if (!protocolErrors->length())
2475 m_debuggerAgent->pause(&error);
2477 RefPtr<InspectorObject> result = InspectorObject::create();
2478 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.pause"), protocolErrors, error);
2481 void InspectorBackendDispatcher::Debugger_resume(long callId, InspectorObject*)
2483 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2485 if (!m_debuggerAgent)
2486 protocolErrors->pushString("Debugger handler is not available.");
2490 if (!protocolErrors->length())
2491 m_debuggerAgent->resume(&error);
2493 RefPtr<InspectorObject> result = InspectorObject::create();
2494 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.resume"), protocolErrors, error);
2497 void InspectorBackendDispatcher::Debugger_searchInContent(long callId, InspectorObject* requestMessageObject)
2499 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2501 if (!m_debuggerAgent)
2502 protocolErrors->pushString("Debugger handler is not available.");
2504 RefPtr<InspectorArray> out_result = InspectorArray::create();
2508 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2509 InspectorObject* paramsContainerPtr = paramsContainer.get();
2510 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2511 String in_scriptId = getString(paramsContainerPtr, "scriptId", 0, protocolErrorsPtr);
2512 String in_query = getString(paramsContainerPtr, "query", 0, protocolErrorsPtr);
2513 bool caseSensitive_valueFound = false;
2514 bool in_caseSensitive = getBoolean(paramsContainerPtr, "caseSensitive", &caseSensitive_valueFound, protocolErrorsPtr);
2515 bool isRegex_valueFound = false;
2516 bool in_isRegex = getBoolean(paramsContainerPtr, "isRegex", &isRegex_valueFound, protocolErrorsPtr);
2518 if (!protocolErrors->length())
2519 m_debuggerAgent->searchInContent(&error, in_scriptId, in_query, caseSensitive_valueFound ? &in_caseSensitive : 0, isRegex_valueFound ? &in_isRegex : 0, &out_result);
2521 RefPtr<InspectorObject> result = InspectorObject::create();
2522 if (!protocolErrors->length() && !error.length()) {
2523 result->setArray("result", out_result);
2525 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.searchInContent"), protocolErrors, error);
2528 void InspectorBackendDispatcher::Debugger_setScriptSource(long callId, InspectorObject* requestMessageObject)
2530 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2532 if (!m_debuggerAgent)
2533 protocolErrors->pushString("Debugger handler is not available.");
2535 RefPtr<InspectorArray> out_callFrames = InspectorArray::create();
2536 RefPtr<InspectorObject> out_result = InspectorObject::create();
2540 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2541 InspectorObject* paramsContainerPtr = paramsContainer.get();
2542 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2543 String in_scriptId = getString(paramsContainerPtr, "scriptId", 0, protocolErrorsPtr);
2544 String in_scriptSource = getString(paramsContainerPtr, "scriptSource", 0, protocolErrorsPtr);
2545 bool preview_valueFound = false;
2546 bool in_preview = getBoolean(paramsContainerPtr, "preview", &preview_valueFound, protocolErrorsPtr);
2548 if (!protocolErrors->length())
2549 m_debuggerAgent->setScriptSource(&error, in_scriptId, in_scriptSource, preview_valueFound ? &in_preview : 0, &out_callFrames, &out_result);
2551 RefPtr<InspectorObject> result = InspectorObject::create();
2552 if (!protocolErrors->length() && !error.length()) {
2553 result->setArray("callFrames", out_callFrames);
2554 result->setObject("result", out_result);
2556 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.setScriptSource"), protocolErrors, error);
2559 void InspectorBackendDispatcher::Debugger_getScriptSource(long callId, InspectorObject* requestMessageObject)
2561 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2563 if (!m_debuggerAgent)
2564 protocolErrors->pushString("Debugger handler is not available.");
2566 String out_scriptSource = "";
2570 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2571 InspectorObject* paramsContainerPtr = paramsContainer.get();
2572 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2573 String in_scriptId = getString(paramsContainerPtr, "scriptId", 0, protocolErrorsPtr);
2575 if (!protocolErrors->length())
2576 m_debuggerAgent->getScriptSource(&error, in_scriptId, &out_scriptSource);
2578 RefPtr<InspectorObject> result = InspectorObject::create();
2579 if (!protocolErrors->length() && !error.length()) {
2580 result->setString("scriptSource", out_scriptSource);
2582 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.getScriptSource"), protocolErrors, error);
2585 void InspectorBackendDispatcher::Debugger_getFunctionLocation(long callId, InspectorObject* requestMessageObject)
2587 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2589 if (!m_debuggerAgent)
2590 protocolErrors->pushString("Debugger handler is not available.");
2592 RefPtr<InspectorObject> out_location = InspectorObject::create();
2596 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2597 InspectorObject* paramsContainerPtr = paramsContainer.get();
2598 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2599 String in_functionId = getString(paramsContainerPtr, "functionId", 0, protocolErrorsPtr);
2601 if (!protocolErrors->length())
2602 m_debuggerAgent->getFunctionLocation(&error, in_functionId, &out_location);
2604 RefPtr<InspectorObject> result = InspectorObject::create();
2605 if (!protocolErrors->length() && !error.length()) {
2606 result->setObject("location", out_location);
2608 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.getFunctionLocation"), protocolErrors, error);
2611 void InspectorBackendDispatcher::Debugger_setPauseOnExceptions(long callId, InspectorObject* requestMessageObject)
2613 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2615 if (!m_debuggerAgent)
2616 protocolErrors->pushString("Debugger handler is not available.");
2620 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2621 InspectorObject* paramsContainerPtr = paramsContainer.get();
2622 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2623 String in_state = getString(paramsContainerPtr, "state", 0, protocolErrorsPtr);
2625 if (!protocolErrors->length())
2626 m_debuggerAgent->setPauseOnExceptions(&error, in_state);
2628 RefPtr<InspectorObject> result = InspectorObject::create();
2629 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.setPauseOnExceptions"), protocolErrors, error);
2632 void InspectorBackendDispatcher::Debugger_evaluateOnCallFrame(long callId, InspectorObject* requestMessageObject)
2634 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2636 if (!m_debuggerAgent)
2637 protocolErrors->pushString("Debugger handler is not available.");
2639 RefPtr<InspectorObject> out_result = InspectorObject::create();
2640 bool out_wasThrown = false;
2644 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2645 InspectorObject* paramsContainerPtr = paramsContainer.get();
2646 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2647 String in_callFrameId = getString(paramsContainerPtr, "callFrameId", 0, protocolErrorsPtr);
2648 String in_expression = getString(paramsContainerPtr, "expression", 0, protocolErrorsPtr);
2649 bool objectGroup_valueFound = false;
2650 String in_objectGroup = getString(paramsContainerPtr, "objectGroup", &objectGroup_valueFound, protocolErrorsPtr);
2651 bool includeCommandLineAPI_valueFound = false;
2652 bool in_includeCommandLineAPI = getBoolean(paramsContainerPtr, "includeCommandLineAPI", &includeCommandLineAPI_valueFound, protocolErrorsPtr);
2653 bool returnByValue_valueFound = false;
2654 bool in_returnByValue = getBoolean(paramsContainerPtr, "returnByValue", &returnByValue_valueFound, protocolErrorsPtr);
2656 if (!protocolErrors->length())
2657 m_debuggerAgent->evaluateOnCallFrame(&error, in_callFrameId, in_expression, objectGroup_valueFound ? &in_objectGroup : 0, includeCommandLineAPI_valueFound ? &in_includeCommandLineAPI : 0, returnByValue_valueFound ? &in_returnByValue : 0, &out_result, &out_wasThrown);
2659 RefPtr<InspectorObject> result = InspectorObject::create();
2660 if (!protocolErrors->length() && !error.length()) {
2661 result->setObject("result", out_result);
2663 result->setBoolean("wasThrown", out_wasThrown);
2665 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.evaluateOnCallFrame"), protocolErrors, error);
2668 void InspectorBackendDispatcher::DOMDebugger_setDOMBreakpoint(long callId, InspectorObject* requestMessageObject)
2670 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2672 if (!m_domDebuggerAgent)
2673 protocolErrors->pushString("DOMDebugger handler is not available.");
2677 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2678 InspectorObject* paramsContainerPtr = paramsContainer.get();
2679 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2680 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
2681 String in_type = getString(paramsContainerPtr, "type", 0, protocolErrorsPtr);
2683 if (!protocolErrors->length())
2684 m_domDebuggerAgent->setDOMBreakpoint(&error, in_nodeId, in_type);
2686 RefPtr<InspectorObject> result = InspectorObject::create();
2687 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMDebugger.setDOMBreakpoint"), protocolErrors, error);
2690 void InspectorBackendDispatcher::DOMDebugger_removeDOMBreakpoint(long callId, InspectorObject* requestMessageObject)
2692 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2694 if (!m_domDebuggerAgent)
2695 protocolErrors->pushString("DOMDebugger handler is not available.");
2699 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2700 InspectorObject* paramsContainerPtr = paramsContainer.get();
2701 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2702 int in_nodeId = getInt(paramsContainerPtr, "nodeId", 0, protocolErrorsPtr);
2703 String in_type = getString(paramsContainerPtr, "type", 0, protocolErrorsPtr);
2705 if (!protocolErrors->length())
2706 m_domDebuggerAgent->removeDOMBreakpoint(&error, in_nodeId, in_type);
2708 RefPtr<InspectorObject> result = InspectorObject::create();
2709 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMDebugger.removeDOMBreakpoint"), protocolErrors, error);
2712 void InspectorBackendDispatcher::DOMDebugger_setEventListenerBreakpoint(long callId, InspectorObject* requestMessageObject)
2714 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2716 if (!m_domDebuggerAgent)
2717 protocolErrors->pushString("DOMDebugger handler is not available.");
2721 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2722 InspectorObject* paramsContainerPtr = paramsContainer.get();
2723 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2724 String in_eventName = getString(paramsContainerPtr, "eventName", 0, protocolErrorsPtr);
2726 if (!protocolErrors->length())
2727 m_domDebuggerAgent->setEventListenerBreakpoint(&error, in_eventName);
2729 RefPtr<InspectorObject> result = InspectorObject::create();
2730 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMDebugger.setEventListenerBreakpoint"), protocolErrors, error);
2733 void InspectorBackendDispatcher::DOMDebugger_removeEventListenerBreakpoint(long callId, InspectorObject* requestMessageObject)
2735 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2737 if (!m_domDebuggerAgent)
2738 protocolErrors->pushString("DOMDebugger handler is not available.");
2742 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2743 InspectorObject* paramsContainerPtr = paramsContainer.get();
2744 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2745 String in_eventName = getString(paramsContainerPtr, "eventName", 0, protocolErrorsPtr);
2747 if (!protocolErrors->length())
2748 m_domDebuggerAgent->removeEventListenerBreakpoint(&error, in_eventName);
2750 RefPtr<InspectorObject> result = InspectorObject::create();
2751 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMDebugger.removeEventListenerBreakpoint"), protocolErrors, error);
2754 void InspectorBackendDispatcher::DOMDebugger_setXHRBreakpoint(long callId, InspectorObject* requestMessageObject)
2756 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2758 if (!m_domDebuggerAgent)
2759 protocolErrors->pushString("DOMDebugger handler is not available.");
2763 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2764 InspectorObject* paramsContainerPtr = paramsContainer.get();
2765 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2766 String in_url = getString(paramsContainerPtr, "url", 0, protocolErrorsPtr);
2768 if (!protocolErrors->length())
2769 m_domDebuggerAgent->setXHRBreakpoint(&error, in_url);
2771 RefPtr<InspectorObject> result = InspectorObject::create();
2772 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMDebugger.setXHRBreakpoint"), protocolErrors, error);
2775 void InspectorBackendDispatcher::DOMDebugger_removeXHRBreakpoint(long callId, InspectorObject* requestMessageObject)
2777 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2779 if (!m_domDebuggerAgent)
2780 protocolErrors->pushString("DOMDebugger handler is not available.");
2784 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2785 InspectorObject* paramsContainerPtr = paramsContainer.get();
2786 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2787 String in_url = getString(paramsContainerPtr, "url", 0, protocolErrorsPtr);
2789 if (!protocolErrors->length())
2790 m_domDebuggerAgent->removeXHRBreakpoint(&error, in_url);
2792 RefPtr<InspectorObject> result = InspectorObject::create();
2793 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMDebugger.removeXHRBreakpoint"), protocolErrors, error);
2796 void InspectorBackendDispatcher::Profiler_enable(long callId, InspectorObject*)
2798 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2800 if (!m_profilerAgent)
2801 protocolErrors->pushString("Profiler handler is not available.");
2805 if (!protocolErrors->length())
2806 m_profilerAgent->enable(&error);
2808 RefPtr<InspectorObject> result = InspectorObject::create();
2809 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.enable"), protocolErrors, error);
2812 void InspectorBackendDispatcher::Profiler_disable(long callId, InspectorObject*)
2814 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2816 if (!m_profilerAgent)
2817 protocolErrors->pushString("Profiler handler is not available.");
2821 if (!protocolErrors->length())
2822 m_profilerAgent->disable(&error);
2824 RefPtr<InspectorObject> result = InspectorObject::create();
2825 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.disable"), protocolErrors, error);
2828 void InspectorBackendDispatcher::Profiler_isEnabled(long callId, InspectorObject*)
2830 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2832 if (!m_profilerAgent)
2833 protocolErrors->pushString("Profiler handler is not available.");
2835 bool out_state = false;
2839 if (!protocolErrors->length())
2840 m_profilerAgent->isEnabled(&error, &out_state);
2842 RefPtr<InspectorObject> result = InspectorObject::create();
2843 if (!protocolErrors->length() && !error.length()) {
2844 result->setBoolean("state", out_state);
2846 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.isEnabled"), protocolErrors, error);
2849 void InspectorBackendDispatcher::Profiler_start(long callId, InspectorObject*)
2851 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2853 if (!m_profilerAgent)
2854 protocolErrors->pushString("Profiler handler is not available.");
2858 if (!protocolErrors->length())
2859 m_profilerAgent->start(&error);
2861 RefPtr<InspectorObject> result = InspectorObject::create();
2862 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.start"), protocolErrors, error);
2865 void InspectorBackendDispatcher::Profiler_stop(long callId, InspectorObject*)
2867 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2869 if (!m_profilerAgent)
2870 protocolErrors->pushString("Profiler handler is not available.");
2874 if (!protocolErrors->length())
2875 m_profilerAgent->stop(&error);
2877 RefPtr<InspectorObject> result = InspectorObject::create();
2878 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.stop"), protocolErrors, error);
2881 void InspectorBackendDispatcher::Profiler_getProfileHeaders(long callId, InspectorObject*)
2883 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2885 if (!m_profilerAgent)
2886 protocolErrors->pushString("Profiler handler is not available.");
2888 RefPtr<InspectorArray> out_headers = InspectorArray::create();
2892 if (!protocolErrors->length())
2893 m_profilerAgent->getProfileHeaders(&error, &out_headers);
2895 RefPtr<InspectorObject> result = InspectorObject::create();
2896 if (!protocolErrors->length() && !error.length()) {
2897 result->setArray("headers", out_headers);
2899 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.getProfileHeaders"), protocolErrors, error);
2902 void InspectorBackendDispatcher::Profiler_getProfile(long callId, InspectorObject* requestMessageObject)
2904 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2906 if (!m_profilerAgent)
2907 protocolErrors->pushString("Profiler handler is not available.");
2909 RefPtr<InspectorObject> out_profile = InspectorObject::create();
2913 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2914 InspectorObject* paramsContainerPtr = paramsContainer.get();
2915 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2916 String in_type = getString(paramsContainerPtr, "type", 0, protocolErrorsPtr);
2917 int in_uid = getInt(paramsContainerPtr, "uid", 0, protocolErrorsPtr);
2919 if (!protocolErrors->length())
2920 m_profilerAgent->getProfile(&error, in_type, in_uid, &out_profile);
2922 RefPtr<InspectorObject> result = InspectorObject::create();
2923 if (!protocolErrors->length() && !error.length()) {
2924 result->setObject("profile", out_profile);
2926 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.getProfile"), protocolErrors, error);
2929 void InspectorBackendDispatcher::Profiler_removeProfile(long callId, InspectorObject* requestMessageObject)
2931 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2933 if (!m_profilerAgent)
2934 protocolErrors->pushString("Profiler handler is not available.");
2938 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
2939 InspectorObject* paramsContainerPtr = paramsContainer.get();
2940 InspectorArray* protocolErrorsPtr = protocolErrors.get();
2941 String in_type = getString(paramsContainerPtr, "type", 0, protocolErrorsPtr);
2942 int in_uid = getInt(paramsContainerPtr, "uid", 0, protocolErrorsPtr);
2944 if (!protocolErrors->length())
2945 m_profilerAgent->removeProfile(&error, in_type, in_uid);
2947 RefPtr<InspectorObject> result = InspectorObject::create();
2948 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.removeProfile"), protocolErrors, error);
2951 void InspectorBackendDispatcher::Profiler_clearProfiles(long callId, InspectorObject*)
2953 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2955 if (!m_profilerAgent)
2956 protocolErrors->pushString("Profiler handler is not available.");
2960 if (!protocolErrors->length())
2961 m_profilerAgent->clearProfiles(&error);
2963 RefPtr<InspectorObject> result = InspectorObject::create();
2964 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.clearProfiles"), protocolErrors, error);
2967 void InspectorBackendDispatcher::Profiler_takeHeapSnapshot(long callId, InspectorObject*)
2969 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2971 if (!m_profilerAgent)
2972 protocolErrors->pushString("Profiler handler is not available.");
2976 if (!protocolErrors->length())
2977 m_profilerAgent->takeHeapSnapshot(&error);
2979 RefPtr<InspectorObject> result = InspectorObject::create();
2980 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.takeHeapSnapshot"), protocolErrors, error);
2983 void InspectorBackendDispatcher::Profiler_collectGarbage(long callId, InspectorObject*)
2985 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2987 if (!m_profilerAgent)
2988 protocolErrors->pushString("Profiler handler is not available.");
2992 if (!protocolErrors->length())
2993 m_profilerAgent->collectGarbage(&error);
2995 RefPtr<InspectorObject> result = InspectorObject::create();
2996 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.collectGarbage"), protocolErrors, error);
2999 void InspectorBackendDispatcher::Profiler_getObjectByHeapObjectId(long callId, InspectorObject* requestMessageObject)
3001 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3003 if (!m_profilerAgent)
3004 protocolErrors->pushString("Profiler handler is not available.");
3006 RefPtr<InspectorObject> out_result = InspectorObject::create();
3010 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
3011 InspectorObject* paramsContainerPtr = paramsContainer.get();
3012 InspectorArray* protocolErrorsPtr = protocolErrors.get();
3013 int in_objectId = getInt(paramsContainerPtr, "objectId", 0, protocolErrorsPtr);
3015 if (!protocolErrors->length())
3016 m_profilerAgent->getObjectByHeapObjectId(&error, in_objectId, &out_result);
3018 RefPtr<InspectorObject> result = InspectorObject::create();
3019 if (!protocolErrors->length() && !error.length()) {
3020 result->setObject("result", out_result);
3022 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.getObjectByHeapObjectId"), protocolErrors, error);
3025 void InspectorBackendDispatcher::Worker_setWorkerInspectionEnabled(long callId, InspectorObject* requestMessageObject)
3027 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3030 protocolErrors->pushString("Worker handler is not available.");
3034 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
3035 InspectorObject* paramsContainerPtr = paramsContainer.get();
3036 InspectorArray* protocolErrorsPtr = protocolErrors.get();
3037 bool in_value = getBoolean(paramsContainerPtr, "value", 0, protocolErrorsPtr);
3039 if (!protocolErrors->length())
3040 m_workerAgent->setWorkerInspectionEnabled(&error, in_value);
3042 RefPtr<InspectorObject> result = InspectorObject::create();
3043 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Worker.setWorkerInspectionEnabled"), protocolErrors, error);
3046 void InspectorBackendDispatcher::Worker_sendMessageToWorker(long callId, InspectorObject* requestMessageObject)
3048 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3051 protocolErrors->pushString("Worker handler is not available.");
3055 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
3056 InspectorObject* paramsContainerPtr = paramsContainer.get();
3057 InspectorArray* protocolErrorsPtr = protocolErrors.get();
3058 int in_workerId = getInt(paramsContainerPtr, "workerId", 0, protocolErrorsPtr);
3059 RefPtr<InspectorObject> in_message = getObject(paramsContainerPtr, "message", 0, protocolErrorsPtr);
3061 if (!protocolErrors->length())
3062 m_workerAgent->sendMessageToWorker(&error, in_workerId, in_message);
3064 RefPtr<InspectorObject> result = InspectorObject::create();
3065 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Worker.sendMessageToWorker"), protocolErrors, error);
3068 void InspectorBackendDispatcher::Worker_connectToWorker(long callId, InspectorObject* requestMessageObject)
3070 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3073 protocolErrors->pushString("Worker handler is not available.");
3077 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
3078 InspectorObject* paramsContainerPtr = paramsContainer.get();
3079 InspectorArray* protocolErrorsPtr = protocolErrors.get();
3080 int in_workerId = getInt(paramsContainerPtr, "workerId", 0, protocolErrorsPtr);
3082 if (!protocolErrors->length())
3083 m_workerAgent->connectToWorker(&error, in_workerId);
3085 RefPtr<InspectorObject> result = InspectorObject::create();
3086 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Worker.connectToWorker"), protocolErrors, error);
3089 void InspectorBackendDispatcher::Worker_disconnectFromWorker(long callId, InspectorObject* requestMessageObject)
3091 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3094 protocolErrors->pushString("Worker handler is not available.");
3098 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
3099 InspectorObject* paramsContainerPtr = paramsContainer.get();
3100 InspectorArray* protocolErrorsPtr = protocolErrors.get();
3101 int in_workerId = getInt(paramsContainerPtr, "workerId", 0, protocolErrorsPtr);
3103 if (!protocolErrors->length())
3104 m_workerAgent->disconnectFromWorker(&error, in_workerId);
3106 RefPtr<InspectorObject> result = InspectorObject::create();
3107 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Worker.disconnectFromWorker"), protocolErrors, error);
3110 void InspectorBackendDispatcher::Worker_setAutoconnectToWorkers(long callId, InspectorObject* requestMessageObject)
3112 RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3115 protocolErrors->pushString("Worker handler is not available.");
3119 RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
3120 InspectorObject* paramsContainerPtr = paramsContainer.get();
3121 InspectorArray* protocolErrorsPtr = protocolErrors.get();
3122 bool in_value = getBoolean(paramsContainerPtr, "value", 0, protocolErrorsPtr);
3124 if (!protocolErrors->length())
3125 m_workerAgent->setAutoconnectToWorkers(&error, in_value);
3127 RefPtr<InspectorObject> result = InspectorObject::create();
3128 sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Worker.setAutoconnectToWorkers"), protocolErrors, error);
3131 void InspectorBackendDispatcher::dispatch(const String& message)
3133 RefPtr<InspectorBackendDispatcher> protect = this;
3134 typedef void (InspectorBackendDispatcher::*CallHandler)(long callId, InspectorObject* messageObject);
3135 typedef HashMap<String, CallHandler> DispatchMap;
3136 DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );
3139 if (dispatchMap.isEmpty()) {
3140 static CallHandler handlers[] = {
3141 &InspectorBackendDispatcher::Inspector_enable,
3142 &InspectorBackendDispatcher::Inspector_disable,
3143 &InspectorBackendDispatcher::Meta_getCapabilities,
3144 &InspectorBackendDispatcher::Page_enable,
3145 &InspectorBackendDispatcher::Page_disable,
3146 &InspectorBackendDispatcher::Page_addScriptToEvaluateOnLoad,
3147 &InspectorBackendDispatcher::Page_removeScriptToEvaluateOnLoad,
3148 &InspectorBackendDispatcher::Page_reload,
3149 &InspectorBackendDispatcher::Page_open,
3150 &InspectorBackendDispatcher::Page_getCookies,
3151 &InspectorBackendDispatcher::Page_deleteCookie,
3152 &InspectorBackendDispatcher::Page_getResourceTree,
3153 &InspectorBackendDispatcher::Page_getResourceContent,
3154 &InspectorBackendDispatcher::Page_searchInResource,
3155 &InspectorBackendDispatcher::Page_searchInResources,
3156 &InspectorBackendDispatcher::Runtime_evaluate,
3157 &InspectorBackendDispatcher::Runtime_callFunctionOn,
3158 &InspectorBackendDispatcher::Runtime_getProperties,
3159 &InspectorBackendDispatcher::Runtime_releaseObject,
3160 &InspectorBackendDispatcher::Runtime_releaseObjectGroup,
3161 &InspectorBackendDispatcher::Runtime_run,
3162 &InspectorBackendDispatcher::Console_enable,
3163 &InspectorBackendDispatcher::Console_disable,
3164 &InspectorBackendDispatcher::Console_clearMessages,
3165 &InspectorBackendDispatcher::Console_setMonitoringXHREnabled,
3166 &InspectorBackendDispatcher::Console_addInspectedNode,
3167 &InspectorBackendDispatcher::Network_enable,
3168 &InspectorBackendDispatcher::Network_disable,
3169 &InspectorBackendDispatcher::Network_setUserAgentOverride,
3170 &InspectorBackendDispatcher::Network_setExtraHTTPHeaders,
3171 &InspectorBackendDispatcher::Network_getResponseBody,
3172 &InspectorBackendDispatcher::Network_clearBrowserCache,
3173 &InspectorBackendDispatcher::Network_clearBrowserCookies,
3174 &InspectorBackendDispatcher::Network_setCacheDisabled,
3175 &InspectorBackendDispatcher::Database_enable,
3176 &InspectorBackendDispatcher::Database_disable,
3177 &InspectorBackendDispatcher::Database_getDatabaseTableNames,
3178 &InspectorBackendDispatcher::Database_executeSQL,
3179 &InspectorBackendDispatcher::DOMStorage_enable,
3180 &InspectorBackendDispatcher::DOMStorage_disable,
3181 &InspectorBackendDispatcher::DOMStorage_getDOMStorageEntries,
3182 &InspectorBackendDispatcher::DOMStorage_setDOMStorageItem,
3183 &InspectorBackendDispatcher::DOMStorage_removeDOMStorageItem,
3184 &InspectorBackendDispatcher::ApplicationCache_getFramesWithManifests,
3185 &InspectorBackendDispatcher::ApplicationCache_enable,
3186 &InspectorBackendDispatcher::ApplicationCache_getManifestForFrame,
3187 &InspectorBackendDispatcher::ApplicationCache_getApplicationCacheForFrame,
3188 &InspectorBackendDispatcher::FileSystem_enable,
3189 &InspectorBackendDispatcher::FileSystem_disable,
3190 &InspectorBackendDispatcher::DOM_getDocument,
3191 &InspectorBackendDispatcher::DOM_requestChildNodes,
3192 &InspectorBackendDispatcher::DOM_querySelector,
3193 &InspectorBackendDispatcher::DOM_querySelectorAll,
3194 &InspectorBackendDispatcher::DOM_setNodeName,
3195 &InspectorBackendDispatcher::DOM_setNodeValue,
3196 &InspectorBackendDispatcher::DOM_removeNode,
3197 &InspectorBackendDispatcher::DOM_setAttributeValue,
3198 &InspectorBackendDispatcher::DOM_setAttributesAsText,
3199 &InspectorBackendDispatcher::DOM_removeAttribute,
3200 &InspectorBackendDispatcher::DOM_getEventListenersForNode,
3201 &InspectorBackendDispatcher::DOM_copyNode,
3202 &InspectorBackendDispatcher::DOM_getOuterHTML,
3203 &InspectorBackendDispatcher::DOM_setOuterHTML,
3204 &InspectorBackendDispatcher::DOM_performSearch,
3205 &InspectorBackendDispatcher::DOM_getSearchResults,
3206 &InspectorBackendDispatcher::DOM_discardSearchResults,
3207 &InspectorBackendDispatcher::DOM_requestNode,
3208 &InspectorBackendDispatcher::DOM_setInspectModeEnabled,
3209 &InspectorBackendDispatcher::DOM_highlightRect,
3210 &InspectorBackendDispatcher::DOM_highlightNode,
3211 &InspectorBackendDispatcher::DOM_hideHighlight,
3212 &InspectorBackendDispatcher::DOM_highlightFrame,
3213 &InspectorBackendDispatcher::DOM_pushNodeByPathToFrontend,
3214 &InspectorBackendDispatcher::DOM_resolveNode,
3215 &InspectorBackendDispatcher::DOM_getAttributes,
3216 &InspectorBackendDispatcher::DOM_moveTo,
3217 &InspectorBackendDispatcher::CSS_getMatchedStylesForNode,
3218 &InspectorBackendDispatcher::CSS_getInlineStylesForNode,
3219 &InspectorBackendDispatcher::CSS_getComputedStyleForNode,
3220 &InspectorBackendDispatcher::CSS_getAllStyleSheets,
3221 &InspectorBackendDispatcher::CSS_getStyleSheet,
3222 &InspectorBackendDispatcher::CSS_getStyleSheetText,
3223 &InspectorBackendDispatcher::CSS_setStyleSheetText,
3224 &InspectorBackendDispatcher::CSS_setPropertyText,
3225 &InspectorBackendDispatcher::CSS_toggleProperty,
3226 &InspectorBackendDispatcher::CSS_setRuleSelector,
3227 &InspectorBackendDispatcher::CSS_addRule,
3228 &InspectorBackendDispatcher::CSS_getSupportedCSSProperties,
3229 &InspectorBackendDispatcher::Timeline_start,
3230 &InspectorBackendDispatcher::Timeline_stop,
3231 &InspectorBackendDispatcher::Debugger_enable,
3232 &InspectorBackendDispatcher::Debugger_disable,
3233 &InspectorBackendDispatcher::Debugger_setBreakpointsActive,
3234 &InspectorBackendDispatcher::Debugger_setBreakpointByUrl,
3235 &InspectorBackendDispatcher::Debugger_setBreakpoint,
3236 &InspectorBackendDispatcher::Debugger_removeBreakpoint,
3237 &InspectorBackendDispatcher::Debugger_continueToLocation,
3238 &InspectorBackendDispatcher::Debugger_stepOver,
3239 &InspectorBackendDispatcher::Debugger_stepInto,
3240 &InspectorBackendDispatcher::Debugger_stepOut,
3241 &InspectorBackendDispatcher::Debugger_pause,
3242 &InspectorBackendDispatcher::Debugger_resume,
3243 &InspectorBackendDispatcher::Debugger_searchInContent,
3244 &InspectorBackendDispatcher::Debugger_setScriptSource,
3245 &InspectorBackendDispatcher::Debugger_getScriptSource,
3246 &InspectorBackendDispatcher::Debugger_getFunctionLocation,
3247 &InspectorBackendDispatcher::Debugger_setPauseOnExceptions,
3248 &InspectorBackendDispatcher::Debugger_evaluateOnCallFrame,
3249 &InspectorBackendDispatcher::DOMDebugger_setDOMBreakpoint,
3250 &InspectorBackendDispatcher::DOMDebugger_removeDOMBreakpoint,
3251 &InspectorBackendDispatcher::DOMDebugger_setEventListenerBreakpoint,
3252 &InspectorBackendDispatcher::DOMDebugger_removeEventListenerBreakpoint,
3253 &InspectorBackendDispatcher::DOMDebugger_setXHRBreakpoint,
3254 &InspectorBackendDispatcher::DOMDebugger_removeXHRBreakpoint,
3255 &InspectorBackendDispatcher::Profiler_enable,
3256 &InspectorBackendDispatcher::Profiler_disable,
3257 &InspectorBackendDispatcher::Profiler_isEnabled,
3258 &InspectorBackendDispatcher::Profiler_start,
3259 &InspectorBackendDispatcher::Profiler_stop,
3260 &InspectorBackendDispatcher::Profiler_getProfileHeaders,
3261 &InspectorBackendDispatcher::Profiler_getProfile,
3262 &InspectorBackendDispatcher::Profiler_removeProfile,
3263 &InspectorBackendDispatcher::Profiler_clearProfiles,
3264 &InspectorBackendDispatcher::Profiler_takeHeapSnapshot,
3265 &InspectorBackendDispatcher::Profiler_collectGarbage,
3266 &InspectorBackendDispatcher::Profiler_getObjectByHeapObjectId,
3267 &InspectorBackendDispatcher::Worker_setWorkerInspectionEnabled,
3268 &InspectorBackendDispatcher::Worker_sendMessageToWorker,
3269 &InspectorBackendDispatcher::Worker_connectToWorker,
3270 &InspectorBackendDispatcher::Worker_disconnectFromWorker,
3271 &InspectorBackendDispatcher::Worker_setAutoconnectToWorkers,
3273 size_t length = sizeof(commandNames) / sizeof(commandNames[0]);
3274 for (size_t i = 0; i < length; ++i)
3275 dispatchMap.add(commandNames[i], handlers[i]);
3278 RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
3279 if (!parsedMessage) {
3280 reportProtocolError(0, ParseError, "Message must be in JSON format");
3284 RefPtr<InspectorObject> messageObject = parsedMessage->asObject();
3285 if (!messageObject) {
3286 reportProtocolError(0, InvalidRequest, "Message must be a JSONified object");
3290 RefPtr<InspectorValue> callIdValue = messageObject->get("id");
3292 reportProtocolError(0, InvalidRequest, "'id' property was not found");
3296 if (!callIdValue->asNumber(&callId)) {
3297 reportProtocolError(0, InvalidRequest, "The type of 'id' property must be number");
3301 RefPtr<InspectorValue> methodValue = messageObject->get("method");
3303 reportProtocolError(&callId, InvalidRequest, "'method' property wasn't found");
3308 if (!methodValue->asString(&method)) {
3309 reportProtocolError(&callId, InvalidRequest, "The type of 'method' property must be string");
3313 HashMap<String, CallHandler>::iterator it = dispatchMap.find(method);
3314 if (it == dispatchMap.end()) {
3315 reportProtocolError(&callId, MethodNotFound, "'" + method + "' wasn't found");
3319 ((*this).*it->second)(callId, messageObject.get());
3322 void InspectorBackendDispatcher::sendResponse(long callId, PassRefPtr<InspectorObject> result, const String& errorMessage, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError)
3324 if (protocolErrors->length()) {
3325 reportProtocolError(&callId, InvalidParams, errorMessage, protocolErrors);
3328 if (invocationError.length()) {
3329 reportProtocolError(&callId, ServerError, invocationError);
3333 RefPtr<InspectorObject> responseMessage = InspectorObject::create();
3334 responseMessage->setObject("result", result);
3335 responseMessage->setNumber("id", callId);
3336 if (m_inspectorFrontendChannel)
3337 m_inspectorFrontendChannel->sendMessageToFrontend(responseMessage->toJSONString());
3340 void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage) const
3342 reportProtocolError(callId, code, errorMessage, 0);
3345 void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage, PassRefPtr<InspectorArray> data) const
3347 DEFINE_STATIC_LOCAL(Vector<int>,s_commonErrors,);
3348 if (!s_commonErrors.size()) {
3349 s_commonErrors.insert(ParseError, -32700);
3350 s_commonErrors.insert(InvalidRequest, -32600);
3351 s_commonErrors.insert(MethodNotFound, -32601);
3352 s_commonErrors.insert(InvalidParams, -32602);
3353 s_commonErrors.insert(InternalError, -32603);
3354 s_commonErrors.insert(ServerError, -32000);
3357 ASSERT((unsigned)code < s_commonErrors.size());
3358 ASSERT(s_commonErrors[code]);
3359 RefPtr<InspectorObject> error = InspectorObject::create();
3360 error->setNumber("code", s_commonErrors[code]);
3361 error->setString("message", errorMessage);
3364 error->setArray("data", data);
3365 RefPtr<InspectorObject> message = InspectorObject::create();
3366 message->setObject("error", error);
3368 message->setNumber("id", *callId);
3370 message->setValue("id", InspectorValue::null());
3371 if (m_inspectorFrontendChannel)
3372 m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString());
3375 int InspectorBackendDispatcher::getInt(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3377 ASSERT(protocolErrors);
3380 *valueFound = false;
3386 // Required parameter in missing params container.
3387 protocolErrors->pushString(String::format("'params' object must contain required parameter '%s' with type 'Number'.", name.utf8().data()));
3392 InspectorObject::const_iterator end = object->end();
3393 InspectorObject::const_iterator valueIterator = object->find(name);
3395 if (valueIterator == end) {
3397 protocolErrors->pushString(String::format("Parameter '%s' with type 'Number' was not found.", name.utf8().data()));
3401 if (!valueIterator->second->asNumber(&value))
3402 protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Number'.", name.utf8().data()));
3409 String InspectorBackendDispatcher::getString(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3411 ASSERT(protocolErrors);
3414 *valueFound = false;
3420 // Required parameter in missing params container.
3421 protocolErrors->pushString(String::format("'params' object must contain required parameter '%s' with type 'String'.", name.utf8().data()));
3426 InspectorObject::const_iterator end = object->end();
3427 InspectorObject::const_iterator valueIterator = object->find(name);
3429 if (valueIterator == end) {
3431 protocolErrors->pushString(String::format("Parameter '%s' with type 'String' was not found.", name.utf8().data()));
3435 if (!valueIterator->second->asString(&value))
3436 protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'String'.", name.utf8().data()));
3443 bool InspectorBackendDispatcher::getBoolean(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3445 ASSERT(protocolErrors);
3448 *valueFound = false;
3454 // Required parameter in missing params container.
3455 protocolErrors->pushString(String::format("'params' object must contain required parameter '%s' with type 'Boolean'.", name.utf8().data()));
3460 InspectorObject::const_iterator end = object->end();
3461 InspectorObject::const_iterator valueIterator = object->find(name);
3463 if (valueIterator == end) {
3465 protocolErrors->pushString(String::format("Parameter '%s' with type 'Boolean' was not found.", name.utf8().data()));
3469 if (!valueIterator->second->asBoolean(&value))
3470 protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Boolean'.", name.utf8().data()));
3477 PassRefPtr<InspectorObject> InspectorBackendDispatcher::getObject(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3479 ASSERT(protocolErrors);
3482 *valueFound = false;
3484 RefPtr<InspectorObject> value = InspectorObject::create();
3488 // Required parameter in missing params container.
3489 protocolErrors->pushString(String::format("'params' object must contain required parameter '%s' with type 'Object'.", name.utf8().data()));
3494 InspectorObject::const_iterator end = object->end();
3495 InspectorObject::const_iterator valueIterator = object->find(name);
3497 if (valueIterator == end) {
3499 protocolErrors->pushString(String::format("Parameter '%s' with type 'Object' was not found.", name.utf8().data()));
3503 if (!valueIterator->second->asObject(&value))
3504 protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Object'.", name.utf8().data()));
3511 PassRefPtr<InspectorArray> InspectorBackendDispatcher::getArray(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3513 ASSERT(protocolErrors);
3516 *valueFound = false;
3518 RefPtr<InspectorArray> value = InspectorArray::create();
3522 // Required parameter in missing params container.
3523 protocolErrors->pushString(String::format("'params' object must contain required parameter '%s' with type 'Array'.", name.utf8().data()));
3528 InspectorObject::const_iterator end = object->end();
3529 InspectorObject::const_iterator valueIterator = object->find(name);
3531 if (valueIterator == end) {
3533 protocolErrors->pushString(String::format("Parameter '%s' with type 'Array' was not found.", name.utf8().data()));
3537 if (!valueIterator->second->asArray(&value))
3538 protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Array'.", name.utf8().data()));
3544 bool InspectorBackendDispatcher::getCommandName(const String& message, String* result)
3546 RefPtr<InspectorValue> value = InspectorValue::parseJSON(message);
3550 RefPtr<InspectorObject> object = value->asObject();
3554 if (!object->getString("method", result))
3561 } // namespace WebCore
3563 #endif // ENABLE(INSPECTOR)