tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / InspectorBackendDispatcher.cpp
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.
4
5
6 #include "config.h"
7 #include "InspectorBackendDispatcher.h"
8 #include <wtf/text/WTFString.h>
9 #include <wtf/text/CString.h>
10
11 #if ENABLE(INSPECTOR)
12
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"
34
35 namespace WebCore {
36
37 const char* InspectorBackendDispatcher::commandNames[] = {
38     "Inspector.enable",
39     "Inspector.disable",
40     "Meta.getCapabilities",
41     "Page.enable",
42     "Page.disable",
43     "Page.addScriptToEvaluateOnLoad",
44     "Page.removeScriptToEvaluateOnLoad",
45     "Page.reload",
46     "Page.open",
47     "Page.getCookies",
48     "Page.deleteCookie",
49     "Page.getResourceTree",
50     "Page.getResourceContent",
51     "Page.searchInResource",
52     "Page.searchInResources",
53     "Runtime.evaluate",
54     "Runtime.callFunctionOn",
55     "Runtime.getProperties",
56     "Runtime.releaseObject",
57     "Runtime.releaseObjectGroup",
58     "Runtime.run",
59     "Console.enable",
60     "Console.disable",
61     "Console.clearMessages",
62     "Console.setMonitoringXHREnabled",
63     "Console.addInspectedNode",
64     "Network.enable",
65     "Network.disable",
66     "Network.setUserAgentOverride",
67     "Network.setExtraHTTPHeaders",
68     "Network.getResponseBody",
69     "Network.clearBrowserCache",
70     "Network.clearBrowserCookies",
71     "Network.setCacheDisabled",
72     "Database.enable",
73     "Database.disable",
74     "Database.getDatabaseTableNames",
75     "Database.executeSQL",
76     "DOMStorage.enable",
77     "DOMStorage.disable",
78     "DOMStorage.getDOMStorageEntries",
79     "DOMStorage.setDOMStorageItem",
80     "DOMStorage.removeDOMStorageItem",
81     "ApplicationCache.getFramesWithManifests",
82     "ApplicationCache.enable",
83     "ApplicationCache.getManifestForFrame",
84     "ApplicationCache.getApplicationCacheForFrame",
85     "FileSystem.enable",
86     "FileSystem.disable",
87     "DOM.getDocument",
88     "DOM.requestChildNodes",
89     "DOM.querySelector",
90     "DOM.querySelectorAll",
91     "DOM.setNodeName",
92     "DOM.setNodeValue",
93     "DOM.removeNode",
94     "DOM.setAttributeValue",
95     "DOM.setAttributesAsText",
96     "DOM.removeAttribute",
97     "DOM.getEventListenersForNode",
98     "DOM.copyNode",
99     "DOM.getOuterHTML",
100     "DOM.setOuterHTML",
101     "DOM.performSearch",
102     "DOM.getSearchResults",
103     "DOM.discardSearchResults",
104     "DOM.requestNode",
105     "DOM.setInspectModeEnabled",
106     "DOM.highlightRect",
107     "DOM.highlightNode",
108     "DOM.hideHighlight",
109     "DOM.highlightFrame",
110     "DOM.pushNodeByPathToFrontend",
111     "DOM.resolveNode",
112     "DOM.getAttributes",
113     "DOM.moveTo",
114     "CSS.getMatchedStylesForNode",
115     "CSS.getInlineStylesForNode",
116     "CSS.getComputedStyleForNode",
117     "CSS.getAllStyleSheets",
118     "CSS.getStyleSheet",
119     "CSS.getStyleSheetText",
120     "CSS.setStyleSheetText",
121     "CSS.setPropertyText",
122     "CSS.toggleProperty",
123     "CSS.setRuleSelector",
124     "CSS.addRule",
125     "CSS.getSupportedCSSProperties",
126     "Timeline.start",
127     "Timeline.stop",
128     "Debugger.enable",
129     "Debugger.disable",
130     "Debugger.setBreakpointsActive",
131     "Debugger.setBreakpointByUrl",
132     "Debugger.setBreakpoint",
133     "Debugger.removeBreakpoint",
134     "Debugger.continueToLocation",
135     "Debugger.stepOver",
136     "Debugger.stepInto",
137     "Debugger.stepOut",
138     "Debugger.pause",
139     "Debugger.resume",
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",
152     "Profiler.enable",
153     "Profiler.disable",
154     "Profiler.isEnabled",
155     "Profiler.start",
156     "Profiler.stop",
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",
169 };
170
171
172 void InspectorBackendDispatcher::Inspector_enable(long callId, InspectorObject*)
173 {
174     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
175
176     if (!m_inspectorAgent)
177         protocolErrors->pushString("Inspector handler is not available.");
178
179     ErrorString error;
180
181     if (!protocolErrors->length())
182         m_inspectorAgent->enable(&error);
183
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);
186 }
187
188 void InspectorBackendDispatcher::Inspector_disable(long callId, InspectorObject*)
189 {
190     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
191
192     if (!m_inspectorAgent)
193         protocolErrors->pushString("Inspector handler is not available.");
194
195     ErrorString error;
196
197     if (!protocolErrors->length())
198         m_inspectorAgent->disable(&error);
199
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);
202 }
203
204 void InspectorBackendDispatcher::Meta_getCapabilities(long callId, InspectorObject* requestMessageObject)
205 {
206     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
207
208     if (!m_metaAgent)
209         protocolErrors->pushString("Meta handler is not available.");
210
211     RefPtr<InspectorArray> out_capabilities = InspectorArray::create();
212
213     ErrorString error;
214
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);
219
220     if (!protocolErrors->length())
221         m_metaAgent->getCapabilities(&error, in_domainNames, &out_capabilities);
222
223     RefPtr<InspectorObject> result = InspectorObject::create();
224     if (!protocolErrors->length() && !error.length()) {
225         result->setArray("capabilities", out_capabilities);
226     }
227     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Meta.getCapabilities"), protocolErrors, error);
228 }
229
230 void InspectorBackendDispatcher::Page_enable(long callId, InspectorObject*)
231 {
232     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
233
234     if (!m_pageAgent)
235         protocolErrors->pushString("Page handler is not available.");
236
237     ErrorString error;
238
239     if (!protocolErrors->length())
240         m_pageAgent->enable(&error);
241
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);
244 }
245
246 void InspectorBackendDispatcher::Page_disable(long callId, InspectorObject*)
247 {
248     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
249
250     if (!m_pageAgent)
251         protocolErrors->pushString("Page handler is not available.");
252
253     ErrorString error;
254
255     if (!protocolErrors->length())
256         m_pageAgent->disable(&error);
257
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);
260 }
261
262 void InspectorBackendDispatcher::Page_addScriptToEvaluateOnLoad(long callId, InspectorObject* requestMessageObject)
263 {
264     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
265
266     if (!m_pageAgent)
267         protocolErrors->pushString("Page handler is not available.");
268
269     String out_identifier = "";
270
271     ErrorString error;
272
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);
277
278     if (!protocolErrors->length())
279         m_pageAgent->addScriptToEvaluateOnLoad(&error, in_scriptSource, &out_identifier);
280
281     RefPtr<InspectorObject> result = InspectorObject::create();
282     if (!protocolErrors->length() && !error.length()) {
283         result->setString("identifier", out_identifier);
284     }
285     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.addScriptToEvaluateOnLoad"), protocolErrors, error);
286 }
287
288 void InspectorBackendDispatcher::Page_removeScriptToEvaluateOnLoad(long callId, InspectorObject* requestMessageObject)
289 {
290     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
291
292     if (!m_pageAgent)
293         protocolErrors->pushString("Page handler is not available.");
294
295     ErrorString error;
296
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);
301
302     if (!protocolErrors->length())
303         m_pageAgent->removeScriptToEvaluateOnLoad(&error, in_identifier);
304
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);
307 }
308
309 void InspectorBackendDispatcher::Page_reload(long callId, InspectorObject* requestMessageObject)
310 {
311     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
312
313     if (!m_pageAgent)
314         protocolErrors->pushString("Page handler is not available.");
315
316     ErrorString error;
317
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);
325
326     if (!protocolErrors->length())
327         m_pageAgent->reload(&error, ignoreCache_valueFound ? &in_ignoreCache : 0, scriptToEvaluateOnLoad_valueFound ? &in_scriptToEvaluateOnLoad : 0);
328
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);
331 }
332
333 void InspectorBackendDispatcher::Page_open(long callId, InspectorObject* requestMessageObject)
334 {
335     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
336
337     if (!m_pageAgent)
338         protocolErrors->pushString("Page handler is not available.");
339
340     ErrorString error;
341
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);
348
349     if (!protocolErrors->length())
350         m_pageAgent->open(&error, in_url, newWindow_valueFound ? &in_newWindow : 0);
351
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);
354 }
355
356 void InspectorBackendDispatcher::Page_getCookies(long callId, InspectorObject*)
357 {
358     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
359
360     if (!m_pageAgent)
361         protocolErrors->pushString("Page handler is not available.");
362
363     RefPtr<InspectorArray> out_cookies = InspectorArray::create();
364     String out_cookiesString = "";
365
366     ErrorString error;
367
368     if (!protocolErrors->length())
369         m_pageAgent->getCookies(&error, &out_cookies, &out_cookiesString);
370
371     RefPtr<InspectorObject> result = InspectorObject::create();
372     if (!protocolErrors->length() && !error.length()) {
373         result->setArray("cookies", out_cookies);
374         result->setString("cookiesString", out_cookiesString);
375     }
376     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.getCookies"), protocolErrors, error);
377 }
378
379 void InspectorBackendDispatcher::Page_deleteCookie(long callId, InspectorObject* requestMessageObject)
380 {
381     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
382
383     if (!m_pageAgent)
384         protocolErrors->pushString("Page handler is not available.");
385
386     ErrorString error;
387
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);
393
394     if (!protocolErrors->length())
395         m_pageAgent->deleteCookie(&error, in_cookieName, in_domain);
396
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);
399 }
400
401 void InspectorBackendDispatcher::Page_getResourceTree(long callId, InspectorObject*)
402 {
403     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
404
405     if (!m_pageAgent)
406         protocolErrors->pushString("Page handler is not available.");
407
408     RefPtr<InspectorObject> out_frameTree = InspectorObject::create();
409
410     ErrorString error;
411
412     if (!protocolErrors->length())
413         m_pageAgent->getResourceTree(&error, &out_frameTree);
414
415     RefPtr<InspectorObject> result = InspectorObject::create();
416     if (!protocolErrors->length() && !error.length()) {
417         result->setObject("frameTree", out_frameTree);
418     }
419     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.getResourceTree"), protocolErrors, error);
420 }
421
422 void InspectorBackendDispatcher::Page_getResourceContent(long callId, InspectorObject* requestMessageObject)
423 {
424     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
425
426     if (!m_pageAgent)
427         protocolErrors->pushString("Page handler is not available.");
428
429     String out_content = "";
430     bool out_base64Encoded = false;
431
432     ErrorString error;
433
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);
439
440     if (!protocolErrors->length())
441         m_pageAgent->getResourceContent(&error, in_frameId, in_url, &out_content, &out_base64Encoded);
442
443     RefPtr<InspectorObject> result = InspectorObject::create();
444     if (!protocolErrors->length() && !error.length()) {
445         result->setString("content", out_content);
446         result->setBoolean("base64Encoded", out_base64Encoded);
447     }
448     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.getResourceContent"), protocolErrors, error);
449 }
450
451 void InspectorBackendDispatcher::Page_searchInResource(long callId, InspectorObject* requestMessageObject)
452 {
453     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
454
455     if (!m_pageAgent)
456         protocolErrors->pushString("Page handler is not available.");
457
458     RefPtr<InspectorArray> out_result = InspectorArray::create();
459
460     ErrorString error;
461
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);
472
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);
475
476     RefPtr<InspectorObject> result = InspectorObject::create();
477     if (!protocolErrors->length() && !error.length()) {
478         result->setArray("result", out_result);
479     }
480     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.searchInResource"), protocolErrors, error);
481 }
482
483 void InspectorBackendDispatcher::Page_searchInResources(long callId, InspectorObject* requestMessageObject)
484 {
485     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
486
487     if (!m_pageAgent)
488         protocolErrors->pushString("Page handler is not available.");
489
490     RefPtr<InspectorArray> out_result = InspectorArray::create();
491
492     ErrorString error;
493
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);
502
503     if (!protocolErrors->length())
504         m_pageAgent->searchInResources(&error, in_text, caseSensitive_valueFound ? &in_caseSensitive : 0, isRegex_valueFound ? &in_isRegex : 0, &out_result);
505
506     RefPtr<InspectorObject> result = InspectorObject::create();
507     if (!protocolErrors->length() && !error.length()) {
508         result->setArray("result", out_result);
509     }
510     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Page.searchInResources"), protocolErrors, error);
511 }
512
513 void InspectorBackendDispatcher::Runtime_evaluate(long callId, InspectorObject* requestMessageObject)
514 {
515     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
516
517     if (!m_runtimeAgent)
518         protocolErrors->pushString("Runtime handler is not available.");
519
520     RefPtr<InspectorObject> out_result = InspectorObject::create();
521     bool out_wasThrown = false;
522
523     ErrorString error;
524
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);
539
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);
542
543     RefPtr<InspectorObject> result = InspectorObject::create();
544     if (!protocolErrors->length() && !error.length()) {
545         result->setObject("result", out_result);
546         if (out_wasThrown)
547             result->setBoolean("wasThrown", out_wasThrown);
548     }
549     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.evaluate"), protocolErrors, error);
550 }
551
552 void InspectorBackendDispatcher::Runtime_callFunctionOn(long callId, InspectorObject* requestMessageObject)
553 {
554     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
555
556     if (!m_runtimeAgent)
557         protocolErrors->pushString("Runtime handler is not available.");
558
559     RefPtr<InspectorObject> out_result = InspectorObject::create();
560     bool out_wasThrown = false;
561
562     ErrorString error;
563
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);
573
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);
576
577     RefPtr<InspectorObject> result = InspectorObject::create();
578     if (!protocolErrors->length() && !error.length()) {
579         result->setObject("result", out_result);
580         if (out_wasThrown)
581             result->setBoolean("wasThrown", out_wasThrown);
582     }
583     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.callFunctionOn"), protocolErrors, error);
584 }
585
586 void InspectorBackendDispatcher::Runtime_getProperties(long callId, InspectorObject* requestMessageObject)
587 {
588     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
589
590     if (!m_runtimeAgent)
591         protocolErrors->pushString("Runtime handler is not available.");
592
593     RefPtr<InspectorArray> out_result = InspectorArray::create();
594
595     ErrorString error;
596
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);
603
604     if (!protocolErrors->length())
605         m_runtimeAgent->getProperties(&error, in_objectId, ownProperties_valueFound ? &in_ownProperties : 0, &out_result);
606
607     RefPtr<InspectorObject> result = InspectorObject::create();
608     if (!protocolErrors->length() && !error.length()) {
609         result->setArray("result", out_result);
610     }
611     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Runtime.getProperties"), protocolErrors, error);
612 }
613
614 void InspectorBackendDispatcher::Runtime_releaseObject(long callId, InspectorObject* requestMessageObject)
615 {
616     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
617
618     if (!m_runtimeAgent)
619         protocolErrors->pushString("Runtime handler is not available.");
620
621     ErrorString error;
622
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);
627
628     if (!protocolErrors->length())
629         m_runtimeAgent->releaseObject(&error, in_objectId);
630
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);
633 }
634
635 void InspectorBackendDispatcher::Runtime_releaseObjectGroup(long callId, InspectorObject* requestMessageObject)
636 {
637     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
638
639     if (!m_runtimeAgent)
640         protocolErrors->pushString("Runtime handler is not available.");
641
642     ErrorString error;
643
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);
648
649     if (!protocolErrors->length())
650         m_runtimeAgent->releaseObjectGroup(&error, in_objectGroup);
651
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);
654 }
655
656 void InspectorBackendDispatcher::Runtime_run(long callId, InspectorObject*)
657 {
658     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
659
660     if (!m_runtimeAgent)
661         protocolErrors->pushString("Runtime handler is not available.");
662
663     ErrorString error;
664
665     if (!protocolErrors->length())
666         m_runtimeAgent->run(&error);
667
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);
670 }
671
672 void InspectorBackendDispatcher::Console_enable(long callId, InspectorObject*)
673 {
674     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
675
676     if (!m_consoleAgent)
677         protocolErrors->pushString("Console handler is not available.");
678
679     ErrorString error;
680
681     if (!protocolErrors->length())
682         m_consoleAgent->enable(&error);
683
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);
686 }
687
688 void InspectorBackendDispatcher::Console_disable(long callId, InspectorObject*)
689 {
690     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
691
692     if (!m_consoleAgent)
693         protocolErrors->pushString("Console handler is not available.");
694
695     ErrorString error;
696
697     if (!protocolErrors->length())
698         m_consoleAgent->disable(&error);
699
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);
702 }
703
704 void InspectorBackendDispatcher::Console_clearMessages(long callId, InspectorObject*)
705 {
706     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
707
708     if (!m_consoleAgent)
709         protocolErrors->pushString("Console handler is not available.");
710
711     ErrorString error;
712
713     if (!protocolErrors->length())
714         m_consoleAgent->clearMessages(&error);
715
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);
718 }
719
720 void InspectorBackendDispatcher::Console_setMonitoringXHREnabled(long callId, InspectorObject* requestMessageObject)
721 {
722     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
723
724     if (!m_consoleAgent)
725         protocolErrors->pushString("Console handler is not available.");
726
727     ErrorString error;
728
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);
733
734     if (!protocolErrors->length())
735         m_consoleAgent->setMonitoringXHREnabled(&error, in_enabled);
736
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);
739 }
740
741 void InspectorBackendDispatcher::Console_addInspectedNode(long callId, InspectorObject* requestMessageObject)
742 {
743     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
744
745     if (!m_consoleAgent)
746         protocolErrors->pushString("Console handler is not available.");
747
748     ErrorString error;
749
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);
754
755     if (!protocolErrors->length())
756         m_consoleAgent->addInspectedNode(&error, in_nodeId);
757
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);
760 }
761
762 void InspectorBackendDispatcher::Network_enable(long callId, InspectorObject*)
763 {
764     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
765
766     if (!m_networkAgent)
767         protocolErrors->pushString("Network handler is not available.");
768
769     ErrorString error;
770
771     if (!protocolErrors->length())
772         m_networkAgent->enable(&error);
773
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);
776 }
777
778 void InspectorBackendDispatcher::Network_disable(long callId, InspectorObject*)
779 {
780     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
781
782     if (!m_networkAgent)
783         protocolErrors->pushString("Network handler is not available.");
784
785     ErrorString error;
786
787     if (!protocolErrors->length())
788         m_networkAgent->disable(&error);
789
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);
792 }
793
794 void InspectorBackendDispatcher::Network_setUserAgentOverride(long callId, InspectorObject* requestMessageObject)
795 {
796     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
797
798     if (!m_networkAgent)
799         protocolErrors->pushString("Network handler is not available.");
800
801     ErrorString error;
802
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);
807
808     if (!protocolErrors->length())
809         m_networkAgent->setUserAgentOverride(&error, in_userAgent);
810
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);
813 }
814
815 void InspectorBackendDispatcher::Network_setExtraHTTPHeaders(long callId, InspectorObject* requestMessageObject)
816 {
817     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
818
819     if (!m_networkAgent)
820         protocolErrors->pushString("Network handler is not available.");
821
822     ErrorString error;
823
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);
828
829     if (!protocolErrors->length())
830         m_networkAgent->setExtraHTTPHeaders(&error, in_headers);
831
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);
834 }
835
836 void InspectorBackendDispatcher::Network_getResponseBody(long callId, InspectorObject* requestMessageObject)
837 {
838     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
839
840     if (!m_networkAgent)
841         protocolErrors->pushString("Network handler is not available.");
842
843     String out_body = "";
844     bool out_base64Encoded = false;
845
846     ErrorString error;
847
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);
852
853     if (!protocolErrors->length())
854         m_networkAgent->getResponseBody(&error, in_requestId, &out_body, &out_base64Encoded);
855
856     RefPtr<InspectorObject> result = InspectorObject::create();
857     if (!protocolErrors->length() && !error.length()) {
858         result->setString("body", out_body);
859         result->setBoolean("base64Encoded", out_base64Encoded);
860     }
861     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Network.getResponseBody"), protocolErrors, error);
862 }
863
864 void InspectorBackendDispatcher::Network_clearBrowserCache(long callId, InspectorObject*)
865 {
866     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
867
868     if (!m_networkAgent)
869         protocolErrors->pushString("Network handler is not available.");
870
871     ErrorString error;
872
873     if (!protocolErrors->length())
874         m_networkAgent->clearBrowserCache(&error);
875
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);
878 }
879
880 void InspectorBackendDispatcher::Network_clearBrowserCookies(long callId, InspectorObject*)
881 {
882     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
883
884     if (!m_networkAgent)
885         protocolErrors->pushString("Network handler is not available.");
886
887     ErrorString error;
888
889     if (!protocolErrors->length())
890         m_networkAgent->clearBrowserCookies(&error);
891
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);
894 }
895
896 void InspectorBackendDispatcher::Network_setCacheDisabled(long callId, InspectorObject* requestMessageObject)
897 {
898     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
899
900     if (!m_networkAgent)
901         protocolErrors->pushString("Network handler is not available.");
902
903     ErrorString error;
904
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);
909
910     if (!protocolErrors->length())
911         m_networkAgent->setCacheDisabled(&error, in_cacheDisabled);
912
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);
915 }
916
917 void InspectorBackendDispatcher::Database_enable(long callId, InspectorObject*)
918 {
919     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
920
921     if (!m_databaseAgent)
922         protocolErrors->pushString("Database handler is not available.");
923
924     ErrorString error;
925
926     if (!protocolErrors->length())
927         m_databaseAgent->enable(&error);
928
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);
931 }
932
933 void InspectorBackendDispatcher::Database_disable(long callId, InspectorObject*)
934 {
935     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
936
937     if (!m_databaseAgent)
938         protocolErrors->pushString("Database handler is not available.");
939
940     ErrorString error;
941
942     if (!protocolErrors->length())
943         m_databaseAgent->disable(&error);
944
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);
947 }
948
949 void InspectorBackendDispatcher::Database_getDatabaseTableNames(long callId, InspectorObject* requestMessageObject)
950 {
951     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
952
953     if (!m_databaseAgent)
954         protocolErrors->pushString("Database handler is not available.");
955
956     RefPtr<InspectorArray> out_tableNames = InspectorArray::create();
957
958     ErrorString error;
959
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);
964
965     if (!protocolErrors->length())
966         m_databaseAgent->getDatabaseTableNames(&error, in_databaseId, &out_tableNames);
967
968     RefPtr<InspectorObject> result = InspectorObject::create();
969     if (!protocolErrors->length() && !error.length()) {
970         result->setArray("tableNames", out_tableNames);
971     }
972     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Database.getDatabaseTableNames"), protocolErrors, error);
973 }
974
975 void InspectorBackendDispatcher::Database_executeSQL(long callId, InspectorObject* requestMessageObject)
976 {
977     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
978
979     if (!m_databaseAgent)
980         protocolErrors->pushString("Database handler is not available.");
981
982     bool out_success = false;
983     int out_transactionId = 0;
984
985     ErrorString error;
986
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);
992
993     if (!protocolErrors->length())
994         m_databaseAgent->executeSQL(&error, in_databaseId, in_query, &out_success, &out_transactionId);
995
996     RefPtr<InspectorObject> result = InspectorObject::create();
997     if (!protocolErrors->length() && !error.length()) {
998         result->setBoolean("success", out_success);
999         result->setNumber("transactionId", out_transactionId);
1000     }
1001     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQL"), protocolErrors, error);
1002 }
1003
1004 void InspectorBackendDispatcher::DOMStorage_enable(long callId, InspectorObject*)
1005 {
1006     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1007
1008     if (!m_domStorageAgent)
1009         protocolErrors->pushString("DOMStorage handler is not available.");
1010
1011     ErrorString error;
1012
1013     if (!protocolErrors->length())
1014         m_domStorageAgent->enable(&error);
1015
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);
1018 }
1019
1020 void InspectorBackendDispatcher::DOMStorage_disable(long callId, InspectorObject*)
1021 {
1022     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1023
1024     if (!m_domStorageAgent)
1025         protocolErrors->pushString("DOMStorage handler is not available.");
1026
1027     ErrorString error;
1028
1029     if (!protocolErrors->length())
1030         m_domStorageAgent->disable(&error);
1031
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);
1034 }
1035
1036 void InspectorBackendDispatcher::DOMStorage_getDOMStorageEntries(long callId, InspectorObject* requestMessageObject)
1037 {
1038     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1039
1040     if (!m_domStorageAgent)
1041         protocolErrors->pushString("DOMStorage handler is not available.");
1042
1043     RefPtr<InspectorArray> out_entries = InspectorArray::create();
1044
1045     ErrorString error;
1046
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);
1051
1052     if (!protocolErrors->length())
1053         m_domStorageAgent->getDOMStorageEntries(&error, in_storageId, &out_entries);
1054
1055     RefPtr<InspectorObject> result = InspectorObject::create();
1056     if (!protocolErrors->length() && !error.length()) {
1057         result->setArray("entries", out_entries);
1058     }
1059     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMStorage.getDOMStorageEntries"), protocolErrors, error);
1060 }
1061
1062 void InspectorBackendDispatcher::DOMStorage_setDOMStorageItem(long callId, InspectorObject* requestMessageObject)
1063 {
1064     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1065
1066     if (!m_domStorageAgent)
1067         protocolErrors->pushString("DOMStorage handler is not available.");
1068
1069     bool out_success = false;
1070
1071     ErrorString error;
1072
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);
1079
1080     if (!protocolErrors->length())
1081         m_domStorageAgent->setDOMStorageItem(&error, in_storageId, in_key, in_value, &out_success);
1082
1083     RefPtr<InspectorObject> result = InspectorObject::create();
1084     if (!protocolErrors->length() && !error.length()) {
1085         result->setBoolean("success", out_success);
1086     }
1087     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMStorage.setDOMStorageItem"), protocolErrors, error);
1088 }
1089
1090 void InspectorBackendDispatcher::DOMStorage_removeDOMStorageItem(long callId, InspectorObject* requestMessageObject)
1091 {
1092     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1093
1094     if (!m_domStorageAgent)
1095         protocolErrors->pushString("DOMStorage handler is not available.");
1096
1097     bool out_success = false;
1098
1099     ErrorString error;
1100
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);
1106
1107     if (!protocolErrors->length())
1108         m_domStorageAgent->removeDOMStorageItem(&error, in_storageId, in_key, &out_success);
1109
1110     RefPtr<InspectorObject> result = InspectorObject::create();
1111     if (!protocolErrors->length() && !error.length()) {
1112         result->setBoolean("success", out_success);
1113     }
1114     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOMStorage.removeDOMStorageItem"), protocolErrors, error);
1115 }
1116
1117 void InspectorBackendDispatcher::ApplicationCache_getFramesWithManifests(long callId, InspectorObject*)
1118 {
1119     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1120
1121     if (!m_applicationCacheAgent)
1122         protocolErrors->pushString("ApplicationCache handler is not available.");
1123
1124     RefPtr<InspectorArray> out_frameIds = InspectorArray::create();
1125
1126     ErrorString error;
1127
1128     if (!protocolErrors->length())
1129         m_applicationCacheAgent->getFramesWithManifests(&error, &out_frameIds);
1130
1131     RefPtr<InspectorObject> result = InspectorObject::create();
1132     if (!protocolErrors->length() && !error.length()) {
1133         result->setArray("frameIds", out_frameIds);
1134     }
1135     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "ApplicationCache.getFramesWithManifests"), protocolErrors, error);
1136 }
1137
1138 void InspectorBackendDispatcher::ApplicationCache_enable(long callId, InspectorObject*)
1139 {
1140     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1141
1142     if (!m_applicationCacheAgent)
1143         protocolErrors->pushString("ApplicationCache handler is not available.");
1144
1145     ErrorString error;
1146
1147     if (!protocolErrors->length())
1148         m_applicationCacheAgent->enable(&error);
1149
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);
1152 }
1153
1154 void InspectorBackendDispatcher::ApplicationCache_getManifestForFrame(long callId, InspectorObject* requestMessageObject)
1155 {
1156     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1157
1158     if (!m_applicationCacheAgent)
1159         protocolErrors->pushString("ApplicationCache handler is not available.");
1160
1161     String out_manifestURL = "";
1162
1163     ErrorString error;
1164
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);
1169
1170     if (!protocolErrors->length())
1171         m_applicationCacheAgent->getManifestForFrame(&error, in_frameId, &out_manifestURL);
1172
1173     RefPtr<InspectorObject> result = InspectorObject::create();
1174     if (!protocolErrors->length() && !error.length()) {
1175         result->setString("manifestURL", out_manifestURL);
1176     }
1177     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "ApplicationCache.getManifestForFrame"), protocolErrors, error);
1178 }
1179
1180 void InspectorBackendDispatcher::ApplicationCache_getApplicationCacheForFrame(long callId, InspectorObject* requestMessageObject)
1181 {
1182     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1183
1184     if (!m_applicationCacheAgent)
1185         protocolErrors->pushString("ApplicationCache handler is not available.");
1186
1187     RefPtr<InspectorObject> out_applicationCache = InspectorObject::create();
1188
1189     ErrorString error;
1190
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);
1195
1196     if (!protocolErrors->length())
1197         m_applicationCacheAgent->getApplicationCacheForFrame(&error, in_frameId, &out_applicationCache);
1198
1199     RefPtr<InspectorObject> result = InspectorObject::create();
1200     if (!protocolErrors->length() && !error.length()) {
1201         result->setObject("applicationCache", out_applicationCache);
1202     }
1203     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "ApplicationCache.getApplicationCacheForFrame"), protocolErrors, error);
1204 }
1205
1206 void InspectorBackendDispatcher::FileSystem_enable(long callId, InspectorObject*)
1207 {
1208     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1209
1210     if (!m_fileSystemAgent)
1211         protocolErrors->pushString("FileSystem handler is not available.");
1212
1213     ErrorString error;
1214
1215     if (!protocolErrors->length())
1216         m_fileSystemAgent->enable(&error);
1217
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);
1220 }
1221
1222 void InspectorBackendDispatcher::FileSystem_disable(long callId, InspectorObject*)
1223 {
1224     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1225
1226     if (!m_fileSystemAgent)
1227         protocolErrors->pushString("FileSystem handler is not available.");
1228
1229     ErrorString error;
1230
1231     if (!protocolErrors->length())
1232         m_fileSystemAgent->disable(&error);
1233
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);
1236 }
1237
1238 void InspectorBackendDispatcher::DOM_getDocument(long callId, InspectorObject*)
1239 {
1240     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1241
1242     if (!m_domAgent)
1243         protocolErrors->pushString("DOM handler is not available.");
1244
1245     RefPtr<InspectorObject> out_root = InspectorObject::create();
1246
1247     ErrorString error;
1248
1249     if (!protocolErrors->length())
1250         m_domAgent->getDocument(&error, &out_root);
1251
1252     RefPtr<InspectorObject> result = InspectorObject::create();
1253     if (!protocolErrors->length() && !error.length()) {
1254         result->setObject("root", out_root);
1255     }
1256     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getDocument"), protocolErrors, error);
1257 }
1258
1259 void InspectorBackendDispatcher::DOM_requestChildNodes(long callId, InspectorObject* requestMessageObject)
1260 {
1261     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1262
1263     if (!m_domAgent)
1264         protocolErrors->pushString("DOM handler is not available.");
1265
1266     ErrorString error;
1267
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);
1272
1273     if (!protocolErrors->length())
1274         m_domAgent->requestChildNodes(&error, in_nodeId);
1275
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);
1278 }
1279
1280 void InspectorBackendDispatcher::DOM_querySelector(long callId, InspectorObject* requestMessageObject)
1281 {
1282     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1283
1284     if (!m_domAgent)
1285         protocolErrors->pushString("DOM handler is not available.");
1286
1287     int out_nodeId = 0;
1288
1289     ErrorString error;
1290
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);
1296
1297     if (!protocolErrors->length())
1298         m_domAgent->querySelector(&error, in_nodeId, in_selector, &out_nodeId);
1299
1300     RefPtr<InspectorObject> result = InspectorObject::create();
1301     if (!protocolErrors->length() && !error.length()) {
1302         result->setNumber("nodeId", out_nodeId);
1303     }
1304     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.querySelector"), protocolErrors, error);
1305 }
1306
1307 void InspectorBackendDispatcher::DOM_querySelectorAll(long callId, InspectorObject* requestMessageObject)
1308 {
1309     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1310
1311     if (!m_domAgent)
1312         protocolErrors->pushString("DOM handler is not available.");
1313
1314     RefPtr<InspectorArray> out_nodeIds = InspectorArray::create();
1315
1316     ErrorString error;
1317
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);
1323
1324     if (!protocolErrors->length())
1325         m_domAgent->querySelectorAll(&error, in_nodeId, in_selector, &out_nodeIds);
1326
1327     RefPtr<InspectorObject> result = InspectorObject::create();
1328     if (!protocolErrors->length() && !error.length()) {
1329         result->setArray("nodeIds", out_nodeIds);
1330     }
1331     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.querySelectorAll"), protocolErrors, error);
1332 }
1333
1334 void InspectorBackendDispatcher::DOM_setNodeName(long callId, InspectorObject* requestMessageObject)
1335 {
1336     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1337
1338     if (!m_domAgent)
1339         protocolErrors->pushString("DOM handler is not available.");
1340
1341     int out_nodeId = 0;
1342
1343     ErrorString error;
1344
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);
1350
1351     if (!protocolErrors->length())
1352         m_domAgent->setNodeName(&error, in_nodeId, in_name, &out_nodeId);
1353
1354     RefPtr<InspectorObject> result = InspectorObject::create();
1355     if (!protocolErrors->length() && !error.length()) {
1356         result->setNumber("nodeId", out_nodeId);
1357     }
1358     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.setNodeName"), protocolErrors, error);
1359 }
1360
1361 void InspectorBackendDispatcher::DOM_setNodeValue(long callId, InspectorObject* requestMessageObject)
1362 {
1363     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1364
1365     if (!m_domAgent)
1366         protocolErrors->pushString("DOM handler is not available.");
1367
1368     ErrorString error;
1369
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);
1375
1376     if (!protocolErrors->length())
1377         m_domAgent->setNodeValue(&error, in_nodeId, in_value);
1378
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);
1381 }
1382
1383 void InspectorBackendDispatcher::DOM_removeNode(long callId, InspectorObject* requestMessageObject)
1384 {
1385     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1386
1387     if (!m_domAgent)
1388         protocolErrors->pushString("DOM handler is not available.");
1389
1390     ErrorString error;
1391
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);
1396
1397     if (!protocolErrors->length())
1398         m_domAgent->removeNode(&error, in_nodeId);
1399
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);
1402 }
1403
1404 void InspectorBackendDispatcher::DOM_setAttributeValue(long callId, InspectorObject* requestMessageObject)
1405 {
1406     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1407
1408     if (!m_domAgent)
1409         protocolErrors->pushString("DOM handler is not available.");
1410
1411     ErrorString error;
1412
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);
1419
1420     if (!protocolErrors->length())
1421         m_domAgent->setAttributeValue(&error, in_nodeId, in_name, in_value);
1422
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);
1425 }
1426
1427 void InspectorBackendDispatcher::DOM_setAttributesAsText(long callId, InspectorObject* requestMessageObject)
1428 {
1429     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1430
1431     if (!m_domAgent)
1432         protocolErrors->pushString("DOM handler is not available.");
1433
1434     ErrorString error;
1435
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);
1443
1444     if (!protocolErrors->length())
1445         m_domAgent->setAttributesAsText(&error, in_nodeId, in_text, name_valueFound ? &in_name : 0);
1446
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);
1449 }
1450
1451 void InspectorBackendDispatcher::DOM_removeAttribute(long callId, InspectorObject* requestMessageObject)
1452 {
1453     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1454
1455     if (!m_domAgent)
1456         protocolErrors->pushString("DOM handler is not available.");
1457
1458     ErrorString error;
1459
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);
1465
1466     if (!protocolErrors->length())
1467         m_domAgent->removeAttribute(&error, in_nodeId, in_name);
1468
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);
1471 }
1472
1473 void InspectorBackendDispatcher::DOM_getEventListenersForNode(long callId, InspectorObject* requestMessageObject)
1474 {
1475     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1476
1477     if (!m_domAgent)
1478         protocolErrors->pushString("DOM handler is not available.");
1479
1480     RefPtr<InspectorArray> out_listeners = InspectorArray::create();
1481
1482     ErrorString error;
1483
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);
1488
1489     if (!protocolErrors->length())
1490         m_domAgent->getEventListenersForNode(&error, in_nodeId, &out_listeners);
1491
1492     RefPtr<InspectorObject> result = InspectorObject::create();
1493     if (!protocolErrors->length() && !error.length()) {
1494         result->setArray("listeners", out_listeners);
1495     }
1496     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getEventListenersForNode"), protocolErrors, error);
1497 }
1498
1499 void InspectorBackendDispatcher::DOM_copyNode(long callId, InspectorObject* requestMessageObject)
1500 {
1501     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1502
1503     if (!m_domAgent)
1504         protocolErrors->pushString("DOM handler is not available.");
1505
1506     ErrorString error;
1507
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);
1512
1513     if (!protocolErrors->length())
1514         m_domAgent->copyNode(&error, in_nodeId);
1515
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);
1518 }
1519
1520 void InspectorBackendDispatcher::DOM_getOuterHTML(long callId, InspectorObject* requestMessageObject)
1521 {
1522     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1523
1524     if (!m_domAgent)
1525         protocolErrors->pushString("DOM handler is not available.");
1526
1527     String out_outerHTML = "";
1528
1529     ErrorString error;
1530
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);
1535
1536     if (!protocolErrors->length())
1537         m_domAgent->getOuterHTML(&error, in_nodeId, &out_outerHTML);
1538
1539     RefPtr<InspectorObject> result = InspectorObject::create();
1540     if (!protocolErrors->length() && !error.length()) {
1541         result->setString("outerHTML", out_outerHTML);
1542     }
1543     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getOuterHTML"), protocolErrors, error);
1544 }
1545
1546 void InspectorBackendDispatcher::DOM_setOuterHTML(long callId, InspectorObject* requestMessageObject)
1547 {
1548     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1549
1550     if (!m_domAgent)
1551         protocolErrors->pushString("DOM handler is not available.");
1552
1553     int out_nodeId = 0;
1554
1555     ErrorString error;
1556
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);
1562
1563     if (!protocolErrors->length())
1564         m_domAgent->setOuterHTML(&error, in_nodeId, in_outerHTML, &out_nodeId);
1565
1566     RefPtr<InspectorObject> result = InspectorObject::create();
1567     if (!protocolErrors->length() && !error.length()) {
1568         result->setNumber("nodeId", out_nodeId);
1569     }
1570     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.setOuterHTML"), protocolErrors, error);
1571 }
1572
1573 void InspectorBackendDispatcher::DOM_performSearch(long callId, InspectorObject* requestMessageObject)
1574 {
1575     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1576
1577     if (!m_domAgent)
1578         protocolErrors->pushString("DOM handler is not available.");
1579
1580     String out_searchId = "";
1581     int out_resultCount = 0;
1582
1583     ErrorString error;
1584
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);
1589
1590     if (!protocolErrors->length())
1591         m_domAgent->performSearch(&error, in_query, &out_searchId, &out_resultCount);
1592
1593     RefPtr<InspectorObject> result = InspectorObject::create();
1594     if (!protocolErrors->length() && !error.length()) {
1595         result->setString("searchId", out_searchId);
1596         result->setNumber("resultCount", out_resultCount);
1597     }
1598     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.performSearch"), protocolErrors, error);
1599 }
1600
1601 void InspectorBackendDispatcher::DOM_getSearchResults(long callId, InspectorObject* requestMessageObject)
1602 {
1603     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1604
1605     if (!m_domAgent)
1606         protocolErrors->pushString("DOM handler is not available.");
1607
1608     RefPtr<InspectorArray> out_nodeIds = InspectorArray::create();
1609
1610     ErrorString error;
1611
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);
1618
1619     if (!protocolErrors->length())
1620         m_domAgent->getSearchResults(&error, in_searchId, in_fromIndex, in_toIndex, &out_nodeIds);
1621
1622     RefPtr<InspectorObject> result = InspectorObject::create();
1623     if (!protocolErrors->length() && !error.length()) {
1624         result->setArray("nodeIds", out_nodeIds);
1625     }
1626     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getSearchResults"), protocolErrors, error);
1627 }
1628
1629 void InspectorBackendDispatcher::DOM_discardSearchResults(long callId, InspectorObject* requestMessageObject)
1630 {
1631     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1632
1633     if (!m_domAgent)
1634         protocolErrors->pushString("DOM handler is not available.");
1635
1636     ErrorString error;
1637
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);
1642
1643     if (!protocolErrors->length())
1644         m_domAgent->discardSearchResults(&error, in_searchId);
1645
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);
1648 }
1649
1650 void InspectorBackendDispatcher::DOM_requestNode(long callId, InspectorObject* requestMessageObject)
1651 {
1652     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1653
1654     if (!m_domAgent)
1655         protocolErrors->pushString("DOM handler is not available.");
1656
1657     int out_nodeId = 0;
1658
1659     ErrorString error;
1660
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);
1665
1666     if (!protocolErrors->length())
1667         m_domAgent->requestNode(&error, in_objectId, &out_nodeId);
1668
1669     RefPtr<InspectorObject> result = InspectorObject::create();
1670     if (!protocolErrors->length() && !error.length()) {
1671         result->setNumber("nodeId", out_nodeId);
1672     }
1673     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.requestNode"), protocolErrors, error);
1674 }
1675
1676 void InspectorBackendDispatcher::DOM_setInspectModeEnabled(long callId, InspectorObject* requestMessageObject)
1677 {
1678     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1679
1680     if (!m_domAgent)
1681         protocolErrors->pushString("DOM handler is not available.");
1682
1683     ErrorString error;
1684
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);
1691
1692     if (!protocolErrors->length())
1693         m_domAgent->setInspectModeEnabled(&error, in_enabled, highlightConfig_valueFound ? &in_highlightConfig : 0);
1694
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);
1697 }
1698
1699 void InspectorBackendDispatcher::DOM_highlightRect(long callId, InspectorObject* requestMessageObject)
1700 {
1701     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1702
1703     if (!m_domAgent)
1704         protocolErrors->pushString("DOM handler is not available.");
1705
1706     ErrorString error;
1707
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);
1719
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);
1722
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);
1725 }
1726
1727 void InspectorBackendDispatcher::DOM_highlightNode(long callId, InspectorObject* requestMessageObject)
1728 {
1729     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1730
1731     if (!m_domAgent)
1732         protocolErrors->pushString("DOM handler is not available.");
1733
1734     ErrorString error;
1735
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);
1741
1742     if (!protocolErrors->length())
1743         m_domAgent->highlightNode(&error, in_nodeId, in_highlightConfig);
1744
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);
1747 }
1748
1749 void InspectorBackendDispatcher::DOM_hideHighlight(long callId, InspectorObject*)
1750 {
1751     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1752
1753     if (!m_domAgent)
1754         protocolErrors->pushString("DOM handler is not available.");
1755
1756     ErrorString error;
1757
1758     if (!protocolErrors->length())
1759         m_domAgent->hideHighlight(&error);
1760
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);
1763 }
1764
1765 void InspectorBackendDispatcher::DOM_highlightFrame(long callId, InspectorObject* requestMessageObject)
1766 {
1767     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1768
1769     if (!m_domAgent)
1770         protocolErrors->pushString("DOM handler is not available.");
1771
1772     ErrorString error;
1773
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);
1782
1783     if (!protocolErrors->length())
1784         m_domAgent->highlightFrame(&error, in_frameId, contentColor_valueFound ? &in_contentColor : 0, contentOutlineColor_valueFound ? &in_contentOutlineColor : 0);
1785
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);
1788 }
1789
1790 void InspectorBackendDispatcher::DOM_pushNodeByPathToFrontend(long callId, InspectorObject* requestMessageObject)
1791 {
1792     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1793
1794     if (!m_domAgent)
1795         protocolErrors->pushString("DOM handler is not available.");
1796
1797     int out_nodeId = 0;
1798
1799     ErrorString error;
1800
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);
1805
1806     if (!protocolErrors->length())
1807         m_domAgent->pushNodeByPathToFrontend(&error, in_path, &out_nodeId);
1808
1809     RefPtr<InspectorObject> result = InspectorObject::create();
1810     if (!protocolErrors->length() && !error.length()) {
1811         result->setNumber("nodeId", out_nodeId);
1812     }
1813     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.pushNodeByPathToFrontend"), protocolErrors, error);
1814 }
1815
1816 void InspectorBackendDispatcher::DOM_resolveNode(long callId, InspectorObject* requestMessageObject)
1817 {
1818     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1819
1820     if (!m_domAgent)
1821         protocolErrors->pushString("DOM handler is not available.");
1822
1823     RefPtr<InspectorObject> out_object = InspectorObject::create();
1824
1825     ErrorString error;
1826
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);
1833
1834     if (!protocolErrors->length())
1835         m_domAgent->resolveNode(&error, in_nodeId, objectGroup_valueFound ? &in_objectGroup : 0, &out_object);
1836
1837     RefPtr<InspectorObject> result = InspectorObject::create();
1838     if (!protocolErrors->length() && !error.length()) {
1839         result->setObject("object", out_object);
1840     }
1841     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.resolveNode"), protocolErrors, error);
1842 }
1843
1844 void InspectorBackendDispatcher::DOM_getAttributes(long callId, InspectorObject* requestMessageObject)
1845 {
1846     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1847
1848     if (!m_domAgent)
1849         protocolErrors->pushString("DOM handler is not available.");
1850
1851     RefPtr<InspectorArray> out_attributes = InspectorArray::create();
1852
1853     ErrorString error;
1854
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);
1859
1860     if (!protocolErrors->length())
1861         m_domAgent->getAttributes(&error, in_nodeId, &out_attributes);
1862
1863     RefPtr<InspectorObject> result = InspectorObject::create();
1864     if (!protocolErrors->length() && !error.length()) {
1865         result->setArray("attributes", out_attributes);
1866     }
1867     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.getAttributes"), protocolErrors, error);
1868 }
1869
1870 void InspectorBackendDispatcher::DOM_moveTo(long callId, InspectorObject* requestMessageObject)
1871 {
1872     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1873
1874     if (!m_domAgent)
1875         protocolErrors->pushString("DOM handler is not available.");
1876
1877     int out_nodeId = 0;
1878
1879     ErrorString error;
1880
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);
1888
1889     if (!protocolErrors->length())
1890         m_domAgent->moveTo(&error, in_nodeId, in_targetNodeId, insertBeforeNodeId_valueFound ? &in_insertBeforeNodeId : 0, &out_nodeId);
1891
1892     RefPtr<InspectorObject> result = InspectorObject::create();
1893     if (!protocolErrors->length() && !error.length()) {
1894         result->setNumber("nodeId", out_nodeId);
1895     }
1896     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "DOM.moveTo"), protocolErrors, error);
1897 }
1898
1899 void InspectorBackendDispatcher::CSS_getMatchedStylesForNode(long callId, InspectorObject* requestMessageObject)
1900 {
1901     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1902
1903     if (!m_cssAgent)
1904         protocolErrors->pushString("CSS handler is not available.");
1905
1906     RefPtr<InspectorArray> out_matchedCSSRules = InspectorArray::create();
1907     RefPtr<InspectorArray> out_pseudoElements = InspectorArray::create();
1908     RefPtr<InspectorArray> out_inherited = InspectorArray::create();
1909
1910     ErrorString error;
1911
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);
1922
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);
1925
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);
1931     }
1932     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getMatchedStylesForNode"), protocolErrors, error);
1933 }
1934
1935 void InspectorBackendDispatcher::CSS_getInlineStylesForNode(long callId, InspectorObject* requestMessageObject)
1936 {
1937     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1938
1939     if (!m_cssAgent)
1940         protocolErrors->pushString("CSS handler is not available.");
1941
1942     RefPtr<InspectorObject> out_inlineStyle = InspectorObject::create();
1943     RefPtr<InspectorArray> out_styleAttributes = InspectorArray::create();
1944
1945     ErrorString error;
1946
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);
1951
1952     if (!protocolErrors->length())
1953         m_cssAgent->getInlineStylesForNode(&error, in_nodeId, &out_inlineStyle, &out_styleAttributes);
1954
1955     RefPtr<InspectorObject> result = InspectorObject::create();
1956     if (!protocolErrors->length() && !error.length()) {
1957         result->setObject("inlineStyle", out_inlineStyle);
1958         result->setArray("styleAttributes", out_styleAttributes);
1959     }
1960     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getInlineStylesForNode"), protocolErrors, error);
1961 }
1962
1963 void InspectorBackendDispatcher::CSS_getComputedStyleForNode(long callId, InspectorObject* requestMessageObject)
1964 {
1965     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1966
1967     if (!m_cssAgent)
1968         protocolErrors->pushString("CSS handler is not available.");
1969
1970     RefPtr<InspectorArray> out_computedStyle = InspectorArray::create();
1971
1972     ErrorString error;
1973
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);
1980
1981     if (!protocolErrors->length())
1982         m_cssAgent->getComputedStyleForNode(&error, in_nodeId, forcedPseudoClasses_valueFound ? &in_forcedPseudoClasses : 0, &out_computedStyle);
1983
1984     RefPtr<InspectorObject> result = InspectorObject::create();
1985     if (!protocolErrors->length() && !error.length()) {
1986         result->setArray("computedStyle", out_computedStyle);
1987     }
1988     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getComputedStyleForNode"), protocolErrors, error);
1989 }
1990
1991 void InspectorBackendDispatcher::CSS_getAllStyleSheets(long callId, InspectorObject*)
1992 {
1993     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
1994
1995     if (!m_cssAgent)
1996         protocolErrors->pushString("CSS handler is not available.");
1997
1998     RefPtr<InspectorArray> out_headers = InspectorArray::create();
1999
2000     ErrorString error;
2001
2002     if (!protocolErrors->length())
2003         m_cssAgent->getAllStyleSheets(&error, &out_headers);
2004
2005     RefPtr<InspectorObject> result = InspectorObject::create();
2006     if (!protocolErrors->length() && !error.length()) {
2007         result->setArray("headers", out_headers);
2008     }
2009     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getAllStyleSheets"), protocolErrors, error);
2010 }
2011
2012 void InspectorBackendDispatcher::CSS_getStyleSheet(long callId, InspectorObject* requestMessageObject)
2013 {
2014     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2015
2016     if (!m_cssAgent)
2017         protocolErrors->pushString("CSS handler is not available.");
2018
2019     RefPtr<InspectorObject> out_styleSheet = InspectorObject::create();
2020
2021     ErrorString error;
2022
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);
2027
2028     if (!protocolErrors->length())
2029         m_cssAgent->getStyleSheet(&error, in_styleSheetId, &out_styleSheet);
2030
2031     RefPtr<InspectorObject> result = InspectorObject::create();
2032     if (!protocolErrors->length() && !error.length()) {
2033         result->setObject("styleSheet", out_styleSheet);
2034     }
2035     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getStyleSheet"), protocolErrors, error);
2036 }
2037
2038 void InspectorBackendDispatcher::CSS_getStyleSheetText(long callId, InspectorObject* requestMessageObject)
2039 {
2040     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2041
2042     if (!m_cssAgent)
2043         protocolErrors->pushString("CSS handler is not available.");
2044
2045     String out_text = "";
2046
2047     ErrorString error;
2048
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);
2053
2054     if (!protocolErrors->length())
2055         m_cssAgent->getStyleSheetText(&error, in_styleSheetId, &out_text);
2056
2057     RefPtr<InspectorObject> result = InspectorObject::create();
2058     if (!protocolErrors->length() && !error.length()) {
2059         result->setString("text", out_text);
2060     }
2061     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getStyleSheetText"), protocolErrors, error);
2062 }
2063
2064 void InspectorBackendDispatcher::CSS_setStyleSheetText(long callId, InspectorObject* requestMessageObject)
2065 {
2066     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2067
2068     if (!m_cssAgent)
2069         protocolErrors->pushString("CSS handler is not available.");
2070
2071     ErrorString error;
2072
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);
2078
2079     if (!protocolErrors->length())
2080         m_cssAgent->setStyleSheetText(&error, in_styleSheetId, in_text);
2081
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);
2084 }
2085
2086 void InspectorBackendDispatcher::CSS_setPropertyText(long callId, InspectorObject* requestMessageObject)
2087 {
2088     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2089
2090     if (!m_cssAgent)
2091         protocolErrors->pushString("CSS handler is not available.");
2092
2093     RefPtr<InspectorObject> out_style = InspectorObject::create();
2094
2095     ErrorString error;
2096
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);
2104
2105     if (!protocolErrors->length())
2106         m_cssAgent->setPropertyText(&error, in_styleId, in_propertyIndex, in_text, in_overwrite, &out_style);
2107
2108     RefPtr<InspectorObject> result = InspectorObject::create();
2109     if (!protocolErrors->length() && !error.length()) {
2110         result->setObject("style", out_style);
2111     }
2112     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.setPropertyText"), protocolErrors, error);
2113 }
2114
2115 void InspectorBackendDispatcher::CSS_toggleProperty(long callId, InspectorObject* requestMessageObject)
2116 {
2117     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2118
2119     if (!m_cssAgent)
2120         protocolErrors->pushString("CSS handler is not available.");
2121
2122     RefPtr<InspectorObject> out_style = InspectorObject::create();
2123
2124     ErrorString error;
2125
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);
2132
2133     if (!protocolErrors->length())
2134         m_cssAgent->toggleProperty(&error, in_styleId, in_propertyIndex, in_disable, &out_style);
2135
2136     RefPtr<InspectorObject> result = InspectorObject::create();
2137     if (!protocolErrors->length() && !error.length()) {
2138         result->setObject("style", out_style);
2139     }
2140     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.toggleProperty"), protocolErrors, error);
2141 }
2142
2143 void InspectorBackendDispatcher::CSS_setRuleSelector(long callId, InspectorObject* requestMessageObject)
2144 {
2145     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2146
2147     if (!m_cssAgent)
2148         protocolErrors->pushString("CSS handler is not available.");
2149
2150     RefPtr<InspectorObject> out_rule = InspectorObject::create();
2151
2152     ErrorString error;
2153
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);
2159
2160     if (!protocolErrors->length())
2161         m_cssAgent->setRuleSelector(&error, in_ruleId, in_selector, &out_rule);
2162
2163     RefPtr<InspectorObject> result = InspectorObject::create();
2164     if (!protocolErrors->length() && !error.length()) {
2165         result->setObject("rule", out_rule);
2166     }
2167     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.setRuleSelector"), protocolErrors, error);
2168 }
2169
2170 void InspectorBackendDispatcher::CSS_addRule(long callId, InspectorObject* requestMessageObject)
2171 {
2172     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2173
2174     if (!m_cssAgent)
2175         protocolErrors->pushString("CSS handler is not available.");
2176
2177     RefPtr<InspectorObject> out_rule = InspectorObject::create();
2178
2179     ErrorString error;
2180
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);
2186
2187     if (!protocolErrors->length())
2188         m_cssAgent->addRule(&error, in_contextNodeId, in_selector, &out_rule);
2189
2190     RefPtr<InspectorObject> result = InspectorObject::create();
2191     if (!protocolErrors->length() && !error.length()) {
2192         result->setObject("rule", out_rule);
2193     }
2194     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.addRule"), protocolErrors, error);
2195 }
2196
2197 void InspectorBackendDispatcher::CSS_getSupportedCSSProperties(long callId, InspectorObject*)
2198 {
2199     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2200
2201     if (!m_cssAgent)
2202         protocolErrors->pushString("CSS handler is not available.");
2203
2204     RefPtr<InspectorArray> out_cssProperties = InspectorArray::create();
2205
2206     ErrorString error;
2207
2208     if (!protocolErrors->length())
2209         m_cssAgent->getSupportedCSSProperties(&error, &out_cssProperties);
2210
2211     RefPtr<InspectorObject> result = InspectorObject::create();
2212     if (!protocolErrors->length() && !error.length()) {
2213         result->setArray("cssProperties", out_cssProperties);
2214     }
2215     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "CSS.getSupportedCSSProperties"), protocolErrors, error);
2216 }
2217
2218 void InspectorBackendDispatcher::Timeline_start(long callId, InspectorObject* requestMessageObject)
2219 {
2220     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2221
2222     if (!m_timelineAgent)
2223         protocolErrors->pushString("Timeline handler is not available.");
2224
2225     ErrorString error;
2226
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);
2232
2233     if (!protocolErrors->length())
2234         m_timelineAgent->start(&error, maxCallStackDepth_valueFound ? &in_maxCallStackDepth : 0);
2235
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);
2238 }
2239
2240 void InspectorBackendDispatcher::Timeline_stop(long callId, InspectorObject*)
2241 {
2242     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2243
2244     if (!m_timelineAgent)
2245         protocolErrors->pushString("Timeline handler is not available.");
2246
2247     ErrorString error;
2248
2249     if (!protocolErrors->length())
2250         m_timelineAgent->stop(&error);
2251
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);
2254 }
2255
2256 void InspectorBackendDispatcher::Debugger_enable(long callId, InspectorObject*)
2257 {
2258     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2259
2260     if (!m_debuggerAgent)
2261         protocolErrors->pushString("Debugger handler is not available.");
2262
2263     ErrorString error;
2264
2265     if (!protocolErrors->length())
2266         m_debuggerAgent->enable(&error);
2267
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);
2270 }
2271
2272 void InspectorBackendDispatcher::Debugger_disable(long callId, InspectorObject*)
2273 {
2274     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2275
2276     if (!m_debuggerAgent)
2277         protocolErrors->pushString("Debugger handler is not available.");
2278
2279     ErrorString error;
2280
2281     if (!protocolErrors->length())
2282         m_debuggerAgent->disable(&error);
2283
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);
2286 }
2287
2288 void InspectorBackendDispatcher::Debugger_setBreakpointsActive(long callId, InspectorObject* requestMessageObject)
2289 {
2290     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2291
2292     if (!m_debuggerAgent)
2293         protocolErrors->pushString("Debugger handler is not available.");
2294
2295     ErrorString error;
2296
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);
2301
2302     if (!protocolErrors->length())
2303         m_debuggerAgent->setBreakpointsActive(&error, in_active);
2304
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);
2307 }
2308
2309 void InspectorBackendDispatcher::Debugger_setBreakpointByUrl(long callId, InspectorObject* requestMessageObject)
2310 {
2311     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2312
2313     if (!m_debuggerAgent)
2314         protocolErrors->pushString("Debugger handler is not available.");
2315
2316     String out_breakpointId = "";
2317     RefPtr<InspectorArray> out_locations = InspectorArray::create();
2318
2319     ErrorString error;
2320
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);
2333
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);
2336
2337     RefPtr<InspectorObject> result = InspectorObject::create();
2338     if (!protocolErrors->length() && !error.length()) {
2339         result->setString("breakpointId", out_breakpointId);
2340         result->setArray("locations", out_locations);
2341     }
2342     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.setBreakpointByUrl"), protocolErrors, error);
2343 }
2344
2345 void InspectorBackendDispatcher::Debugger_setBreakpoint(long callId, InspectorObject* requestMessageObject)
2346 {
2347     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2348
2349     if (!m_debuggerAgent)
2350         protocolErrors->pushString("Debugger handler is not available.");
2351
2352     String out_breakpointId = "";
2353     RefPtr<InspectorObject> out_actualLocation = InspectorObject::create();
2354
2355     ErrorString error;
2356
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);
2363
2364     if (!protocolErrors->length())
2365         m_debuggerAgent->setBreakpoint(&error, in_location, condition_valueFound ? &in_condition : 0, &out_breakpointId, &out_actualLocation);
2366
2367     RefPtr<InspectorObject> result = InspectorObject::create();
2368     if (!protocolErrors->length() && !error.length()) {
2369         result->setString("breakpointId", out_breakpointId);
2370         result->setObject("actualLocation", out_actualLocation);
2371     }
2372     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.setBreakpoint"), protocolErrors, error);
2373 }
2374
2375 void InspectorBackendDispatcher::Debugger_removeBreakpoint(long callId, InspectorObject* requestMessageObject)
2376 {
2377     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2378
2379     if (!m_debuggerAgent)
2380         protocolErrors->pushString("Debugger handler is not available.");
2381
2382     ErrorString error;
2383
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);
2388
2389     if (!protocolErrors->length())
2390         m_debuggerAgent->removeBreakpoint(&error, in_breakpointId);
2391
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);
2394 }
2395
2396 void InspectorBackendDispatcher::Debugger_continueToLocation(long callId, InspectorObject* requestMessageObject)
2397 {
2398     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2399
2400     if (!m_debuggerAgent)
2401         protocolErrors->pushString("Debugger handler is not available.");
2402
2403     ErrorString error;
2404
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);
2409
2410     if (!protocolErrors->length())
2411         m_debuggerAgent->continueToLocation(&error, in_location);
2412
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);
2415 }
2416
2417 void InspectorBackendDispatcher::Debugger_stepOver(long callId, InspectorObject*)
2418 {
2419     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2420
2421     if (!m_debuggerAgent)
2422         protocolErrors->pushString("Debugger handler is not available.");
2423
2424     ErrorString error;
2425
2426     if (!protocolErrors->length())
2427         m_debuggerAgent->stepOver(&error);
2428
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);
2431 }
2432
2433 void InspectorBackendDispatcher::Debugger_stepInto(long callId, InspectorObject*)
2434 {
2435     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2436
2437     if (!m_debuggerAgent)
2438         protocolErrors->pushString("Debugger handler is not available.");
2439
2440     ErrorString error;
2441
2442     if (!protocolErrors->length())
2443         m_debuggerAgent->stepInto(&error);
2444
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);
2447 }
2448
2449 void InspectorBackendDispatcher::Debugger_stepOut(long callId, InspectorObject*)
2450 {
2451     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2452
2453     if (!m_debuggerAgent)
2454         protocolErrors->pushString("Debugger handler is not available.");
2455
2456     ErrorString error;
2457
2458     if (!protocolErrors->length())
2459         m_debuggerAgent->stepOut(&error);
2460
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);
2463 }
2464
2465 void InspectorBackendDispatcher::Debugger_pause(long callId, InspectorObject*)
2466 {
2467     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2468
2469     if (!m_debuggerAgent)
2470         protocolErrors->pushString("Debugger handler is not available.");
2471
2472     ErrorString error;
2473
2474     if (!protocolErrors->length())
2475         m_debuggerAgent->pause(&error);
2476
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);
2479 }
2480
2481 void InspectorBackendDispatcher::Debugger_resume(long callId, InspectorObject*)
2482 {
2483     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2484
2485     if (!m_debuggerAgent)
2486         protocolErrors->pushString("Debugger handler is not available.");
2487
2488     ErrorString error;
2489
2490     if (!protocolErrors->length())
2491         m_debuggerAgent->resume(&error);
2492
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);
2495 }
2496
2497 void InspectorBackendDispatcher::Debugger_searchInContent(long callId, InspectorObject* requestMessageObject)
2498 {
2499     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2500
2501     if (!m_debuggerAgent)
2502         protocolErrors->pushString("Debugger handler is not available.");
2503
2504     RefPtr<InspectorArray> out_result = InspectorArray::create();
2505
2506     ErrorString error;
2507
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);
2517
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);
2520
2521     RefPtr<InspectorObject> result = InspectorObject::create();
2522     if (!protocolErrors->length() && !error.length()) {
2523         result->setArray("result", out_result);
2524     }
2525     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.searchInContent"), protocolErrors, error);
2526 }
2527
2528 void InspectorBackendDispatcher::Debugger_setScriptSource(long callId, InspectorObject* requestMessageObject)
2529 {
2530     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2531
2532     if (!m_debuggerAgent)
2533         protocolErrors->pushString("Debugger handler is not available.");
2534
2535     RefPtr<InspectorArray> out_callFrames = InspectorArray::create();
2536     RefPtr<InspectorObject> out_result = InspectorObject::create();
2537
2538     ErrorString error;
2539
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);
2547
2548     if (!protocolErrors->length())
2549         m_debuggerAgent->setScriptSource(&error, in_scriptId, in_scriptSource, preview_valueFound ? &in_preview : 0, &out_callFrames, &out_result);
2550
2551     RefPtr<InspectorObject> result = InspectorObject::create();
2552     if (!protocolErrors->length() && !error.length()) {
2553         result->setArray("callFrames", out_callFrames);
2554         result->setObject("result", out_result);
2555     }
2556     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.setScriptSource"), protocolErrors, error);
2557 }
2558
2559 void InspectorBackendDispatcher::Debugger_getScriptSource(long callId, InspectorObject* requestMessageObject)
2560 {
2561     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2562
2563     if (!m_debuggerAgent)
2564         protocolErrors->pushString("Debugger handler is not available.");
2565
2566     String out_scriptSource = "";
2567
2568     ErrorString error;
2569
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);
2574
2575     if (!protocolErrors->length())
2576         m_debuggerAgent->getScriptSource(&error, in_scriptId, &out_scriptSource);
2577
2578     RefPtr<InspectorObject> result = InspectorObject::create();
2579     if (!protocolErrors->length() && !error.length()) {
2580         result->setString("scriptSource", out_scriptSource);
2581     }
2582     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.getScriptSource"), protocolErrors, error);
2583 }
2584
2585 void InspectorBackendDispatcher::Debugger_getFunctionLocation(long callId, InspectorObject* requestMessageObject)
2586 {
2587     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2588
2589     if (!m_debuggerAgent)
2590         protocolErrors->pushString("Debugger handler is not available.");
2591
2592     RefPtr<InspectorObject> out_location = InspectorObject::create();
2593
2594     ErrorString error;
2595
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);
2600
2601     if (!protocolErrors->length())
2602         m_debuggerAgent->getFunctionLocation(&error, in_functionId, &out_location);
2603
2604     RefPtr<InspectorObject> result = InspectorObject::create();
2605     if (!protocolErrors->length() && !error.length()) {
2606         result->setObject("location", out_location);
2607     }
2608     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.getFunctionLocation"), protocolErrors, error);
2609 }
2610
2611 void InspectorBackendDispatcher::Debugger_setPauseOnExceptions(long callId, InspectorObject* requestMessageObject)
2612 {
2613     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2614
2615     if (!m_debuggerAgent)
2616         protocolErrors->pushString("Debugger handler is not available.");
2617
2618     ErrorString error;
2619
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);
2624
2625     if (!protocolErrors->length())
2626         m_debuggerAgent->setPauseOnExceptions(&error, in_state);
2627
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);
2630 }
2631
2632 void InspectorBackendDispatcher::Debugger_evaluateOnCallFrame(long callId, InspectorObject* requestMessageObject)
2633 {
2634     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2635
2636     if (!m_debuggerAgent)
2637         protocolErrors->pushString("Debugger handler is not available.");
2638
2639     RefPtr<InspectorObject> out_result = InspectorObject::create();
2640     bool out_wasThrown = false;
2641
2642     ErrorString error;
2643
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);
2655
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);
2658
2659     RefPtr<InspectorObject> result = InspectorObject::create();
2660     if (!protocolErrors->length() && !error.length()) {
2661         result->setObject("result", out_result);
2662         if (out_wasThrown)
2663             result->setBoolean("wasThrown", out_wasThrown);
2664     }
2665     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Debugger.evaluateOnCallFrame"), protocolErrors, error);
2666 }
2667
2668 void InspectorBackendDispatcher::DOMDebugger_setDOMBreakpoint(long callId, InspectorObject* requestMessageObject)
2669 {
2670     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2671
2672     if (!m_domDebuggerAgent)
2673         protocolErrors->pushString("DOMDebugger handler is not available.");
2674
2675     ErrorString error;
2676
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);
2682
2683     if (!protocolErrors->length())
2684         m_domDebuggerAgent->setDOMBreakpoint(&error, in_nodeId, in_type);
2685
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);
2688 }
2689
2690 void InspectorBackendDispatcher::DOMDebugger_removeDOMBreakpoint(long callId, InspectorObject* requestMessageObject)
2691 {
2692     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2693
2694     if (!m_domDebuggerAgent)
2695         protocolErrors->pushString("DOMDebugger handler is not available.");
2696
2697     ErrorString error;
2698
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);
2704
2705     if (!protocolErrors->length())
2706         m_domDebuggerAgent->removeDOMBreakpoint(&error, in_nodeId, in_type);
2707
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);
2710 }
2711
2712 void InspectorBackendDispatcher::DOMDebugger_setEventListenerBreakpoint(long callId, InspectorObject* requestMessageObject)
2713 {
2714     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2715
2716     if (!m_domDebuggerAgent)
2717         protocolErrors->pushString("DOMDebugger handler is not available.");
2718
2719     ErrorString error;
2720
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);
2725
2726     if (!protocolErrors->length())
2727         m_domDebuggerAgent->setEventListenerBreakpoint(&error, in_eventName);
2728
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);
2731 }
2732
2733 void InspectorBackendDispatcher::DOMDebugger_removeEventListenerBreakpoint(long callId, InspectorObject* requestMessageObject)
2734 {
2735     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2736
2737     if (!m_domDebuggerAgent)
2738         protocolErrors->pushString("DOMDebugger handler is not available.");
2739
2740     ErrorString error;
2741
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);
2746
2747     if (!protocolErrors->length())
2748         m_domDebuggerAgent->removeEventListenerBreakpoint(&error, in_eventName);
2749
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);
2752 }
2753
2754 void InspectorBackendDispatcher::DOMDebugger_setXHRBreakpoint(long callId, InspectorObject* requestMessageObject)
2755 {
2756     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2757
2758     if (!m_domDebuggerAgent)
2759         protocolErrors->pushString("DOMDebugger handler is not available.");
2760
2761     ErrorString error;
2762
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);
2767
2768     if (!protocolErrors->length())
2769         m_domDebuggerAgent->setXHRBreakpoint(&error, in_url);
2770
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);
2773 }
2774
2775 void InspectorBackendDispatcher::DOMDebugger_removeXHRBreakpoint(long callId, InspectorObject* requestMessageObject)
2776 {
2777     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2778
2779     if (!m_domDebuggerAgent)
2780         protocolErrors->pushString("DOMDebugger handler is not available.");
2781
2782     ErrorString error;
2783
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);
2788
2789     if (!protocolErrors->length())
2790         m_domDebuggerAgent->removeXHRBreakpoint(&error, in_url);
2791
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);
2794 }
2795
2796 void InspectorBackendDispatcher::Profiler_enable(long callId, InspectorObject*)
2797 {
2798     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2799
2800     if (!m_profilerAgent)
2801         protocolErrors->pushString("Profiler handler is not available.");
2802
2803     ErrorString error;
2804
2805     if (!protocolErrors->length())
2806         m_profilerAgent->enable(&error);
2807
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);
2810 }
2811
2812 void InspectorBackendDispatcher::Profiler_disable(long callId, InspectorObject*)
2813 {
2814     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2815
2816     if (!m_profilerAgent)
2817         protocolErrors->pushString("Profiler handler is not available.");
2818
2819     ErrorString error;
2820
2821     if (!protocolErrors->length())
2822         m_profilerAgent->disable(&error);
2823
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);
2826 }
2827
2828 void InspectorBackendDispatcher::Profiler_isEnabled(long callId, InspectorObject*)
2829 {
2830     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2831
2832     if (!m_profilerAgent)
2833         protocolErrors->pushString("Profiler handler is not available.");
2834
2835     bool out_state = false;
2836
2837     ErrorString error;
2838
2839     if (!protocolErrors->length())
2840         m_profilerAgent->isEnabled(&error, &out_state);
2841
2842     RefPtr<InspectorObject> result = InspectorObject::create();
2843     if (!protocolErrors->length() && !error.length()) {
2844         result->setBoolean("state", out_state);
2845     }
2846     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.isEnabled"), protocolErrors, error);
2847 }
2848
2849 void InspectorBackendDispatcher::Profiler_start(long callId, InspectorObject*)
2850 {
2851     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2852
2853     if (!m_profilerAgent)
2854         protocolErrors->pushString("Profiler handler is not available.");
2855
2856     ErrorString error;
2857
2858     if (!protocolErrors->length())
2859         m_profilerAgent->start(&error);
2860
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);
2863 }
2864
2865 void InspectorBackendDispatcher::Profiler_stop(long callId, InspectorObject*)
2866 {
2867     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2868
2869     if (!m_profilerAgent)
2870         protocolErrors->pushString("Profiler handler is not available.");
2871
2872     ErrorString error;
2873
2874     if (!protocolErrors->length())
2875         m_profilerAgent->stop(&error);
2876
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);
2879 }
2880
2881 void InspectorBackendDispatcher::Profiler_getProfileHeaders(long callId, InspectorObject*)
2882 {
2883     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2884
2885     if (!m_profilerAgent)
2886         protocolErrors->pushString("Profiler handler is not available.");
2887
2888     RefPtr<InspectorArray> out_headers = InspectorArray::create();
2889
2890     ErrorString error;
2891
2892     if (!protocolErrors->length())
2893         m_profilerAgent->getProfileHeaders(&error, &out_headers);
2894
2895     RefPtr<InspectorObject> result = InspectorObject::create();
2896     if (!protocolErrors->length() && !error.length()) {
2897         result->setArray("headers", out_headers);
2898     }
2899     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.getProfileHeaders"), protocolErrors, error);
2900 }
2901
2902 void InspectorBackendDispatcher::Profiler_getProfile(long callId, InspectorObject* requestMessageObject)
2903 {
2904     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2905
2906     if (!m_profilerAgent)
2907         protocolErrors->pushString("Profiler handler is not available.");
2908
2909     RefPtr<InspectorObject> out_profile = InspectorObject::create();
2910
2911     ErrorString error;
2912
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);
2918
2919     if (!protocolErrors->length())
2920         m_profilerAgent->getProfile(&error, in_type, in_uid, &out_profile);
2921
2922     RefPtr<InspectorObject> result = InspectorObject::create();
2923     if (!protocolErrors->length() && !error.length()) {
2924         result->setObject("profile", out_profile);
2925     }
2926     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.getProfile"), protocolErrors, error);
2927 }
2928
2929 void InspectorBackendDispatcher::Profiler_removeProfile(long callId, InspectorObject* requestMessageObject)
2930 {
2931     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2932
2933     if (!m_profilerAgent)
2934         protocolErrors->pushString("Profiler handler is not available.");
2935
2936     ErrorString error;
2937
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);
2943
2944     if (!protocolErrors->length())
2945         m_profilerAgent->removeProfile(&error, in_type, in_uid);
2946
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);
2949 }
2950
2951 void InspectorBackendDispatcher::Profiler_clearProfiles(long callId, InspectorObject*)
2952 {
2953     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2954
2955     if (!m_profilerAgent)
2956         protocolErrors->pushString("Profiler handler is not available.");
2957
2958     ErrorString error;
2959
2960     if (!protocolErrors->length())
2961         m_profilerAgent->clearProfiles(&error);
2962
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);
2965 }
2966
2967 void InspectorBackendDispatcher::Profiler_takeHeapSnapshot(long callId, InspectorObject*)
2968 {
2969     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2970
2971     if (!m_profilerAgent)
2972         protocolErrors->pushString("Profiler handler is not available.");
2973
2974     ErrorString error;
2975
2976     if (!protocolErrors->length())
2977         m_profilerAgent->takeHeapSnapshot(&error);
2978
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);
2981 }
2982
2983 void InspectorBackendDispatcher::Profiler_collectGarbage(long callId, InspectorObject*)
2984 {
2985     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
2986
2987     if (!m_profilerAgent)
2988         protocolErrors->pushString("Profiler handler is not available.");
2989
2990     ErrorString error;
2991
2992     if (!protocolErrors->length())
2993         m_profilerAgent->collectGarbage(&error);
2994
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);
2997 }
2998
2999 void InspectorBackendDispatcher::Profiler_getObjectByHeapObjectId(long callId, InspectorObject* requestMessageObject)
3000 {
3001     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3002
3003     if (!m_profilerAgent)
3004         protocolErrors->pushString("Profiler handler is not available.");
3005
3006     RefPtr<InspectorObject> out_result = InspectorObject::create();
3007
3008     ErrorString error;
3009
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);
3014
3015     if (!protocolErrors->length())
3016         m_profilerAgent->getObjectByHeapObjectId(&error, in_objectId, &out_result);
3017
3018     RefPtr<InspectorObject> result = InspectorObject::create();
3019     if (!protocolErrors->length() && !error.length()) {
3020         result->setObject("result", out_result);
3021     }
3022     sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "Profiler.getObjectByHeapObjectId"), protocolErrors, error);
3023 }
3024
3025 void InspectorBackendDispatcher::Worker_setWorkerInspectionEnabled(long callId, InspectorObject* requestMessageObject)
3026 {
3027     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3028
3029     if (!m_workerAgent)
3030         protocolErrors->pushString("Worker handler is not available.");
3031
3032     ErrorString error;
3033
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);
3038
3039     if (!protocolErrors->length())
3040         m_workerAgent->setWorkerInspectionEnabled(&error, in_value);
3041
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);
3044 }
3045
3046 void InspectorBackendDispatcher::Worker_sendMessageToWorker(long callId, InspectorObject* requestMessageObject)
3047 {
3048     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3049
3050     if (!m_workerAgent)
3051         protocolErrors->pushString("Worker handler is not available.");
3052
3053     ErrorString error;
3054
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);
3060
3061     if (!protocolErrors->length())
3062         m_workerAgent->sendMessageToWorker(&error, in_workerId, in_message);
3063
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);
3066 }
3067
3068 void InspectorBackendDispatcher::Worker_connectToWorker(long callId, InspectorObject* requestMessageObject)
3069 {
3070     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3071
3072     if (!m_workerAgent)
3073         protocolErrors->pushString("Worker handler is not available.");
3074
3075     ErrorString error;
3076
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);
3081
3082     if (!protocolErrors->length())
3083         m_workerAgent->connectToWorker(&error, in_workerId);
3084
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);
3087 }
3088
3089 void InspectorBackendDispatcher::Worker_disconnectFromWorker(long callId, InspectorObject* requestMessageObject)
3090 {
3091     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3092
3093     if (!m_workerAgent)
3094         protocolErrors->pushString("Worker handler is not available.");
3095
3096     ErrorString error;
3097
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);
3102
3103     if (!protocolErrors->length())
3104         m_workerAgent->disconnectFromWorker(&error, in_workerId);
3105
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);
3108 }
3109
3110 void InspectorBackendDispatcher::Worker_setAutoconnectToWorkers(long callId, InspectorObject* requestMessageObject)
3111 {
3112     RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
3113
3114     if (!m_workerAgent)
3115         protocolErrors->pushString("Worker handler is not available.");
3116
3117     ErrorString error;
3118
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);
3123
3124     if (!protocolErrors->length())
3125         m_workerAgent->setAutoconnectToWorkers(&error, in_value);
3126
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);
3129 }
3130
3131 void InspectorBackendDispatcher::dispatch(const String& message)
3132 {
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, );
3137     long callId = 0;
3138
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,
3272         };
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]);
3276     }
3277
3278     RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
3279     if (!parsedMessage) {
3280         reportProtocolError(0, ParseError, "Message must be in JSON format");
3281         return;
3282     }
3283
3284     RefPtr<InspectorObject> messageObject = parsedMessage->asObject();
3285     if (!messageObject) {
3286         reportProtocolError(0, InvalidRequest, "Message must be a JSONified object");
3287         return;
3288     }
3289
3290     RefPtr<InspectorValue> callIdValue = messageObject->get("id");
3291     if (!callIdValue) {
3292         reportProtocolError(0, InvalidRequest, "'id' property was not found");
3293         return;
3294     }
3295
3296     if (!callIdValue->asNumber(&callId)) {
3297         reportProtocolError(0, InvalidRequest, "The type of 'id' property must be number");
3298         return;
3299     }
3300
3301     RefPtr<InspectorValue> methodValue = messageObject->get("method");
3302     if (!methodValue) {
3303         reportProtocolError(&callId, InvalidRequest, "'method' property wasn't found");
3304         return;
3305     }
3306
3307     String method;
3308     if (!methodValue->asString(&method)) {
3309         reportProtocolError(&callId, InvalidRequest, "The type of 'method' property must be string");
3310         return;
3311     }
3312
3313     HashMap<String, CallHandler>::iterator it = dispatchMap.find(method);
3314     if (it == dispatchMap.end()) {
3315         reportProtocolError(&callId, MethodNotFound, "'" + method + "' wasn't found");
3316         return;
3317     }
3318
3319     ((*this).*it->second)(callId, messageObject.get());
3320 }
3321
3322 void InspectorBackendDispatcher::sendResponse(long callId, PassRefPtr<InspectorObject> result, const String& errorMessage, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError)
3323 {
3324     if (protocolErrors->length()) {
3325         reportProtocolError(&callId, InvalidParams, errorMessage, protocolErrors);
3326         return;
3327     }
3328     if (invocationError.length()) {
3329         reportProtocolError(&callId, ServerError, invocationError);
3330         return;
3331     }
3332
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());
3338 }
3339
3340 void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage) const
3341 {
3342     reportProtocolError(callId, code, errorMessage, 0);
3343 }
3344
3345 void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage, PassRefPtr<InspectorArray> data) const
3346 {
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);
3355     }
3356     ASSERT(code >=0);
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);
3362     ASSERT(error);
3363     if (data)
3364         error->setArray("data", data);
3365     RefPtr<InspectorObject> message = InspectorObject::create();
3366     message->setObject("error", error);
3367     if (callId)
3368         message->setNumber("id", *callId);
3369     else
3370         message->setValue("id", InspectorValue::null());
3371     if (m_inspectorFrontendChannel)
3372         m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString());
3373 }
3374
3375 int InspectorBackendDispatcher::getInt(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3376 {
3377     ASSERT(protocolErrors);
3378
3379     if (valueFound)
3380         *valueFound = false;
3381
3382     int value = 0;
3383
3384     if (!object) {
3385         if (!valueFound) {
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()));
3388         }
3389         return value;
3390     }
3391
3392     InspectorObject::const_iterator end = object->end();
3393     InspectorObject::const_iterator valueIterator = object->find(name);
3394
3395     if (valueIterator == end) {
3396         if (!valueFound)
3397             protocolErrors->pushString(String::format("Parameter '%s' with type 'Number' was not found.", name.utf8().data()));
3398         return value;
3399     }
3400
3401     if (!valueIterator->second->asNumber(&value))
3402         protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Number'.", name.utf8().data()));
3403     else
3404         if (valueFound)
3405             *valueFound = true;
3406     return value;
3407 }
3408
3409 String InspectorBackendDispatcher::getString(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3410 {
3411     ASSERT(protocolErrors);
3412
3413     if (valueFound)
3414         *valueFound = false;
3415
3416     String value = "";
3417
3418     if (!object) {
3419         if (!valueFound) {
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()));
3422         }
3423         return value;
3424     }
3425
3426     InspectorObject::const_iterator end = object->end();
3427     InspectorObject::const_iterator valueIterator = object->find(name);
3428
3429     if (valueIterator == end) {
3430         if (!valueFound)
3431             protocolErrors->pushString(String::format("Parameter '%s' with type 'String' was not found.", name.utf8().data()));
3432         return value;
3433     }
3434
3435     if (!valueIterator->second->asString(&value))
3436         protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'String'.", name.utf8().data()));
3437     else
3438         if (valueFound)
3439             *valueFound = true;
3440     return value;
3441 }
3442
3443 bool InspectorBackendDispatcher::getBoolean(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3444 {
3445     ASSERT(protocolErrors);
3446
3447     if (valueFound)
3448         *valueFound = false;
3449
3450     bool value = false;
3451
3452     if (!object) {
3453         if (!valueFound) {
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()));
3456         }
3457         return value;
3458     }
3459
3460     InspectorObject::const_iterator end = object->end();
3461     InspectorObject::const_iterator valueIterator = object->find(name);
3462
3463     if (valueIterator == end) {
3464         if (!valueFound)
3465             protocolErrors->pushString(String::format("Parameter '%s' with type 'Boolean' was not found.", name.utf8().data()));
3466         return value;
3467     }
3468
3469     if (!valueIterator->second->asBoolean(&value))
3470         protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Boolean'.", name.utf8().data()));
3471     else
3472         if (valueFound)
3473             *valueFound = true;
3474     return value;
3475 }
3476
3477 PassRefPtr<InspectorObject> InspectorBackendDispatcher::getObject(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3478 {
3479     ASSERT(protocolErrors);
3480
3481     if (valueFound)
3482         *valueFound = false;
3483
3484     RefPtr<InspectorObject> value = InspectorObject::create();
3485
3486     if (!object) {
3487         if (!valueFound) {
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()));
3490         }
3491         return value;
3492     }
3493
3494     InspectorObject::const_iterator end = object->end();
3495     InspectorObject::const_iterator valueIterator = object->find(name);
3496
3497     if (valueIterator == end) {
3498         if (!valueFound)
3499             protocolErrors->pushString(String::format("Parameter '%s' with type 'Object' was not found.", name.utf8().data()));
3500         return value;
3501     }
3502
3503     if (!valueIterator->second->asObject(&value))
3504         protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Object'.", name.utf8().data()));
3505     else
3506         if (valueFound)
3507             *valueFound = true;
3508     return value;
3509 }
3510
3511 PassRefPtr<InspectorArray> InspectorBackendDispatcher::getArray(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
3512 {
3513     ASSERT(protocolErrors);
3514
3515     if (valueFound)
3516         *valueFound = false;
3517
3518     RefPtr<InspectorArray> value = InspectorArray::create();
3519
3520     if (!object) {
3521         if (!valueFound) {
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()));
3524         }
3525         return value;
3526     }
3527
3528     InspectorObject::const_iterator end = object->end();
3529     InspectorObject::const_iterator valueIterator = object->find(name);
3530
3531     if (valueIterator == end) {
3532         if (!valueFound)
3533             protocolErrors->pushString(String::format("Parameter '%s' with type 'Array' was not found.", name.utf8().data()));
3534         return value;
3535     }
3536
3537     if (!valueIterator->second->asArray(&value))
3538         protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Array'.", name.utf8().data()));
3539     else
3540         if (valueFound)
3541             *valueFound = true;
3542     return value;
3543 }
3544 bool InspectorBackendDispatcher::getCommandName(const String& message, String* result)
3545 {
3546     RefPtr<InspectorValue> value = InspectorValue::parseJSON(message);
3547     if (!value)
3548         return false;
3549
3550     RefPtr<InspectorObject> object = value->asObject();
3551     if (!object)
3552         return false;
3553
3554     if (!object->getString("method", result))
3555         return false;
3556
3557     return true;
3558 }
3559
3560
3561 } // namespace WebCore
3562
3563 #endif // ENABLE(INSPECTOR)