| 1 | /* |
| 2 | * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 | * Copyright (C) 2013-2016 Apple Inc. All rights reserved. |
| 4 | * Copyright (C) 2014 University of Washington. All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 17 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 19 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 25 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | // DO NOT EDIT THIS FILE. It is automatically generated from CombinedDomains.json |
| 29 | // by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py |
| 30 | |
| 31 | #include "config.h" |
| 32 | #include "InspectorBackendDispatchers.h" |
| 33 | |
| 34 | #include "InspectorFrontendRouter.h" |
| 35 | #include <wtf/JSONValues.h> |
| 36 | #include <wtf/NeverDestroyed.h> |
| 37 | #include <wtf/text/CString.h> |
| 38 | |
| 39 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 40 | #include "InspectorAlternateBackendDispatchers.h" |
| 41 | #endif |
| 42 | |
| 43 | namespace Inspector { |
| 44 | |
| 45 | ApplicationCacheBackendDispatcherHandler::~ApplicationCacheBackendDispatcherHandler() { } |
| 46 | AuditBackendDispatcherHandler::~AuditBackendDispatcherHandler() { } |
| 47 | #if ENABLE(RESOURCE_USAGE) |
| 48 | CPUProfilerBackendDispatcherHandler::~CPUProfilerBackendDispatcherHandler() { } |
| 49 | #endif // ENABLE(RESOURCE_USAGE) |
| 50 | CSSBackendDispatcherHandler::~CSSBackendDispatcherHandler() { } |
| 51 | CanvasBackendDispatcherHandler::~CanvasBackendDispatcherHandler() { } |
| 52 | ConsoleBackendDispatcherHandler::~ConsoleBackendDispatcherHandler() { } |
| 53 | DOMBackendDispatcherHandler::~DOMBackendDispatcherHandler() { } |
| 54 | DOMDebuggerBackendDispatcherHandler::~DOMDebuggerBackendDispatcherHandler() { } |
| 55 | DOMStorageBackendDispatcherHandler::~DOMStorageBackendDispatcherHandler() { } |
| 56 | DatabaseBackendDispatcherHandler::~DatabaseBackendDispatcherHandler() { } |
| 57 | DebuggerBackendDispatcherHandler::~DebuggerBackendDispatcherHandler() { } |
| 58 | HeapBackendDispatcherHandler::~HeapBackendDispatcherHandler() { } |
| 59 | #if ENABLE(INDEXED_DATABASE) |
| 60 | IndexedDBBackendDispatcherHandler::~IndexedDBBackendDispatcherHandler() { } |
| 61 | #endif // ENABLE(INDEXED_DATABASE) |
| 62 | InspectorBackendDispatcherHandler::~InspectorBackendDispatcherHandler() { } |
| 63 | LayerTreeBackendDispatcherHandler::~LayerTreeBackendDispatcherHandler() { } |
| 64 | #if ENABLE(RESOURCE_USAGE) |
| 65 | MemoryBackendDispatcherHandler::~MemoryBackendDispatcherHandler() { } |
| 66 | #endif // ENABLE(RESOURCE_USAGE) |
| 67 | NetworkBackendDispatcherHandler::~NetworkBackendDispatcherHandler() { } |
| 68 | PageBackendDispatcherHandler::~PageBackendDispatcherHandler() { } |
| 69 | RuntimeBackendDispatcherHandler::~RuntimeBackendDispatcherHandler() { } |
| 70 | ScriptProfilerBackendDispatcherHandler::~ScriptProfilerBackendDispatcherHandler() { } |
| 71 | TargetBackendDispatcherHandler::~TargetBackendDispatcherHandler() { } |
| 72 | TimelineBackendDispatcherHandler::~TimelineBackendDispatcherHandler() { } |
| 73 | WorkerBackendDispatcherHandler::~WorkerBackendDispatcherHandler() { } |
| 74 | |
| 75 | Ref<ApplicationCacheBackendDispatcher> ApplicationCacheBackendDispatcher::create(BackendDispatcher& backendDispatcher, ApplicationCacheBackendDispatcherHandler* agent) |
| 76 | { |
| 77 | return adoptRef(*new ApplicationCacheBackendDispatcher(backendDispatcher, agent)); |
| 78 | } |
| 79 | |
| 80 | ApplicationCacheBackendDispatcher::ApplicationCacheBackendDispatcher(BackendDispatcher& backendDispatcher, ApplicationCacheBackendDispatcherHandler* agent) |
| 81 | : SupplementalBackendDispatcher(backendDispatcher) |
| 82 | , m_agent(agent) |
| 83 | { |
| 84 | m_backendDispatcher->registerDispatcherForDomain("ApplicationCache"_s , this); |
| 85 | } |
| 86 | |
| 87 | void ApplicationCacheBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 88 | { |
| 89 | Ref<ApplicationCacheBackendDispatcher> protect(*this); |
| 90 | |
| 91 | RefPtr<JSON::Object> parameters; |
| 92 | message->getObject("params"_s , parameters); |
| 93 | |
| 94 | if (method == "getFramesWithManifests" ) |
| 95 | getFramesWithManifests(requestId, WTFMove(parameters)); |
| 96 | else if (method == "enable" ) |
| 97 | enable(requestId, WTFMove(parameters)); |
| 98 | else if (method == "getManifestForFrame" ) |
| 99 | getManifestForFrame(requestId, WTFMove(parameters)); |
| 100 | else if (method == "getApplicationCacheForFrame" ) |
| 101 | getApplicationCacheForFrame(requestId, WTFMove(parameters)); |
| 102 | else |
| 103 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'ApplicationCache." + method + "' was not found" ); |
| 104 | } |
| 105 | |
| 106 | void ApplicationCacheBackendDispatcher::getFramesWithManifests(long requestId, RefPtr<JSON::Object>&&) |
| 107 | { |
| 108 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 109 | if (m_alternateDispatcher) { |
| 110 | m_alternateDispatcher->getFramesWithManifests(requestId); |
| 111 | return; |
| 112 | } |
| 113 | #endif |
| 114 | |
| 115 | ErrorString error; |
| 116 | Ref<JSON::Object> result = JSON::Object::create(); |
| 117 | RefPtr<JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>> out_frameIds; |
| 118 | m_agent->getFramesWithManifests(error, out_frameIds); |
| 119 | |
| 120 | if (!error.length()) |
| 121 | result->setArray("frameIds"_s , out_frameIds); |
| 122 | |
| 123 | if (!error.length()) |
| 124 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 125 | else |
| 126 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 127 | } |
| 128 | |
| 129 | void ApplicationCacheBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 130 | { |
| 131 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 132 | if (m_alternateDispatcher) { |
| 133 | m_alternateDispatcher->enable(requestId); |
| 134 | return; |
| 135 | } |
| 136 | #endif |
| 137 | |
| 138 | ErrorString error; |
| 139 | Ref<JSON::Object> result = JSON::Object::create(); |
| 140 | m_agent->enable(error); |
| 141 | |
| 142 | if (!error.length()) |
| 143 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 144 | else |
| 145 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 146 | } |
| 147 | |
| 148 | void ApplicationCacheBackendDispatcher::getManifestForFrame(long requestId, RefPtr<JSON::Object>&& parameters) |
| 149 | { |
| 150 | String in_frameId = m_backendDispatcher->getString(parameters.get(), "frameId"_s , nullptr); |
| 151 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 152 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'ApplicationCache.getManifestForFrame' can't be processed"_s ); |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 157 | if (m_alternateDispatcher) { |
| 158 | m_alternateDispatcher->getManifestForFrame(requestId, in_frameId); |
| 159 | return; |
| 160 | } |
| 161 | #endif |
| 162 | |
| 163 | ErrorString error; |
| 164 | Ref<JSON::Object> result = JSON::Object::create(); |
| 165 | String out_manifestURL; |
| 166 | m_agent->getManifestForFrame(error, in_frameId, &out_manifestURL); |
| 167 | |
| 168 | if (!error.length()) |
| 169 | result->setString("manifestURL"_s , out_manifestURL); |
| 170 | |
| 171 | if (!error.length()) |
| 172 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 173 | else |
| 174 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 175 | } |
| 176 | |
| 177 | void ApplicationCacheBackendDispatcher::getApplicationCacheForFrame(long requestId, RefPtr<JSON::Object>&& parameters) |
| 178 | { |
| 179 | String in_frameId = m_backendDispatcher->getString(parameters.get(), "frameId"_s , nullptr); |
| 180 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 181 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'ApplicationCache.getApplicationCacheForFrame' can't be processed"_s ); |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 186 | if (m_alternateDispatcher) { |
| 187 | m_alternateDispatcher->getApplicationCacheForFrame(requestId, in_frameId); |
| 188 | return; |
| 189 | } |
| 190 | #endif |
| 191 | |
| 192 | ErrorString error; |
| 193 | Ref<JSON::Object> result = JSON::Object::create(); |
| 194 | RefPtr<Inspector::Protocol::ApplicationCache::ApplicationCache> out_applicationCache; |
| 195 | m_agent->getApplicationCacheForFrame(error, in_frameId, out_applicationCache); |
| 196 | |
| 197 | if (!error.length()) |
| 198 | result->setObject("applicationCache"_s , out_applicationCache); |
| 199 | |
| 200 | if (!error.length()) |
| 201 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 202 | else |
| 203 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 204 | } |
| 205 | |
| 206 | Ref<AuditBackendDispatcher> AuditBackendDispatcher::create(BackendDispatcher& backendDispatcher, AuditBackendDispatcherHandler* agent) |
| 207 | { |
| 208 | return adoptRef(*new AuditBackendDispatcher(backendDispatcher, agent)); |
| 209 | } |
| 210 | |
| 211 | AuditBackendDispatcher::AuditBackendDispatcher(BackendDispatcher& backendDispatcher, AuditBackendDispatcherHandler* agent) |
| 212 | : SupplementalBackendDispatcher(backendDispatcher) |
| 213 | , m_agent(agent) |
| 214 | { |
| 215 | m_backendDispatcher->registerDispatcherForDomain("Audit"_s , this); |
| 216 | } |
| 217 | |
| 218 | void AuditBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 219 | { |
| 220 | Ref<AuditBackendDispatcher> protect(*this); |
| 221 | |
| 222 | RefPtr<JSON::Object> parameters; |
| 223 | message->getObject("params"_s , parameters); |
| 224 | |
| 225 | if (method == "setup" ) |
| 226 | setup(requestId, WTFMove(parameters)); |
| 227 | else if (method == "run" ) |
| 228 | run(requestId, WTFMove(parameters)); |
| 229 | else if (method == "teardown" ) |
| 230 | teardown(requestId, WTFMove(parameters)); |
| 231 | else |
| 232 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Audit." + method + "' was not found" ); |
| 233 | } |
| 234 | |
| 235 | void AuditBackendDispatcher::setup(long requestId, RefPtr<JSON::Object>&& parameters) |
| 236 | { |
| 237 | bool opt_in_contextId_valueFound = false; |
| 238 | int opt_in_contextId = m_backendDispatcher->getInteger(parameters.get(), "contextId"_s , &opt_in_contextId_valueFound); |
| 239 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 240 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Audit.setup' can't be processed"_s ); |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 245 | if (m_alternateDispatcher) { |
| 246 | m_alternateDispatcher->setup(requestId, opt_in_contextId_valueFound ? &opt_in_contextId : nullptr); |
| 247 | return; |
| 248 | } |
| 249 | #endif |
| 250 | |
| 251 | ErrorString error; |
| 252 | Ref<JSON::Object> result = JSON::Object::create(); |
| 253 | m_agent->setup(error, opt_in_contextId_valueFound ? &opt_in_contextId : nullptr); |
| 254 | |
| 255 | if (!error.length()) |
| 256 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 257 | else |
| 258 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 259 | } |
| 260 | |
| 261 | void AuditBackendDispatcher::run(long requestId, RefPtr<JSON::Object>&& parameters) |
| 262 | { |
| 263 | String in_test = m_backendDispatcher->getString(parameters.get(), "test"_s , nullptr); |
| 264 | bool opt_in_contextId_valueFound = false; |
| 265 | int opt_in_contextId = m_backendDispatcher->getInteger(parameters.get(), "contextId"_s , &opt_in_contextId_valueFound); |
| 266 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 267 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Audit.run' can't be processed"_s ); |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 272 | if (m_alternateDispatcher) { |
| 273 | m_alternateDispatcher->run(requestId, in_test, opt_in_contextId_valueFound ? &opt_in_contextId : nullptr); |
| 274 | return; |
| 275 | } |
| 276 | #endif |
| 277 | |
| 278 | ErrorString error; |
| 279 | Ref<JSON::Object> result = JSON::Object::create(); |
| 280 | RefPtr<Inspector::Protocol::Runtime::RemoteObject> out_result; |
| 281 | Optional<bool> out_wasThrown; |
| 282 | m_agent->run(error, in_test, opt_in_contextId_valueFound ? &opt_in_contextId : nullptr, out_result, out_wasThrown); |
| 283 | |
| 284 | if (!error.length()) { |
| 285 | result->setObject("result"_s , out_result); |
| 286 | if (out_wasThrown.hasValue()) |
| 287 | result->setBoolean("wasThrown"_s , *out_wasThrown); |
| 288 | } |
| 289 | if (!error.length()) |
| 290 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 291 | else |
| 292 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 293 | } |
| 294 | |
| 295 | void AuditBackendDispatcher::teardown(long requestId, RefPtr<JSON::Object>&&) |
| 296 | { |
| 297 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 298 | if (m_alternateDispatcher) { |
| 299 | m_alternateDispatcher->teardown(requestId); |
| 300 | return; |
| 301 | } |
| 302 | #endif |
| 303 | |
| 304 | ErrorString error; |
| 305 | Ref<JSON::Object> result = JSON::Object::create(); |
| 306 | m_agent->teardown(error); |
| 307 | |
| 308 | if (!error.length()) |
| 309 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 310 | else |
| 311 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 312 | } |
| 313 | |
| 314 | #if ENABLE(RESOURCE_USAGE) |
| 315 | Ref<CPUProfilerBackendDispatcher> CPUProfilerBackendDispatcher::create(BackendDispatcher& backendDispatcher, CPUProfilerBackendDispatcherHandler* agent) |
| 316 | { |
| 317 | return adoptRef(*new CPUProfilerBackendDispatcher(backendDispatcher, agent)); |
| 318 | } |
| 319 | |
| 320 | CPUProfilerBackendDispatcher::CPUProfilerBackendDispatcher(BackendDispatcher& backendDispatcher, CPUProfilerBackendDispatcherHandler* agent) |
| 321 | : SupplementalBackendDispatcher(backendDispatcher) |
| 322 | , m_agent(agent) |
| 323 | { |
| 324 | m_backendDispatcher->registerDispatcherForDomain("CPUProfiler"_s , this); |
| 325 | } |
| 326 | |
| 327 | void CPUProfilerBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 328 | { |
| 329 | Ref<CPUProfilerBackendDispatcher> protect(*this); |
| 330 | |
| 331 | RefPtr<JSON::Object> parameters; |
| 332 | message->getObject("params"_s , parameters); |
| 333 | |
| 334 | if (method == "startTracking" ) |
| 335 | startTracking(requestId, WTFMove(parameters)); |
| 336 | else if (method == "stopTracking" ) |
| 337 | stopTracking(requestId, WTFMove(parameters)); |
| 338 | else |
| 339 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'CPUProfiler." + method + "' was not found" ); |
| 340 | } |
| 341 | |
| 342 | void CPUProfilerBackendDispatcher::startTracking(long requestId, RefPtr<JSON::Object>&&) |
| 343 | { |
| 344 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 345 | if (m_alternateDispatcher) { |
| 346 | m_alternateDispatcher->startTracking(requestId); |
| 347 | return; |
| 348 | } |
| 349 | #endif |
| 350 | |
| 351 | ErrorString error; |
| 352 | Ref<JSON::Object> result = JSON::Object::create(); |
| 353 | m_agent->startTracking(error); |
| 354 | |
| 355 | if (!error.length()) |
| 356 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 357 | else |
| 358 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 359 | } |
| 360 | |
| 361 | void CPUProfilerBackendDispatcher::stopTracking(long requestId, RefPtr<JSON::Object>&&) |
| 362 | { |
| 363 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 364 | if (m_alternateDispatcher) { |
| 365 | m_alternateDispatcher->stopTracking(requestId); |
| 366 | return; |
| 367 | } |
| 368 | #endif |
| 369 | |
| 370 | ErrorString error; |
| 371 | Ref<JSON::Object> result = JSON::Object::create(); |
| 372 | m_agent->stopTracking(error); |
| 373 | |
| 374 | if (!error.length()) |
| 375 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 376 | else |
| 377 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 378 | } |
| 379 | #endif // ENABLE(RESOURCE_USAGE) |
| 380 | |
| 381 | Ref<CSSBackendDispatcher> CSSBackendDispatcher::create(BackendDispatcher& backendDispatcher, CSSBackendDispatcherHandler* agent) |
| 382 | { |
| 383 | return adoptRef(*new CSSBackendDispatcher(backendDispatcher, agent)); |
| 384 | } |
| 385 | |
| 386 | CSSBackendDispatcher::CSSBackendDispatcher(BackendDispatcher& backendDispatcher, CSSBackendDispatcherHandler* agent) |
| 387 | : SupplementalBackendDispatcher(backendDispatcher) |
| 388 | , m_agent(agent) |
| 389 | { |
| 390 | m_backendDispatcher->registerDispatcherForDomain("CSS"_s , this); |
| 391 | } |
| 392 | |
| 393 | void CSSBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 394 | { |
| 395 | Ref<CSSBackendDispatcher> protect(*this); |
| 396 | |
| 397 | RefPtr<JSON::Object> parameters; |
| 398 | message->getObject("params"_s , parameters); |
| 399 | |
| 400 | typedef void (CSSBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 401 | typedef HashMap<String, CallHandler> DispatchMap; |
| 402 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 403 | if (dispatchMap.get().isEmpty()) { |
| 404 | static const struct MethodTable { |
| 405 | const char* name; |
| 406 | CallHandler handler; |
| 407 | } commands[] = { |
| 408 | { "enable" , &CSSBackendDispatcher::enable }, |
| 409 | { "disable" , &CSSBackendDispatcher::disable }, |
| 410 | { "getMatchedStylesForNode" , &CSSBackendDispatcher::getMatchedStylesForNode }, |
| 411 | { "getInlineStylesForNode" , &CSSBackendDispatcher::getInlineStylesForNode }, |
| 412 | { "getComputedStyleForNode" , &CSSBackendDispatcher::getComputedStyleForNode }, |
| 413 | { "getAllStyleSheets" , &CSSBackendDispatcher::getAllStyleSheets }, |
| 414 | { "getStyleSheet" , &CSSBackendDispatcher::getStyleSheet }, |
| 415 | { "getStyleSheetText" , &CSSBackendDispatcher::getStyleSheetText }, |
| 416 | { "setStyleSheetText" , &CSSBackendDispatcher::setStyleSheetText }, |
| 417 | { "setStyleText" , &CSSBackendDispatcher::setStyleText }, |
| 418 | { "setRuleSelector" , &CSSBackendDispatcher::setRuleSelector }, |
| 419 | { "createStyleSheet" , &CSSBackendDispatcher::createStyleSheet }, |
| 420 | { "addRule" , &CSSBackendDispatcher::addRule }, |
| 421 | { "getSupportedCSSProperties" , &CSSBackendDispatcher::getSupportedCSSProperties }, |
| 422 | { "getSupportedSystemFontFamilyNames" , &CSSBackendDispatcher::getSupportedSystemFontFamilyNames }, |
| 423 | { "forcePseudoState" , &CSSBackendDispatcher::forcePseudoState }, |
| 424 | }; |
| 425 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 426 | for (size_t i = 0; i < length; ++i) |
| 427 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 428 | } |
| 429 | |
| 430 | auto findResult = dispatchMap.get().find(method); |
| 431 | if (findResult == dispatchMap.get().end()) { |
| 432 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'CSS." + method + "' was not found" ); |
| 433 | return; |
| 434 | } |
| 435 | |
| 436 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 437 | } |
| 438 | |
| 439 | void CSSBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 440 | { |
| 441 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 442 | if (m_alternateDispatcher) { |
| 443 | m_alternateDispatcher->enable(requestId); |
| 444 | return; |
| 445 | } |
| 446 | #endif |
| 447 | |
| 448 | ErrorString error; |
| 449 | Ref<JSON::Object> result = JSON::Object::create(); |
| 450 | m_agent->enable(error); |
| 451 | |
| 452 | if (!error.length()) |
| 453 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 454 | else |
| 455 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 456 | } |
| 457 | |
| 458 | void CSSBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 459 | { |
| 460 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 461 | if (m_alternateDispatcher) { |
| 462 | m_alternateDispatcher->disable(requestId); |
| 463 | return; |
| 464 | } |
| 465 | #endif |
| 466 | |
| 467 | ErrorString error; |
| 468 | Ref<JSON::Object> result = JSON::Object::create(); |
| 469 | m_agent->disable(error); |
| 470 | |
| 471 | if (!error.length()) |
| 472 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 473 | else |
| 474 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 475 | } |
| 476 | |
| 477 | void CSSBackendDispatcher::getMatchedStylesForNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 478 | { |
| 479 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 480 | bool opt_in_includePseudo_valueFound = false; |
| 481 | bool opt_in_includePseudo = m_backendDispatcher->getBoolean(parameters.get(), "includePseudo"_s , &opt_in_includePseudo_valueFound); |
| 482 | bool opt_in_includeInherited_valueFound = false; |
| 483 | bool opt_in_includeInherited = m_backendDispatcher->getBoolean(parameters.get(), "includeInherited"_s , &opt_in_includeInherited_valueFound); |
| 484 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 485 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.getMatchedStylesForNode' can't be processed"_s ); |
| 486 | return; |
| 487 | } |
| 488 | |
| 489 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 490 | if (m_alternateDispatcher) { |
| 491 | m_alternateDispatcher->getMatchedStylesForNode(requestId, in_nodeId, opt_in_includePseudo_valueFound ? &opt_in_includePseudo : nullptr, opt_in_includeInherited_valueFound ? &opt_in_includeInherited : nullptr); |
| 492 | return; |
| 493 | } |
| 494 | #endif |
| 495 | |
| 496 | ErrorString error; |
| 497 | Ref<JSON::Object> result = JSON::Object::create(); |
| 498 | RefPtr<JSON::ArrayOf<Inspector::Protocol::CSS::RuleMatch>> out_matchedCSSRules; |
| 499 | RefPtr<JSON::ArrayOf<Inspector::Protocol::CSS::PseudoIdMatches>> out_pseudoElements; |
| 500 | RefPtr<JSON::ArrayOf<Inspector::Protocol::CSS::InheritedStyleEntry>> out_inherited; |
| 501 | m_agent->getMatchedStylesForNode(error, in_nodeId, opt_in_includePseudo_valueFound ? &opt_in_includePseudo : nullptr, opt_in_includeInherited_valueFound ? &opt_in_includeInherited : nullptr, out_matchedCSSRules, out_pseudoElements, out_inherited); |
| 502 | |
| 503 | if (!error.length()) { |
| 504 | if (out_matchedCSSRules) |
| 505 | result->setArray("matchedCSSRules"_s , out_matchedCSSRules); |
| 506 | if (out_pseudoElements) |
| 507 | result->setArray("pseudoElements"_s , out_pseudoElements); |
| 508 | if (out_inherited) |
| 509 | result->setArray("inherited"_s , out_inherited); |
| 510 | } |
| 511 | if (!error.length()) |
| 512 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 513 | else |
| 514 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 515 | } |
| 516 | |
| 517 | void CSSBackendDispatcher::getInlineStylesForNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 518 | { |
| 519 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 520 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 521 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.getInlineStylesForNode' can't be processed"_s ); |
| 522 | return; |
| 523 | } |
| 524 | |
| 525 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 526 | if (m_alternateDispatcher) { |
| 527 | m_alternateDispatcher->getInlineStylesForNode(requestId, in_nodeId); |
| 528 | return; |
| 529 | } |
| 530 | #endif |
| 531 | |
| 532 | ErrorString error; |
| 533 | Ref<JSON::Object> result = JSON::Object::create(); |
| 534 | RefPtr<Inspector::Protocol::CSS::CSSStyle> out_inlineStyle; |
| 535 | RefPtr<Inspector::Protocol::CSS::CSSStyle> out_attributesStyle; |
| 536 | m_agent->getInlineStylesForNode(error, in_nodeId, out_inlineStyle, out_attributesStyle); |
| 537 | |
| 538 | if (!error.length()) { |
| 539 | if (out_inlineStyle) |
| 540 | result->setObject("inlineStyle"_s , out_inlineStyle); |
| 541 | if (out_attributesStyle) |
| 542 | result->setObject("attributesStyle"_s , out_attributesStyle); |
| 543 | } |
| 544 | if (!error.length()) |
| 545 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 546 | else |
| 547 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 548 | } |
| 549 | |
| 550 | void CSSBackendDispatcher::getComputedStyleForNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 551 | { |
| 552 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 553 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 554 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.getComputedStyleForNode' can't be processed"_s ); |
| 555 | return; |
| 556 | } |
| 557 | |
| 558 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 559 | if (m_alternateDispatcher) { |
| 560 | m_alternateDispatcher->getComputedStyleForNode(requestId, in_nodeId); |
| 561 | return; |
| 562 | } |
| 563 | #endif |
| 564 | |
| 565 | ErrorString error; |
| 566 | Ref<JSON::Object> result = JSON::Object::create(); |
| 567 | RefPtr<JSON::ArrayOf<Inspector::Protocol::CSS::CSSComputedStyleProperty>> out_computedStyle; |
| 568 | m_agent->getComputedStyleForNode(error, in_nodeId, out_computedStyle); |
| 569 | |
| 570 | if (!error.length()) |
| 571 | result->setArray("computedStyle"_s , out_computedStyle); |
| 572 | |
| 573 | if (!error.length()) |
| 574 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 575 | else |
| 576 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 577 | } |
| 578 | |
| 579 | void CSSBackendDispatcher::getAllStyleSheets(long requestId, RefPtr<JSON::Object>&&) |
| 580 | { |
| 581 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 582 | if (m_alternateDispatcher) { |
| 583 | m_alternateDispatcher->getAllStyleSheets(requestId); |
| 584 | return; |
| 585 | } |
| 586 | #endif |
| 587 | |
| 588 | ErrorString error; |
| 589 | Ref<JSON::Object> result = JSON::Object::create(); |
| 590 | RefPtr<JSON::ArrayOf<Inspector::Protocol::CSS::CSSStyleSheetHeader>> ; |
| 591 | m_agent->getAllStyleSheets(error, out_headers); |
| 592 | |
| 593 | if (!error.length()) |
| 594 | result->setArray("headers"_s , out_headers); |
| 595 | |
| 596 | if (!error.length()) |
| 597 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 598 | else |
| 599 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 600 | } |
| 601 | |
| 602 | void CSSBackendDispatcher::getStyleSheet(long requestId, RefPtr<JSON::Object>&& parameters) |
| 603 | { |
| 604 | String in_styleSheetId = m_backendDispatcher->getString(parameters.get(), "styleSheetId"_s , nullptr); |
| 605 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 606 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.getStyleSheet' can't be processed"_s ); |
| 607 | return; |
| 608 | } |
| 609 | |
| 610 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 611 | if (m_alternateDispatcher) { |
| 612 | m_alternateDispatcher->getStyleSheet(requestId, in_styleSheetId); |
| 613 | return; |
| 614 | } |
| 615 | #endif |
| 616 | |
| 617 | ErrorString error; |
| 618 | Ref<JSON::Object> result = JSON::Object::create(); |
| 619 | RefPtr<Inspector::Protocol::CSS::CSSStyleSheetBody> out_styleSheet; |
| 620 | m_agent->getStyleSheet(error, in_styleSheetId, out_styleSheet); |
| 621 | |
| 622 | if (!error.length()) |
| 623 | result->setObject("styleSheet"_s , out_styleSheet); |
| 624 | |
| 625 | if (!error.length()) |
| 626 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 627 | else |
| 628 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 629 | } |
| 630 | |
| 631 | void CSSBackendDispatcher::getStyleSheetText(long requestId, RefPtr<JSON::Object>&& parameters) |
| 632 | { |
| 633 | String in_styleSheetId = m_backendDispatcher->getString(parameters.get(), "styleSheetId"_s , nullptr); |
| 634 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 635 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.getStyleSheetText' can't be processed"_s ); |
| 636 | return; |
| 637 | } |
| 638 | |
| 639 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 640 | if (m_alternateDispatcher) { |
| 641 | m_alternateDispatcher->getStyleSheetText(requestId, in_styleSheetId); |
| 642 | return; |
| 643 | } |
| 644 | #endif |
| 645 | |
| 646 | ErrorString error; |
| 647 | Ref<JSON::Object> result = JSON::Object::create(); |
| 648 | String out_text; |
| 649 | m_agent->getStyleSheetText(error, in_styleSheetId, &out_text); |
| 650 | |
| 651 | if (!error.length()) |
| 652 | result->setString("text"_s , out_text); |
| 653 | |
| 654 | if (!error.length()) |
| 655 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 656 | else |
| 657 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 658 | } |
| 659 | |
| 660 | void CSSBackendDispatcher::setStyleSheetText(long requestId, RefPtr<JSON::Object>&& parameters) |
| 661 | { |
| 662 | String in_styleSheetId = m_backendDispatcher->getString(parameters.get(), "styleSheetId"_s , nullptr); |
| 663 | String in_text = m_backendDispatcher->getString(parameters.get(), "text"_s , nullptr); |
| 664 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 665 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.setStyleSheetText' can't be processed"_s ); |
| 666 | return; |
| 667 | } |
| 668 | |
| 669 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 670 | if (m_alternateDispatcher) { |
| 671 | m_alternateDispatcher->setStyleSheetText(requestId, in_styleSheetId, in_text); |
| 672 | return; |
| 673 | } |
| 674 | #endif |
| 675 | |
| 676 | ErrorString error; |
| 677 | Ref<JSON::Object> result = JSON::Object::create(); |
| 678 | m_agent->setStyleSheetText(error, in_styleSheetId, in_text); |
| 679 | |
| 680 | if (!error.length()) |
| 681 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 682 | else |
| 683 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 684 | } |
| 685 | |
| 686 | void CSSBackendDispatcher::setStyleText(long requestId, RefPtr<JSON::Object>&& parameters) |
| 687 | { |
| 688 | RefPtr<JSON::Object> in_styleId = m_backendDispatcher->getObject(parameters.get(), "styleId"_s , nullptr); |
| 689 | String in_text = m_backendDispatcher->getString(parameters.get(), "text"_s , nullptr); |
| 690 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 691 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.setStyleText' can't be processed"_s ); |
| 692 | return; |
| 693 | } |
| 694 | |
| 695 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 696 | if (m_alternateDispatcher) { |
| 697 | m_alternateDispatcher->setStyleText(requestId, *in_styleId, in_text); |
| 698 | return; |
| 699 | } |
| 700 | #endif |
| 701 | |
| 702 | ErrorString error; |
| 703 | Ref<JSON::Object> result = JSON::Object::create(); |
| 704 | RefPtr<Inspector::Protocol::CSS::CSSStyle> out_style; |
| 705 | m_agent->setStyleText(error, *in_styleId, in_text, out_style); |
| 706 | |
| 707 | if (!error.length()) |
| 708 | result->setObject("style"_s , out_style); |
| 709 | |
| 710 | if (!error.length()) |
| 711 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 712 | else |
| 713 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 714 | } |
| 715 | |
| 716 | void CSSBackendDispatcher::setRuleSelector(long requestId, RefPtr<JSON::Object>&& parameters) |
| 717 | { |
| 718 | RefPtr<JSON::Object> in_ruleId = m_backendDispatcher->getObject(parameters.get(), "ruleId"_s , nullptr); |
| 719 | String in_selector = m_backendDispatcher->getString(parameters.get(), "selector"_s , nullptr); |
| 720 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 721 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.setRuleSelector' can't be processed"_s ); |
| 722 | return; |
| 723 | } |
| 724 | |
| 725 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 726 | if (m_alternateDispatcher) { |
| 727 | m_alternateDispatcher->setRuleSelector(requestId, *in_ruleId, in_selector); |
| 728 | return; |
| 729 | } |
| 730 | #endif |
| 731 | |
| 732 | ErrorString error; |
| 733 | Ref<JSON::Object> result = JSON::Object::create(); |
| 734 | RefPtr<Inspector::Protocol::CSS::CSSRule> out_rule; |
| 735 | m_agent->setRuleSelector(error, *in_ruleId, in_selector, out_rule); |
| 736 | |
| 737 | if (!error.length()) |
| 738 | result->setObject("rule"_s , out_rule); |
| 739 | |
| 740 | if (!error.length()) |
| 741 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 742 | else |
| 743 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 744 | } |
| 745 | |
| 746 | void CSSBackendDispatcher::createStyleSheet(long requestId, RefPtr<JSON::Object>&& parameters) |
| 747 | { |
| 748 | String in_frameId = m_backendDispatcher->getString(parameters.get(), "frameId"_s , nullptr); |
| 749 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 750 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.createStyleSheet' can't be processed"_s ); |
| 751 | return; |
| 752 | } |
| 753 | |
| 754 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 755 | if (m_alternateDispatcher) { |
| 756 | m_alternateDispatcher->createStyleSheet(requestId, in_frameId); |
| 757 | return; |
| 758 | } |
| 759 | #endif |
| 760 | |
| 761 | ErrorString error; |
| 762 | Ref<JSON::Object> result = JSON::Object::create(); |
| 763 | String out_styleSheetId; |
| 764 | m_agent->createStyleSheet(error, in_frameId, &out_styleSheetId); |
| 765 | |
| 766 | if (!error.length()) |
| 767 | result->setString("styleSheetId"_s , out_styleSheetId); |
| 768 | |
| 769 | if (!error.length()) |
| 770 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 771 | else |
| 772 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 773 | } |
| 774 | |
| 775 | void CSSBackendDispatcher::addRule(long requestId, RefPtr<JSON::Object>&& parameters) |
| 776 | { |
| 777 | String in_styleSheetId = m_backendDispatcher->getString(parameters.get(), "styleSheetId"_s , nullptr); |
| 778 | String in_selector = m_backendDispatcher->getString(parameters.get(), "selector"_s , nullptr); |
| 779 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 780 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.addRule' can't be processed"_s ); |
| 781 | return; |
| 782 | } |
| 783 | |
| 784 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 785 | if (m_alternateDispatcher) { |
| 786 | m_alternateDispatcher->addRule(requestId, in_styleSheetId, in_selector); |
| 787 | return; |
| 788 | } |
| 789 | #endif |
| 790 | |
| 791 | ErrorString error; |
| 792 | Ref<JSON::Object> result = JSON::Object::create(); |
| 793 | RefPtr<Inspector::Protocol::CSS::CSSRule> out_rule; |
| 794 | m_agent->addRule(error, in_styleSheetId, in_selector, out_rule); |
| 795 | |
| 796 | if (!error.length()) |
| 797 | result->setObject("rule"_s , out_rule); |
| 798 | |
| 799 | if (!error.length()) |
| 800 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 801 | else |
| 802 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 803 | } |
| 804 | |
| 805 | void CSSBackendDispatcher::getSupportedCSSProperties(long requestId, RefPtr<JSON::Object>&&) |
| 806 | { |
| 807 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 808 | if (m_alternateDispatcher) { |
| 809 | m_alternateDispatcher->getSupportedCSSProperties(requestId); |
| 810 | return; |
| 811 | } |
| 812 | #endif |
| 813 | |
| 814 | ErrorString error; |
| 815 | Ref<JSON::Object> result = JSON::Object::create(); |
| 816 | RefPtr<JSON::ArrayOf<Inspector::Protocol::CSS::CSSPropertyInfo>> out_cssProperties; |
| 817 | m_agent->getSupportedCSSProperties(error, out_cssProperties); |
| 818 | |
| 819 | if (!error.length()) |
| 820 | result->setArray("cssProperties"_s , out_cssProperties); |
| 821 | |
| 822 | if (!error.length()) |
| 823 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 824 | else |
| 825 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 826 | } |
| 827 | |
| 828 | void CSSBackendDispatcher::getSupportedSystemFontFamilyNames(long requestId, RefPtr<JSON::Object>&&) |
| 829 | { |
| 830 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 831 | if (m_alternateDispatcher) { |
| 832 | m_alternateDispatcher->getSupportedSystemFontFamilyNames(requestId); |
| 833 | return; |
| 834 | } |
| 835 | #endif |
| 836 | |
| 837 | ErrorString error; |
| 838 | Ref<JSON::Object> result = JSON::Object::create(); |
| 839 | RefPtr<JSON::ArrayOf<String>> out_fontFamilyNames; |
| 840 | m_agent->getSupportedSystemFontFamilyNames(error, out_fontFamilyNames); |
| 841 | |
| 842 | if (!error.length()) |
| 843 | result->setArray("fontFamilyNames"_s , out_fontFamilyNames); |
| 844 | |
| 845 | if (!error.length()) |
| 846 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 847 | else |
| 848 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 849 | } |
| 850 | |
| 851 | void CSSBackendDispatcher::forcePseudoState(long requestId, RefPtr<JSON::Object>&& parameters) |
| 852 | { |
| 853 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 854 | RefPtr<JSON::Array> in_forcedPseudoClasses = m_backendDispatcher->getArray(parameters.get(), "forcedPseudoClasses"_s , nullptr); |
| 855 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 856 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'CSS.forcePseudoState' can't be processed"_s ); |
| 857 | return; |
| 858 | } |
| 859 | |
| 860 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 861 | if (m_alternateDispatcher) { |
| 862 | m_alternateDispatcher->forcePseudoState(requestId, in_nodeId, *in_forcedPseudoClasses); |
| 863 | return; |
| 864 | } |
| 865 | #endif |
| 866 | |
| 867 | ErrorString error; |
| 868 | Ref<JSON::Object> result = JSON::Object::create(); |
| 869 | m_agent->forcePseudoState(error, in_nodeId, *in_forcedPseudoClasses); |
| 870 | |
| 871 | if (!error.length()) |
| 872 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 873 | else |
| 874 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 875 | } |
| 876 | |
| 877 | Ref<CanvasBackendDispatcher> CanvasBackendDispatcher::create(BackendDispatcher& backendDispatcher, CanvasBackendDispatcherHandler* agent) |
| 878 | { |
| 879 | return adoptRef(*new CanvasBackendDispatcher(backendDispatcher, agent)); |
| 880 | } |
| 881 | |
| 882 | CanvasBackendDispatcher::CanvasBackendDispatcher(BackendDispatcher& backendDispatcher, CanvasBackendDispatcherHandler* agent) |
| 883 | : SupplementalBackendDispatcher(backendDispatcher) |
| 884 | , m_agent(agent) |
| 885 | { |
| 886 | m_backendDispatcher->registerDispatcherForDomain("Canvas"_s , this); |
| 887 | } |
| 888 | |
| 889 | void CanvasBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 890 | { |
| 891 | Ref<CanvasBackendDispatcher> protect(*this); |
| 892 | |
| 893 | RefPtr<JSON::Object> parameters; |
| 894 | message->getObject("params"_s , parameters); |
| 895 | |
| 896 | typedef void (CanvasBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 897 | typedef HashMap<String, CallHandler> DispatchMap; |
| 898 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 899 | if (dispatchMap.get().isEmpty()) { |
| 900 | static const struct MethodTable { |
| 901 | const char* name; |
| 902 | CallHandler handler; |
| 903 | } commands[] = { |
| 904 | { "enable" , &CanvasBackendDispatcher::enable }, |
| 905 | { "disable" , &CanvasBackendDispatcher::disable }, |
| 906 | { "requestNode" , &CanvasBackendDispatcher::requestNode }, |
| 907 | { "requestContent" , &CanvasBackendDispatcher::requestContent }, |
| 908 | { "requestCSSCanvasClientNodes" , &CanvasBackendDispatcher::requestCSSCanvasClientNodes }, |
| 909 | { "resolveCanvasContext" , &CanvasBackendDispatcher::resolveCanvasContext }, |
| 910 | { "setRecordingAutoCaptureFrameCount" , &CanvasBackendDispatcher::setRecordingAutoCaptureFrameCount }, |
| 911 | { "startRecording" , &CanvasBackendDispatcher::startRecording }, |
| 912 | { "stopRecording" , &CanvasBackendDispatcher::stopRecording }, |
| 913 | { "requestShaderSource" , &CanvasBackendDispatcher::requestShaderSource }, |
| 914 | { "updateShader" , &CanvasBackendDispatcher::updateShader }, |
| 915 | { "setShaderProgramDisabled" , &CanvasBackendDispatcher::setShaderProgramDisabled }, |
| 916 | { "setShaderProgramHighlighted" , &CanvasBackendDispatcher::setShaderProgramHighlighted }, |
| 917 | }; |
| 918 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 919 | for (size_t i = 0; i < length; ++i) |
| 920 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 921 | } |
| 922 | |
| 923 | auto findResult = dispatchMap.get().find(method); |
| 924 | if (findResult == dispatchMap.get().end()) { |
| 925 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Canvas." + method + "' was not found" ); |
| 926 | return; |
| 927 | } |
| 928 | |
| 929 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 930 | } |
| 931 | |
| 932 | void CanvasBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 933 | { |
| 934 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 935 | if (m_alternateDispatcher) { |
| 936 | m_alternateDispatcher->enable(requestId); |
| 937 | return; |
| 938 | } |
| 939 | #endif |
| 940 | |
| 941 | ErrorString error; |
| 942 | Ref<JSON::Object> result = JSON::Object::create(); |
| 943 | m_agent->enable(error); |
| 944 | |
| 945 | if (!error.length()) |
| 946 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 947 | else |
| 948 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 949 | } |
| 950 | |
| 951 | void CanvasBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 952 | { |
| 953 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 954 | if (m_alternateDispatcher) { |
| 955 | m_alternateDispatcher->disable(requestId); |
| 956 | return; |
| 957 | } |
| 958 | #endif |
| 959 | |
| 960 | ErrorString error; |
| 961 | Ref<JSON::Object> result = JSON::Object::create(); |
| 962 | m_agent->disable(error); |
| 963 | |
| 964 | if (!error.length()) |
| 965 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 966 | else |
| 967 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 968 | } |
| 969 | |
| 970 | void CanvasBackendDispatcher::requestNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 971 | { |
| 972 | String in_canvasId = m_backendDispatcher->getString(parameters.get(), "canvasId"_s , nullptr); |
| 973 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 974 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.requestNode' can't be processed"_s ); |
| 975 | return; |
| 976 | } |
| 977 | |
| 978 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 979 | if (m_alternateDispatcher) { |
| 980 | m_alternateDispatcher->requestNode(requestId, in_canvasId); |
| 981 | return; |
| 982 | } |
| 983 | #endif |
| 984 | |
| 985 | ErrorString error; |
| 986 | Ref<JSON::Object> result = JSON::Object::create(); |
| 987 | int out_nodeId; |
| 988 | m_agent->requestNode(error, in_canvasId, &out_nodeId); |
| 989 | |
| 990 | if (!error.length()) |
| 991 | result->setInteger("nodeId"_s , out_nodeId); |
| 992 | |
| 993 | if (!error.length()) |
| 994 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 995 | else |
| 996 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 997 | } |
| 998 | |
| 999 | void CanvasBackendDispatcher::requestContent(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1000 | { |
| 1001 | String in_canvasId = m_backendDispatcher->getString(parameters.get(), "canvasId"_s , nullptr); |
| 1002 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1003 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.requestContent' can't be processed"_s ); |
| 1004 | return; |
| 1005 | } |
| 1006 | |
| 1007 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1008 | if (m_alternateDispatcher) { |
| 1009 | m_alternateDispatcher->requestContent(requestId, in_canvasId); |
| 1010 | return; |
| 1011 | } |
| 1012 | #endif |
| 1013 | |
| 1014 | ErrorString error; |
| 1015 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1016 | String out_content; |
| 1017 | m_agent->requestContent(error, in_canvasId, &out_content); |
| 1018 | |
| 1019 | if (!error.length()) |
| 1020 | result->setString("content"_s , out_content); |
| 1021 | |
| 1022 | if (!error.length()) |
| 1023 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1024 | else |
| 1025 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1026 | } |
| 1027 | |
| 1028 | void CanvasBackendDispatcher::requestCSSCanvasClientNodes(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1029 | { |
| 1030 | String in_canvasId = m_backendDispatcher->getString(parameters.get(), "canvasId"_s , nullptr); |
| 1031 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1032 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.requestCSSCanvasClientNodes' can't be processed"_s ); |
| 1033 | return; |
| 1034 | } |
| 1035 | |
| 1036 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1037 | if (m_alternateDispatcher) { |
| 1038 | m_alternateDispatcher->requestCSSCanvasClientNodes(requestId, in_canvasId); |
| 1039 | return; |
| 1040 | } |
| 1041 | #endif |
| 1042 | |
| 1043 | ErrorString error; |
| 1044 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1045 | RefPtr<JSON::ArrayOf<int>> out_clientNodeIds; |
| 1046 | m_agent->requestCSSCanvasClientNodes(error, in_canvasId, out_clientNodeIds); |
| 1047 | |
| 1048 | if (!error.length()) |
| 1049 | result->setArray("clientNodeIds"_s , out_clientNodeIds); |
| 1050 | |
| 1051 | if (!error.length()) |
| 1052 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1053 | else |
| 1054 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1055 | } |
| 1056 | |
| 1057 | void CanvasBackendDispatcher::resolveCanvasContext(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1058 | { |
| 1059 | String in_canvasId = m_backendDispatcher->getString(parameters.get(), "canvasId"_s , nullptr); |
| 1060 | bool opt_in_objectGroup_valueFound = false; |
| 1061 | String opt_in_objectGroup = m_backendDispatcher->getString(parameters.get(), "objectGroup"_s , &opt_in_objectGroup_valueFound); |
| 1062 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1063 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.resolveCanvasContext' can't be processed"_s ); |
| 1064 | return; |
| 1065 | } |
| 1066 | |
| 1067 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1068 | if (m_alternateDispatcher) { |
| 1069 | m_alternateDispatcher->resolveCanvasContext(requestId, in_canvasId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr); |
| 1070 | return; |
| 1071 | } |
| 1072 | #endif |
| 1073 | |
| 1074 | ErrorString error; |
| 1075 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1076 | RefPtr<Inspector::Protocol::Runtime::RemoteObject> out_object; |
| 1077 | m_agent->resolveCanvasContext(error, in_canvasId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, out_object); |
| 1078 | |
| 1079 | if (!error.length()) |
| 1080 | result->setObject("object"_s , out_object); |
| 1081 | |
| 1082 | if (!error.length()) |
| 1083 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1084 | else |
| 1085 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1086 | } |
| 1087 | |
| 1088 | void CanvasBackendDispatcher::setRecordingAutoCaptureFrameCount(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1089 | { |
| 1090 | int in_count = m_backendDispatcher->getInteger(parameters.get(), "count"_s , nullptr); |
| 1091 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1092 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.setRecordingAutoCaptureFrameCount' can't be processed"_s ); |
| 1093 | return; |
| 1094 | } |
| 1095 | |
| 1096 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1097 | if (m_alternateDispatcher) { |
| 1098 | m_alternateDispatcher->setRecordingAutoCaptureFrameCount(requestId, in_count); |
| 1099 | return; |
| 1100 | } |
| 1101 | #endif |
| 1102 | |
| 1103 | ErrorString error; |
| 1104 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1105 | m_agent->setRecordingAutoCaptureFrameCount(error, in_count); |
| 1106 | |
| 1107 | if (!error.length()) |
| 1108 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1109 | else |
| 1110 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1111 | } |
| 1112 | |
| 1113 | void CanvasBackendDispatcher::startRecording(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1114 | { |
| 1115 | String in_canvasId = m_backendDispatcher->getString(parameters.get(), "canvasId"_s , nullptr); |
| 1116 | bool opt_in_frameCount_valueFound = false; |
| 1117 | int opt_in_frameCount = m_backendDispatcher->getInteger(parameters.get(), "frameCount"_s , &opt_in_frameCount_valueFound); |
| 1118 | bool opt_in_memoryLimit_valueFound = false; |
| 1119 | int opt_in_memoryLimit = m_backendDispatcher->getInteger(parameters.get(), "memoryLimit"_s , &opt_in_memoryLimit_valueFound); |
| 1120 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1121 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.startRecording' can't be processed"_s ); |
| 1122 | return; |
| 1123 | } |
| 1124 | |
| 1125 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1126 | if (m_alternateDispatcher) { |
| 1127 | m_alternateDispatcher->startRecording(requestId, in_canvasId, opt_in_frameCount_valueFound ? &opt_in_frameCount : nullptr, opt_in_memoryLimit_valueFound ? &opt_in_memoryLimit : nullptr); |
| 1128 | return; |
| 1129 | } |
| 1130 | #endif |
| 1131 | |
| 1132 | ErrorString error; |
| 1133 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1134 | m_agent->startRecording(error, in_canvasId, opt_in_frameCount_valueFound ? &opt_in_frameCount : nullptr, opt_in_memoryLimit_valueFound ? &opt_in_memoryLimit : nullptr); |
| 1135 | |
| 1136 | if (!error.length()) |
| 1137 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1138 | else |
| 1139 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1140 | } |
| 1141 | |
| 1142 | void CanvasBackendDispatcher::stopRecording(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1143 | { |
| 1144 | String in_canvasId = m_backendDispatcher->getString(parameters.get(), "canvasId"_s , nullptr); |
| 1145 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1146 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.stopRecording' can't be processed"_s ); |
| 1147 | return; |
| 1148 | } |
| 1149 | |
| 1150 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1151 | if (m_alternateDispatcher) { |
| 1152 | m_alternateDispatcher->stopRecording(requestId, in_canvasId); |
| 1153 | return; |
| 1154 | } |
| 1155 | #endif |
| 1156 | |
| 1157 | ErrorString error; |
| 1158 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1159 | m_agent->stopRecording(error, in_canvasId); |
| 1160 | |
| 1161 | if (!error.length()) |
| 1162 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1163 | else |
| 1164 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1165 | } |
| 1166 | |
| 1167 | void CanvasBackendDispatcher::requestShaderSource(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1168 | { |
| 1169 | String in_programId = m_backendDispatcher->getString(parameters.get(), "programId"_s , nullptr); |
| 1170 | String in_shaderType = m_backendDispatcher->getString(parameters.get(), "shaderType"_s , nullptr); |
| 1171 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1172 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.requestShaderSource' can't be processed"_s ); |
| 1173 | return; |
| 1174 | } |
| 1175 | |
| 1176 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1177 | if (m_alternateDispatcher) { |
| 1178 | m_alternateDispatcher->requestShaderSource(requestId, in_programId, in_shaderType); |
| 1179 | return; |
| 1180 | } |
| 1181 | #endif |
| 1182 | |
| 1183 | ErrorString error; |
| 1184 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1185 | String out_content; |
| 1186 | m_agent->requestShaderSource(error, in_programId, in_shaderType, &out_content); |
| 1187 | |
| 1188 | if (!error.length()) |
| 1189 | result->setString("content"_s , out_content); |
| 1190 | |
| 1191 | if (!error.length()) |
| 1192 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1193 | else |
| 1194 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1195 | } |
| 1196 | |
| 1197 | void CanvasBackendDispatcher::updateShader(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1198 | { |
| 1199 | String in_programId = m_backendDispatcher->getString(parameters.get(), "programId"_s , nullptr); |
| 1200 | String in_shaderType = m_backendDispatcher->getString(parameters.get(), "shaderType"_s , nullptr); |
| 1201 | String in_source = m_backendDispatcher->getString(parameters.get(), "source"_s , nullptr); |
| 1202 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1203 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.updateShader' can't be processed"_s ); |
| 1204 | return; |
| 1205 | } |
| 1206 | |
| 1207 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1208 | if (m_alternateDispatcher) { |
| 1209 | m_alternateDispatcher->updateShader(requestId, in_programId, in_shaderType, in_source); |
| 1210 | return; |
| 1211 | } |
| 1212 | #endif |
| 1213 | |
| 1214 | ErrorString error; |
| 1215 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1216 | m_agent->updateShader(error, in_programId, in_shaderType, in_source); |
| 1217 | |
| 1218 | if (!error.length()) |
| 1219 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1220 | else |
| 1221 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1222 | } |
| 1223 | |
| 1224 | void CanvasBackendDispatcher::setShaderProgramDisabled(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1225 | { |
| 1226 | String in_programId = m_backendDispatcher->getString(parameters.get(), "programId"_s , nullptr); |
| 1227 | bool in_disabled = m_backendDispatcher->getBoolean(parameters.get(), "disabled"_s , nullptr); |
| 1228 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1229 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.setShaderProgramDisabled' can't be processed"_s ); |
| 1230 | return; |
| 1231 | } |
| 1232 | |
| 1233 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1234 | if (m_alternateDispatcher) { |
| 1235 | m_alternateDispatcher->setShaderProgramDisabled(requestId, in_programId, in_disabled); |
| 1236 | return; |
| 1237 | } |
| 1238 | #endif |
| 1239 | |
| 1240 | ErrorString error; |
| 1241 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1242 | m_agent->setShaderProgramDisabled(error, in_programId, in_disabled); |
| 1243 | |
| 1244 | if (!error.length()) |
| 1245 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1246 | else |
| 1247 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1248 | } |
| 1249 | |
| 1250 | void CanvasBackendDispatcher::setShaderProgramHighlighted(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1251 | { |
| 1252 | String in_programId = m_backendDispatcher->getString(parameters.get(), "programId"_s , nullptr); |
| 1253 | bool in_highlighted = m_backendDispatcher->getBoolean(parameters.get(), "highlighted"_s , nullptr); |
| 1254 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1255 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Canvas.setShaderProgramHighlighted' can't be processed"_s ); |
| 1256 | return; |
| 1257 | } |
| 1258 | |
| 1259 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1260 | if (m_alternateDispatcher) { |
| 1261 | m_alternateDispatcher->setShaderProgramHighlighted(requestId, in_programId, in_highlighted); |
| 1262 | return; |
| 1263 | } |
| 1264 | #endif |
| 1265 | |
| 1266 | ErrorString error; |
| 1267 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1268 | m_agent->setShaderProgramHighlighted(error, in_programId, in_highlighted); |
| 1269 | |
| 1270 | if (!error.length()) |
| 1271 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1272 | else |
| 1273 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1274 | } |
| 1275 | |
| 1276 | Ref<ConsoleBackendDispatcher> ConsoleBackendDispatcher::create(BackendDispatcher& backendDispatcher, ConsoleBackendDispatcherHandler* agent) |
| 1277 | { |
| 1278 | return adoptRef(*new ConsoleBackendDispatcher(backendDispatcher, agent)); |
| 1279 | } |
| 1280 | |
| 1281 | ConsoleBackendDispatcher::ConsoleBackendDispatcher(BackendDispatcher& backendDispatcher, ConsoleBackendDispatcherHandler* agent) |
| 1282 | : SupplementalBackendDispatcher(backendDispatcher) |
| 1283 | , m_agent(agent) |
| 1284 | { |
| 1285 | m_backendDispatcher->registerDispatcherForDomain("Console"_s , this); |
| 1286 | } |
| 1287 | |
| 1288 | void ConsoleBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 1289 | { |
| 1290 | Ref<ConsoleBackendDispatcher> protect(*this); |
| 1291 | |
| 1292 | RefPtr<JSON::Object> parameters; |
| 1293 | message->getObject("params"_s , parameters); |
| 1294 | |
| 1295 | if (method == "enable" ) |
| 1296 | enable(requestId, WTFMove(parameters)); |
| 1297 | else if (method == "disable" ) |
| 1298 | disable(requestId, WTFMove(parameters)); |
| 1299 | else if (method == "clearMessages" ) |
| 1300 | clearMessages(requestId, WTFMove(parameters)); |
| 1301 | else if (method == "getLoggingChannels" ) |
| 1302 | getLoggingChannels(requestId, WTFMove(parameters)); |
| 1303 | else if (method == "setLoggingChannelLevel" ) |
| 1304 | setLoggingChannelLevel(requestId, WTFMove(parameters)); |
| 1305 | else |
| 1306 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Console." + method + "' was not found" ); |
| 1307 | } |
| 1308 | |
| 1309 | void ConsoleBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 1310 | { |
| 1311 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1312 | if (m_alternateDispatcher) { |
| 1313 | m_alternateDispatcher->enable(requestId); |
| 1314 | return; |
| 1315 | } |
| 1316 | #endif |
| 1317 | |
| 1318 | ErrorString error; |
| 1319 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1320 | m_agent->enable(error); |
| 1321 | |
| 1322 | if (!error.length()) |
| 1323 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1324 | else |
| 1325 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1326 | } |
| 1327 | |
| 1328 | void ConsoleBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 1329 | { |
| 1330 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1331 | if (m_alternateDispatcher) { |
| 1332 | m_alternateDispatcher->disable(requestId); |
| 1333 | return; |
| 1334 | } |
| 1335 | #endif |
| 1336 | |
| 1337 | ErrorString error; |
| 1338 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1339 | m_agent->disable(error); |
| 1340 | |
| 1341 | if (!error.length()) |
| 1342 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1343 | else |
| 1344 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1345 | } |
| 1346 | |
| 1347 | void ConsoleBackendDispatcher::clearMessages(long requestId, RefPtr<JSON::Object>&&) |
| 1348 | { |
| 1349 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1350 | if (m_alternateDispatcher) { |
| 1351 | m_alternateDispatcher->clearMessages(requestId); |
| 1352 | return; |
| 1353 | } |
| 1354 | #endif |
| 1355 | |
| 1356 | ErrorString error; |
| 1357 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1358 | m_agent->clearMessages(error); |
| 1359 | |
| 1360 | if (!error.length()) |
| 1361 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1362 | else |
| 1363 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1364 | } |
| 1365 | |
| 1366 | void ConsoleBackendDispatcher::getLoggingChannels(long requestId, RefPtr<JSON::Object>&&) |
| 1367 | { |
| 1368 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1369 | if (m_alternateDispatcher) { |
| 1370 | m_alternateDispatcher->getLoggingChannels(requestId); |
| 1371 | return; |
| 1372 | } |
| 1373 | #endif |
| 1374 | |
| 1375 | ErrorString error; |
| 1376 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1377 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Console::Channel>> out_channels; |
| 1378 | m_agent->getLoggingChannels(error, out_channels); |
| 1379 | |
| 1380 | if (!error.length()) |
| 1381 | result->setArray("channels"_s , out_channels); |
| 1382 | |
| 1383 | if (!error.length()) |
| 1384 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1385 | else |
| 1386 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1387 | } |
| 1388 | |
| 1389 | void ConsoleBackendDispatcher::setLoggingChannelLevel(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1390 | { |
| 1391 | String in_source = m_backendDispatcher->getString(parameters.get(), "source"_s , nullptr); |
| 1392 | String in_level = m_backendDispatcher->getString(parameters.get(), "level"_s , nullptr); |
| 1393 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1394 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Console.setLoggingChannelLevel' can't be processed"_s ); |
| 1395 | return; |
| 1396 | } |
| 1397 | |
| 1398 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1399 | if (m_alternateDispatcher) { |
| 1400 | m_alternateDispatcher->setLoggingChannelLevel(requestId, in_source, in_level); |
| 1401 | return; |
| 1402 | } |
| 1403 | #endif |
| 1404 | |
| 1405 | ErrorString error; |
| 1406 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1407 | m_agent->setLoggingChannelLevel(error, in_source, in_level); |
| 1408 | |
| 1409 | if (!error.length()) |
| 1410 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1411 | else |
| 1412 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1413 | } |
| 1414 | |
| 1415 | Ref<DOMBackendDispatcher> DOMBackendDispatcher::create(BackendDispatcher& backendDispatcher, DOMBackendDispatcherHandler* agent) |
| 1416 | { |
| 1417 | return adoptRef(*new DOMBackendDispatcher(backendDispatcher, agent)); |
| 1418 | } |
| 1419 | |
| 1420 | DOMBackendDispatcher::DOMBackendDispatcher(BackendDispatcher& backendDispatcher, DOMBackendDispatcherHandler* agent) |
| 1421 | : SupplementalBackendDispatcher(backendDispatcher) |
| 1422 | , m_agent(agent) |
| 1423 | { |
| 1424 | m_backendDispatcher->registerDispatcherForDomain("DOM"_s , this); |
| 1425 | } |
| 1426 | |
| 1427 | void DOMBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 1428 | { |
| 1429 | Ref<DOMBackendDispatcher> protect(*this); |
| 1430 | |
| 1431 | RefPtr<JSON::Object> parameters; |
| 1432 | message->getObject("params"_s , parameters); |
| 1433 | |
| 1434 | typedef void (DOMBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 1435 | typedef HashMap<String, CallHandler> DispatchMap; |
| 1436 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 1437 | if (dispatchMap.get().isEmpty()) { |
| 1438 | static const struct MethodTable { |
| 1439 | const char* name; |
| 1440 | CallHandler handler; |
| 1441 | } commands[] = { |
| 1442 | { "getDocument" , &DOMBackendDispatcher::getDocument }, |
| 1443 | { "requestChildNodes" , &DOMBackendDispatcher::requestChildNodes }, |
| 1444 | { "querySelector" , &DOMBackendDispatcher::querySelector }, |
| 1445 | { "querySelectorAll" , &DOMBackendDispatcher::querySelectorAll }, |
| 1446 | { "setNodeName" , &DOMBackendDispatcher::setNodeName }, |
| 1447 | { "setNodeValue" , &DOMBackendDispatcher::setNodeValue }, |
| 1448 | { "removeNode" , &DOMBackendDispatcher::removeNode }, |
| 1449 | { "setAttributeValue" , &DOMBackendDispatcher::setAttributeValue }, |
| 1450 | { "setAttributesAsText" , &DOMBackendDispatcher::setAttributesAsText }, |
| 1451 | { "removeAttribute" , &DOMBackendDispatcher::removeAttribute }, |
| 1452 | { "getSupportedEventNames" , &DOMBackendDispatcher::getSupportedEventNames }, |
| 1453 | { "getDataBindingsForNode" , &DOMBackendDispatcher::getDataBindingsForNode }, |
| 1454 | { "getAssociatedDataForNode" , &DOMBackendDispatcher::getAssociatedDataForNode }, |
| 1455 | { "getEventListenersForNode" , &DOMBackendDispatcher::getEventListenersForNode }, |
| 1456 | { "setEventListenerDisabled" , &DOMBackendDispatcher::setEventListenerDisabled }, |
| 1457 | { "setBreakpointForEventListener" , &DOMBackendDispatcher::setBreakpointForEventListener }, |
| 1458 | { "removeBreakpointForEventListener" , &DOMBackendDispatcher::removeBreakpointForEventListener }, |
| 1459 | { "getAccessibilityPropertiesForNode" , &DOMBackendDispatcher::getAccessibilityPropertiesForNode }, |
| 1460 | { "getOuterHTML" , &DOMBackendDispatcher::getOuterHTML }, |
| 1461 | { "setOuterHTML" , &DOMBackendDispatcher::setOuterHTML }, |
| 1462 | { "insertAdjacentHTML" , &DOMBackendDispatcher::insertAdjacentHTML }, |
| 1463 | { "performSearch" , &DOMBackendDispatcher::performSearch }, |
| 1464 | { "getSearchResults" , &DOMBackendDispatcher::getSearchResults }, |
| 1465 | { "discardSearchResults" , &DOMBackendDispatcher::discardSearchResults }, |
| 1466 | { "requestNode" , &DOMBackendDispatcher::requestNode }, |
| 1467 | { "setInspectModeEnabled" , &DOMBackendDispatcher::setInspectModeEnabled }, |
| 1468 | { "highlightRect" , &DOMBackendDispatcher::highlightRect }, |
| 1469 | { "highlightQuad" , &DOMBackendDispatcher::highlightQuad }, |
| 1470 | { "highlightSelector" , &DOMBackendDispatcher::highlightSelector }, |
| 1471 | { "highlightNode" , &DOMBackendDispatcher::highlightNode }, |
| 1472 | { "highlightNodeList" , &DOMBackendDispatcher::highlightNodeList }, |
| 1473 | { "hideHighlight" , &DOMBackendDispatcher::hideHighlight }, |
| 1474 | { "highlightFrame" , &DOMBackendDispatcher::highlightFrame }, |
| 1475 | { "pushNodeByPathToFrontend" , &DOMBackendDispatcher::pushNodeByPathToFrontend }, |
| 1476 | { "resolveNode" , &DOMBackendDispatcher::resolveNode }, |
| 1477 | { "getAttributes" , &DOMBackendDispatcher::getAttributes }, |
| 1478 | { "moveTo" , &DOMBackendDispatcher::moveTo }, |
| 1479 | { "undo" , &DOMBackendDispatcher::undo }, |
| 1480 | { "redo" , &DOMBackendDispatcher::redo }, |
| 1481 | { "markUndoableState" , &DOMBackendDispatcher::markUndoableState }, |
| 1482 | { "focus" , &DOMBackendDispatcher::focus }, |
| 1483 | { "setInspectedNode" , &DOMBackendDispatcher::setInspectedNode }, |
| 1484 | }; |
| 1485 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 1486 | for (size_t i = 0; i < length; ++i) |
| 1487 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 1488 | } |
| 1489 | |
| 1490 | auto findResult = dispatchMap.get().find(method); |
| 1491 | if (findResult == dispatchMap.get().end()) { |
| 1492 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'DOM." + method + "' was not found" ); |
| 1493 | return; |
| 1494 | } |
| 1495 | |
| 1496 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 1497 | } |
| 1498 | |
| 1499 | void DOMBackendDispatcher::getDocument(long requestId, RefPtr<JSON::Object>&&) |
| 1500 | { |
| 1501 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1502 | if (m_alternateDispatcher) { |
| 1503 | m_alternateDispatcher->getDocument(requestId); |
| 1504 | return; |
| 1505 | } |
| 1506 | #endif |
| 1507 | |
| 1508 | ErrorString error; |
| 1509 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1510 | RefPtr<Inspector::Protocol::DOM::Node> out_root; |
| 1511 | m_agent->getDocument(error, out_root); |
| 1512 | |
| 1513 | if (!error.length()) |
| 1514 | result->setObject("root"_s , out_root); |
| 1515 | |
| 1516 | if (!error.length()) |
| 1517 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1518 | else |
| 1519 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1520 | } |
| 1521 | |
| 1522 | void DOMBackendDispatcher::requestChildNodes(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1523 | { |
| 1524 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1525 | bool opt_in_depth_valueFound = false; |
| 1526 | int opt_in_depth = m_backendDispatcher->getInteger(parameters.get(), "depth"_s , &opt_in_depth_valueFound); |
| 1527 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1528 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.requestChildNodes' can't be processed"_s ); |
| 1529 | return; |
| 1530 | } |
| 1531 | |
| 1532 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1533 | if (m_alternateDispatcher) { |
| 1534 | m_alternateDispatcher->requestChildNodes(requestId, in_nodeId, opt_in_depth_valueFound ? &opt_in_depth : nullptr); |
| 1535 | return; |
| 1536 | } |
| 1537 | #endif |
| 1538 | |
| 1539 | ErrorString error; |
| 1540 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1541 | m_agent->requestChildNodes(error, in_nodeId, opt_in_depth_valueFound ? &opt_in_depth : nullptr); |
| 1542 | |
| 1543 | if (!error.length()) |
| 1544 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1545 | else |
| 1546 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1547 | } |
| 1548 | |
| 1549 | void DOMBackendDispatcher::querySelector(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1550 | { |
| 1551 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1552 | String in_selector = m_backendDispatcher->getString(parameters.get(), "selector"_s , nullptr); |
| 1553 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1554 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.querySelector' can't be processed"_s ); |
| 1555 | return; |
| 1556 | } |
| 1557 | |
| 1558 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1559 | if (m_alternateDispatcher) { |
| 1560 | m_alternateDispatcher->querySelector(requestId, in_nodeId, in_selector); |
| 1561 | return; |
| 1562 | } |
| 1563 | #endif |
| 1564 | |
| 1565 | ErrorString error; |
| 1566 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1567 | int out_nodeId; |
| 1568 | m_agent->querySelector(error, in_nodeId, in_selector, &out_nodeId); |
| 1569 | |
| 1570 | if (!error.length()) |
| 1571 | result->setInteger("nodeId"_s , out_nodeId); |
| 1572 | |
| 1573 | if (!error.length()) |
| 1574 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1575 | else |
| 1576 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1577 | } |
| 1578 | |
| 1579 | void DOMBackendDispatcher::querySelectorAll(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1580 | { |
| 1581 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1582 | String in_selector = m_backendDispatcher->getString(parameters.get(), "selector"_s , nullptr); |
| 1583 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1584 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.querySelectorAll' can't be processed"_s ); |
| 1585 | return; |
| 1586 | } |
| 1587 | |
| 1588 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1589 | if (m_alternateDispatcher) { |
| 1590 | m_alternateDispatcher->querySelectorAll(requestId, in_nodeId, in_selector); |
| 1591 | return; |
| 1592 | } |
| 1593 | #endif |
| 1594 | |
| 1595 | ErrorString error; |
| 1596 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1597 | RefPtr<JSON::ArrayOf<int>> out_nodeIds; |
| 1598 | m_agent->querySelectorAll(error, in_nodeId, in_selector, out_nodeIds); |
| 1599 | |
| 1600 | if (!error.length()) |
| 1601 | result->setArray("nodeIds"_s , out_nodeIds); |
| 1602 | |
| 1603 | if (!error.length()) |
| 1604 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1605 | else |
| 1606 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1607 | } |
| 1608 | |
| 1609 | void DOMBackendDispatcher::setNodeName(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1610 | { |
| 1611 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1612 | String in_name = m_backendDispatcher->getString(parameters.get(), "name"_s , nullptr); |
| 1613 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1614 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setNodeName' can't be processed"_s ); |
| 1615 | return; |
| 1616 | } |
| 1617 | |
| 1618 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1619 | if (m_alternateDispatcher) { |
| 1620 | m_alternateDispatcher->setNodeName(requestId, in_nodeId, in_name); |
| 1621 | return; |
| 1622 | } |
| 1623 | #endif |
| 1624 | |
| 1625 | ErrorString error; |
| 1626 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1627 | int out_nodeId; |
| 1628 | m_agent->setNodeName(error, in_nodeId, in_name, &out_nodeId); |
| 1629 | |
| 1630 | if (!error.length()) |
| 1631 | result->setInteger("nodeId"_s , out_nodeId); |
| 1632 | |
| 1633 | if (!error.length()) |
| 1634 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1635 | else |
| 1636 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1637 | } |
| 1638 | |
| 1639 | void DOMBackendDispatcher::setNodeValue(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1640 | { |
| 1641 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1642 | String in_value = m_backendDispatcher->getString(parameters.get(), "value"_s , nullptr); |
| 1643 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1644 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setNodeValue' can't be processed"_s ); |
| 1645 | return; |
| 1646 | } |
| 1647 | |
| 1648 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1649 | if (m_alternateDispatcher) { |
| 1650 | m_alternateDispatcher->setNodeValue(requestId, in_nodeId, in_value); |
| 1651 | return; |
| 1652 | } |
| 1653 | #endif |
| 1654 | |
| 1655 | ErrorString error; |
| 1656 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1657 | m_agent->setNodeValue(error, in_nodeId, in_value); |
| 1658 | |
| 1659 | if (!error.length()) |
| 1660 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1661 | else |
| 1662 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1663 | } |
| 1664 | |
| 1665 | void DOMBackendDispatcher::removeNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1666 | { |
| 1667 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1668 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1669 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.removeNode' can't be processed"_s ); |
| 1670 | return; |
| 1671 | } |
| 1672 | |
| 1673 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1674 | if (m_alternateDispatcher) { |
| 1675 | m_alternateDispatcher->removeNode(requestId, in_nodeId); |
| 1676 | return; |
| 1677 | } |
| 1678 | #endif |
| 1679 | |
| 1680 | ErrorString error; |
| 1681 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1682 | m_agent->removeNode(error, in_nodeId); |
| 1683 | |
| 1684 | if (!error.length()) |
| 1685 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1686 | else |
| 1687 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1688 | } |
| 1689 | |
| 1690 | void DOMBackendDispatcher::setAttributeValue(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1691 | { |
| 1692 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1693 | String in_name = m_backendDispatcher->getString(parameters.get(), "name"_s , nullptr); |
| 1694 | String in_value = m_backendDispatcher->getString(parameters.get(), "value"_s , nullptr); |
| 1695 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1696 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setAttributeValue' can't be processed"_s ); |
| 1697 | return; |
| 1698 | } |
| 1699 | |
| 1700 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1701 | if (m_alternateDispatcher) { |
| 1702 | m_alternateDispatcher->setAttributeValue(requestId, in_nodeId, in_name, in_value); |
| 1703 | return; |
| 1704 | } |
| 1705 | #endif |
| 1706 | |
| 1707 | ErrorString error; |
| 1708 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1709 | m_agent->setAttributeValue(error, in_nodeId, in_name, in_value); |
| 1710 | |
| 1711 | if (!error.length()) |
| 1712 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1713 | else |
| 1714 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1715 | } |
| 1716 | |
| 1717 | void DOMBackendDispatcher::setAttributesAsText(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1718 | { |
| 1719 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1720 | String in_text = m_backendDispatcher->getString(parameters.get(), "text"_s , nullptr); |
| 1721 | bool opt_in_name_valueFound = false; |
| 1722 | String opt_in_name = m_backendDispatcher->getString(parameters.get(), "name"_s , &opt_in_name_valueFound); |
| 1723 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1724 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setAttributesAsText' can't be processed"_s ); |
| 1725 | return; |
| 1726 | } |
| 1727 | |
| 1728 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1729 | if (m_alternateDispatcher) { |
| 1730 | m_alternateDispatcher->setAttributesAsText(requestId, in_nodeId, in_text, opt_in_name_valueFound ? &opt_in_name : nullptr); |
| 1731 | return; |
| 1732 | } |
| 1733 | #endif |
| 1734 | |
| 1735 | ErrorString error; |
| 1736 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1737 | m_agent->setAttributesAsText(error, in_nodeId, in_text, opt_in_name_valueFound ? &opt_in_name : nullptr); |
| 1738 | |
| 1739 | if (!error.length()) |
| 1740 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1741 | else |
| 1742 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1743 | } |
| 1744 | |
| 1745 | void DOMBackendDispatcher::removeAttribute(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1746 | { |
| 1747 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1748 | String in_name = m_backendDispatcher->getString(parameters.get(), "name"_s , nullptr); |
| 1749 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1750 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.removeAttribute' can't be processed"_s ); |
| 1751 | return; |
| 1752 | } |
| 1753 | |
| 1754 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1755 | if (m_alternateDispatcher) { |
| 1756 | m_alternateDispatcher->removeAttribute(requestId, in_nodeId, in_name); |
| 1757 | return; |
| 1758 | } |
| 1759 | #endif |
| 1760 | |
| 1761 | ErrorString error; |
| 1762 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1763 | m_agent->removeAttribute(error, in_nodeId, in_name); |
| 1764 | |
| 1765 | if (!error.length()) |
| 1766 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1767 | else |
| 1768 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1769 | } |
| 1770 | |
| 1771 | void DOMBackendDispatcher::getSupportedEventNames(long requestId, RefPtr<JSON::Object>&&) |
| 1772 | { |
| 1773 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1774 | if (m_alternateDispatcher) { |
| 1775 | m_alternateDispatcher->getSupportedEventNames(requestId); |
| 1776 | return; |
| 1777 | } |
| 1778 | #endif |
| 1779 | |
| 1780 | ErrorString error; |
| 1781 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1782 | RefPtr<JSON::ArrayOf<String>> out_eventNames; |
| 1783 | m_agent->getSupportedEventNames(error, out_eventNames); |
| 1784 | |
| 1785 | if (!error.length()) |
| 1786 | result->setArray("eventNames"_s , out_eventNames); |
| 1787 | |
| 1788 | if (!error.length()) |
| 1789 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1790 | else |
| 1791 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1792 | } |
| 1793 | |
| 1794 | void DOMBackendDispatcher::getDataBindingsForNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1795 | { |
| 1796 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1797 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1798 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.getDataBindingsForNode' can't be processed"_s ); |
| 1799 | return; |
| 1800 | } |
| 1801 | |
| 1802 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1803 | if (m_alternateDispatcher) { |
| 1804 | m_alternateDispatcher->getDataBindingsForNode(requestId, in_nodeId); |
| 1805 | return; |
| 1806 | } |
| 1807 | #endif |
| 1808 | |
| 1809 | ErrorString error; |
| 1810 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1811 | RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::DataBinding>> out_dataBindings; |
| 1812 | m_agent->getDataBindingsForNode(error, in_nodeId, out_dataBindings); |
| 1813 | |
| 1814 | if (!error.length()) |
| 1815 | result->setArray("dataBindings"_s , out_dataBindings); |
| 1816 | |
| 1817 | if (!error.length()) |
| 1818 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1819 | else |
| 1820 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1821 | } |
| 1822 | |
| 1823 | void DOMBackendDispatcher::getAssociatedDataForNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1824 | { |
| 1825 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1826 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1827 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.getAssociatedDataForNode' can't be processed"_s ); |
| 1828 | return; |
| 1829 | } |
| 1830 | |
| 1831 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1832 | if (m_alternateDispatcher) { |
| 1833 | m_alternateDispatcher->getAssociatedDataForNode(requestId, in_nodeId); |
| 1834 | return; |
| 1835 | } |
| 1836 | #endif |
| 1837 | |
| 1838 | ErrorString error; |
| 1839 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1840 | Optional<String> out_associatedData; |
| 1841 | m_agent->getAssociatedDataForNode(error, in_nodeId, out_associatedData); |
| 1842 | |
| 1843 | if (!error.length()) |
| 1844 | if (out_associatedData.hasValue()) |
| 1845 | result->setString("associatedData"_s , *out_associatedData); |
| 1846 | |
| 1847 | if (!error.length()) |
| 1848 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1849 | else |
| 1850 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1851 | } |
| 1852 | |
| 1853 | void DOMBackendDispatcher::getEventListenersForNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1854 | { |
| 1855 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1856 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1857 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.getEventListenersForNode' can't be processed"_s ); |
| 1858 | return; |
| 1859 | } |
| 1860 | |
| 1861 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1862 | if (m_alternateDispatcher) { |
| 1863 | m_alternateDispatcher->getEventListenersForNode(requestId, in_nodeId); |
| 1864 | return; |
| 1865 | } |
| 1866 | #endif |
| 1867 | |
| 1868 | ErrorString error; |
| 1869 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1870 | RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::EventListener>> out_listeners; |
| 1871 | m_agent->getEventListenersForNode(error, in_nodeId, out_listeners); |
| 1872 | |
| 1873 | if (!error.length()) |
| 1874 | result->setArray("listeners"_s , out_listeners); |
| 1875 | |
| 1876 | if (!error.length()) |
| 1877 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1878 | else |
| 1879 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1880 | } |
| 1881 | |
| 1882 | void DOMBackendDispatcher::setEventListenerDisabled(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1883 | { |
| 1884 | int in_eventListenerId = m_backendDispatcher->getInteger(parameters.get(), "eventListenerId"_s , nullptr); |
| 1885 | bool in_disabled = m_backendDispatcher->getBoolean(parameters.get(), "disabled"_s , nullptr); |
| 1886 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1887 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setEventListenerDisabled' can't be processed"_s ); |
| 1888 | return; |
| 1889 | } |
| 1890 | |
| 1891 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1892 | if (m_alternateDispatcher) { |
| 1893 | m_alternateDispatcher->setEventListenerDisabled(requestId, in_eventListenerId, in_disabled); |
| 1894 | return; |
| 1895 | } |
| 1896 | #endif |
| 1897 | |
| 1898 | ErrorString error; |
| 1899 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1900 | m_agent->setEventListenerDisabled(error, in_eventListenerId, in_disabled); |
| 1901 | |
| 1902 | if (!error.length()) |
| 1903 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1904 | else |
| 1905 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1906 | } |
| 1907 | |
| 1908 | void DOMBackendDispatcher::setBreakpointForEventListener(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1909 | { |
| 1910 | int in_eventListenerId = m_backendDispatcher->getInteger(parameters.get(), "eventListenerId"_s , nullptr); |
| 1911 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1912 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setBreakpointForEventListener' can't be processed"_s ); |
| 1913 | return; |
| 1914 | } |
| 1915 | |
| 1916 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1917 | if (m_alternateDispatcher) { |
| 1918 | m_alternateDispatcher->setBreakpointForEventListener(requestId, in_eventListenerId); |
| 1919 | return; |
| 1920 | } |
| 1921 | #endif |
| 1922 | |
| 1923 | ErrorString error; |
| 1924 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1925 | m_agent->setBreakpointForEventListener(error, in_eventListenerId); |
| 1926 | |
| 1927 | if (!error.length()) |
| 1928 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1929 | else |
| 1930 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1931 | } |
| 1932 | |
| 1933 | void DOMBackendDispatcher::removeBreakpointForEventListener(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1934 | { |
| 1935 | int in_eventListenerId = m_backendDispatcher->getInteger(parameters.get(), "eventListenerId"_s , nullptr); |
| 1936 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1937 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.removeBreakpointForEventListener' can't be processed"_s ); |
| 1938 | return; |
| 1939 | } |
| 1940 | |
| 1941 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1942 | if (m_alternateDispatcher) { |
| 1943 | m_alternateDispatcher->removeBreakpointForEventListener(requestId, in_eventListenerId); |
| 1944 | return; |
| 1945 | } |
| 1946 | #endif |
| 1947 | |
| 1948 | ErrorString error; |
| 1949 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1950 | m_agent->removeBreakpointForEventListener(error, in_eventListenerId); |
| 1951 | |
| 1952 | if (!error.length()) |
| 1953 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1954 | else |
| 1955 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1956 | } |
| 1957 | |
| 1958 | void DOMBackendDispatcher::getAccessibilityPropertiesForNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1959 | { |
| 1960 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1961 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1962 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.getAccessibilityPropertiesForNode' can't be processed"_s ); |
| 1963 | return; |
| 1964 | } |
| 1965 | |
| 1966 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1967 | if (m_alternateDispatcher) { |
| 1968 | m_alternateDispatcher->getAccessibilityPropertiesForNode(requestId, in_nodeId); |
| 1969 | return; |
| 1970 | } |
| 1971 | #endif |
| 1972 | |
| 1973 | ErrorString error; |
| 1974 | Ref<JSON::Object> result = JSON::Object::create(); |
| 1975 | RefPtr<Inspector::Protocol::DOM::AccessibilityProperties> out_properties; |
| 1976 | m_agent->getAccessibilityPropertiesForNode(error, in_nodeId, out_properties); |
| 1977 | |
| 1978 | if (!error.length()) |
| 1979 | result->setObject("properties"_s , out_properties); |
| 1980 | |
| 1981 | if (!error.length()) |
| 1982 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 1983 | else |
| 1984 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 1985 | } |
| 1986 | |
| 1987 | void DOMBackendDispatcher::getOuterHTML(long requestId, RefPtr<JSON::Object>&& parameters) |
| 1988 | { |
| 1989 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 1990 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 1991 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.getOuterHTML' can't be processed"_s ); |
| 1992 | return; |
| 1993 | } |
| 1994 | |
| 1995 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 1996 | if (m_alternateDispatcher) { |
| 1997 | m_alternateDispatcher->getOuterHTML(requestId, in_nodeId); |
| 1998 | return; |
| 1999 | } |
| 2000 | #endif |
| 2001 | |
| 2002 | ErrorString error; |
| 2003 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2004 | String out_outerHTML; |
| 2005 | m_agent->getOuterHTML(error, in_nodeId, &out_outerHTML); |
| 2006 | |
| 2007 | if (!error.length()) |
| 2008 | result->setString("outerHTML"_s , out_outerHTML); |
| 2009 | |
| 2010 | if (!error.length()) |
| 2011 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2012 | else |
| 2013 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2014 | } |
| 2015 | |
| 2016 | void DOMBackendDispatcher::setOuterHTML(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2017 | { |
| 2018 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2019 | String in_outerHTML = m_backendDispatcher->getString(parameters.get(), "outerHTML"_s , nullptr); |
| 2020 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2021 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setOuterHTML' can't be processed"_s ); |
| 2022 | return; |
| 2023 | } |
| 2024 | |
| 2025 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2026 | if (m_alternateDispatcher) { |
| 2027 | m_alternateDispatcher->setOuterHTML(requestId, in_nodeId, in_outerHTML); |
| 2028 | return; |
| 2029 | } |
| 2030 | #endif |
| 2031 | |
| 2032 | ErrorString error; |
| 2033 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2034 | m_agent->setOuterHTML(error, in_nodeId, in_outerHTML); |
| 2035 | |
| 2036 | if (!error.length()) |
| 2037 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2038 | else |
| 2039 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2040 | } |
| 2041 | |
| 2042 | void DOMBackendDispatcher::insertAdjacentHTML(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2043 | { |
| 2044 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2045 | String in_position = m_backendDispatcher->getString(parameters.get(), "position"_s , nullptr); |
| 2046 | String in_html = m_backendDispatcher->getString(parameters.get(), "html"_s , nullptr); |
| 2047 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2048 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.insertAdjacentHTML' can't be processed"_s ); |
| 2049 | return; |
| 2050 | } |
| 2051 | |
| 2052 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2053 | if (m_alternateDispatcher) { |
| 2054 | m_alternateDispatcher->insertAdjacentHTML(requestId, in_nodeId, in_position, in_html); |
| 2055 | return; |
| 2056 | } |
| 2057 | #endif |
| 2058 | |
| 2059 | ErrorString error; |
| 2060 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2061 | m_agent->insertAdjacentHTML(error, in_nodeId, in_position, in_html); |
| 2062 | |
| 2063 | if (!error.length()) |
| 2064 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2065 | else |
| 2066 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2067 | } |
| 2068 | |
| 2069 | void DOMBackendDispatcher::performSearch(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2070 | { |
| 2071 | String in_query = m_backendDispatcher->getString(parameters.get(), "query"_s , nullptr); |
| 2072 | bool opt_in_nodeIds_valueFound = false; |
| 2073 | RefPtr<JSON::Array> opt_in_nodeIds = m_backendDispatcher->getArray(parameters.get(), "nodeIds"_s , &opt_in_nodeIds_valueFound); |
| 2074 | bool opt_in_caseSensitive_valueFound = false; |
| 2075 | bool opt_in_caseSensitive = m_backendDispatcher->getBoolean(parameters.get(), "caseSensitive"_s , &opt_in_caseSensitive_valueFound); |
| 2076 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2077 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.performSearch' can't be processed"_s ); |
| 2078 | return; |
| 2079 | } |
| 2080 | |
| 2081 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2082 | if (m_alternateDispatcher) { |
| 2083 | m_alternateDispatcher->performSearch(requestId, in_query, opt_in_nodeIds_valueFound ? opt_in_nodeIds.get() : nullptr, opt_in_caseSensitive_valueFound ? &opt_in_caseSensitive : nullptr); |
| 2084 | return; |
| 2085 | } |
| 2086 | #endif |
| 2087 | |
| 2088 | ErrorString error; |
| 2089 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2090 | String out_searchId; |
| 2091 | int out_resultCount; |
| 2092 | m_agent->performSearch(error, in_query, opt_in_nodeIds_valueFound ? opt_in_nodeIds.get() : nullptr, opt_in_caseSensitive_valueFound ? &opt_in_caseSensitive : nullptr, &out_searchId, &out_resultCount); |
| 2093 | |
| 2094 | if (!error.length()) { |
| 2095 | result->setString("searchId"_s , out_searchId); |
| 2096 | result->setInteger("resultCount"_s , out_resultCount); |
| 2097 | } |
| 2098 | if (!error.length()) |
| 2099 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2100 | else |
| 2101 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2102 | } |
| 2103 | |
| 2104 | void DOMBackendDispatcher::getSearchResults(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2105 | { |
| 2106 | String in_searchId = m_backendDispatcher->getString(parameters.get(), "searchId"_s , nullptr); |
| 2107 | int in_fromIndex = m_backendDispatcher->getInteger(parameters.get(), "fromIndex"_s , nullptr); |
| 2108 | int in_toIndex = m_backendDispatcher->getInteger(parameters.get(), "toIndex"_s , nullptr); |
| 2109 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2110 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.getSearchResults' can't be processed"_s ); |
| 2111 | return; |
| 2112 | } |
| 2113 | |
| 2114 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2115 | if (m_alternateDispatcher) { |
| 2116 | m_alternateDispatcher->getSearchResults(requestId, in_searchId, in_fromIndex, in_toIndex); |
| 2117 | return; |
| 2118 | } |
| 2119 | #endif |
| 2120 | |
| 2121 | ErrorString error; |
| 2122 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2123 | RefPtr<JSON::ArrayOf<int>> out_nodeIds; |
| 2124 | m_agent->getSearchResults(error, in_searchId, in_fromIndex, in_toIndex, out_nodeIds); |
| 2125 | |
| 2126 | if (!error.length()) |
| 2127 | result->setArray("nodeIds"_s , out_nodeIds); |
| 2128 | |
| 2129 | if (!error.length()) |
| 2130 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2131 | else |
| 2132 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2133 | } |
| 2134 | |
| 2135 | void DOMBackendDispatcher::discardSearchResults(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2136 | { |
| 2137 | String in_searchId = m_backendDispatcher->getString(parameters.get(), "searchId"_s , nullptr); |
| 2138 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2139 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.discardSearchResults' can't be processed"_s ); |
| 2140 | return; |
| 2141 | } |
| 2142 | |
| 2143 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2144 | if (m_alternateDispatcher) { |
| 2145 | m_alternateDispatcher->discardSearchResults(requestId, in_searchId); |
| 2146 | return; |
| 2147 | } |
| 2148 | #endif |
| 2149 | |
| 2150 | ErrorString error; |
| 2151 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2152 | m_agent->discardSearchResults(error, in_searchId); |
| 2153 | |
| 2154 | if (!error.length()) |
| 2155 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2156 | else |
| 2157 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2158 | } |
| 2159 | |
| 2160 | void DOMBackendDispatcher::requestNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2161 | { |
| 2162 | String in_objectId = m_backendDispatcher->getString(parameters.get(), "objectId"_s , nullptr); |
| 2163 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2164 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.requestNode' can't be processed"_s ); |
| 2165 | return; |
| 2166 | } |
| 2167 | |
| 2168 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2169 | if (m_alternateDispatcher) { |
| 2170 | m_alternateDispatcher->requestNode(requestId, in_objectId); |
| 2171 | return; |
| 2172 | } |
| 2173 | #endif |
| 2174 | |
| 2175 | ErrorString error; |
| 2176 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2177 | int out_nodeId; |
| 2178 | m_agent->requestNode(error, in_objectId, &out_nodeId); |
| 2179 | |
| 2180 | if (!error.length()) |
| 2181 | result->setInteger("nodeId"_s , out_nodeId); |
| 2182 | |
| 2183 | if (!error.length()) |
| 2184 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2185 | else |
| 2186 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2187 | } |
| 2188 | |
| 2189 | void DOMBackendDispatcher::setInspectModeEnabled(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2190 | { |
| 2191 | bool in_enabled = m_backendDispatcher->getBoolean(parameters.get(), "enabled"_s , nullptr); |
| 2192 | bool opt_in_highlightConfig_valueFound = false; |
| 2193 | RefPtr<JSON::Object> opt_in_highlightConfig = m_backendDispatcher->getObject(parameters.get(), "highlightConfig"_s , &opt_in_highlightConfig_valueFound); |
| 2194 | bool opt_in_showRulers_valueFound = false; |
| 2195 | bool opt_in_showRulers = m_backendDispatcher->getBoolean(parameters.get(), "showRulers"_s , &opt_in_showRulers_valueFound); |
| 2196 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2197 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setInspectModeEnabled' can't be processed"_s ); |
| 2198 | return; |
| 2199 | } |
| 2200 | |
| 2201 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2202 | if (m_alternateDispatcher) { |
| 2203 | m_alternateDispatcher->setInspectModeEnabled(requestId, in_enabled, opt_in_highlightConfig_valueFound ? opt_in_highlightConfig.get() : nullptr, opt_in_showRulers_valueFound ? &opt_in_showRulers : nullptr); |
| 2204 | return; |
| 2205 | } |
| 2206 | #endif |
| 2207 | |
| 2208 | ErrorString error; |
| 2209 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2210 | m_agent->setInspectModeEnabled(error, in_enabled, opt_in_highlightConfig_valueFound ? opt_in_highlightConfig.get() : nullptr, opt_in_showRulers_valueFound ? &opt_in_showRulers : nullptr); |
| 2211 | |
| 2212 | if (!error.length()) |
| 2213 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2214 | else |
| 2215 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2216 | } |
| 2217 | |
| 2218 | void DOMBackendDispatcher::highlightRect(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2219 | { |
| 2220 | int in_x = m_backendDispatcher->getInteger(parameters.get(), "x"_s , nullptr); |
| 2221 | int in_y = m_backendDispatcher->getInteger(parameters.get(), "y"_s , nullptr); |
| 2222 | int in_width = m_backendDispatcher->getInteger(parameters.get(), "width"_s , nullptr); |
| 2223 | int in_height = m_backendDispatcher->getInteger(parameters.get(), "height"_s , nullptr); |
| 2224 | bool opt_in_color_valueFound = false; |
| 2225 | RefPtr<JSON::Object> opt_in_color = m_backendDispatcher->getObject(parameters.get(), "color"_s , &opt_in_color_valueFound); |
| 2226 | bool opt_in_outlineColor_valueFound = false; |
| 2227 | RefPtr<JSON::Object> opt_in_outlineColor = m_backendDispatcher->getObject(parameters.get(), "outlineColor"_s , &opt_in_outlineColor_valueFound); |
| 2228 | bool opt_in_usePageCoordinates_valueFound = false; |
| 2229 | bool opt_in_usePageCoordinates = m_backendDispatcher->getBoolean(parameters.get(), "usePageCoordinates"_s , &opt_in_usePageCoordinates_valueFound); |
| 2230 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2231 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.highlightRect' can't be processed"_s ); |
| 2232 | return; |
| 2233 | } |
| 2234 | |
| 2235 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2236 | if (m_alternateDispatcher) { |
| 2237 | m_alternateDispatcher->highlightRect(requestId, in_x, in_y, in_width, in_height, opt_in_color_valueFound ? opt_in_color.get() : nullptr, opt_in_outlineColor_valueFound ? opt_in_outlineColor.get() : nullptr, opt_in_usePageCoordinates_valueFound ? &opt_in_usePageCoordinates : nullptr); |
| 2238 | return; |
| 2239 | } |
| 2240 | #endif |
| 2241 | |
| 2242 | ErrorString error; |
| 2243 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2244 | m_agent->highlightRect(error, in_x, in_y, in_width, in_height, opt_in_color_valueFound ? opt_in_color.get() : nullptr, opt_in_outlineColor_valueFound ? opt_in_outlineColor.get() : nullptr, opt_in_usePageCoordinates_valueFound ? &opt_in_usePageCoordinates : nullptr); |
| 2245 | |
| 2246 | if (!error.length()) |
| 2247 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2248 | else |
| 2249 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2250 | } |
| 2251 | |
| 2252 | void DOMBackendDispatcher::highlightQuad(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2253 | { |
| 2254 | RefPtr<JSON::Array> in_quad = m_backendDispatcher->getArray(parameters.get(), "quad"_s , nullptr); |
| 2255 | bool opt_in_color_valueFound = false; |
| 2256 | RefPtr<JSON::Object> opt_in_color = m_backendDispatcher->getObject(parameters.get(), "color"_s , &opt_in_color_valueFound); |
| 2257 | bool opt_in_outlineColor_valueFound = false; |
| 2258 | RefPtr<JSON::Object> opt_in_outlineColor = m_backendDispatcher->getObject(parameters.get(), "outlineColor"_s , &opt_in_outlineColor_valueFound); |
| 2259 | bool opt_in_usePageCoordinates_valueFound = false; |
| 2260 | bool opt_in_usePageCoordinates = m_backendDispatcher->getBoolean(parameters.get(), "usePageCoordinates"_s , &opt_in_usePageCoordinates_valueFound); |
| 2261 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2262 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.highlightQuad' can't be processed"_s ); |
| 2263 | return; |
| 2264 | } |
| 2265 | |
| 2266 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2267 | if (m_alternateDispatcher) { |
| 2268 | m_alternateDispatcher->highlightQuad(requestId, *in_quad, opt_in_color_valueFound ? opt_in_color.get() : nullptr, opt_in_outlineColor_valueFound ? opt_in_outlineColor.get() : nullptr, opt_in_usePageCoordinates_valueFound ? &opt_in_usePageCoordinates : nullptr); |
| 2269 | return; |
| 2270 | } |
| 2271 | #endif |
| 2272 | |
| 2273 | ErrorString error; |
| 2274 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2275 | m_agent->highlightQuad(error, *in_quad, opt_in_color_valueFound ? opt_in_color.get() : nullptr, opt_in_outlineColor_valueFound ? opt_in_outlineColor.get() : nullptr, opt_in_usePageCoordinates_valueFound ? &opt_in_usePageCoordinates : nullptr); |
| 2276 | |
| 2277 | if (!error.length()) |
| 2278 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2279 | else |
| 2280 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2281 | } |
| 2282 | |
| 2283 | void DOMBackendDispatcher::highlightSelector(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2284 | { |
| 2285 | RefPtr<JSON::Object> in_highlightConfig = m_backendDispatcher->getObject(parameters.get(), "highlightConfig"_s , nullptr); |
| 2286 | String in_selectorString = m_backendDispatcher->getString(parameters.get(), "selectorString"_s , nullptr); |
| 2287 | bool opt_in_frameId_valueFound = false; |
| 2288 | String opt_in_frameId = m_backendDispatcher->getString(parameters.get(), "frameId"_s , &opt_in_frameId_valueFound); |
| 2289 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2290 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.highlightSelector' can't be processed"_s ); |
| 2291 | return; |
| 2292 | } |
| 2293 | |
| 2294 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2295 | if (m_alternateDispatcher) { |
| 2296 | m_alternateDispatcher->highlightSelector(requestId, *in_highlightConfig, in_selectorString, opt_in_frameId_valueFound ? &opt_in_frameId : nullptr); |
| 2297 | return; |
| 2298 | } |
| 2299 | #endif |
| 2300 | |
| 2301 | ErrorString error; |
| 2302 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2303 | m_agent->highlightSelector(error, *in_highlightConfig, in_selectorString, opt_in_frameId_valueFound ? &opt_in_frameId : nullptr); |
| 2304 | |
| 2305 | if (!error.length()) |
| 2306 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2307 | else |
| 2308 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2309 | } |
| 2310 | |
| 2311 | void DOMBackendDispatcher::highlightNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2312 | { |
| 2313 | RefPtr<JSON::Object> in_highlightConfig = m_backendDispatcher->getObject(parameters.get(), "highlightConfig"_s , nullptr); |
| 2314 | bool opt_in_nodeId_valueFound = false; |
| 2315 | int opt_in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , &opt_in_nodeId_valueFound); |
| 2316 | bool opt_in_objectId_valueFound = false; |
| 2317 | String opt_in_objectId = m_backendDispatcher->getString(parameters.get(), "objectId"_s , &opt_in_objectId_valueFound); |
| 2318 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2319 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.highlightNode' can't be processed"_s ); |
| 2320 | return; |
| 2321 | } |
| 2322 | |
| 2323 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2324 | if (m_alternateDispatcher) { |
| 2325 | m_alternateDispatcher->highlightNode(requestId, *in_highlightConfig, opt_in_nodeId_valueFound ? &opt_in_nodeId : nullptr, opt_in_objectId_valueFound ? &opt_in_objectId : nullptr); |
| 2326 | return; |
| 2327 | } |
| 2328 | #endif |
| 2329 | |
| 2330 | ErrorString error; |
| 2331 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2332 | m_agent->highlightNode(error, *in_highlightConfig, opt_in_nodeId_valueFound ? &opt_in_nodeId : nullptr, opt_in_objectId_valueFound ? &opt_in_objectId : nullptr); |
| 2333 | |
| 2334 | if (!error.length()) |
| 2335 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2336 | else |
| 2337 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2338 | } |
| 2339 | |
| 2340 | void DOMBackendDispatcher::highlightNodeList(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2341 | { |
| 2342 | RefPtr<JSON::Array> in_nodeIds = m_backendDispatcher->getArray(parameters.get(), "nodeIds"_s , nullptr); |
| 2343 | RefPtr<JSON::Object> in_highlightConfig = m_backendDispatcher->getObject(parameters.get(), "highlightConfig"_s , nullptr); |
| 2344 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2345 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.highlightNodeList' can't be processed"_s ); |
| 2346 | return; |
| 2347 | } |
| 2348 | |
| 2349 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2350 | if (m_alternateDispatcher) { |
| 2351 | m_alternateDispatcher->highlightNodeList(requestId, *in_nodeIds, *in_highlightConfig); |
| 2352 | return; |
| 2353 | } |
| 2354 | #endif |
| 2355 | |
| 2356 | ErrorString error; |
| 2357 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2358 | m_agent->highlightNodeList(error, *in_nodeIds, *in_highlightConfig); |
| 2359 | |
| 2360 | if (!error.length()) |
| 2361 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2362 | else |
| 2363 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2364 | } |
| 2365 | |
| 2366 | void DOMBackendDispatcher::hideHighlight(long requestId, RefPtr<JSON::Object>&&) |
| 2367 | { |
| 2368 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2369 | if (m_alternateDispatcher) { |
| 2370 | m_alternateDispatcher->hideHighlight(requestId); |
| 2371 | return; |
| 2372 | } |
| 2373 | #endif |
| 2374 | |
| 2375 | ErrorString error; |
| 2376 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2377 | m_agent->hideHighlight(error); |
| 2378 | |
| 2379 | if (!error.length()) |
| 2380 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2381 | else |
| 2382 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2383 | } |
| 2384 | |
| 2385 | void DOMBackendDispatcher::highlightFrame(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2386 | { |
| 2387 | String in_frameId = m_backendDispatcher->getString(parameters.get(), "frameId"_s , nullptr); |
| 2388 | bool opt_in_contentColor_valueFound = false; |
| 2389 | RefPtr<JSON::Object> opt_in_contentColor = m_backendDispatcher->getObject(parameters.get(), "contentColor"_s , &opt_in_contentColor_valueFound); |
| 2390 | bool opt_in_contentOutlineColor_valueFound = false; |
| 2391 | RefPtr<JSON::Object> opt_in_contentOutlineColor = m_backendDispatcher->getObject(parameters.get(), "contentOutlineColor"_s , &opt_in_contentOutlineColor_valueFound); |
| 2392 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2393 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.highlightFrame' can't be processed"_s ); |
| 2394 | return; |
| 2395 | } |
| 2396 | |
| 2397 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2398 | if (m_alternateDispatcher) { |
| 2399 | m_alternateDispatcher->highlightFrame(requestId, in_frameId, opt_in_contentColor_valueFound ? opt_in_contentColor.get() : nullptr, opt_in_contentOutlineColor_valueFound ? opt_in_contentOutlineColor.get() : nullptr); |
| 2400 | return; |
| 2401 | } |
| 2402 | #endif |
| 2403 | |
| 2404 | ErrorString error; |
| 2405 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2406 | m_agent->highlightFrame(error, in_frameId, opt_in_contentColor_valueFound ? opt_in_contentColor.get() : nullptr, opt_in_contentOutlineColor_valueFound ? opt_in_contentOutlineColor.get() : nullptr); |
| 2407 | |
| 2408 | if (!error.length()) |
| 2409 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2410 | else |
| 2411 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2412 | } |
| 2413 | |
| 2414 | void DOMBackendDispatcher::pushNodeByPathToFrontend(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2415 | { |
| 2416 | String in_path = m_backendDispatcher->getString(parameters.get(), "path"_s , nullptr); |
| 2417 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2418 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.pushNodeByPathToFrontend' can't be processed"_s ); |
| 2419 | return; |
| 2420 | } |
| 2421 | |
| 2422 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2423 | if (m_alternateDispatcher) { |
| 2424 | m_alternateDispatcher->pushNodeByPathToFrontend(requestId, in_path); |
| 2425 | return; |
| 2426 | } |
| 2427 | #endif |
| 2428 | |
| 2429 | ErrorString error; |
| 2430 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2431 | int out_nodeId; |
| 2432 | m_agent->pushNodeByPathToFrontend(error, in_path, &out_nodeId); |
| 2433 | |
| 2434 | if (!error.length()) |
| 2435 | result->setInteger("nodeId"_s , out_nodeId); |
| 2436 | |
| 2437 | if (!error.length()) |
| 2438 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2439 | else |
| 2440 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2441 | } |
| 2442 | |
| 2443 | void DOMBackendDispatcher::resolveNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2444 | { |
| 2445 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2446 | bool opt_in_objectGroup_valueFound = false; |
| 2447 | String opt_in_objectGroup = m_backendDispatcher->getString(parameters.get(), "objectGroup"_s , &opt_in_objectGroup_valueFound); |
| 2448 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2449 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.resolveNode' can't be processed"_s ); |
| 2450 | return; |
| 2451 | } |
| 2452 | |
| 2453 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2454 | if (m_alternateDispatcher) { |
| 2455 | m_alternateDispatcher->resolveNode(requestId, in_nodeId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr); |
| 2456 | return; |
| 2457 | } |
| 2458 | #endif |
| 2459 | |
| 2460 | ErrorString error; |
| 2461 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2462 | RefPtr<Inspector::Protocol::Runtime::RemoteObject> out_object; |
| 2463 | m_agent->resolveNode(error, in_nodeId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, out_object); |
| 2464 | |
| 2465 | if (!error.length()) |
| 2466 | result->setObject("object"_s , out_object); |
| 2467 | |
| 2468 | if (!error.length()) |
| 2469 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2470 | else |
| 2471 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2472 | } |
| 2473 | |
| 2474 | void DOMBackendDispatcher::getAttributes(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2475 | { |
| 2476 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2477 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2478 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.getAttributes' can't be processed"_s ); |
| 2479 | return; |
| 2480 | } |
| 2481 | |
| 2482 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2483 | if (m_alternateDispatcher) { |
| 2484 | m_alternateDispatcher->getAttributes(requestId, in_nodeId); |
| 2485 | return; |
| 2486 | } |
| 2487 | #endif |
| 2488 | |
| 2489 | ErrorString error; |
| 2490 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2491 | RefPtr<JSON::ArrayOf<String>> out_attributes; |
| 2492 | m_agent->getAttributes(error, in_nodeId, out_attributes); |
| 2493 | |
| 2494 | if (!error.length()) |
| 2495 | result->setArray("attributes"_s , out_attributes); |
| 2496 | |
| 2497 | if (!error.length()) |
| 2498 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2499 | else |
| 2500 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2501 | } |
| 2502 | |
| 2503 | void DOMBackendDispatcher::moveTo(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2504 | { |
| 2505 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2506 | int in_targetNodeId = m_backendDispatcher->getInteger(parameters.get(), "targetNodeId"_s , nullptr); |
| 2507 | bool opt_in_insertBeforeNodeId_valueFound = false; |
| 2508 | int opt_in_insertBeforeNodeId = m_backendDispatcher->getInteger(parameters.get(), "insertBeforeNodeId"_s , &opt_in_insertBeforeNodeId_valueFound); |
| 2509 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2510 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.moveTo' can't be processed"_s ); |
| 2511 | return; |
| 2512 | } |
| 2513 | |
| 2514 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2515 | if (m_alternateDispatcher) { |
| 2516 | m_alternateDispatcher->moveTo(requestId, in_nodeId, in_targetNodeId, opt_in_insertBeforeNodeId_valueFound ? &opt_in_insertBeforeNodeId : nullptr); |
| 2517 | return; |
| 2518 | } |
| 2519 | #endif |
| 2520 | |
| 2521 | ErrorString error; |
| 2522 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2523 | int out_nodeId; |
| 2524 | m_agent->moveTo(error, in_nodeId, in_targetNodeId, opt_in_insertBeforeNodeId_valueFound ? &opt_in_insertBeforeNodeId : nullptr, &out_nodeId); |
| 2525 | |
| 2526 | if (!error.length()) |
| 2527 | result->setInteger("nodeId"_s , out_nodeId); |
| 2528 | |
| 2529 | if (!error.length()) |
| 2530 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2531 | else |
| 2532 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2533 | } |
| 2534 | |
| 2535 | void DOMBackendDispatcher::undo(long requestId, RefPtr<JSON::Object>&&) |
| 2536 | { |
| 2537 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2538 | if (m_alternateDispatcher) { |
| 2539 | m_alternateDispatcher->undo(requestId); |
| 2540 | return; |
| 2541 | } |
| 2542 | #endif |
| 2543 | |
| 2544 | ErrorString error; |
| 2545 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2546 | m_agent->undo(error); |
| 2547 | |
| 2548 | if (!error.length()) |
| 2549 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2550 | else |
| 2551 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2552 | } |
| 2553 | |
| 2554 | void DOMBackendDispatcher::redo(long requestId, RefPtr<JSON::Object>&&) |
| 2555 | { |
| 2556 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2557 | if (m_alternateDispatcher) { |
| 2558 | m_alternateDispatcher->redo(requestId); |
| 2559 | return; |
| 2560 | } |
| 2561 | #endif |
| 2562 | |
| 2563 | ErrorString error; |
| 2564 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2565 | m_agent->redo(error); |
| 2566 | |
| 2567 | if (!error.length()) |
| 2568 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2569 | else |
| 2570 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2571 | } |
| 2572 | |
| 2573 | void DOMBackendDispatcher::markUndoableState(long requestId, RefPtr<JSON::Object>&&) |
| 2574 | { |
| 2575 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2576 | if (m_alternateDispatcher) { |
| 2577 | m_alternateDispatcher->markUndoableState(requestId); |
| 2578 | return; |
| 2579 | } |
| 2580 | #endif |
| 2581 | |
| 2582 | ErrorString error; |
| 2583 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2584 | m_agent->markUndoableState(error); |
| 2585 | |
| 2586 | if (!error.length()) |
| 2587 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2588 | else |
| 2589 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2590 | } |
| 2591 | |
| 2592 | void DOMBackendDispatcher::focus(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2593 | { |
| 2594 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2595 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2596 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.focus' can't be processed"_s ); |
| 2597 | return; |
| 2598 | } |
| 2599 | |
| 2600 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2601 | if (m_alternateDispatcher) { |
| 2602 | m_alternateDispatcher->focus(requestId, in_nodeId); |
| 2603 | return; |
| 2604 | } |
| 2605 | #endif |
| 2606 | |
| 2607 | ErrorString error; |
| 2608 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2609 | m_agent->focus(error, in_nodeId); |
| 2610 | |
| 2611 | if (!error.length()) |
| 2612 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2613 | else |
| 2614 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2615 | } |
| 2616 | |
| 2617 | void DOMBackendDispatcher::setInspectedNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2618 | { |
| 2619 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2620 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2621 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOM.setInspectedNode' can't be processed"_s ); |
| 2622 | return; |
| 2623 | } |
| 2624 | |
| 2625 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2626 | if (m_alternateDispatcher) { |
| 2627 | m_alternateDispatcher->setInspectedNode(requestId, in_nodeId); |
| 2628 | return; |
| 2629 | } |
| 2630 | #endif |
| 2631 | |
| 2632 | ErrorString error; |
| 2633 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2634 | m_agent->setInspectedNode(error, in_nodeId); |
| 2635 | |
| 2636 | if (!error.length()) |
| 2637 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2638 | else |
| 2639 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2640 | } |
| 2641 | |
| 2642 | Ref<DOMDebuggerBackendDispatcher> DOMDebuggerBackendDispatcher::create(BackendDispatcher& backendDispatcher, DOMDebuggerBackendDispatcherHandler* agent) |
| 2643 | { |
| 2644 | return adoptRef(*new DOMDebuggerBackendDispatcher(backendDispatcher, agent)); |
| 2645 | } |
| 2646 | |
| 2647 | DOMDebuggerBackendDispatcher::DOMDebuggerBackendDispatcher(BackendDispatcher& backendDispatcher, DOMDebuggerBackendDispatcherHandler* agent) |
| 2648 | : SupplementalBackendDispatcher(backendDispatcher) |
| 2649 | , m_agent(agent) |
| 2650 | { |
| 2651 | m_backendDispatcher->registerDispatcherForDomain("DOMDebugger"_s , this); |
| 2652 | } |
| 2653 | |
| 2654 | void DOMDebuggerBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 2655 | { |
| 2656 | Ref<DOMDebuggerBackendDispatcher> protect(*this); |
| 2657 | |
| 2658 | RefPtr<JSON::Object> parameters; |
| 2659 | message->getObject("params"_s , parameters); |
| 2660 | |
| 2661 | typedef void (DOMDebuggerBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 2662 | typedef HashMap<String, CallHandler> DispatchMap; |
| 2663 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 2664 | if (dispatchMap.get().isEmpty()) { |
| 2665 | static const struct MethodTable { |
| 2666 | const char* name; |
| 2667 | CallHandler handler; |
| 2668 | } commands[] = { |
| 2669 | { "setDOMBreakpoint" , &DOMDebuggerBackendDispatcher::setDOMBreakpoint }, |
| 2670 | { "removeDOMBreakpoint" , &DOMDebuggerBackendDispatcher::removeDOMBreakpoint }, |
| 2671 | { "setEventBreakpoint" , &DOMDebuggerBackendDispatcher::setEventBreakpoint }, |
| 2672 | { "removeEventBreakpoint" , &DOMDebuggerBackendDispatcher::removeEventBreakpoint }, |
| 2673 | { "setURLBreakpoint" , &DOMDebuggerBackendDispatcher::setURLBreakpoint }, |
| 2674 | { "removeURLBreakpoint" , &DOMDebuggerBackendDispatcher::removeURLBreakpoint }, |
| 2675 | }; |
| 2676 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 2677 | for (size_t i = 0; i < length; ++i) |
| 2678 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 2679 | } |
| 2680 | |
| 2681 | auto findResult = dispatchMap.get().find(method); |
| 2682 | if (findResult == dispatchMap.get().end()) { |
| 2683 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'DOMDebugger." + method + "' was not found" ); |
| 2684 | return; |
| 2685 | } |
| 2686 | |
| 2687 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 2688 | } |
| 2689 | |
| 2690 | void DOMDebuggerBackendDispatcher::setDOMBreakpoint(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2691 | { |
| 2692 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2693 | String in_type = m_backendDispatcher->getString(parameters.get(), "type"_s , nullptr); |
| 2694 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2695 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMDebugger.setDOMBreakpoint' can't be processed"_s ); |
| 2696 | return; |
| 2697 | } |
| 2698 | |
| 2699 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2700 | if (m_alternateDispatcher) { |
| 2701 | m_alternateDispatcher->setDOMBreakpoint(requestId, in_nodeId, in_type); |
| 2702 | return; |
| 2703 | } |
| 2704 | #endif |
| 2705 | |
| 2706 | ErrorString error; |
| 2707 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2708 | m_agent->setDOMBreakpoint(error, in_nodeId, in_type); |
| 2709 | |
| 2710 | if (!error.length()) |
| 2711 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2712 | else |
| 2713 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2714 | } |
| 2715 | |
| 2716 | void DOMDebuggerBackendDispatcher::removeDOMBreakpoint(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2717 | { |
| 2718 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 2719 | String in_type = m_backendDispatcher->getString(parameters.get(), "type"_s , nullptr); |
| 2720 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2721 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMDebugger.removeDOMBreakpoint' can't be processed"_s ); |
| 2722 | return; |
| 2723 | } |
| 2724 | |
| 2725 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2726 | if (m_alternateDispatcher) { |
| 2727 | m_alternateDispatcher->removeDOMBreakpoint(requestId, in_nodeId, in_type); |
| 2728 | return; |
| 2729 | } |
| 2730 | #endif |
| 2731 | |
| 2732 | ErrorString error; |
| 2733 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2734 | m_agent->removeDOMBreakpoint(error, in_nodeId, in_type); |
| 2735 | |
| 2736 | if (!error.length()) |
| 2737 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2738 | else |
| 2739 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2740 | } |
| 2741 | |
| 2742 | void DOMDebuggerBackendDispatcher::setEventBreakpoint(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2743 | { |
| 2744 | String in_breakpointType = m_backendDispatcher->getString(parameters.get(), "breakpointType"_s , nullptr); |
| 2745 | String in_eventName = m_backendDispatcher->getString(parameters.get(), "eventName"_s , nullptr); |
| 2746 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2747 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMDebugger.setEventBreakpoint' can't be processed"_s ); |
| 2748 | return; |
| 2749 | } |
| 2750 | |
| 2751 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2752 | if (m_alternateDispatcher) { |
| 2753 | m_alternateDispatcher->setEventBreakpoint(requestId, in_breakpointType, in_eventName); |
| 2754 | return; |
| 2755 | } |
| 2756 | #endif |
| 2757 | |
| 2758 | ErrorString error; |
| 2759 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2760 | m_agent->setEventBreakpoint(error, in_breakpointType, in_eventName); |
| 2761 | |
| 2762 | if (!error.length()) |
| 2763 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2764 | else |
| 2765 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2766 | } |
| 2767 | |
| 2768 | void DOMDebuggerBackendDispatcher::removeEventBreakpoint(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2769 | { |
| 2770 | String in_breakpointType = m_backendDispatcher->getString(parameters.get(), "breakpointType"_s , nullptr); |
| 2771 | String in_eventName = m_backendDispatcher->getString(parameters.get(), "eventName"_s , nullptr); |
| 2772 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2773 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMDebugger.removeEventBreakpoint' can't be processed"_s ); |
| 2774 | return; |
| 2775 | } |
| 2776 | |
| 2777 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2778 | if (m_alternateDispatcher) { |
| 2779 | m_alternateDispatcher->removeEventBreakpoint(requestId, in_breakpointType, in_eventName); |
| 2780 | return; |
| 2781 | } |
| 2782 | #endif |
| 2783 | |
| 2784 | ErrorString error; |
| 2785 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2786 | m_agent->removeEventBreakpoint(error, in_breakpointType, in_eventName); |
| 2787 | |
| 2788 | if (!error.length()) |
| 2789 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2790 | else |
| 2791 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2792 | } |
| 2793 | |
| 2794 | void DOMDebuggerBackendDispatcher::setURLBreakpoint(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2795 | { |
| 2796 | String in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , nullptr); |
| 2797 | bool opt_in_isRegex_valueFound = false; |
| 2798 | bool opt_in_isRegex = m_backendDispatcher->getBoolean(parameters.get(), "isRegex"_s , &opt_in_isRegex_valueFound); |
| 2799 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2800 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMDebugger.setURLBreakpoint' can't be processed"_s ); |
| 2801 | return; |
| 2802 | } |
| 2803 | |
| 2804 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2805 | if (m_alternateDispatcher) { |
| 2806 | m_alternateDispatcher->setURLBreakpoint(requestId, in_url, opt_in_isRegex_valueFound ? &opt_in_isRegex : nullptr); |
| 2807 | return; |
| 2808 | } |
| 2809 | #endif |
| 2810 | |
| 2811 | ErrorString error; |
| 2812 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2813 | m_agent->setURLBreakpoint(error, in_url, opt_in_isRegex_valueFound ? &opt_in_isRegex : nullptr); |
| 2814 | |
| 2815 | if (!error.length()) |
| 2816 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2817 | else |
| 2818 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2819 | } |
| 2820 | |
| 2821 | void DOMDebuggerBackendDispatcher::removeURLBreakpoint(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2822 | { |
| 2823 | String in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , nullptr); |
| 2824 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2825 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMDebugger.removeURLBreakpoint' can't be processed"_s ); |
| 2826 | return; |
| 2827 | } |
| 2828 | |
| 2829 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2830 | if (m_alternateDispatcher) { |
| 2831 | m_alternateDispatcher->removeURLBreakpoint(requestId, in_url); |
| 2832 | return; |
| 2833 | } |
| 2834 | #endif |
| 2835 | |
| 2836 | ErrorString error; |
| 2837 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2838 | m_agent->removeURLBreakpoint(error, in_url); |
| 2839 | |
| 2840 | if (!error.length()) |
| 2841 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2842 | else |
| 2843 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2844 | } |
| 2845 | |
| 2846 | Ref<DOMStorageBackendDispatcher> DOMStorageBackendDispatcher::create(BackendDispatcher& backendDispatcher, DOMStorageBackendDispatcherHandler* agent) |
| 2847 | { |
| 2848 | return adoptRef(*new DOMStorageBackendDispatcher(backendDispatcher, agent)); |
| 2849 | } |
| 2850 | |
| 2851 | DOMStorageBackendDispatcher::DOMStorageBackendDispatcher(BackendDispatcher& backendDispatcher, DOMStorageBackendDispatcherHandler* agent) |
| 2852 | : SupplementalBackendDispatcher(backendDispatcher) |
| 2853 | , m_agent(agent) |
| 2854 | { |
| 2855 | m_backendDispatcher->registerDispatcherForDomain("DOMStorage"_s , this); |
| 2856 | } |
| 2857 | |
| 2858 | void DOMStorageBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 2859 | { |
| 2860 | Ref<DOMStorageBackendDispatcher> protect(*this); |
| 2861 | |
| 2862 | RefPtr<JSON::Object> parameters; |
| 2863 | message->getObject("params"_s , parameters); |
| 2864 | |
| 2865 | if (method == "enable" ) |
| 2866 | enable(requestId, WTFMove(parameters)); |
| 2867 | else if (method == "disable" ) |
| 2868 | disable(requestId, WTFMove(parameters)); |
| 2869 | else if (method == "getDOMStorageItems" ) |
| 2870 | getDOMStorageItems(requestId, WTFMove(parameters)); |
| 2871 | else if (method == "setDOMStorageItem" ) |
| 2872 | setDOMStorageItem(requestId, WTFMove(parameters)); |
| 2873 | else if (method == "removeDOMStorageItem" ) |
| 2874 | removeDOMStorageItem(requestId, WTFMove(parameters)); |
| 2875 | else |
| 2876 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'DOMStorage." + method + "' was not found" ); |
| 2877 | } |
| 2878 | |
| 2879 | void DOMStorageBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 2880 | { |
| 2881 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2882 | if (m_alternateDispatcher) { |
| 2883 | m_alternateDispatcher->enable(requestId); |
| 2884 | return; |
| 2885 | } |
| 2886 | #endif |
| 2887 | |
| 2888 | ErrorString error; |
| 2889 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2890 | m_agent->enable(error); |
| 2891 | |
| 2892 | if (!error.length()) |
| 2893 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2894 | else |
| 2895 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2896 | } |
| 2897 | |
| 2898 | void DOMStorageBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 2899 | { |
| 2900 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2901 | if (m_alternateDispatcher) { |
| 2902 | m_alternateDispatcher->disable(requestId); |
| 2903 | return; |
| 2904 | } |
| 2905 | #endif |
| 2906 | |
| 2907 | ErrorString error; |
| 2908 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2909 | m_agent->disable(error); |
| 2910 | |
| 2911 | if (!error.length()) |
| 2912 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2913 | else |
| 2914 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2915 | } |
| 2916 | |
| 2917 | void DOMStorageBackendDispatcher::getDOMStorageItems(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2918 | { |
| 2919 | RefPtr<JSON::Object> in_storageId = m_backendDispatcher->getObject(parameters.get(), "storageId"_s , nullptr); |
| 2920 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2921 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMStorage.getDOMStorageItems' can't be processed"_s ); |
| 2922 | return; |
| 2923 | } |
| 2924 | |
| 2925 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2926 | if (m_alternateDispatcher) { |
| 2927 | m_alternateDispatcher->getDOMStorageItems(requestId, *in_storageId); |
| 2928 | return; |
| 2929 | } |
| 2930 | #endif |
| 2931 | |
| 2932 | ErrorString error; |
| 2933 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2934 | RefPtr<JSON::ArrayOf<Inspector::Protocol::DOMStorage::Item>> out_entries; |
| 2935 | m_agent->getDOMStorageItems(error, *in_storageId, out_entries); |
| 2936 | |
| 2937 | if (!error.length()) |
| 2938 | result->setArray("entries"_s , out_entries); |
| 2939 | |
| 2940 | if (!error.length()) |
| 2941 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2942 | else |
| 2943 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2944 | } |
| 2945 | |
| 2946 | void DOMStorageBackendDispatcher::setDOMStorageItem(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2947 | { |
| 2948 | RefPtr<JSON::Object> in_storageId = m_backendDispatcher->getObject(parameters.get(), "storageId"_s , nullptr); |
| 2949 | String in_key = m_backendDispatcher->getString(parameters.get(), "key"_s , nullptr); |
| 2950 | String in_value = m_backendDispatcher->getString(parameters.get(), "value"_s , nullptr); |
| 2951 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2952 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMStorage.setDOMStorageItem' can't be processed"_s ); |
| 2953 | return; |
| 2954 | } |
| 2955 | |
| 2956 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2957 | if (m_alternateDispatcher) { |
| 2958 | m_alternateDispatcher->setDOMStorageItem(requestId, *in_storageId, in_key, in_value); |
| 2959 | return; |
| 2960 | } |
| 2961 | #endif |
| 2962 | |
| 2963 | ErrorString error; |
| 2964 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2965 | m_agent->setDOMStorageItem(error, *in_storageId, in_key, in_value); |
| 2966 | |
| 2967 | if (!error.length()) |
| 2968 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2969 | else |
| 2970 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2971 | } |
| 2972 | |
| 2973 | void DOMStorageBackendDispatcher::removeDOMStorageItem(long requestId, RefPtr<JSON::Object>&& parameters) |
| 2974 | { |
| 2975 | RefPtr<JSON::Object> in_storageId = m_backendDispatcher->getObject(parameters.get(), "storageId"_s , nullptr); |
| 2976 | String in_key = m_backendDispatcher->getString(parameters.get(), "key"_s , nullptr); |
| 2977 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 2978 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'DOMStorage.removeDOMStorageItem' can't be processed"_s ); |
| 2979 | return; |
| 2980 | } |
| 2981 | |
| 2982 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 2983 | if (m_alternateDispatcher) { |
| 2984 | m_alternateDispatcher->removeDOMStorageItem(requestId, *in_storageId, in_key); |
| 2985 | return; |
| 2986 | } |
| 2987 | #endif |
| 2988 | |
| 2989 | ErrorString error; |
| 2990 | Ref<JSON::Object> result = JSON::Object::create(); |
| 2991 | m_agent->removeDOMStorageItem(error, *in_storageId, in_key); |
| 2992 | |
| 2993 | if (!error.length()) |
| 2994 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 2995 | else |
| 2996 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 2997 | } |
| 2998 | |
| 2999 | Ref<DatabaseBackendDispatcher> DatabaseBackendDispatcher::create(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) |
| 3000 | { |
| 3001 | return adoptRef(*new DatabaseBackendDispatcher(backendDispatcher, agent)); |
| 3002 | } |
| 3003 | |
| 3004 | DatabaseBackendDispatcher::DatabaseBackendDispatcher(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) |
| 3005 | : SupplementalBackendDispatcher(backendDispatcher) |
| 3006 | , m_agent(agent) |
| 3007 | { |
| 3008 | m_backendDispatcher->registerDispatcherForDomain("Database"_s , this); |
| 3009 | } |
| 3010 | |
| 3011 | void DatabaseBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 3012 | { |
| 3013 | Ref<DatabaseBackendDispatcher> protect(*this); |
| 3014 | |
| 3015 | RefPtr<JSON::Object> parameters; |
| 3016 | message->getObject("params"_s , parameters); |
| 3017 | |
| 3018 | if (method == "enable" ) |
| 3019 | enable(requestId, WTFMove(parameters)); |
| 3020 | else if (method == "disable" ) |
| 3021 | disable(requestId, WTFMove(parameters)); |
| 3022 | else if (method == "getDatabaseTableNames" ) |
| 3023 | getDatabaseTableNames(requestId, WTFMove(parameters)); |
| 3024 | else if (method == "executeSQL" ) |
| 3025 | executeSQL(requestId, WTFMove(parameters)); |
| 3026 | else |
| 3027 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Database." + method + "' was not found" ); |
| 3028 | } |
| 3029 | |
| 3030 | void DatabaseBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 3031 | { |
| 3032 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3033 | if (m_alternateDispatcher) { |
| 3034 | m_alternateDispatcher->enable(requestId); |
| 3035 | return; |
| 3036 | } |
| 3037 | #endif |
| 3038 | |
| 3039 | ErrorString error; |
| 3040 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3041 | m_agent->enable(error); |
| 3042 | |
| 3043 | if (!error.length()) |
| 3044 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3045 | else |
| 3046 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3047 | } |
| 3048 | |
| 3049 | void DatabaseBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 3050 | { |
| 3051 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3052 | if (m_alternateDispatcher) { |
| 3053 | m_alternateDispatcher->disable(requestId); |
| 3054 | return; |
| 3055 | } |
| 3056 | #endif |
| 3057 | |
| 3058 | ErrorString error; |
| 3059 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3060 | m_agent->disable(error); |
| 3061 | |
| 3062 | if (!error.length()) |
| 3063 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3064 | else |
| 3065 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3066 | } |
| 3067 | |
| 3068 | void DatabaseBackendDispatcher::getDatabaseTableNames(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3069 | { |
| 3070 | String in_databaseId = m_backendDispatcher->getString(parameters.get(), "databaseId"_s , nullptr); |
| 3071 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3072 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Database.getDatabaseTableNames' can't be processed"_s ); |
| 3073 | return; |
| 3074 | } |
| 3075 | |
| 3076 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3077 | if (m_alternateDispatcher) { |
| 3078 | m_alternateDispatcher->getDatabaseTableNames(requestId, in_databaseId); |
| 3079 | return; |
| 3080 | } |
| 3081 | #endif |
| 3082 | |
| 3083 | ErrorString error; |
| 3084 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3085 | RefPtr<JSON::ArrayOf<String>> out_tableNames; |
| 3086 | m_agent->getDatabaseTableNames(error, in_databaseId, out_tableNames); |
| 3087 | |
| 3088 | if (!error.length()) |
| 3089 | result->setArray("tableNames"_s , out_tableNames); |
| 3090 | |
| 3091 | if (!error.length()) |
| 3092 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3093 | else |
| 3094 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3095 | } |
| 3096 | |
| 3097 | DatabaseBackendDispatcherHandler::ExecuteSQLCallback::ExecuteSQLCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
| 3098 | |
| 3099 | void DatabaseBackendDispatcherHandler::ExecuteSQLCallback::sendSuccess(RefPtr<JSON::ArrayOf<String>>&& columnNames, RefPtr<JSON::ArrayOf<JSON::Value>>&& values, RefPtr<Inspector::Protocol::Database::Error>&& sqlError) |
| 3100 | { |
| 3101 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
| 3102 | if (columnNames) |
| 3103 | jsonMessage->setArray("columnNames"_s , columnNames); |
| 3104 | if (values) |
| 3105 | jsonMessage->setArray("values"_s , values); |
| 3106 | if (sqlError) |
| 3107 | jsonMessage->setObject("sqlError"_s , sqlError); |
| 3108 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
| 3109 | } |
| 3110 | |
| 3111 | void DatabaseBackendDispatcher::executeSQL(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3112 | { |
| 3113 | String in_databaseId = m_backendDispatcher->getString(parameters.get(), "databaseId"_s , nullptr); |
| 3114 | String in_query = m_backendDispatcher->getString(parameters.get(), "query"_s , nullptr); |
| 3115 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3116 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Database.executeSQL' can't be processed"_s ); |
| 3117 | return; |
| 3118 | } |
| 3119 | |
| 3120 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3121 | if (m_alternateDispatcher) { |
| 3122 | m_alternateDispatcher->executeSQL(requestId, in_databaseId, in_query); |
| 3123 | return; |
| 3124 | } |
| 3125 | #endif |
| 3126 | |
| 3127 | Ref<DatabaseBackendDispatcherHandler::ExecuteSQLCallback> callback = adoptRef(*new DatabaseBackendDispatcherHandler::ExecuteSQLCallback(m_backendDispatcher.copyRef(), requestId)); |
| 3128 | m_agent->executeSQL(in_databaseId, in_query, callback.copyRef()); |
| 3129 | |
| 3130 | } |
| 3131 | |
| 3132 | Ref<DebuggerBackendDispatcher> DebuggerBackendDispatcher::create(BackendDispatcher& backendDispatcher, DebuggerBackendDispatcherHandler* agent) |
| 3133 | { |
| 3134 | return adoptRef(*new DebuggerBackendDispatcher(backendDispatcher, agent)); |
| 3135 | } |
| 3136 | |
| 3137 | DebuggerBackendDispatcher::DebuggerBackendDispatcher(BackendDispatcher& backendDispatcher, DebuggerBackendDispatcherHandler* agent) |
| 3138 | : SupplementalBackendDispatcher(backendDispatcher) |
| 3139 | , m_agent(agent) |
| 3140 | { |
| 3141 | m_backendDispatcher->registerDispatcherForDomain("Debugger"_s , this); |
| 3142 | } |
| 3143 | |
| 3144 | void DebuggerBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 3145 | { |
| 3146 | Ref<DebuggerBackendDispatcher> protect(*this); |
| 3147 | |
| 3148 | RefPtr<JSON::Object> parameters; |
| 3149 | message->getObject("params"_s , parameters); |
| 3150 | |
| 3151 | typedef void (DebuggerBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 3152 | typedef HashMap<String, CallHandler> DispatchMap; |
| 3153 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 3154 | if (dispatchMap.get().isEmpty()) { |
| 3155 | static const struct MethodTable { |
| 3156 | const char* name; |
| 3157 | CallHandler handler; |
| 3158 | } commands[] = { |
| 3159 | { "enable" , &DebuggerBackendDispatcher::enable }, |
| 3160 | { "disable" , &DebuggerBackendDispatcher::disable }, |
| 3161 | { "setAsyncStackTraceDepth" , &DebuggerBackendDispatcher::setAsyncStackTraceDepth }, |
| 3162 | { "setBreakpointsActive" , &DebuggerBackendDispatcher::setBreakpointsActive }, |
| 3163 | { "setBreakpointByUrl" , &DebuggerBackendDispatcher::setBreakpointByUrl }, |
| 3164 | { "setBreakpoint" , &DebuggerBackendDispatcher::setBreakpoint }, |
| 3165 | { "removeBreakpoint" , &DebuggerBackendDispatcher::removeBreakpoint }, |
| 3166 | { "continueUntilNextRunLoop" , &DebuggerBackendDispatcher::continueUntilNextRunLoop }, |
| 3167 | { "continueToLocation" , &DebuggerBackendDispatcher::continueToLocation }, |
| 3168 | { "stepOver" , &DebuggerBackendDispatcher::stepOver }, |
| 3169 | { "stepInto" , &DebuggerBackendDispatcher::stepInto }, |
| 3170 | { "stepOut" , &DebuggerBackendDispatcher::stepOut }, |
| 3171 | { "pause" , &DebuggerBackendDispatcher::pause }, |
| 3172 | { "resume" , &DebuggerBackendDispatcher::resume }, |
| 3173 | { "searchInContent" , &DebuggerBackendDispatcher::searchInContent }, |
| 3174 | { "getScriptSource" , &DebuggerBackendDispatcher::getScriptSource }, |
| 3175 | { "getFunctionDetails" , &DebuggerBackendDispatcher::getFunctionDetails }, |
| 3176 | { "setPauseOnExceptions" , &DebuggerBackendDispatcher::setPauseOnExceptions }, |
| 3177 | { "setPauseOnAssertions" , &DebuggerBackendDispatcher::setPauseOnAssertions }, |
| 3178 | { "setPauseForInternalScripts" , &DebuggerBackendDispatcher::setPauseForInternalScripts }, |
| 3179 | { "evaluateOnCallFrame" , &DebuggerBackendDispatcher::evaluateOnCallFrame }, |
| 3180 | }; |
| 3181 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 3182 | for (size_t i = 0; i < length; ++i) |
| 3183 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 3184 | } |
| 3185 | |
| 3186 | auto findResult = dispatchMap.get().find(method); |
| 3187 | if (findResult == dispatchMap.get().end()) { |
| 3188 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Debugger." + method + "' was not found" ); |
| 3189 | return; |
| 3190 | } |
| 3191 | |
| 3192 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 3193 | } |
| 3194 | |
| 3195 | void DebuggerBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 3196 | { |
| 3197 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3198 | if (m_alternateDispatcher) { |
| 3199 | m_alternateDispatcher->enable(requestId); |
| 3200 | return; |
| 3201 | } |
| 3202 | #endif |
| 3203 | |
| 3204 | ErrorString error; |
| 3205 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3206 | m_agent->enable(error); |
| 3207 | |
| 3208 | if (!error.length()) |
| 3209 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3210 | else |
| 3211 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3212 | } |
| 3213 | |
| 3214 | void DebuggerBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 3215 | { |
| 3216 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3217 | if (m_alternateDispatcher) { |
| 3218 | m_alternateDispatcher->disable(requestId); |
| 3219 | return; |
| 3220 | } |
| 3221 | #endif |
| 3222 | |
| 3223 | ErrorString error; |
| 3224 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3225 | m_agent->disable(error); |
| 3226 | |
| 3227 | if (!error.length()) |
| 3228 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3229 | else |
| 3230 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3231 | } |
| 3232 | |
| 3233 | void DebuggerBackendDispatcher::setAsyncStackTraceDepth(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3234 | { |
| 3235 | int in_depth = m_backendDispatcher->getInteger(parameters.get(), "depth"_s , nullptr); |
| 3236 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3237 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.setAsyncStackTraceDepth' can't be processed"_s ); |
| 3238 | return; |
| 3239 | } |
| 3240 | |
| 3241 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3242 | if (m_alternateDispatcher) { |
| 3243 | m_alternateDispatcher->setAsyncStackTraceDepth(requestId, in_depth); |
| 3244 | return; |
| 3245 | } |
| 3246 | #endif |
| 3247 | |
| 3248 | ErrorString error; |
| 3249 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3250 | m_agent->setAsyncStackTraceDepth(error, in_depth); |
| 3251 | |
| 3252 | if (!error.length()) |
| 3253 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3254 | else |
| 3255 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3256 | } |
| 3257 | |
| 3258 | void DebuggerBackendDispatcher::setBreakpointsActive(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3259 | { |
| 3260 | bool in_active = m_backendDispatcher->getBoolean(parameters.get(), "active"_s , nullptr); |
| 3261 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3262 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.setBreakpointsActive' can't be processed"_s ); |
| 3263 | return; |
| 3264 | } |
| 3265 | |
| 3266 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3267 | if (m_alternateDispatcher) { |
| 3268 | m_alternateDispatcher->setBreakpointsActive(requestId, in_active); |
| 3269 | return; |
| 3270 | } |
| 3271 | #endif |
| 3272 | |
| 3273 | ErrorString error; |
| 3274 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3275 | m_agent->setBreakpointsActive(error, in_active); |
| 3276 | |
| 3277 | if (!error.length()) |
| 3278 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3279 | else |
| 3280 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3281 | } |
| 3282 | |
| 3283 | void DebuggerBackendDispatcher::setBreakpointByUrl(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3284 | { |
| 3285 | int in_lineNumber = m_backendDispatcher->getInteger(parameters.get(), "lineNumber"_s , nullptr); |
| 3286 | bool opt_in_url_valueFound = false; |
| 3287 | String opt_in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , &opt_in_url_valueFound); |
| 3288 | bool opt_in_urlRegex_valueFound = false; |
| 3289 | String opt_in_urlRegex = m_backendDispatcher->getString(parameters.get(), "urlRegex"_s , &opt_in_urlRegex_valueFound); |
| 3290 | bool opt_in_columnNumber_valueFound = false; |
| 3291 | int opt_in_columnNumber = m_backendDispatcher->getInteger(parameters.get(), "columnNumber"_s , &opt_in_columnNumber_valueFound); |
| 3292 | bool opt_in_options_valueFound = false; |
| 3293 | RefPtr<JSON::Object> opt_in_options = m_backendDispatcher->getObject(parameters.get(), "options"_s , &opt_in_options_valueFound); |
| 3294 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3295 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.setBreakpointByUrl' can't be processed"_s ); |
| 3296 | return; |
| 3297 | } |
| 3298 | |
| 3299 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3300 | if (m_alternateDispatcher) { |
| 3301 | m_alternateDispatcher->setBreakpointByUrl(requestId, in_lineNumber, opt_in_url_valueFound ? &opt_in_url : nullptr, opt_in_urlRegex_valueFound ? &opt_in_urlRegex : nullptr, opt_in_columnNumber_valueFound ? &opt_in_columnNumber : nullptr, opt_in_options_valueFound ? opt_in_options.get() : nullptr); |
| 3302 | return; |
| 3303 | } |
| 3304 | #endif |
| 3305 | |
| 3306 | ErrorString error; |
| 3307 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3308 | String out_breakpointId; |
| 3309 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Debugger::Location>> out_locations; |
| 3310 | m_agent->setBreakpointByUrl(error, in_lineNumber, opt_in_url_valueFound ? &opt_in_url : nullptr, opt_in_urlRegex_valueFound ? &opt_in_urlRegex : nullptr, opt_in_columnNumber_valueFound ? &opt_in_columnNumber : nullptr, opt_in_options_valueFound ? opt_in_options.get() : nullptr, &out_breakpointId, out_locations); |
| 3311 | |
| 3312 | if (!error.length()) { |
| 3313 | result->setString("breakpointId"_s , out_breakpointId); |
| 3314 | result->setArray("locations"_s , out_locations); |
| 3315 | } |
| 3316 | if (!error.length()) |
| 3317 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3318 | else |
| 3319 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3320 | } |
| 3321 | |
| 3322 | void DebuggerBackendDispatcher::setBreakpoint(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3323 | { |
| 3324 | RefPtr<JSON::Object> in_location = m_backendDispatcher->getObject(parameters.get(), "location"_s , nullptr); |
| 3325 | bool opt_in_options_valueFound = false; |
| 3326 | RefPtr<JSON::Object> opt_in_options = m_backendDispatcher->getObject(parameters.get(), "options"_s , &opt_in_options_valueFound); |
| 3327 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3328 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.setBreakpoint' can't be processed"_s ); |
| 3329 | return; |
| 3330 | } |
| 3331 | |
| 3332 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3333 | if (m_alternateDispatcher) { |
| 3334 | m_alternateDispatcher->setBreakpoint(requestId, *in_location, opt_in_options_valueFound ? opt_in_options.get() : nullptr); |
| 3335 | return; |
| 3336 | } |
| 3337 | #endif |
| 3338 | |
| 3339 | ErrorString error; |
| 3340 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3341 | String out_breakpointId; |
| 3342 | RefPtr<Inspector::Protocol::Debugger::Location> out_actualLocation; |
| 3343 | m_agent->setBreakpoint(error, *in_location, opt_in_options_valueFound ? opt_in_options.get() : nullptr, &out_breakpointId, out_actualLocation); |
| 3344 | |
| 3345 | if (!error.length()) { |
| 3346 | result->setString("breakpointId"_s , out_breakpointId); |
| 3347 | result->setObject("actualLocation"_s , out_actualLocation); |
| 3348 | } |
| 3349 | if (!error.length()) |
| 3350 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3351 | else |
| 3352 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3353 | } |
| 3354 | |
| 3355 | void DebuggerBackendDispatcher::removeBreakpoint(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3356 | { |
| 3357 | String in_breakpointId = m_backendDispatcher->getString(parameters.get(), "breakpointId"_s , nullptr); |
| 3358 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3359 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.removeBreakpoint' can't be processed"_s ); |
| 3360 | return; |
| 3361 | } |
| 3362 | |
| 3363 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3364 | if (m_alternateDispatcher) { |
| 3365 | m_alternateDispatcher->removeBreakpoint(requestId, in_breakpointId); |
| 3366 | return; |
| 3367 | } |
| 3368 | #endif |
| 3369 | |
| 3370 | ErrorString error; |
| 3371 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3372 | m_agent->removeBreakpoint(error, in_breakpointId); |
| 3373 | |
| 3374 | if (!error.length()) |
| 3375 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3376 | else |
| 3377 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3378 | } |
| 3379 | |
| 3380 | void DebuggerBackendDispatcher::continueUntilNextRunLoop(long requestId, RefPtr<JSON::Object>&&) |
| 3381 | { |
| 3382 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3383 | if (m_alternateDispatcher) { |
| 3384 | m_alternateDispatcher->continueUntilNextRunLoop(requestId); |
| 3385 | return; |
| 3386 | } |
| 3387 | #endif |
| 3388 | |
| 3389 | ErrorString error; |
| 3390 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3391 | m_agent->continueUntilNextRunLoop(error); |
| 3392 | |
| 3393 | if (!error.length()) |
| 3394 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3395 | else |
| 3396 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3397 | } |
| 3398 | |
| 3399 | void DebuggerBackendDispatcher::continueToLocation(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3400 | { |
| 3401 | RefPtr<JSON::Object> in_location = m_backendDispatcher->getObject(parameters.get(), "location"_s , nullptr); |
| 3402 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3403 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.continueToLocation' can't be processed"_s ); |
| 3404 | return; |
| 3405 | } |
| 3406 | |
| 3407 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3408 | if (m_alternateDispatcher) { |
| 3409 | m_alternateDispatcher->continueToLocation(requestId, *in_location); |
| 3410 | return; |
| 3411 | } |
| 3412 | #endif |
| 3413 | |
| 3414 | ErrorString error; |
| 3415 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3416 | m_agent->continueToLocation(error, *in_location); |
| 3417 | |
| 3418 | if (!error.length()) |
| 3419 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3420 | else |
| 3421 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3422 | } |
| 3423 | |
| 3424 | void DebuggerBackendDispatcher::stepOver(long requestId, RefPtr<JSON::Object>&&) |
| 3425 | { |
| 3426 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3427 | if (m_alternateDispatcher) { |
| 3428 | m_alternateDispatcher->stepOver(requestId); |
| 3429 | return; |
| 3430 | } |
| 3431 | #endif |
| 3432 | |
| 3433 | ErrorString error; |
| 3434 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3435 | m_agent->stepOver(error); |
| 3436 | |
| 3437 | if (!error.length()) |
| 3438 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3439 | else |
| 3440 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3441 | } |
| 3442 | |
| 3443 | void DebuggerBackendDispatcher::stepInto(long requestId, RefPtr<JSON::Object>&&) |
| 3444 | { |
| 3445 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3446 | if (m_alternateDispatcher) { |
| 3447 | m_alternateDispatcher->stepInto(requestId); |
| 3448 | return; |
| 3449 | } |
| 3450 | #endif |
| 3451 | |
| 3452 | ErrorString error; |
| 3453 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3454 | m_agent->stepInto(error); |
| 3455 | |
| 3456 | if (!error.length()) |
| 3457 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3458 | else |
| 3459 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3460 | } |
| 3461 | |
| 3462 | void DebuggerBackendDispatcher::stepOut(long requestId, RefPtr<JSON::Object>&&) |
| 3463 | { |
| 3464 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3465 | if (m_alternateDispatcher) { |
| 3466 | m_alternateDispatcher->stepOut(requestId); |
| 3467 | return; |
| 3468 | } |
| 3469 | #endif |
| 3470 | |
| 3471 | ErrorString error; |
| 3472 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3473 | m_agent->stepOut(error); |
| 3474 | |
| 3475 | if (!error.length()) |
| 3476 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3477 | else |
| 3478 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3479 | } |
| 3480 | |
| 3481 | void DebuggerBackendDispatcher::pause(long requestId, RefPtr<JSON::Object>&&) |
| 3482 | { |
| 3483 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3484 | if (m_alternateDispatcher) { |
| 3485 | m_alternateDispatcher->pause(requestId); |
| 3486 | return; |
| 3487 | } |
| 3488 | #endif |
| 3489 | |
| 3490 | ErrorString error; |
| 3491 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3492 | m_agent->pause(error); |
| 3493 | |
| 3494 | if (!error.length()) |
| 3495 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3496 | else |
| 3497 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3498 | } |
| 3499 | |
| 3500 | void DebuggerBackendDispatcher::resume(long requestId, RefPtr<JSON::Object>&&) |
| 3501 | { |
| 3502 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3503 | if (m_alternateDispatcher) { |
| 3504 | m_alternateDispatcher->resume(requestId); |
| 3505 | return; |
| 3506 | } |
| 3507 | #endif |
| 3508 | |
| 3509 | ErrorString error; |
| 3510 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3511 | m_agent->resume(error); |
| 3512 | |
| 3513 | if (!error.length()) |
| 3514 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3515 | else |
| 3516 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3517 | } |
| 3518 | |
| 3519 | void DebuggerBackendDispatcher::searchInContent(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3520 | { |
| 3521 | String in_scriptId = m_backendDispatcher->getString(parameters.get(), "scriptId"_s , nullptr); |
| 3522 | String in_query = m_backendDispatcher->getString(parameters.get(), "query"_s , nullptr); |
| 3523 | bool opt_in_caseSensitive_valueFound = false; |
| 3524 | bool opt_in_caseSensitive = m_backendDispatcher->getBoolean(parameters.get(), "caseSensitive"_s , &opt_in_caseSensitive_valueFound); |
| 3525 | bool opt_in_isRegex_valueFound = false; |
| 3526 | bool opt_in_isRegex = m_backendDispatcher->getBoolean(parameters.get(), "isRegex"_s , &opt_in_isRegex_valueFound); |
| 3527 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3528 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.searchInContent' can't be processed"_s ); |
| 3529 | return; |
| 3530 | } |
| 3531 | |
| 3532 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3533 | if (m_alternateDispatcher) { |
| 3534 | m_alternateDispatcher->searchInContent(requestId, in_scriptId, in_query, opt_in_caseSensitive_valueFound ? &opt_in_caseSensitive : nullptr, opt_in_isRegex_valueFound ? &opt_in_isRegex : nullptr); |
| 3535 | return; |
| 3536 | } |
| 3537 | #endif |
| 3538 | |
| 3539 | ErrorString error; |
| 3540 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3541 | RefPtr<JSON::ArrayOf<Inspector::Protocol::GenericTypes::SearchMatch>> out_result; |
| 3542 | m_agent->searchInContent(error, in_scriptId, in_query, opt_in_caseSensitive_valueFound ? &opt_in_caseSensitive : nullptr, opt_in_isRegex_valueFound ? &opt_in_isRegex : nullptr, out_result); |
| 3543 | |
| 3544 | if (!error.length()) |
| 3545 | result->setArray("result"_s , out_result); |
| 3546 | |
| 3547 | if (!error.length()) |
| 3548 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3549 | else |
| 3550 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3551 | } |
| 3552 | |
| 3553 | void DebuggerBackendDispatcher::getScriptSource(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3554 | { |
| 3555 | String in_scriptId = m_backendDispatcher->getString(parameters.get(), "scriptId"_s , nullptr); |
| 3556 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3557 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.getScriptSource' can't be processed"_s ); |
| 3558 | return; |
| 3559 | } |
| 3560 | |
| 3561 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3562 | if (m_alternateDispatcher) { |
| 3563 | m_alternateDispatcher->getScriptSource(requestId, in_scriptId); |
| 3564 | return; |
| 3565 | } |
| 3566 | #endif |
| 3567 | |
| 3568 | ErrorString error; |
| 3569 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3570 | String out_scriptSource; |
| 3571 | m_agent->getScriptSource(error, in_scriptId, &out_scriptSource); |
| 3572 | |
| 3573 | if (!error.length()) |
| 3574 | result->setString("scriptSource"_s , out_scriptSource); |
| 3575 | |
| 3576 | if (!error.length()) |
| 3577 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3578 | else |
| 3579 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3580 | } |
| 3581 | |
| 3582 | void DebuggerBackendDispatcher::getFunctionDetails(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3583 | { |
| 3584 | String in_functionId = m_backendDispatcher->getString(parameters.get(), "functionId"_s , nullptr); |
| 3585 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3586 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.getFunctionDetails' can't be processed"_s ); |
| 3587 | return; |
| 3588 | } |
| 3589 | |
| 3590 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3591 | if (m_alternateDispatcher) { |
| 3592 | m_alternateDispatcher->getFunctionDetails(requestId, in_functionId); |
| 3593 | return; |
| 3594 | } |
| 3595 | #endif |
| 3596 | |
| 3597 | ErrorString error; |
| 3598 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3599 | RefPtr<Inspector::Protocol::Debugger::FunctionDetails> out_details; |
| 3600 | m_agent->getFunctionDetails(error, in_functionId, out_details); |
| 3601 | |
| 3602 | if (!error.length()) |
| 3603 | result->setObject("details"_s , out_details); |
| 3604 | |
| 3605 | if (!error.length()) |
| 3606 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3607 | else |
| 3608 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3609 | } |
| 3610 | |
| 3611 | void DebuggerBackendDispatcher::setPauseOnExceptions(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3612 | { |
| 3613 | String in_state = m_backendDispatcher->getString(parameters.get(), "state"_s , nullptr); |
| 3614 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3615 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.setPauseOnExceptions' can't be processed"_s ); |
| 3616 | return; |
| 3617 | } |
| 3618 | |
| 3619 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3620 | if (m_alternateDispatcher) { |
| 3621 | m_alternateDispatcher->setPauseOnExceptions(requestId, in_state); |
| 3622 | return; |
| 3623 | } |
| 3624 | #endif |
| 3625 | |
| 3626 | ErrorString error; |
| 3627 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3628 | m_agent->setPauseOnExceptions(error, in_state); |
| 3629 | |
| 3630 | if (!error.length()) |
| 3631 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3632 | else |
| 3633 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3634 | } |
| 3635 | |
| 3636 | void DebuggerBackendDispatcher::setPauseOnAssertions(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3637 | { |
| 3638 | bool in_enabled = m_backendDispatcher->getBoolean(parameters.get(), "enabled"_s , nullptr); |
| 3639 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3640 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.setPauseOnAssertions' can't be processed"_s ); |
| 3641 | return; |
| 3642 | } |
| 3643 | |
| 3644 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3645 | if (m_alternateDispatcher) { |
| 3646 | m_alternateDispatcher->setPauseOnAssertions(requestId, in_enabled); |
| 3647 | return; |
| 3648 | } |
| 3649 | #endif |
| 3650 | |
| 3651 | ErrorString error; |
| 3652 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3653 | m_agent->setPauseOnAssertions(error, in_enabled); |
| 3654 | |
| 3655 | if (!error.length()) |
| 3656 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3657 | else |
| 3658 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3659 | } |
| 3660 | |
| 3661 | void DebuggerBackendDispatcher::setPauseForInternalScripts(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3662 | { |
| 3663 | bool in_shouldPause = m_backendDispatcher->getBoolean(parameters.get(), "shouldPause"_s , nullptr); |
| 3664 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3665 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.setPauseForInternalScripts' can't be processed"_s ); |
| 3666 | return; |
| 3667 | } |
| 3668 | |
| 3669 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3670 | if (m_alternateDispatcher) { |
| 3671 | m_alternateDispatcher->setPauseForInternalScripts(requestId, in_shouldPause); |
| 3672 | return; |
| 3673 | } |
| 3674 | #endif |
| 3675 | |
| 3676 | ErrorString error; |
| 3677 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3678 | m_agent->setPauseForInternalScripts(error, in_shouldPause); |
| 3679 | |
| 3680 | if (!error.length()) |
| 3681 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3682 | else |
| 3683 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3684 | } |
| 3685 | |
| 3686 | void DebuggerBackendDispatcher::evaluateOnCallFrame(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3687 | { |
| 3688 | String in_callFrameId = m_backendDispatcher->getString(parameters.get(), "callFrameId"_s , nullptr); |
| 3689 | String in_expression = m_backendDispatcher->getString(parameters.get(), "expression"_s , nullptr); |
| 3690 | bool opt_in_objectGroup_valueFound = false; |
| 3691 | String opt_in_objectGroup = m_backendDispatcher->getString(parameters.get(), "objectGroup"_s , &opt_in_objectGroup_valueFound); |
| 3692 | bool opt_in_includeCommandLineAPI_valueFound = false; |
| 3693 | bool opt_in_includeCommandLineAPI = m_backendDispatcher->getBoolean(parameters.get(), "includeCommandLineAPI"_s , &opt_in_includeCommandLineAPI_valueFound); |
| 3694 | bool opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound = false; |
| 3695 | bool opt_in_doNotPauseOnExceptionsAndMuteConsole = m_backendDispatcher->getBoolean(parameters.get(), "doNotPauseOnExceptionsAndMuteConsole"_s , &opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound); |
| 3696 | bool opt_in_returnByValue_valueFound = false; |
| 3697 | bool opt_in_returnByValue = m_backendDispatcher->getBoolean(parameters.get(), "returnByValue"_s , &opt_in_returnByValue_valueFound); |
| 3698 | bool opt_in_generatePreview_valueFound = false; |
| 3699 | bool opt_in_generatePreview = m_backendDispatcher->getBoolean(parameters.get(), "generatePreview"_s , &opt_in_generatePreview_valueFound); |
| 3700 | bool opt_in_saveResult_valueFound = false; |
| 3701 | bool opt_in_saveResult = m_backendDispatcher->getBoolean(parameters.get(), "saveResult"_s , &opt_in_saveResult_valueFound); |
| 3702 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3703 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Debugger.evaluateOnCallFrame' can't be processed"_s ); |
| 3704 | return; |
| 3705 | } |
| 3706 | |
| 3707 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3708 | if (m_alternateDispatcher) { |
| 3709 | m_alternateDispatcher->evaluateOnCallFrame(requestId, in_callFrameId, in_expression, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, opt_in_includeCommandLineAPI_valueFound ? &opt_in_includeCommandLineAPI : nullptr, opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound ? &opt_in_doNotPauseOnExceptionsAndMuteConsole : nullptr, opt_in_returnByValue_valueFound ? &opt_in_returnByValue : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, opt_in_saveResult_valueFound ? &opt_in_saveResult : nullptr); |
| 3710 | return; |
| 3711 | } |
| 3712 | #endif |
| 3713 | |
| 3714 | ErrorString error; |
| 3715 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3716 | RefPtr<Inspector::Protocol::Runtime::RemoteObject> out_result; |
| 3717 | Optional<bool> out_wasThrown; |
| 3718 | Optional<int> out_savedResultIndex; |
| 3719 | m_agent->evaluateOnCallFrame(error, in_callFrameId, in_expression, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, opt_in_includeCommandLineAPI_valueFound ? &opt_in_includeCommandLineAPI : nullptr, opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound ? &opt_in_doNotPauseOnExceptionsAndMuteConsole : nullptr, opt_in_returnByValue_valueFound ? &opt_in_returnByValue : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, opt_in_saveResult_valueFound ? &opt_in_saveResult : nullptr, out_result, out_wasThrown, out_savedResultIndex); |
| 3720 | |
| 3721 | if (!error.length()) { |
| 3722 | result->setObject("result"_s , out_result); |
| 3723 | if (out_wasThrown.hasValue()) |
| 3724 | result->setBoolean("wasThrown"_s , *out_wasThrown); |
| 3725 | if (out_savedResultIndex.hasValue()) |
| 3726 | result->setInteger("savedResultIndex"_s , *out_savedResultIndex); |
| 3727 | } |
| 3728 | if (!error.length()) |
| 3729 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3730 | else |
| 3731 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3732 | } |
| 3733 | |
| 3734 | Ref<HeapBackendDispatcher> HeapBackendDispatcher::create(BackendDispatcher& backendDispatcher, HeapBackendDispatcherHandler* agent) |
| 3735 | { |
| 3736 | return adoptRef(*new HeapBackendDispatcher(backendDispatcher, agent)); |
| 3737 | } |
| 3738 | |
| 3739 | HeapBackendDispatcher::HeapBackendDispatcher(BackendDispatcher& backendDispatcher, HeapBackendDispatcherHandler* agent) |
| 3740 | : SupplementalBackendDispatcher(backendDispatcher) |
| 3741 | , m_agent(agent) |
| 3742 | { |
| 3743 | m_backendDispatcher->registerDispatcherForDomain("Heap"_s , this); |
| 3744 | } |
| 3745 | |
| 3746 | void HeapBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 3747 | { |
| 3748 | Ref<HeapBackendDispatcher> protect(*this); |
| 3749 | |
| 3750 | RefPtr<JSON::Object> parameters; |
| 3751 | message->getObject("params"_s , parameters); |
| 3752 | |
| 3753 | typedef void (HeapBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 3754 | typedef HashMap<String, CallHandler> DispatchMap; |
| 3755 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 3756 | if (dispatchMap.get().isEmpty()) { |
| 3757 | static const struct MethodTable { |
| 3758 | const char* name; |
| 3759 | CallHandler handler; |
| 3760 | } commands[] = { |
| 3761 | { "enable" , &HeapBackendDispatcher::enable }, |
| 3762 | { "disable" , &HeapBackendDispatcher::disable }, |
| 3763 | { "gc" , &HeapBackendDispatcher::gc }, |
| 3764 | { "snapshot" , &HeapBackendDispatcher::snapshot }, |
| 3765 | { "startTracking" , &HeapBackendDispatcher::startTracking }, |
| 3766 | { "stopTracking" , &HeapBackendDispatcher::stopTracking }, |
| 3767 | { "getPreview" , &HeapBackendDispatcher::getPreview }, |
| 3768 | { "getRemoteObject" , &HeapBackendDispatcher::getRemoteObject }, |
| 3769 | }; |
| 3770 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 3771 | for (size_t i = 0; i < length; ++i) |
| 3772 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 3773 | } |
| 3774 | |
| 3775 | auto findResult = dispatchMap.get().find(method); |
| 3776 | if (findResult == dispatchMap.get().end()) { |
| 3777 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Heap." + method + "' was not found" ); |
| 3778 | return; |
| 3779 | } |
| 3780 | |
| 3781 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 3782 | } |
| 3783 | |
| 3784 | void HeapBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 3785 | { |
| 3786 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3787 | if (m_alternateDispatcher) { |
| 3788 | m_alternateDispatcher->enable(requestId); |
| 3789 | return; |
| 3790 | } |
| 3791 | #endif |
| 3792 | |
| 3793 | ErrorString error; |
| 3794 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3795 | m_agent->enable(error); |
| 3796 | |
| 3797 | if (!error.length()) |
| 3798 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3799 | else |
| 3800 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3801 | } |
| 3802 | |
| 3803 | void HeapBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 3804 | { |
| 3805 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3806 | if (m_alternateDispatcher) { |
| 3807 | m_alternateDispatcher->disable(requestId); |
| 3808 | return; |
| 3809 | } |
| 3810 | #endif |
| 3811 | |
| 3812 | ErrorString error; |
| 3813 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3814 | m_agent->disable(error); |
| 3815 | |
| 3816 | if (!error.length()) |
| 3817 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3818 | else |
| 3819 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3820 | } |
| 3821 | |
| 3822 | void HeapBackendDispatcher::gc(long requestId, RefPtr<JSON::Object>&&) |
| 3823 | { |
| 3824 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3825 | if (m_alternateDispatcher) { |
| 3826 | m_alternateDispatcher->gc(requestId); |
| 3827 | return; |
| 3828 | } |
| 3829 | #endif |
| 3830 | |
| 3831 | ErrorString error; |
| 3832 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3833 | m_agent->gc(error); |
| 3834 | |
| 3835 | if (!error.length()) |
| 3836 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3837 | else |
| 3838 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3839 | } |
| 3840 | |
| 3841 | void HeapBackendDispatcher::snapshot(long requestId, RefPtr<JSON::Object>&&) |
| 3842 | { |
| 3843 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3844 | if (m_alternateDispatcher) { |
| 3845 | m_alternateDispatcher->snapshot(requestId); |
| 3846 | return; |
| 3847 | } |
| 3848 | #endif |
| 3849 | |
| 3850 | ErrorString error; |
| 3851 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3852 | double out_timestamp; |
| 3853 | String out_snapshotData; |
| 3854 | m_agent->snapshot(error, &out_timestamp, &out_snapshotData); |
| 3855 | |
| 3856 | if (!error.length()) { |
| 3857 | result->setDouble("timestamp"_s , out_timestamp); |
| 3858 | result->setString("snapshotData"_s , out_snapshotData); |
| 3859 | } |
| 3860 | if (!error.length()) |
| 3861 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3862 | else |
| 3863 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3864 | } |
| 3865 | |
| 3866 | void HeapBackendDispatcher::startTracking(long requestId, RefPtr<JSON::Object>&&) |
| 3867 | { |
| 3868 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3869 | if (m_alternateDispatcher) { |
| 3870 | m_alternateDispatcher->startTracking(requestId); |
| 3871 | return; |
| 3872 | } |
| 3873 | #endif |
| 3874 | |
| 3875 | ErrorString error; |
| 3876 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3877 | m_agent->startTracking(error); |
| 3878 | |
| 3879 | if (!error.length()) |
| 3880 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3881 | else |
| 3882 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3883 | } |
| 3884 | |
| 3885 | void HeapBackendDispatcher::stopTracking(long requestId, RefPtr<JSON::Object>&&) |
| 3886 | { |
| 3887 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3888 | if (m_alternateDispatcher) { |
| 3889 | m_alternateDispatcher->stopTracking(requestId); |
| 3890 | return; |
| 3891 | } |
| 3892 | #endif |
| 3893 | |
| 3894 | ErrorString error; |
| 3895 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3896 | m_agent->stopTracking(error); |
| 3897 | |
| 3898 | if (!error.length()) |
| 3899 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3900 | else |
| 3901 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3902 | } |
| 3903 | |
| 3904 | void HeapBackendDispatcher::getPreview(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3905 | { |
| 3906 | int in_heapObjectId = m_backendDispatcher->getInteger(parameters.get(), "heapObjectId"_s , nullptr); |
| 3907 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3908 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Heap.getPreview' can't be processed"_s ); |
| 3909 | return; |
| 3910 | } |
| 3911 | |
| 3912 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3913 | if (m_alternateDispatcher) { |
| 3914 | m_alternateDispatcher->getPreview(requestId, in_heapObjectId); |
| 3915 | return; |
| 3916 | } |
| 3917 | #endif |
| 3918 | |
| 3919 | ErrorString error; |
| 3920 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3921 | Optional<String> out_string; |
| 3922 | RefPtr<Inspector::Protocol::Debugger::FunctionDetails> out_functionDetails; |
| 3923 | RefPtr<Inspector::Protocol::Runtime::ObjectPreview> out_preview; |
| 3924 | m_agent->getPreview(error, in_heapObjectId, out_string, out_functionDetails, out_preview); |
| 3925 | |
| 3926 | if (!error.length()) { |
| 3927 | if (out_string.hasValue()) |
| 3928 | result->setString("string"_s , *out_string); |
| 3929 | if (out_functionDetails) |
| 3930 | result->setObject("functionDetails"_s , out_functionDetails); |
| 3931 | if (out_preview) |
| 3932 | result->setObject("preview"_s , out_preview); |
| 3933 | } |
| 3934 | if (!error.length()) |
| 3935 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3936 | else |
| 3937 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3938 | } |
| 3939 | |
| 3940 | void HeapBackendDispatcher::getRemoteObject(long requestId, RefPtr<JSON::Object>&& parameters) |
| 3941 | { |
| 3942 | int in_heapObjectId = m_backendDispatcher->getInteger(parameters.get(), "heapObjectId"_s , nullptr); |
| 3943 | bool opt_in_objectGroup_valueFound = false; |
| 3944 | String opt_in_objectGroup = m_backendDispatcher->getString(parameters.get(), "objectGroup"_s , &opt_in_objectGroup_valueFound); |
| 3945 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 3946 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Heap.getRemoteObject' can't be processed"_s ); |
| 3947 | return; |
| 3948 | } |
| 3949 | |
| 3950 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 3951 | if (m_alternateDispatcher) { |
| 3952 | m_alternateDispatcher->getRemoteObject(requestId, in_heapObjectId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr); |
| 3953 | return; |
| 3954 | } |
| 3955 | #endif |
| 3956 | |
| 3957 | ErrorString error; |
| 3958 | Ref<JSON::Object> result = JSON::Object::create(); |
| 3959 | RefPtr<Inspector::Protocol::Runtime::RemoteObject> out_result; |
| 3960 | m_agent->getRemoteObject(error, in_heapObjectId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, out_result); |
| 3961 | |
| 3962 | if (!error.length()) |
| 3963 | result->setObject("result"_s , out_result); |
| 3964 | |
| 3965 | if (!error.length()) |
| 3966 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 3967 | else |
| 3968 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 3969 | } |
| 3970 | |
| 3971 | #if ENABLE(INDEXED_DATABASE) |
| 3972 | Ref<IndexedDBBackendDispatcher> IndexedDBBackendDispatcher::create(BackendDispatcher& backendDispatcher, IndexedDBBackendDispatcherHandler* agent) |
| 3973 | { |
| 3974 | return adoptRef(*new IndexedDBBackendDispatcher(backendDispatcher, agent)); |
| 3975 | } |
| 3976 | |
| 3977 | IndexedDBBackendDispatcher::IndexedDBBackendDispatcher(BackendDispatcher& backendDispatcher, IndexedDBBackendDispatcherHandler* agent) |
| 3978 | : SupplementalBackendDispatcher(backendDispatcher) |
| 3979 | , m_agent(agent) |
| 3980 | { |
| 3981 | m_backendDispatcher->registerDispatcherForDomain("IndexedDB"_s , this); |
| 3982 | } |
| 3983 | |
| 3984 | void IndexedDBBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 3985 | { |
| 3986 | Ref<IndexedDBBackendDispatcher> protect(*this); |
| 3987 | |
| 3988 | RefPtr<JSON::Object> parameters; |
| 3989 | message->getObject("params"_s , parameters); |
| 3990 | |
| 3991 | typedef void (IndexedDBBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 3992 | typedef HashMap<String, CallHandler> DispatchMap; |
| 3993 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 3994 | if (dispatchMap.get().isEmpty()) { |
| 3995 | static const struct MethodTable { |
| 3996 | const char* name; |
| 3997 | CallHandler handler; |
| 3998 | } commands[] = { |
| 3999 | { "enable" , &IndexedDBBackendDispatcher::enable }, |
| 4000 | { "disable" , &IndexedDBBackendDispatcher::disable }, |
| 4001 | { "requestDatabaseNames" , &IndexedDBBackendDispatcher::requestDatabaseNames }, |
| 4002 | { "requestDatabase" , &IndexedDBBackendDispatcher::requestDatabase }, |
| 4003 | { "requestData" , &IndexedDBBackendDispatcher::requestData }, |
| 4004 | { "clearObjectStore" , &IndexedDBBackendDispatcher::clearObjectStore }, |
| 4005 | }; |
| 4006 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 4007 | for (size_t i = 0; i < length; ++i) |
| 4008 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 4009 | } |
| 4010 | |
| 4011 | auto findResult = dispatchMap.get().find(method); |
| 4012 | if (findResult == dispatchMap.get().end()) { |
| 4013 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'IndexedDB." + method + "' was not found" ); |
| 4014 | return; |
| 4015 | } |
| 4016 | |
| 4017 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 4018 | } |
| 4019 | |
| 4020 | void IndexedDBBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 4021 | { |
| 4022 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4023 | if (m_alternateDispatcher) { |
| 4024 | m_alternateDispatcher->enable(requestId); |
| 4025 | return; |
| 4026 | } |
| 4027 | #endif |
| 4028 | |
| 4029 | ErrorString error; |
| 4030 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4031 | m_agent->enable(error); |
| 4032 | |
| 4033 | if (!error.length()) |
| 4034 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4035 | else |
| 4036 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4037 | } |
| 4038 | |
| 4039 | void IndexedDBBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 4040 | { |
| 4041 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4042 | if (m_alternateDispatcher) { |
| 4043 | m_alternateDispatcher->disable(requestId); |
| 4044 | return; |
| 4045 | } |
| 4046 | #endif |
| 4047 | |
| 4048 | ErrorString error; |
| 4049 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4050 | m_agent->disable(error); |
| 4051 | |
| 4052 | if (!error.length()) |
| 4053 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4054 | else |
| 4055 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4056 | } |
| 4057 | |
| 4058 | IndexedDBBackendDispatcherHandler::RequestDatabaseNamesCallback::RequestDatabaseNamesCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
| 4059 | |
| 4060 | void IndexedDBBackendDispatcherHandler::RequestDatabaseNamesCallback::sendSuccess(RefPtr<JSON::ArrayOf<String>>&& databaseNames) |
| 4061 | { |
| 4062 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
| 4063 | jsonMessage->setArray("databaseNames"_s , databaseNames); |
| 4064 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
| 4065 | } |
| 4066 | |
| 4067 | void IndexedDBBackendDispatcher::requestDatabaseNames(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4068 | { |
| 4069 | String in_securityOrigin = m_backendDispatcher->getString(parameters.get(), "securityOrigin"_s , nullptr); |
| 4070 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4071 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'IndexedDB.requestDatabaseNames' can't be processed"_s ); |
| 4072 | return; |
| 4073 | } |
| 4074 | |
| 4075 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4076 | if (m_alternateDispatcher) { |
| 4077 | m_alternateDispatcher->requestDatabaseNames(requestId, in_securityOrigin); |
| 4078 | return; |
| 4079 | } |
| 4080 | #endif |
| 4081 | |
| 4082 | Ref<IndexedDBBackendDispatcherHandler::RequestDatabaseNamesCallback> callback = adoptRef(*new IndexedDBBackendDispatcherHandler::RequestDatabaseNamesCallback(m_backendDispatcher.copyRef(), requestId)); |
| 4083 | m_agent->requestDatabaseNames(in_securityOrigin, callback.copyRef()); |
| 4084 | |
| 4085 | } |
| 4086 | |
| 4087 | IndexedDBBackendDispatcherHandler::RequestDatabaseCallback::RequestDatabaseCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
| 4088 | |
| 4089 | void IndexedDBBackendDispatcherHandler::RequestDatabaseCallback::sendSuccess(RefPtr<Inspector::Protocol::IndexedDB::DatabaseWithObjectStores>&& databaseWithObjectStores) |
| 4090 | { |
| 4091 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
| 4092 | jsonMessage->setObject("databaseWithObjectStores"_s , databaseWithObjectStores); |
| 4093 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
| 4094 | } |
| 4095 | |
| 4096 | void IndexedDBBackendDispatcher::requestDatabase(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4097 | { |
| 4098 | String in_securityOrigin = m_backendDispatcher->getString(parameters.get(), "securityOrigin"_s , nullptr); |
| 4099 | String in_databaseName = m_backendDispatcher->getString(parameters.get(), "databaseName"_s , nullptr); |
| 4100 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4101 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'IndexedDB.requestDatabase' can't be processed"_s ); |
| 4102 | return; |
| 4103 | } |
| 4104 | |
| 4105 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4106 | if (m_alternateDispatcher) { |
| 4107 | m_alternateDispatcher->requestDatabase(requestId, in_securityOrigin, in_databaseName); |
| 4108 | return; |
| 4109 | } |
| 4110 | #endif |
| 4111 | |
| 4112 | Ref<IndexedDBBackendDispatcherHandler::RequestDatabaseCallback> callback = adoptRef(*new IndexedDBBackendDispatcherHandler::RequestDatabaseCallback(m_backendDispatcher.copyRef(), requestId)); |
| 4113 | m_agent->requestDatabase(in_securityOrigin, in_databaseName, callback.copyRef()); |
| 4114 | |
| 4115 | } |
| 4116 | |
| 4117 | IndexedDBBackendDispatcherHandler::RequestDataCallback::RequestDataCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
| 4118 | |
| 4119 | void IndexedDBBackendDispatcherHandler::RequestDataCallback::sendSuccess(RefPtr<JSON::ArrayOf<Inspector::Protocol::IndexedDB::DataEntry>>&& objectStoreDataEntries, bool hasMore) |
| 4120 | { |
| 4121 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
| 4122 | jsonMessage->setArray("objectStoreDataEntries"_s , objectStoreDataEntries); |
| 4123 | jsonMessage->setBoolean("hasMore"_s , hasMore); |
| 4124 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
| 4125 | } |
| 4126 | |
| 4127 | void IndexedDBBackendDispatcher::requestData(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4128 | { |
| 4129 | String in_securityOrigin = m_backendDispatcher->getString(parameters.get(), "securityOrigin"_s , nullptr); |
| 4130 | String in_databaseName = m_backendDispatcher->getString(parameters.get(), "databaseName"_s , nullptr); |
| 4131 | String in_objectStoreName = m_backendDispatcher->getString(parameters.get(), "objectStoreName"_s , nullptr); |
| 4132 | String in_indexName = m_backendDispatcher->getString(parameters.get(), "indexName"_s , nullptr); |
| 4133 | int in_skipCount = m_backendDispatcher->getInteger(parameters.get(), "skipCount"_s , nullptr); |
| 4134 | int in_pageSize = m_backendDispatcher->getInteger(parameters.get(), "pageSize"_s , nullptr); |
| 4135 | bool opt_in_keyRange_valueFound = false; |
| 4136 | RefPtr<JSON::Object> opt_in_keyRange = m_backendDispatcher->getObject(parameters.get(), "keyRange"_s , &opt_in_keyRange_valueFound); |
| 4137 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4138 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'IndexedDB.requestData' can't be processed"_s ); |
| 4139 | return; |
| 4140 | } |
| 4141 | |
| 4142 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4143 | if (m_alternateDispatcher) { |
| 4144 | m_alternateDispatcher->requestData(requestId, in_securityOrigin, in_databaseName, in_objectStoreName, in_indexName, in_skipCount, in_pageSize, opt_in_keyRange_valueFound ? opt_in_keyRange.get() : nullptr); |
| 4145 | return; |
| 4146 | } |
| 4147 | #endif |
| 4148 | |
| 4149 | Ref<IndexedDBBackendDispatcherHandler::RequestDataCallback> callback = adoptRef(*new IndexedDBBackendDispatcherHandler::RequestDataCallback(m_backendDispatcher.copyRef(), requestId)); |
| 4150 | m_agent->requestData(in_securityOrigin, in_databaseName, in_objectStoreName, in_indexName, in_skipCount, in_pageSize, opt_in_keyRange_valueFound ? opt_in_keyRange.get() : nullptr, callback.copyRef()); |
| 4151 | |
| 4152 | } |
| 4153 | |
| 4154 | IndexedDBBackendDispatcherHandler::ClearObjectStoreCallback::ClearObjectStoreCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
| 4155 | |
| 4156 | void IndexedDBBackendDispatcherHandler::ClearObjectStoreCallback::sendSuccess() |
| 4157 | { |
| 4158 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
| 4159 | |
| 4160 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
| 4161 | } |
| 4162 | |
| 4163 | void IndexedDBBackendDispatcher::clearObjectStore(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4164 | { |
| 4165 | String in_securityOrigin = m_backendDispatcher->getString(parameters.get(), "securityOrigin"_s , nullptr); |
| 4166 | String in_databaseName = m_backendDispatcher->getString(parameters.get(), "databaseName"_s , nullptr); |
| 4167 | String in_objectStoreName = m_backendDispatcher->getString(parameters.get(), "objectStoreName"_s , nullptr); |
| 4168 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4169 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'IndexedDB.clearObjectStore' can't be processed"_s ); |
| 4170 | return; |
| 4171 | } |
| 4172 | |
| 4173 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4174 | if (m_alternateDispatcher) { |
| 4175 | m_alternateDispatcher->clearObjectStore(requestId, in_securityOrigin, in_databaseName, in_objectStoreName); |
| 4176 | return; |
| 4177 | } |
| 4178 | #endif |
| 4179 | |
| 4180 | Ref<IndexedDBBackendDispatcherHandler::ClearObjectStoreCallback> callback = adoptRef(*new IndexedDBBackendDispatcherHandler::ClearObjectStoreCallback(m_backendDispatcher.copyRef(), requestId)); |
| 4181 | m_agent->clearObjectStore(in_securityOrigin, in_databaseName, in_objectStoreName, callback.copyRef()); |
| 4182 | |
| 4183 | } |
| 4184 | #endif // ENABLE(INDEXED_DATABASE) |
| 4185 | |
| 4186 | Ref<InspectorBackendDispatcher> InspectorBackendDispatcher::create(BackendDispatcher& backendDispatcher, InspectorBackendDispatcherHandler* agent) |
| 4187 | { |
| 4188 | return adoptRef(*new InspectorBackendDispatcher(backendDispatcher, agent)); |
| 4189 | } |
| 4190 | |
| 4191 | InspectorBackendDispatcher::InspectorBackendDispatcher(BackendDispatcher& backendDispatcher, InspectorBackendDispatcherHandler* agent) |
| 4192 | : SupplementalBackendDispatcher(backendDispatcher) |
| 4193 | , m_agent(agent) |
| 4194 | { |
| 4195 | m_backendDispatcher->registerDispatcherForDomain("Inspector"_s , this); |
| 4196 | } |
| 4197 | |
| 4198 | void InspectorBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 4199 | { |
| 4200 | Ref<InspectorBackendDispatcher> protect(*this); |
| 4201 | |
| 4202 | RefPtr<JSON::Object> parameters; |
| 4203 | message->getObject("params"_s , parameters); |
| 4204 | |
| 4205 | if (method == "enable" ) |
| 4206 | enable(requestId, WTFMove(parameters)); |
| 4207 | else if (method == "disable" ) |
| 4208 | disable(requestId, WTFMove(parameters)); |
| 4209 | else if (method == "initialized" ) |
| 4210 | initialized(requestId, WTFMove(parameters)); |
| 4211 | else |
| 4212 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Inspector." + method + "' was not found" ); |
| 4213 | } |
| 4214 | |
| 4215 | void InspectorBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 4216 | { |
| 4217 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4218 | if (m_alternateDispatcher) { |
| 4219 | m_alternateDispatcher->enable(requestId); |
| 4220 | return; |
| 4221 | } |
| 4222 | #endif |
| 4223 | |
| 4224 | ErrorString error; |
| 4225 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4226 | m_agent->enable(error); |
| 4227 | |
| 4228 | if (!error.length()) |
| 4229 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4230 | else |
| 4231 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4232 | } |
| 4233 | |
| 4234 | void InspectorBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 4235 | { |
| 4236 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4237 | if (m_alternateDispatcher) { |
| 4238 | m_alternateDispatcher->disable(requestId); |
| 4239 | return; |
| 4240 | } |
| 4241 | #endif |
| 4242 | |
| 4243 | ErrorString error; |
| 4244 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4245 | m_agent->disable(error); |
| 4246 | |
| 4247 | if (!error.length()) |
| 4248 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4249 | else |
| 4250 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4251 | } |
| 4252 | |
| 4253 | void InspectorBackendDispatcher::initialized(long requestId, RefPtr<JSON::Object>&&) |
| 4254 | { |
| 4255 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4256 | if (m_alternateDispatcher) { |
| 4257 | m_alternateDispatcher->initialized(requestId); |
| 4258 | return; |
| 4259 | } |
| 4260 | #endif |
| 4261 | |
| 4262 | ErrorString error; |
| 4263 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4264 | m_agent->initialized(error); |
| 4265 | |
| 4266 | if (!error.length()) |
| 4267 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4268 | else |
| 4269 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4270 | } |
| 4271 | |
| 4272 | Ref<LayerTreeBackendDispatcher> LayerTreeBackendDispatcher::create(BackendDispatcher& backendDispatcher, LayerTreeBackendDispatcherHandler* agent) |
| 4273 | { |
| 4274 | return adoptRef(*new LayerTreeBackendDispatcher(backendDispatcher, agent)); |
| 4275 | } |
| 4276 | |
| 4277 | LayerTreeBackendDispatcher::LayerTreeBackendDispatcher(BackendDispatcher& backendDispatcher, LayerTreeBackendDispatcherHandler* agent) |
| 4278 | : SupplementalBackendDispatcher(backendDispatcher) |
| 4279 | , m_agent(agent) |
| 4280 | { |
| 4281 | m_backendDispatcher->registerDispatcherForDomain("LayerTree"_s , this); |
| 4282 | } |
| 4283 | |
| 4284 | void LayerTreeBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 4285 | { |
| 4286 | Ref<LayerTreeBackendDispatcher> protect(*this); |
| 4287 | |
| 4288 | RefPtr<JSON::Object> parameters; |
| 4289 | message->getObject("params"_s , parameters); |
| 4290 | |
| 4291 | if (method == "enable" ) |
| 4292 | enable(requestId, WTFMove(parameters)); |
| 4293 | else if (method == "disable" ) |
| 4294 | disable(requestId, WTFMove(parameters)); |
| 4295 | else if (method == "layersForNode" ) |
| 4296 | layersForNode(requestId, WTFMove(parameters)); |
| 4297 | else if (method == "reasonsForCompositingLayer" ) |
| 4298 | reasonsForCompositingLayer(requestId, WTFMove(parameters)); |
| 4299 | else |
| 4300 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'LayerTree." + method + "' was not found" ); |
| 4301 | } |
| 4302 | |
| 4303 | void LayerTreeBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 4304 | { |
| 4305 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4306 | if (m_alternateDispatcher) { |
| 4307 | m_alternateDispatcher->enable(requestId); |
| 4308 | return; |
| 4309 | } |
| 4310 | #endif |
| 4311 | |
| 4312 | ErrorString error; |
| 4313 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4314 | m_agent->enable(error); |
| 4315 | |
| 4316 | if (!error.length()) |
| 4317 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4318 | else |
| 4319 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4320 | } |
| 4321 | |
| 4322 | void LayerTreeBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 4323 | { |
| 4324 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4325 | if (m_alternateDispatcher) { |
| 4326 | m_alternateDispatcher->disable(requestId); |
| 4327 | return; |
| 4328 | } |
| 4329 | #endif |
| 4330 | |
| 4331 | ErrorString error; |
| 4332 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4333 | m_agent->disable(error); |
| 4334 | |
| 4335 | if (!error.length()) |
| 4336 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4337 | else |
| 4338 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4339 | } |
| 4340 | |
| 4341 | void LayerTreeBackendDispatcher::layersForNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4342 | { |
| 4343 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 4344 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4345 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'LayerTree.layersForNode' can't be processed"_s ); |
| 4346 | return; |
| 4347 | } |
| 4348 | |
| 4349 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4350 | if (m_alternateDispatcher) { |
| 4351 | m_alternateDispatcher->layersForNode(requestId, in_nodeId); |
| 4352 | return; |
| 4353 | } |
| 4354 | #endif |
| 4355 | |
| 4356 | ErrorString error; |
| 4357 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4358 | RefPtr<JSON::ArrayOf<Inspector::Protocol::LayerTree::Layer>> out_layers; |
| 4359 | m_agent->layersForNode(error, in_nodeId, out_layers); |
| 4360 | |
| 4361 | if (!error.length()) |
| 4362 | result->setArray("layers"_s , out_layers); |
| 4363 | |
| 4364 | if (!error.length()) |
| 4365 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4366 | else |
| 4367 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4368 | } |
| 4369 | |
| 4370 | void LayerTreeBackendDispatcher::reasonsForCompositingLayer(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4371 | { |
| 4372 | String in_layerId = m_backendDispatcher->getString(parameters.get(), "layerId"_s , nullptr); |
| 4373 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4374 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'LayerTree.reasonsForCompositingLayer' can't be processed"_s ); |
| 4375 | return; |
| 4376 | } |
| 4377 | |
| 4378 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4379 | if (m_alternateDispatcher) { |
| 4380 | m_alternateDispatcher->reasonsForCompositingLayer(requestId, in_layerId); |
| 4381 | return; |
| 4382 | } |
| 4383 | #endif |
| 4384 | |
| 4385 | ErrorString error; |
| 4386 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4387 | RefPtr<Inspector::Protocol::LayerTree::CompositingReasons> out_compositingReasons; |
| 4388 | m_agent->reasonsForCompositingLayer(error, in_layerId, out_compositingReasons); |
| 4389 | |
| 4390 | if (!error.length()) |
| 4391 | result->setObject("compositingReasons"_s , out_compositingReasons); |
| 4392 | |
| 4393 | if (!error.length()) |
| 4394 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4395 | else |
| 4396 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4397 | } |
| 4398 | |
| 4399 | #if ENABLE(RESOURCE_USAGE) |
| 4400 | Ref<MemoryBackendDispatcher> MemoryBackendDispatcher::create(BackendDispatcher& backendDispatcher, MemoryBackendDispatcherHandler* agent) |
| 4401 | { |
| 4402 | return adoptRef(*new MemoryBackendDispatcher(backendDispatcher, agent)); |
| 4403 | } |
| 4404 | |
| 4405 | MemoryBackendDispatcher::MemoryBackendDispatcher(BackendDispatcher& backendDispatcher, MemoryBackendDispatcherHandler* agent) |
| 4406 | : SupplementalBackendDispatcher(backendDispatcher) |
| 4407 | , m_agent(agent) |
| 4408 | { |
| 4409 | m_backendDispatcher->registerDispatcherForDomain("Memory"_s , this); |
| 4410 | } |
| 4411 | |
| 4412 | void MemoryBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 4413 | { |
| 4414 | Ref<MemoryBackendDispatcher> protect(*this); |
| 4415 | |
| 4416 | RefPtr<JSON::Object> parameters; |
| 4417 | message->getObject("params"_s , parameters); |
| 4418 | |
| 4419 | if (method == "enable" ) |
| 4420 | enable(requestId, WTFMove(parameters)); |
| 4421 | else if (method == "disable" ) |
| 4422 | disable(requestId, WTFMove(parameters)); |
| 4423 | else if (method == "startTracking" ) |
| 4424 | startTracking(requestId, WTFMove(parameters)); |
| 4425 | else if (method == "stopTracking" ) |
| 4426 | stopTracking(requestId, WTFMove(parameters)); |
| 4427 | else |
| 4428 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Memory." + method + "' was not found" ); |
| 4429 | } |
| 4430 | |
| 4431 | void MemoryBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 4432 | { |
| 4433 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4434 | if (m_alternateDispatcher) { |
| 4435 | m_alternateDispatcher->enable(requestId); |
| 4436 | return; |
| 4437 | } |
| 4438 | #endif |
| 4439 | |
| 4440 | ErrorString error; |
| 4441 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4442 | m_agent->enable(error); |
| 4443 | |
| 4444 | if (!error.length()) |
| 4445 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4446 | else |
| 4447 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4448 | } |
| 4449 | |
| 4450 | void MemoryBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 4451 | { |
| 4452 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4453 | if (m_alternateDispatcher) { |
| 4454 | m_alternateDispatcher->disable(requestId); |
| 4455 | return; |
| 4456 | } |
| 4457 | #endif |
| 4458 | |
| 4459 | ErrorString error; |
| 4460 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4461 | m_agent->disable(error); |
| 4462 | |
| 4463 | if (!error.length()) |
| 4464 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4465 | else |
| 4466 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4467 | } |
| 4468 | |
| 4469 | void MemoryBackendDispatcher::startTracking(long requestId, RefPtr<JSON::Object>&&) |
| 4470 | { |
| 4471 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4472 | if (m_alternateDispatcher) { |
| 4473 | m_alternateDispatcher->startTracking(requestId); |
| 4474 | return; |
| 4475 | } |
| 4476 | #endif |
| 4477 | |
| 4478 | ErrorString error; |
| 4479 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4480 | m_agent->startTracking(error); |
| 4481 | |
| 4482 | if (!error.length()) |
| 4483 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4484 | else |
| 4485 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4486 | } |
| 4487 | |
| 4488 | void MemoryBackendDispatcher::stopTracking(long requestId, RefPtr<JSON::Object>&&) |
| 4489 | { |
| 4490 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4491 | if (m_alternateDispatcher) { |
| 4492 | m_alternateDispatcher->stopTracking(requestId); |
| 4493 | return; |
| 4494 | } |
| 4495 | #endif |
| 4496 | |
| 4497 | ErrorString error; |
| 4498 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4499 | m_agent->stopTracking(error); |
| 4500 | |
| 4501 | if (!error.length()) |
| 4502 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4503 | else |
| 4504 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4505 | } |
| 4506 | #endif // ENABLE(RESOURCE_USAGE) |
| 4507 | |
| 4508 | Ref<NetworkBackendDispatcher> NetworkBackendDispatcher::create(BackendDispatcher& backendDispatcher, NetworkBackendDispatcherHandler* agent) |
| 4509 | { |
| 4510 | return adoptRef(*new NetworkBackendDispatcher(backendDispatcher, agent)); |
| 4511 | } |
| 4512 | |
| 4513 | NetworkBackendDispatcher::NetworkBackendDispatcher(BackendDispatcher& backendDispatcher, NetworkBackendDispatcherHandler* agent) |
| 4514 | : SupplementalBackendDispatcher(backendDispatcher) |
| 4515 | , m_agent(agent) |
| 4516 | { |
| 4517 | m_backendDispatcher->registerDispatcherForDomain("Network"_s , this); |
| 4518 | } |
| 4519 | |
| 4520 | void NetworkBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 4521 | { |
| 4522 | Ref<NetworkBackendDispatcher> protect(*this); |
| 4523 | |
| 4524 | RefPtr<JSON::Object> parameters; |
| 4525 | message->getObject("params"_s , parameters); |
| 4526 | |
| 4527 | typedef void (NetworkBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 4528 | typedef HashMap<String, CallHandler> DispatchMap; |
| 4529 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 4530 | if (dispatchMap.get().isEmpty()) { |
| 4531 | static const struct MethodTable { |
| 4532 | const char* name; |
| 4533 | CallHandler handler; |
| 4534 | } commands[] = { |
| 4535 | { "enable" , &NetworkBackendDispatcher::enable }, |
| 4536 | { "disable" , &NetworkBackendDispatcher::disable }, |
| 4537 | { "setExtraHTTPHeaders" , &NetworkBackendDispatcher::setExtraHTTPHeaders }, |
| 4538 | { "getResponseBody" , &NetworkBackendDispatcher::getResponseBody }, |
| 4539 | { "setResourceCachingDisabled" , &NetworkBackendDispatcher::setResourceCachingDisabled }, |
| 4540 | { "loadResource" , &NetworkBackendDispatcher::loadResource }, |
| 4541 | { "getSerializedCertificate" , &NetworkBackendDispatcher::getSerializedCertificate }, |
| 4542 | { "resolveWebSocket" , &NetworkBackendDispatcher::resolveWebSocket }, |
| 4543 | }; |
| 4544 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 4545 | for (size_t i = 0; i < length; ++i) |
| 4546 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 4547 | } |
| 4548 | |
| 4549 | auto findResult = dispatchMap.get().find(method); |
| 4550 | if (findResult == dispatchMap.get().end()) { |
| 4551 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Network." + method + "' was not found" ); |
| 4552 | return; |
| 4553 | } |
| 4554 | |
| 4555 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 4556 | } |
| 4557 | |
| 4558 | void NetworkBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 4559 | { |
| 4560 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4561 | if (m_alternateDispatcher) { |
| 4562 | m_alternateDispatcher->enable(requestId); |
| 4563 | return; |
| 4564 | } |
| 4565 | #endif |
| 4566 | |
| 4567 | ErrorString error; |
| 4568 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4569 | m_agent->enable(error); |
| 4570 | |
| 4571 | if (!error.length()) |
| 4572 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4573 | else |
| 4574 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4575 | } |
| 4576 | |
| 4577 | void NetworkBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 4578 | { |
| 4579 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4580 | if (m_alternateDispatcher) { |
| 4581 | m_alternateDispatcher->disable(requestId); |
| 4582 | return; |
| 4583 | } |
| 4584 | #endif |
| 4585 | |
| 4586 | ErrorString error; |
| 4587 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4588 | m_agent->disable(error); |
| 4589 | |
| 4590 | if (!error.length()) |
| 4591 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4592 | else |
| 4593 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4594 | } |
| 4595 | |
| 4596 | void NetworkBackendDispatcher::(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4597 | { |
| 4598 | RefPtr<JSON::Object> = m_backendDispatcher->getObject(parameters.get(), "headers"_s , nullptr); |
| 4599 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4600 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Network.setExtraHTTPHeaders' can't be processed"_s ); |
| 4601 | return; |
| 4602 | } |
| 4603 | |
| 4604 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4605 | if (m_alternateDispatcher) { |
| 4606 | m_alternateDispatcher->setExtraHTTPHeaders(requestId, *in_headers); |
| 4607 | return; |
| 4608 | } |
| 4609 | #endif |
| 4610 | |
| 4611 | ErrorString error; |
| 4612 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4613 | m_agent->setExtraHTTPHeaders(error, *in_headers); |
| 4614 | |
| 4615 | if (!error.length()) |
| 4616 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4617 | else |
| 4618 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4619 | } |
| 4620 | |
| 4621 | void NetworkBackendDispatcher::getResponseBody(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4622 | { |
| 4623 | String in_requestId = m_backendDispatcher->getString(parameters.get(), "requestId"_s , nullptr); |
| 4624 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4625 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Network.getResponseBody' can't be processed"_s ); |
| 4626 | return; |
| 4627 | } |
| 4628 | |
| 4629 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4630 | if (m_alternateDispatcher) { |
| 4631 | m_alternateDispatcher->getResponseBody(requestId, in_requestId); |
| 4632 | return; |
| 4633 | } |
| 4634 | #endif |
| 4635 | |
| 4636 | ErrorString error; |
| 4637 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4638 | String out_body; |
| 4639 | bool out_base64Encoded; |
| 4640 | m_agent->getResponseBody(error, in_requestId, &out_body, &out_base64Encoded); |
| 4641 | |
| 4642 | if (!error.length()) { |
| 4643 | result->setString("body"_s , out_body); |
| 4644 | result->setBoolean("base64Encoded"_s , out_base64Encoded); |
| 4645 | } |
| 4646 | if (!error.length()) |
| 4647 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4648 | else |
| 4649 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4650 | } |
| 4651 | |
| 4652 | void NetworkBackendDispatcher::setResourceCachingDisabled(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4653 | { |
| 4654 | bool in_disabled = m_backendDispatcher->getBoolean(parameters.get(), "disabled"_s , nullptr); |
| 4655 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4656 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Network.setResourceCachingDisabled' can't be processed"_s ); |
| 4657 | return; |
| 4658 | } |
| 4659 | |
| 4660 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4661 | if (m_alternateDispatcher) { |
| 4662 | m_alternateDispatcher->setResourceCachingDisabled(requestId, in_disabled); |
| 4663 | return; |
| 4664 | } |
| 4665 | #endif |
| 4666 | |
| 4667 | ErrorString error; |
| 4668 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4669 | m_agent->setResourceCachingDisabled(error, in_disabled); |
| 4670 | |
| 4671 | if (!error.length()) |
| 4672 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4673 | else |
| 4674 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4675 | } |
| 4676 | |
| 4677 | NetworkBackendDispatcherHandler::LoadResourceCallback::LoadResourceCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
| 4678 | |
| 4679 | void NetworkBackendDispatcherHandler::LoadResourceCallback::sendSuccess(const String& content, const String& mimeType, int status) |
| 4680 | { |
| 4681 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
| 4682 | jsonMessage->setString("content"_s , content); |
| 4683 | jsonMessage->setString("mimeType"_s , mimeType); |
| 4684 | jsonMessage->setInteger("status"_s , status); |
| 4685 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
| 4686 | } |
| 4687 | |
| 4688 | void NetworkBackendDispatcher::loadResource(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4689 | { |
| 4690 | String in_frameId = m_backendDispatcher->getString(parameters.get(), "frameId"_s , nullptr); |
| 4691 | String in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , nullptr); |
| 4692 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4693 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Network.loadResource' can't be processed"_s ); |
| 4694 | return; |
| 4695 | } |
| 4696 | |
| 4697 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4698 | if (m_alternateDispatcher) { |
| 4699 | m_alternateDispatcher->loadResource(requestId, in_frameId, in_url); |
| 4700 | return; |
| 4701 | } |
| 4702 | #endif |
| 4703 | |
| 4704 | Ref<NetworkBackendDispatcherHandler::LoadResourceCallback> callback = adoptRef(*new NetworkBackendDispatcherHandler::LoadResourceCallback(m_backendDispatcher.copyRef(), requestId)); |
| 4705 | m_agent->loadResource(in_frameId, in_url, callback.copyRef()); |
| 4706 | |
| 4707 | } |
| 4708 | |
| 4709 | void NetworkBackendDispatcher::getSerializedCertificate(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4710 | { |
| 4711 | String in_requestId = m_backendDispatcher->getString(parameters.get(), "requestId"_s , nullptr); |
| 4712 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4713 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Network.getSerializedCertificate' can't be processed"_s ); |
| 4714 | return; |
| 4715 | } |
| 4716 | |
| 4717 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4718 | if (m_alternateDispatcher) { |
| 4719 | m_alternateDispatcher->getSerializedCertificate(requestId, in_requestId); |
| 4720 | return; |
| 4721 | } |
| 4722 | #endif |
| 4723 | |
| 4724 | ErrorString error; |
| 4725 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4726 | String out_serializedCertificate; |
| 4727 | m_agent->getSerializedCertificate(error, in_requestId, &out_serializedCertificate); |
| 4728 | |
| 4729 | if (!error.length()) |
| 4730 | result->setString("serializedCertificate"_s , out_serializedCertificate); |
| 4731 | |
| 4732 | if (!error.length()) |
| 4733 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4734 | else |
| 4735 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4736 | } |
| 4737 | |
| 4738 | void NetworkBackendDispatcher::resolveWebSocket(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4739 | { |
| 4740 | String in_requestId = m_backendDispatcher->getString(parameters.get(), "requestId"_s , nullptr); |
| 4741 | bool opt_in_objectGroup_valueFound = false; |
| 4742 | String opt_in_objectGroup = m_backendDispatcher->getString(parameters.get(), "objectGroup"_s , &opt_in_objectGroup_valueFound); |
| 4743 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4744 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Network.resolveWebSocket' can't be processed"_s ); |
| 4745 | return; |
| 4746 | } |
| 4747 | |
| 4748 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4749 | if (m_alternateDispatcher) { |
| 4750 | m_alternateDispatcher->resolveWebSocket(requestId, in_requestId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr); |
| 4751 | return; |
| 4752 | } |
| 4753 | #endif |
| 4754 | |
| 4755 | ErrorString error; |
| 4756 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4757 | RefPtr<Inspector::Protocol::Runtime::RemoteObject> out_object; |
| 4758 | m_agent->resolveWebSocket(error, in_requestId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, out_object); |
| 4759 | |
| 4760 | if (!error.length()) |
| 4761 | result->setObject("object"_s , out_object); |
| 4762 | |
| 4763 | if (!error.length()) |
| 4764 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4765 | else |
| 4766 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4767 | } |
| 4768 | |
| 4769 | Ref<PageBackendDispatcher> PageBackendDispatcher::create(BackendDispatcher& backendDispatcher, PageBackendDispatcherHandler* agent) |
| 4770 | { |
| 4771 | return adoptRef(*new PageBackendDispatcher(backendDispatcher, agent)); |
| 4772 | } |
| 4773 | |
| 4774 | PageBackendDispatcher::PageBackendDispatcher(BackendDispatcher& backendDispatcher, PageBackendDispatcherHandler* agent) |
| 4775 | : SupplementalBackendDispatcher(backendDispatcher) |
| 4776 | , m_agent(agent) |
| 4777 | { |
| 4778 | m_backendDispatcher->registerDispatcherForDomain("Page"_s , this); |
| 4779 | } |
| 4780 | |
| 4781 | void PageBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 4782 | { |
| 4783 | Ref<PageBackendDispatcher> protect(*this); |
| 4784 | |
| 4785 | RefPtr<JSON::Object> parameters; |
| 4786 | message->getObject("params"_s , parameters); |
| 4787 | |
| 4788 | typedef void (PageBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 4789 | typedef HashMap<String, CallHandler> DispatchMap; |
| 4790 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 4791 | if (dispatchMap.get().isEmpty()) { |
| 4792 | static const struct MethodTable { |
| 4793 | const char* name; |
| 4794 | CallHandler handler; |
| 4795 | } commands[] = { |
| 4796 | { "enable" , &PageBackendDispatcher::enable }, |
| 4797 | { "disable" , &PageBackendDispatcher::disable }, |
| 4798 | { "reload" , &PageBackendDispatcher::reload }, |
| 4799 | { "navigate" , &PageBackendDispatcher::navigate }, |
| 4800 | { "overrideUserAgent" , &PageBackendDispatcher::overrideUserAgent }, |
| 4801 | { "overrideSetting" , &PageBackendDispatcher::overrideSetting }, |
| 4802 | { "getCookies" , &PageBackendDispatcher::getCookies }, |
| 4803 | { "deleteCookie" , &PageBackendDispatcher::deleteCookie }, |
| 4804 | { "getResourceTree" , &PageBackendDispatcher::getResourceTree }, |
| 4805 | { "getResourceContent" , &PageBackendDispatcher::getResourceContent }, |
| 4806 | { "searchInResource" , &PageBackendDispatcher::searchInResource }, |
| 4807 | { "searchInResources" , &PageBackendDispatcher::searchInResources }, |
| 4808 | { "setShowRulers" , &PageBackendDispatcher::setShowRulers }, |
| 4809 | { "setShowPaintRects" , &PageBackendDispatcher::setShowPaintRects }, |
| 4810 | { "setEmulatedMedia" , &PageBackendDispatcher::setEmulatedMedia }, |
| 4811 | { "setForcedAppearance" , &PageBackendDispatcher::setForcedAppearance }, |
| 4812 | { "getCompositingBordersVisible" , &PageBackendDispatcher::getCompositingBordersVisible }, |
| 4813 | { "setCompositingBordersVisible" , &PageBackendDispatcher::setCompositingBordersVisible }, |
| 4814 | { "snapshotNode" , &PageBackendDispatcher::snapshotNode }, |
| 4815 | { "snapshotRect" , &PageBackendDispatcher::snapshotRect }, |
| 4816 | { "archive" , &PageBackendDispatcher::archive }, |
| 4817 | }; |
| 4818 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 4819 | for (size_t i = 0; i < length; ++i) |
| 4820 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 4821 | } |
| 4822 | |
| 4823 | auto findResult = dispatchMap.get().find(method); |
| 4824 | if (findResult == dispatchMap.get().end()) { |
| 4825 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Page." + method + "' was not found" ); |
| 4826 | return; |
| 4827 | } |
| 4828 | |
| 4829 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 4830 | } |
| 4831 | |
| 4832 | void PageBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 4833 | { |
| 4834 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4835 | if (m_alternateDispatcher) { |
| 4836 | m_alternateDispatcher->enable(requestId); |
| 4837 | return; |
| 4838 | } |
| 4839 | #endif |
| 4840 | |
| 4841 | ErrorString error; |
| 4842 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4843 | m_agent->enable(error); |
| 4844 | |
| 4845 | if (!error.length()) |
| 4846 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4847 | else |
| 4848 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4849 | } |
| 4850 | |
| 4851 | void PageBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 4852 | { |
| 4853 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4854 | if (m_alternateDispatcher) { |
| 4855 | m_alternateDispatcher->disable(requestId); |
| 4856 | return; |
| 4857 | } |
| 4858 | #endif |
| 4859 | |
| 4860 | ErrorString error; |
| 4861 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4862 | m_agent->disable(error); |
| 4863 | |
| 4864 | if (!error.length()) |
| 4865 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4866 | else |
| 4867 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4868 | } |
| 4869 | |
| 4870 | void PageBackendDispatcher::reload(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4871 | { |
| 4872 | bool opt_in_ignoreCache_valueFound = false; |
| 4873 | bool opt_in_ignoreCache = m_backendDispatcher->getBoolean(parameters.get(), "ignoreCache"_s , &opt_in_ignoreCache_valueFound); |
| 4874 | bool opt_in_revalidateAllResources_valueFound = false; |
| 4875 | bool opt_in_revalidateAllResources = m_backendDispatcher->getBoolean(parameters.get(), "revalidateAllResources"_s , &opt_in_revalidateAllResources_valueFound); |
| 4876 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4877 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.reload' can't be processed"_s ); |
| 4878 | return; |
| 4879 | } |
| 4880 | |
| 4881 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4882 | if (m_alternateDispatcher) { |
| 4883 | m_alternateDispatcher->reload(requestId, opt_in_ignoreCache_valueFound ? &opt_in_ignoreCache : nullptr, opt_in_revalidateAllResources_valueFound ? &opt_in_revalidateAllResources : nullptr); |
| 4884 | return; |
| 4885 | } |
| 4886 | #endif |
| 4887 | |
| 4888 | ErrorString error; |
| 4889 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4890 | m_agent->reload(error, opt_in_ignoreCache_valueFound ? &opt_in_ignoreCache : nullptr, opt_in_revalidateAllResources_valueFound ? &opt_in_revalidateAllResources : nullptr); |
| 4891 | |
| 4892 | if (!error.length()) |
| 4893 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4894 | else |
| 4895 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4896 | } |
| 4897 | |
| 4898 | void PageBackendDispatcher::navigate(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4899 | { |
| 4900 | String in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , nullptr); |
| 4901 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4902 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.navigate' can't be processed"_s ); |
| 4903 | return; |
| 4904 | } |
| 4905 | |
| 4906 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4907 | if (m_alternateDispatcher) { |
| 4908 | m_alternateDispatcher->navigate(requestId, in_url); |
| 4909 | return; |
| 4910 | } |
| 4911 | #endif |
| 4912 | |
| 4913 | ErrorString error; |
| 4914 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4915 | m_agent->navigate(error, in_url); |
| 4916 | |
| 4917 | if (!error.length()) |
| 4918 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4919 | else |
| 4920 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4921 | } |
| 4922 | |
| 4923 | void PageBackendDispatcher::overrideUserAgent(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4924 | { |
| 4925 | bool opt_in_value_valueFound = false; |
| 4926 | String opt_in_value = m_backendDispatcher->getString(parameters.get(), "value"_s , &opt_in_value_valueFound); |
| 4927 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4928 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.overrideUserAgent' can't be processed"_s ); |
| 4929 | return; |
| 4930 | } |
| 4931 | |
| 4932 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4933 | if (m_alternateDispatcher) { |
| 4934 | m_alternateDispatcher->overrideUserAgent(requestId, opt_in_value_valueFound ? &opt_in_value : nullptr); |
| 4935 | return; |
| 4936 | } |
| 4937 | #endif |
| 4938 | |
| 4939 | ErrorString error; |
| 4940 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4941 | m_agent->overrideUserAgent(error, opt_in_value_valueFound ? &opt_in_value : nullptr); |
| 4942 | |
| 4943 | if (!error.length()) |
| 4944 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4945 | else |
| 4946 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4947 | } |
| 4948 | |
| 4949 | void PageBackendDispatcher::overrideSetting(long requestId, RefPtr<JSON::Object>&& parameters) |
| 4950 | { |
| 4951 | String in_setting = m_backendDispatcher->getString(parameters.get(), "setting"_s , nullptr); |
| 4952 | bool opt_in_value_valueFound = false; |
| 4953 | bool opt_in_value = m_backendDispatcher->getBoolean(parameters.get(), "value"_s , &opt_in_value_valueFound); |
| 4954 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 4955 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.overrideSetting' can't be processed"_s ); |
| 4956 | return; |
| 4957 | } |
| 4958 | |
| 4959 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4960 | if (m_alternateDispatcher) { |
| 4961 | m_alternateDispatcher->overrideSetting(requestId, in_setting, opt_in_value_valueFound ? &opt_in_value : nullptr); |
| 4962 | return; |
| 4963 | } |
| 4964 | #endif |
| 4965 | |
| 4966 | ErrorString error; |
| 4967 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4968 | m_agent->overrideSetting(error, in_setting, opt_in_value_valueFound ? &opt_in_value : nullptr); |
| 4969 | |
| 4970 | if (!error.length()) |
| 4971 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4972 | else |
| 4973 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4974 | } |
| 4975 | |
| 4976 | void PageBackendDispatcher::getCookies(long requestId, RefPtr<JSON::Object>&&) |
| 4977 | { |
| 4978 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 4979 | if (m_alternateDispatcher) { |
| 4980 | m_alternateDispatcher->getCookies(requestId); |
| 4981 | return; |
| 4982 | } |
| 4983 | #endif |
| 4984 | |
| 4985 | ErrorString error; |
| 4986 | Ref<JSON::Object> result = JSON::Object::create(); |
| 4987 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::Cookie>> out_cookies; |
| 4988 | m_agent->getCookies(error, out_cookies); |
| 4989 | |
| 4990 | if (!error.length()) |
| 4991 | result->setArray("cookies"_s , out_cookies); |
| 4992 | |
| 4993 | if (!error.length()) |
| 4994 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 4995 | else |
| 4996 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 4997 | } |
| 4998 | |
| 4999 | void PageBackendDispatcher::deleteCookie(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5000 | { |
| 5001 | String in_cookieName = m_backendDispatcher->getString(parameters.get(), "cookieName"_s , nullptr); |
| 5002 | String in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , nullptr); |
| 5003 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5004 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.deleteCookie' can't be processed"_s ); |
| 5005 | return; |
| 5006 | } |
| 5007 | |
| 5008 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5009 | if (m_alternateDispatcher) { |
| 5010 | m_alternateDispatcher->deleteCookie(requestId, in_cookieName, in_url); |
| 5011 | return; |
| 5012 | } |
| 5013 | #endif |
| 5014 | |
| 5015 | ErrorString error; |
| 5016 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5017 | m_agent->deleteCookie(error, in_cookieName, in_url); |
| 5018 | |
| 5019 | if (!error.length()) |
| 5020 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5021 | else |
| 5022 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5023 | } |
| 5024 | |
| 5025 | void PageBackendDispatcher::getResourceTree(long requestId, RefPtr<JSON::Object>&&) |
| 5026 | { |
| 5027 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5028 | if (m_alternateDispatcher) { |
| 5029 | m_alternateDispatcher->getResourceTree(requestId); |
| 5030 | return; |
| 5031 | } |
| 5032 | #endif |
| 5033 | |
| 5034 | ErrorString error; |
| 5035 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5036 | RefPtr<Inspector::Protocol::Page::FrameResourceTree> out_frameTree; |
| 5037 | m_agent->getResourceTree(error, out_frameTree); |
| 5038 | |
| 5039 | if (!error.length()) |
| 5040 | result->setObject("frameTree"_s , out_frameTree); |
| 5041 | |
| 5042 | if (!error.length()) |
| 5043 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5044 | else |
| 5045 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5046 | } |
| 5047 | |
| 5048 | void PageBackendDispatcher::getResourceContent(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5049 | { |
| 5050 | String in_frameId = m_backendDispatcher->getString(parameters.get(), "frameId"_s , nullptr); |
| 5051 | String in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , nullptr); |
| 5052 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5053 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.getResourceContent' can't be processed"_s ); |
| 5054 | return; |
| 5055 | } |
| 5056 | |
| 5057 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5058 | if (m_alternateDispatcher) { |
| 5059 | m_alternateDispatcher->getResourceContent(requestId, in_frameId, in_url); |
| 5060 | return; |
| 5061 | } |
| 5062 | #endif |
| 5063 | |
| 5064 | ErrorString error; |
| 5065 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5066 | String out_content; |
| 5067 | bool out_base64Encoded; |
| 5068 | m_agent->getResourceContent(error, in_frameId, in_url, &out_content, &out_base64Encoded); |
| 5069 | |
| 5070 | if (!error.length()) { |
| 5071 | result->setString("content"_s , out_content); |
| 5072 | result->setBoolean("base64Encoded"_s , out_base64Encoded); |
| 5073 | } |
| 5074 | if (!error.length()) |
| 5075 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5076 | else |
| 5077 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5078 | } |
| 5079 | |
| 5080 | void PageBackendDispatcher::searchInResource(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5081 | { |
| 5082 | String in_frameId = m_backendDispatcher->getString(parameters.get(), "frameId"_s , nullptr); |
| 5083 | String in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , nullptr); |
| 5084 | String in_query = m_backendDispatcher->getString(parameters.get(), "query"_s , nullptr); |
| 5085 | bool opt_in_caseSensitive_valueFound = false; |
| 5086 | bool opt_in_caseSensitive = m_backendDispatcher->getBoolean(parameters.get(), "caseSensitive"_s , &opt_in_caseSensitive_valueFound); |
| 5087 | bool opt_in_isRegex_valueFound = false; |
| 5088 | bool opt_in_isRegex = m_backendDispatcher->getBoolean(parameters.get(), "isRegex"_s , &opt_in_isRegex_valueFound); |
| 5089 | bool opt_in_requestId_valueFound = false; |
| 5090 | String opt_in_requestId = m_backendDispatcher->getString(parameters.get(), "requestId"_s , &opt_in_requestId_valueFound); |
| 5091 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5092 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.searchInResource' can't be processed"_s ); |
| 5093 | return; |
| 5094 | } |
| 5095 | |
| 5096 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5097 | if (m_alternateDispatcher) { |
| 5098 | m_alternateDispatcher->searchInResource(requestId, in_frameId, in_url, in_query, opt_in_caseSensitive_valueFound ? &opt_in_caseSensitive : nullptr, opt_in_isRegex_valueFound ? &opt_in_isRegex : nullptr, opt_in_requestId_valueFound ? &opt_in_requestId : nullptr); |
| 5099 | return; |
| 5100 | } |
| 5101 | #endif |
| 5102 | |
| 5103 | ErrorString error; |
| 5104 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5105 | RefPtr<JSON::ArrayOf<Inspector::Protocol::GenericTypes::SearchMatch>> out_result; |
| 5106 | m_agent->searchInResource(error, in_frameId, in_url, in_query, opt_in_caseSensitive_valueFound ? &opt_in_caseSensitive : nullptr, opt_in_isRegex_valueFound ? &opt_in_isRegex : nullptr, opt_in_requestId_valueFound ? &opt_in_requestId : nullptr, out_result); |
| 5107 | |
| 5108 | if (!error.length()) |
| 5109 | result->setArray("result"_s , out_result); |
| 5110 | |
| 5111 | if (!error.length()) |
| 5112 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5113 | else |
| 5114 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5115 | } |
| 5116 | |
| 5117 | void PageBackendDispatcher::searchInResources(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5118 | { |
| 5119 | String in_text = m_backendDispatcher->getString(parameters.get(), "text"_s , nullptr); |
| 5120 | bool opt_in_caseSensitive_valueFound = false; |
| 5121 | bool opt_in_caseSensitive = m_backendDispatcher->getBoolean(parameters.get(), "caseSensitive"_s , &opt_in_caseSensitive_valueFound); |
| 5122 | bool opt_in_isRegex_valueFound = false; |
| 5123 | bool opt_in_isRegex = m_backendDispatcher->getBoolean(parameters.get(), "isRegex"_s , &opt_in_isRegex_valueFound); |
| 5124 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5125 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.searchInResources' can't be processed"_s ); |
| 5126 | return; |
| 5127 | } |
| 5128 | |
| 5129 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5130 | if (m_alternateDispatcher) { |
| 5131 | m_alternateDispatcher->searchInResources(requestId, in_text, opt_in_caseSensitive_valueFound ? &opt_in_caseSensitive : nullptr, opt_in_isRegex_valueFound ? &opt_in_isRegex : nullptr); |
| 5132 | return; |
| 5133 | } |
| 5134 | #endif |
| 5135 | |
| 5136 | ErrorString error; |
| 5137 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5138 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::SearchResult>> out_result; |
| 5139 | m_agent->searchInResources(error, in_text, opt_in_caseSensitive_valueFound ? &opt_in_caseSensitive : nullptr, opt_in_isRegex_valueFound ? &opt_in_isRegex : nullptr, out_result); |
| 5140 | |
| 5141 | if (!error.length()) |
| 5142 | result->setArray("result"_s , out_result); |
| 5143 | |
| 5144 | if (!error.length()) |
| 5145 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5146 | else |
| 5147 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5148 | } |
| 5149 | |
| 5150 | void PageBackendDispatcher::setShowRulers(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5151 | { |
| 5152 | bool in_result = m_backendDispatcher->getBoolean(parameters.get(), "result"_s , nullptr); |
| 5153 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5154 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.setShowRulers' can't be processed"_s ); |
| 5155 | return; |
| 5156 | } |
| 5157 | |
| 5158 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5159 | if (m_alternateDispatcher) { |
| 5160 | m_alternateDispatcher->setShowRulers(requestId, in_result); |
| 5161 | return; |
| 5162 | } |
| 5163 | #endif |
| 5164 | |
| 5165 | ErrorString error; |
| 5166 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5167 | m_agent->setShowRulers(error, in_result); |
| 5168 | |
| 5169 | if (!error.length()) |
| 5170 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5171 | else |
| 5172 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5173 | } |
| 5174 | |
| 5175 | void PageBackendDispatcher::setShowPaintRects(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5176 | { |
| 5177 | bool in_result = m_backendDispatcher->getBoolean(parameters.get(), "result"_s , nullptr); |
| 5178 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5179 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.setShowPaintRects' can't be processed"_s ); |
| 5180 | return; |
| 5181 | } |
| 5182 | |
| 5183 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5184 | if (m_alternateDispatcher) { |
| 5185 | m_alternateDispatcher->setShowPaintRects(requestId, in_result); |
| 5186 | return; |
| 5187 | } |
| 5188 | #endif |
| 5189 | |
| 5190 | ErrorString error; |
| 5191 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5192 | m_agent->setShowPaintRects(error, in_result); |
| 5193 | |
| 5194 | if (!error.length()) |
| 5195 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5196 | else |
| 5197 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5198 | } |
| 5199 | |
| 5200 | void PageBackendDispatcher::setEmulatedMedia(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5201 | { |
| 5202 | String in_media = m_backendDispatcher->getString(parameters.get(), "media"_s , nullptr); |
| 5203 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5204 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.setEmulatedMedia' can't be processed"_s ); |
| 5205 | return; |
| 5206 | } |
| 5207 | |
| 5208 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5209 | if (m_alternateDispatcher) { |
| 5210 | m_alternateDispatcher->setEmulatedMedia(requestId, in_media); |
| 5211 | return; |
| 5212 | } |
| 5213 | #endif |
| 5214 | |
| 5215 | ErrorString error; |
| 5216 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5217 | m_agent->setEmulatedMedia(error, in_media); |
| 5218 | |
| 5219 | if (!error.length()) |
| 5220 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5221 | else |
| 5222 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5223 | } |
| 5224 | |
| 5225 | void PageBackendDispatcher::setForcedAppearance(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5226 | { |
| 5227 | String in_appearance = m_backendDispatcher->getString(parameters.get(), "appearance"_s , nullptr); |
| 5228 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5229 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.setForcedAppearance' can't be processed"_s ); |
| 5230 | return; |
| 5231 | } |
| 5232 | |
| 5233 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5234 | if (m_alternateDispatcher) { |
| 5235 | m_alternateDispatcher->setForcedAppearance(requestId, in_appearance); |
| 5236 | return; |
| 5237 | } |
| 5238 | #endif |
| 5239 | |
| 5240 | ErrorString error; |
| 5241 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5242 | m_agent->setForcedAppearance(error, in_appearance); |
| 5243 | |
| 5244 | if (!error.length()) |
| 5245 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5246 | else |
| 5247 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5248 | } |
| 5249 | |
| 5250 | void PageBackendDispatcher::getCompositingBordersVisible(long requestId, RefPtr<JSON::Object>&&) |
| 5251 | { |
| 5252 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5253 | if (m_alternateDispatcher) { |
| 5254 | m_alternateDispatcher->getCompositingBordersVisible(requestId); |
| 5255 | return; |
| 5256 | } |
| 5257 | #endif |
| 5258 | |
| 5259 | ErrorString error; |
| 5260 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5261 | bool out_result; |
| 5262 | m_agent->getCompositingBordersVisible(error, &out_result); |
| 5263 | |
| 5264 | if (!error.length()) |
| 5265 | result->setBoolean("result"_s , out_result); |
| 5266 | |
| 5267 | if (!error.length()) |
| 5268 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5269 | else |
| 5270 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5271 | } |
| 5272 | |
| 5273 | void PageBackendDispatcher::setCompositingBordersVisible(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5274 | { |
| 5275 | bool in_visible = m_backendDispatcher->getBoolean(parameters.get(), "visible"_s , nullptr); |
| 5276 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5277 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.setCompositingBordersVisible' can't be processed"_s ); |
| 5278 | return; |
| 5279 | } |
| 5280 | |
| 5281 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5282 | if (m_alternateDispatcher) { |
| 5283 | m_alternateDispatcher->setCompositingBordersVisible(requestId, in_visible); |
| 5284 | return; |
| 5285 | } |
| 5286 | #endif |
| 5287 | |
| 5288 | ErrorString error; |
| 5289 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5290 | m_agent->setCompositingBordersVisible(error, in_visible); |
| 5291 | |
| 5292 | if (!error.length()) |
| 5293 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5294 | else |
| 5295 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5296 | } |
| 5297 | |
| 5298 | void PageBackendDispatcher::snapshotNode(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5299 | { |
| 5300 | int in_nodeId = m_backendDispatcher->getInteger(parameters.get(), "nodeId"_s , nullptr); |
| 5301 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5302 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.snapshotNode' can't be processed"_s ); |
| 5303 | return; |
| 5304 | } |
| 5305 | |
| 5306 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5307 | if (m_alternateDispatcher) { |
| 5308 | m_alternateDispatcher->snapshotNode(requestId, in_nodeId); |
| 5309 | return; |
| 5310 | } |
| 5311 | #endif |
| 5312 | |
| 5313 | ErrorString error; |
| 5314 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5315 | String out_dataURL; |
| 5316 | m_agent->snapshotNode(error, in_nodeId, &out_dataURL); |
| 5317 | |
| 5318 | if (!error.length()) |
| 5319 | result->setString("dataURL"_s , out_dataURL); |
| 5320 | |
| 5321 | if (!error.length()) |
| 5322 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5323 | else |
| 5324 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5325 | } |
| 5326 | |
| 5327 | void PageBackendDispatcher::snapshotRect(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5328 | { |
| 5329 | int in_x = m_backendDispatcher->getInteger(parameters.get(), "x"_s , nullptr); |
| 5330 | int in_y = m_backendDispatcher->getInteger(parameters.get(), "y"_s , nullptr); |
| 5331 | int in_width = m_backendDispatcher->getInteger(parameters.get(), "width"_s , nullptr); |
| 5332 | int in_height = m_backendDispatcher->getInteger(parameters.get(), "height"_s , nullptr); |
| 5333 | String in_coordinateSystem = m_backendDispatcher->getString(parameters.get(), "coordinateSystem"_s , nullptr); |
| 5334 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5335 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Page.snapshotRect' can't be processed"_s ); |
| 5336 | return; |
| 5337 | } |
| 5338 | |
| 5339 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5340 | if (m_alternateDispatcher) { |
| 5341 | m_alternateDispatcher->snapshotRect(requestId, in_x, in_y, in_width, in_height, in_coordinateSystem); |
| 5342 | return; |
| 5343 | } |
| 5344 | #endif |
| 5345 | |
| 5346 | ErrorString error; |
| 5347 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5348 | String out_dataURL; |
| 5349 | m_agent->snapshotRect(error, in_x, in_y, in_width, in_height, in_coordinateSystem, &out_dataURL); |
| 5350 | |
| 5351 | if (!error.length()) |
| 5352 | result->setString("dataURL"_s , out_dataURL); |
| 5353 | |
| 5354 | if (!error.length()) |
| 5355 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5356 | else |
| 5357 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5358 | } |
| 5359 | |
| 5360 | void PageBackendDispatcher::archive(long requestId, RefPtr<JSON::Object>&&) |
| 5361 | { |
| 5362 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5363 | if (m_alternateDispatcher) { |
| 5364 | m_alternateDispatcher->archive(requestId); |
| 5365 | return; |
| 5366 | } |
| 5367 | #endif |
| 5368 | |
| 5369 | ErrorString error; |
| 5370 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5371 | String out_data; |
| 5372 | m_agent->archive(error, &out_data); |
| 5373 | |
| 5374 | if (!error.length()) |
| 5375 | result->setString("data"_s , out_data); |
| 5376 | |
| 5377 | if (!error.length()) |
| 5378 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5379 | else |
| 5380 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5381 | } |
| 5382 | |
| 5383 | Ref<RuntimeBackendDispatcher> RuntimeBackendDispatcher::create(BackendDispatcher& backendDispatcher, RuntimeBackendDispatcherHandler* agent) |
| 5384 | { |
| 5385 | return adoptRef(*new RuntimeBackendDispatcher(backendDispatcher, agent)); |
| 5386 | } |
| 5387 | |
| 5388 | RuntimeBackendDispatcher::RuntimeBackendDispatcher(BackendDispatcher& backendDispatcher, RuntimeBackendDispatcherHandler* agent) |
| 5389 | : SupplementalBackendDispatcher(backendDispatcher) |
| 5390 | , m_agent(agent) |
| 5391 | { |
| 5392 | m_backendDispatcher->registerDispatcherForDomain("Runtime"_s , this); |
| 5393 | } |
| 5394 | |
| 5395 | void RuntimeBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 5396 | { |
| 5397 | Ref<RuntimeBackendDispatcher> protect(*this); |
| 5398 | |
| 5399 | RefPtr<JSON::Object> parameters; |
| 5400 | message->getObject("params"_s , parameters); |
| 5401 | |
| 5402 | typedef void (RuntimeBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
| 5403 | typedef HashMap<String, CallHandler> DispatchMap; |
| 5404 | static NeverDestroyed<DispatchMap> dispatchMap; |
| 5405 | if (dispatchMap.get().isEmpty()) { |
| 5406 | static const struct MethodTable { |
| 5407 | const char* name; |
| 5408 | CallHandler handler; |
| 5409 | } commands[] = { |
| 5410 | { "parse" , &RuntimeBackendDispatcher::parse }, |
| 5411 | { "evaluate" , &RuntimeBackendDispatcher::evaluate }, |
| 5412 | { "awaitPromise" , &RuntimeBackendDispatcher::awaitPromise }, |
| 5413 | { "callFunctionOn" , &RuntimeBackendDispatcher::callFunctionOn }, |
| 5414 | { "getPreview" , &RuntimeBackendDispatcher::getPreview }, |
| 5415 | { "getProperties" , &RuntimeBackendDispatcher::getProperties }, |
| 5416 | { "getDisplayableProperties" , &RuntimeBackendDispatcher::getDisplayableProperties }, |
| 5417 | { "getCollectionEntries" , &RuntimeBackendDispatcher::getCollectionEntries }, |
| 5418 | { "saveResult" , &RuntimeBackendDispatcher::saveResult }, |
| 5419 | { "releaseObject" , &RuntimeBackendDispatcher::releaseObject }, |
| 5420 | { "releaseObjectGroup" , &RuntimeBackendDispatcher::releaseObjectGroup }, |
| 5421 | { "enable" , &RuntimeBackendDispatcher::enable }, |
| 5422 | { "disable" , &RuntimeBackendDispatcher::disable }, |
| 5423 | { "getRuntimeTypesForVariablesAtOffsets" , &RuntimeBackendDispatcher::getRuntimeTypesForVariablesAtOffsets }, |
| 5424 | { "enableTypeProfiler" , &RuntimeBackendDispatcher::enableTypeProfiler }, |
| 5425 | { "disableTypeProfiler" , &RuntimeBackendDispatcher::disableTypeProfiler }, |
| 5426 | { "enableControlFlowProfiler" , &RuntimeBackendDispatcher::enableControlFlowProfiler }, |
| 5427 | { "disableControlFlowProfiler" , &RuntimeBackendDispatcher::disableControlFlowProfiler }, |
| 5428 | { "getBasicBlocks" , &RuntimeBackendDispatcher::getBasicBlocks }, |
| 5429 | }; |
| 5430 | size_t length = WTF_ARRAY_LENGTH(commands); |
| 5431 | for (size_t i = 0; i < length; ++i) |
| 5432 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
| 5433 | } |
| 5434 | |
| 5435 | auto findResult = dispatchMap.get().find(method); |
| 5436 | if (findResult == dispatchMap.get().end()) { |
| 5437 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Runtime." + method + "' was not found" ); |
| 5438 | return; |
| 5439 | } |
| 5440 | |
| 5441 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
| 5442 | } |
| 5443 | |
| 5444 | void RuntimeBackendDispatcher::parse(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5445 | { |
| 5446 | String in_source = m_backendDispatcher->getString(parameters.get(), "source"_s , nullptr); |
| 5447 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5448 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.parse' can't be processed"_s ); |
| 5449 | return; |
| 5450 | } |
| 5451 | |
| 5452 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5453 | if (m_alternateDispatcher) { |
| 5454 | m_alternateDispatcher->parse(requestId, in_source); |
| 5455 | return; |
| 5456 | } |
| 5457 | #endif |
| 5458 | |
| 5459 | ErrorString error; |
| 5460 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5461 | Inspector::Protocol::Runtime::SyntaxErrorType out_result; |
| 5462 | Optional<String> out_message; |
| 5463 | RefPtr<Inspector::Protocol::Runtime::ErrorRange> out_range; |
| 5464 | m_agent->parse(error, in_source, &out_result, out_message, out_range); |
| 5465 | |
| 5466 | if (!error.length()) { |
| 5467 | result->setString("result"_s , Inspector::Protocol::InspectorHelpers::getEnumConstantValue(out_result)); |
| 5468 | if (out_message.hasValue()) |
| 5469 | result->setString("message"_s , *out_message); |
| 5470 | if (out_range) |
| 5471 | result->setObject("range"_s , out_range); |
| 5472 | } |
| 5473 | if (!error.length()) |
| 5474 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5475 | else |
| 5476 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5477 | } |
| 5478 | |
| 5479 | void RuntimeBackendDispatcher::evaluate(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5480 | { |
| 5481 | String in_expression = m_backendDispatcher->getString(parameters.get(), "expression"_s , nullptr); |
| 5482 | bool opt_in_objectGroup_valueFound = false; |
| 5483 | String opt_in_objectGroup = m_backendDispatcher->getString(parameters.get(), "objectGroup"_s , &opt_in_objectGroup_valueFound); |
| 5484 | bool opt_in_includeCommandLineAPI_valueFound = false; |
| 5485 | bool opt_in_includeCommandLineAPI = m_backendDispatcher->getBoolean(parameters.get(), "includeCommandLineAPI"_s , &opt_in_includeCommandLineAPI_valueFound); |
| 5486 | bool opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound = false; |
| 5487 | bool opt_in_doNotPauseOnExceptionsAndMuteConsole = m_backendDispatcher->getBoolean(parameters.get(), "doNotPauseOnExceptionsAndMuteConsole"_s , &opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound); |
| 5488 | bool opt_in_contextId_valueFound = false; |
| 5489 | int opt_in_contextId = m_backendDispatcher->getInteger(parameters.get(), "contextId"_s , &opt_in_contextId_valueFound); |
| 5490 | bool opt_in_returnByValue_valueFound = false; |
| 5491 | bool opt_in_returnByValue = m_backendDispatcher->getBoolean(parameters.get(), "returnByValue"_s , &opt_in_returnByValue_valueFound); |
| 5492 | bool opt_in_generatePreview_valueFound = false; |
| 5493 | bool opt_in_generatePreview = m_backendDispatcher->getBoolean(parameters.get(), "generatePreview"_s , &opt_in_generatePreview_valueFound); |
| 5494 | bool opt_in_saveResult_valueFound = false; |
| 5495 | bool opt_in_saveResult = m_backendDispatcher->getBoolean(parameters.get(), "saveResult"_s , &opt_in_saveResult_valueFound); |
| 5496 | bool opt_in_emulateUserGesture_valueFound = false; |
| 5497 | bool opt_in_emulateUserGesture = m_backendDispatcher->getBoolean(parameters.get(), "emulateUserGesture"_s , &opt_in_emulateUserGesture_valueFound); |
| 5498 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5499 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.evaluate' can't be processed"_s ); |
| 5500 | return; |
| 5501 | } |
| 5502 | |
| 5503 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5504 | if (m_alternateDispatcher) { |
| 5505 | m_alternateDispatcher->evaluate(requestId, in_expression, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, opt_in_includeCommandLineAPI_valueFound ? &opt_in_includeCommandLineAPI : nullptr, opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound ? &opt_in_doNotPauseOnExceptionsAndMuteConsole : nullptr, opt_in_contextId_valueFound ? &opt_in_contextId : nullptr, opt_in_returnByValue_valueFound ? &opt_in_returnByValue : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, opt_in_saveResult_valueFound ? &opt_in_saveResult : nullptr, opt_in_emulateUserGesture_valueFound ? &opt_in_emulateUserGesture : nullptr); |
| 5506 | return; |
| 5507 | } |
| 5508 | #endif |
| 5509 | |
| 5510 | ErrorString error; |
| 5511 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5512 | RefPtr<Inspector::Protocol::Runtime::RemoteObject> out_result; |
| 5513 | Optional<bool> out_wasThrown; |
| 5514 | Optional<int> out_savedResultIndex; |
| 5515 | m_agent->evaluate(error, in_expression, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, opt_in_includeCommandLineAPI_valueFound ? &opt_in_includeCommandLineAPI : nullptr, opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound ? &opt_in_doNotPauseOnExceptionsAndMuteConsole : nullptr, opt_in_contextId_valueFound ? &opt_in_contextId : nullptr, opt_in_returnByValue_valueFound ? &opt_in_returnByValue : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, opt_in_saveResult_valueFound ? &opt_in_saveResult : nullptr, opt_in_emulateUserGesture_valueFound ? &opt_in_emulateUserGesture : nullptr, out_result, out_wasThrown, out_savedResultIndex); |
| 5516 | |
| 5517 | if (!error.length()) { |
| 5518 | result->setObject("result"_s , out_result); |
| 5519 | if (out_wasThrown.hasValue()) |
| 5520 | result->setBoolean("wasThrown"_s , *out_wasThrown); |
| 5521 | if (out_savedResultIndex.hasValue()) |
| 5522 | result->setInteger("savedResultIndex"_s , *out_savedResultIndex); |
| 5523 | } |
| 5524 | if (!error.length()) |
| 5525 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5526 | else |
| 5527 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5528 | } |
| 5529 | |
| 5530 | RuntimeBackendDispatcherHandler::AwaitPromiseCallback::AwaitPromiseCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
| 5531 | |
| 5532 | void RuntimeBackendDispatcherHandler::AwaitPromiseCallback::sendSuccess(RefPtr<Inspector::Protocol::Runtime::RemoteObject>&& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex) |
| 5533 | { |
| 5534 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
| 5535 | jsonMessage->setObject("result"_s , result); |
| 5536 | if (wasThrown.hasValue()) |
| 5537 | jsonMessage->setBoolean("wasThrown"_s , *wasThrown); |
| 5538 | if (savedResultIndex.hasValue()) |
| 5539 | jsonMessage->setInteger("savedResultIndex"_s , *savedResultIndex); |
| 5540 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
| 5541 | } |
| 5542 | |
| 5543 | void RuntimeBackendDispatcher::awaitPromise(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5544 | { |
| 5545 | String in_promiseObjectId = m_backendDispatcher->getString(parameters.get(), "promiseObjectId"_s , nullptr); |
| 5546 | bool opt_in_returnByValue_valueFound = false; |
| 5547 | bool opt_in_returnByValue = m_backendDispatcher->getBoolean(parameters.get(), "returnByValue"_s , &opt_in_returnByValue_valueFound); |
| 5548 | bool opt_in_generatePreview_valueFound = false; |
| 5549 | bool opt_in_generatePreview = m_backendDispatcher->getBoolean(parameters.get(), "generatePreview"_s , &opt_in_generatePreview_valueFound); |
| 5550 | bool opt_in_saveResult_valueFound = false; |
| 5551 | bool opt_in_saveResult = m_backendDispatcher->getBoolean(parameters.get(), "saveResult"_s , &opt_in_saveResult_valueFound); |
| 5552 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5553 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.awaitPromise' can't be processed"_s ); |
| 5554 | return; |
| 5555 | } |
| 5556 | |
| 5557 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5558 | if (m_alternateDispatcher) { |
| 5559 | m_alternateDispatcher->awaitPromise(requestId, in_promiseObjectId, opt_in_returnByValue_valueFound ? &opt_in_returnByValue : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, opt_in_saveResult_valueFound ? &opt_in_saveResult : nullptr); |
| 5560 | return; |
| 5561 | } |
| 5562 | #endif |
| 5563 | |
| 5564 | Ref<RuntimeBackendDispatcherHandler::AwaitPromiseCallback> callback = adoptRef(*new RuntimeBackendDispatcherHandler::AwaitPromiseCallback(m_backendDispatcher.copyRef(), requestId)); |
| 5565 | m_agent->awaitPromise(in_promiseObjectId, opt_in_returnByValue_valueFound ? &opt_in_returnByValue : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, opt_in_saveResult_valueFound ? &opt_in_saveResult : nullptr, callback.copyRef()); |
| 5566 | |
| 5567 | } |
| 5568 | |
| 5569 | void RuntimeBackendDispatcher::callFunctionOn(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5570 | { |
| 5571 | String in_objectId = m_backendDispatcher->getString(parameters.get(), "objectId"_s , nullptr); |
| 5572 | String in_functionDeclaration = m_backendDispatcher->getString(parameters.get(), "functionDeclaration"_s , nullptr); |
| 5573 | bool opt_in_arguments_valueFound = false; |
| 5574 | RefPtr<JSON::Array> opt_in_arguments = m_backendDispatcher->getArray(parameters.get(), "arguments"_s , &opt_in_arguments_valueFound); |
| 5575 | bool opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound = false; |
| 5576 | bool opt_in_doNotPauseOnExceptionsAndMuteConsole = m_backendDispatcher->getBoolean(parameters.get(), "doNotPauseOnExceptionsAndMuteConsole"_s , &opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound); |
| 5577 | bool opt_in_returnByValue_valueFound = false; |
| 5578 | bool opt_in_returnByValue = m_backendDispatcher->getBoolean(parameters.get(), "returnByValue"_s , &opt_in_returnByValue_valueFound); |
| 5579 | bool opt_in_generatePreview_valueFound = false; |
| 5580 | bool opt_in_generatePreview = m_backendDispatcher->getBoolean(parameters.get(), "generatePreview"_s , &opt_in_generatePreview_valueFound); |
| 5581 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5582 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.callFunctionOn' can't be processed"_s ); |
| 5583 | return; |
| 5584 | } |
| 5585 | |
| 5586 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5587 | if (m_alternateDispatcher) { |
| 5588 | m_alternateDispatcher->callFunctionOn(requestId, in_objectId, in_functionDeclaration, opt_in_arguments_valueFound ? opt_in_arguments.get() : nullptr, opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound ? &opt_in_doNotPauseOnExceptionsAndMuteConsole : nullptr, opt_in_returnByValue_valueFound ? &opt_in_returnByValue : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr); |
| 5589 | return; |
| 5590 | } |
| 5591 | #endif |
| 5592 | |
| 5593 | ErrorString error; |
| 5594 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5595 | RefPtr<Inspector::Protocol::Runtime::RemoteObject> out_result; |
| 5596 | Optional<bool> out_wasThrown; |
| 5597 | m_agent->callFunctionOn(error, in_objectId, in_functionDeclaration, opt_in_arguments_valueFound ? opt_in_arguments.get() : nullptr, opt_in_doNotPauseOnExceptionsAndMuteConsole_valueFound ? &opt_in_doNotPauseOnExceptionsAndMuteConsole : nullptr, opt_in_returnByValue_valueFound ? &opt_in_returnByValue : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, out_result, out_wasThrown); |
| 5598 | |
| 5599 | if (!error.length()) { |
| 5600 | result->setObject("result"_s , out_result); |
| 5601 | if (out_wasThrown.hasValue()) |
| 5602 | result->setBoolean("wasThrown"_s , *out_wasThrown); |
| 5603 | } |
| 5604 | if (!error.length()) |
| 5605 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5606 | else |
| 5607 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5608 | } |
| 5609 | |
| 5610 | void RuntimeBackendDispatcher::getPreview(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5611 | { |
| 5612 | String in_objectId = m_backendDispatcher->getString(parameters.get(), "objectId"_s , nullptr); |
| 5613 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5614 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.getPreview' can't be processed"_s ); |
| 5615 | return; |
| 5616 | } |
| 5617 | |
| 5618 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5619 | if (m_alternateDispatcher) { |
| 5620 | m_alternateDispatcher->getPreview(requestId, in_objectId); |
| 5621 | return; |
| 5622 | } |
| 5623 | #endif |
| 5624 | |
| 5625 | ErrorString error; |
| 5626 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5627 | RefPtr<Inspector::Protocol::Runtime::ObjectPreview> out_preview; |
| 5628 | m_agent->getPreview(error, in_objectId, out_preview); |
| 5629 | |
| 5630 | if (!error.length()) |
| 5631 | result->setObject("preview"_s , out_preview); |
| 5632 | |
| 5633 | if (!error.length()) |
| 5634 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5635 | else |
| 5636 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5637 | } |
| 5638 | |
| 5639 | void RuntimeBackendDispatcher::getProperties(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5640 | { |
| 5641 | String in_objectId = m_backendDispatcher->getString(parameters.get(), "objectId"_s , nullptr); |
| 5642 | bool opt_in_ownProperties_valueFound = false; |
| 5643 | bool opt_in_ownProperties = m_backendDispatcher->getBoolean(parameters.get(), "ownProperties"_s , &opt_in_ownProperties_valueFound); |
| 5644 | bool opt_in_generatePreview_valueFound = false; |
| 5645 | bool opt_in_generatePreview = m_backendDispatcher->getBoolean(parameters.get(), "generatePreview"_s , &opt_in_generatePreview_valueFound); |
| 5646 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5647 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.getProperties' can't be processed"_s ); |
| 5648 | return; |
| 5649 | } |
| 5650 | |
| 5651 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5652 | if (m_alternateDispatcher) { |
| 5653 | m_alternateDispatcher->getProperties(requestId, in_objectId, opt_in_ownProperties_valueFound ? &opt_in_ownProperties : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr); |
| 5654 | return; |
| 5655 | } |
| 5656 | #endif |
| 5657 | |
| 5658 | ErrorString error; |
| 5659 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5660 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>> out_result; |
| 5661 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::InternalPropertyDescriptor>> out_internalProperties; |
| 5662 | m_agent->getProperties(error, in_objectId, opt_in_ownProperties_valueFound ? &opt_in_ownProperties : nullptr, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, out_result, out_internalProperties); |
| 5663 | |
| 5664 | if (!error.length()) { |
| 5665 | result->setArray("result"_s , out_result); |
| 5666 | if (out_internalProperties) |
| 5667 | result->setArray("internalProperties"_s , out_internalProperties); |
| 5668 | } |
| 5669 | if (!error.length()) |
| 5670 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5671 | else |
| 5672 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5673 | } |
| 5674 | |
| 5675 | void RuntimeBackendDispatcher::getDisplayableProperties(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5676 | { |
| 5677 | String in_objectId = m_backendDispatcher->getString(parameters.get(), "objectId"_s , nullptr); |
| 5678 | bool opt_in_generatePreview_valueFound = false; |
| 5679 | bool opt_in_generatePreview = m_backendDispatcher->getBoolean(parameters.get(), "generatePreview"_s , &opt_in_generatePreview_valueFound); |
| 5680 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5681 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.getDisplayableProperties' can't be processed"_s ); |
| 5682 | return; |
| 5683 | } |
| 5684 | |
| 5685 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5686 | if (m_alternateDispatcher) { |
| 5687 | m_alternateDispatcher->getDisplayableProperties(requestId, in_objectId, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr); |
| 5688 | return; |
| 5689 | } |
| 5690 | #endif |
| 5691 | |
| 5692 | ErrorString error; |
| 5693 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5694 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>> out_properties; |
| 5695 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::InternalPropertyDescriptor>> out_internalProperties; |
| 5696 | m_agent->getDisplayableProperties(error, in_objectId, opt_in_generatePreview_valueFound ? &opt_in_generatePreview : nullptr, out_properties, out_internalProperties); |
| 5697 | |
| 5698 | if (!error.length()) { |
| 5699 | result->setArray("properties"_s , out_properties); |
| 5700 | if (out_internalProperties) |
| 5701 | result->setArray("internalProperties"_s , out_internalProperties); |
| 5702 | } |
| 5703 | if (!error.length()) |
| 5704 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5705 | else |
| 5706 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5707 | } |
| 5708 | |
| 5709 | void RuntimeBackendDispatcher::getCollectionEntries(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5710 | { |
| 5711 | String in_objectId = m_backendDispatcher->getString(parameters.get(), "objectId"_s , nullptr); |
| 5712 | bool opt_in_objectGroup_valueFound = false; |
| 5713 | String opt_in_objectGroup = m_backendDispatcher->getString(parameters.get(), "objectGroup"_s , &opt_in_objectGroup_valueFound); |
| 5714 | bool opt_in_startIndex_valueFound = false; |
| 5715 | int opt_in_startIndex = m_backendDispatcher->getInteger(parameters.get(), "startIndex"_s , &opt_in_startIndex_valueFound); |
| 5716 | bool opt_in_numberToFetch_valueFound = false; |
| 5717 | int opt_in_numberToFetch = m_backendDispatcher->getInteger(parameters.get(), "numberToFetch"_s , &opt_in_numberToFetch_valueFound); |
| 5718 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5719 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.getCollectionEntries' can't be processed"_s ); |
| 5720 | return; |
| 5721 | } |
| 5722 | |
| 5723 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5724 | if (m_alternateDispatcher) { |
| 5725 | m_alternateDispatcher->getCollectionEntries(requestId, in_objectId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, opt_in_startIndex_valueFound ? &opt_in_startIndex : nullptr, opt_in_numberToFetch_valueFound ? &opt_in_numberToFetch : nullptr); |
| 5726 | return; |
| 5727 | } |
| 5728 | #endif |
| 5729 | |
| 5730 | ErrorString error; |
| 5731 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5732 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::CollectionEntry>> out_entries; |
| 5733 | m_agent->getCollectionEntries(error, in_objectId, opt_in_objectGroup_valueFound ? &opt_in_objectGroup : nullptr, opt_in_startIndex_valueFound ? &opt_in_startIndex : nullptr, opt_in_numberToFetch_valueFound ? &opt_in_numberToFetch : nullptr, out_entries); |
| 5734 | |
| 5735 | if (!error.length()) |
| 5736 | result->setArray("entries"_s , out_entries); |
| 5737 | |
| 5738 | if (!error.length()) |
| 5739 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5740 | else |
| 5741 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5742 | } |
| 5743 | |
| 5744 | void RuntimeBackendDispatcher::saveResult(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5745 | { |
| 5746 | RefPtr<JSON::Object> in_value = m_backendDispatcher->getObject(parameters.get(), "value"_s , nullptr); |
| 5747 | bool opt_in_contextId_valueFound = false; |
| 5748 | int opt_in_contextId = m_backendDispatcher->getInteger(parameters.get(), "contextId"_s , &opt_in_contextId_valueFound); |
| 5749 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5750 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.saveResult' can't be processed"_s ); |
| 5751 | return; |
| 5752 | } |
| 5753 | |
| 5754 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5755 | if (m_alternateDispatcher) { |
| 5756 | m_alternateDispatcher->saveResult(requestId, *in_value, opt_in_contextId_valueFound ? &opt_in_contextId : nullptr); |
| 5757 | return; |
| 5758 | } |
| 5759 | #endif |
| 5760 | |
| 5761 | ErrorString error; |
| 5762 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5763 | Optional<int> out_savedResultIndex; |
| 5764 | m_agent->saveResult(error, *in_value, opt_in_contextId_valueFound ? &opt_in_contextId : nullptr, out_savedResultIndex); |
| 5765 | |
| 5766 | if (!error.length()) |
| 5767 | if (out_savedResultIndex.hasValue()) |
| 5768 | result->setInteger("savedResultIndex"_s , *out_savedResultIndex); |
| 5769 | |
| 5770 | if (!error.length()) |
| 5771 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5772 | else |
| 5773 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5774 | } |
| 5775 | |
| 5776 | void RuntimeBackendDispatcher::releaseObject(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5777 | { |
| 5778 | String in_objectId = m_backendDispatcher->getString(parameters.get(), "objectId"_s , nullptr); |
| 5779 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5780 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.releaseObject' can't be processed"_s ); |
| 5781 | return; |
| 5782 | } |
| 5783 | |
| 5784 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5785 | if (m_alternateDispatcher) { |
| 5786 | m_alternateDispatcher->releaseObject(requestId, in_objectId); |
| 5787 | return; |
| 5788 | } |
| 5789 | #endif |
| 5790 | |
| 5791 | ErrorString error; |
| 5792 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5793 | m_agent->releaseObject(error, in_objectId); |
| 5794 | |
| 5795 | if (!error.length()) |
| 5796 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5797 | else |
| 5798 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5799 | } |
| 5800 | |
| 5801 | void RuntimeBackendDispatcher::releaseObjectGroup(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5802 | { |
| 5803 | String in_objectGroup = m_backendDispatcher->getString(parameters.get(), "objectGroup"_s , nullptr); |
| 5804 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5805 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.releaseObjectGroup' can't be processed"_s ); |
| 5806 | return; |
| 5807 | } |
| 5808 | |
| 5809 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5810 | if (m_alternateDispatcher) { |
| 5811 | m_alternateDispatcher->releaseObjectGroup(requestId, in_objectGroup); |
| 5812 | return; |
| 5813 | } |
| 5814 | #endif |
| 5815 | |
| 5816 | ErrorString error; |
| 5817 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5818 | m_agent->releaseObjectGroup(error, in_objectGroup); |
| 5819 | |
| 5820 | if (!error.length()) |
| 5821 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5822 | else |
| 5823 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5824 | } |
| 5825 | |
| 5826 | void RuntimeBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 5827 | { |
| 5828 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5829 | if (m_alternateDispatcher) { |
| 5830 | m_alternateDispatcher->enable(requestId); |
| 5831 | return; |
| 5832 | } |
| 5833 | #endif |
| 5834 | |
| 5835 | ErrorString error; |
| 5836 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5837 | m_agent->enable(error); |
| 5838 | |
| 5839 | if (!error.length()) |
| 5840 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5841 | else |
| 5842 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5843 | } |
| 5844 | |
| 5845 | void RuntimeBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 5846 | { |
| 5847 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5848 | if (m_alternateDispatcher) { |
| 5849 | m_alternateDispatcher->disable(requestId); |
| 5850 | return; |
| 5851 | } |
| 5852 | #endif |
| 5853 | |
| 5854 | ErrorString error; |
| 5855 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5856 | m_agent->disable(error); |
| 5857 | |
| 5858 | if (!error.length()) |
| 5859 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5860 | else |
| 5861 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5862 | } |
| 5863 | |
| 5864 | void RuntimeBackendDispatcher::getRuntimeTypesForVariablesAtOffsets(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5865 | { |
| 5866 | RefPtr<JSON::Array> in_locations = m_backendDispatcher->getArray(parameters.get(), "locations"_s , nullptr); |
| 5867 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5868 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.getRuntimeTypesForVariablesAtOffsets' can't be processed"_s ); |
| 5869 | return; |
| 5870 | } |
| 5871 | |
| 5872 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5873 | if (m_alternateDispatcher) { |
| 5874 | m_alternateDispatcher->getRuntimeTypesForVariablesAtOffsets(requestId, *in_locations); |
| 5875 | return; |
| 5876 | } |
| 5877 | #endif |
| 5878 | |
| 5879 | ErrorString error; |
| 5880 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5881 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::TypeDescription>> out_types; |
| 5882 | m_agent->getRuntimeTypesForVariablesAtOffsets(error, *in_locations, out_types); |
| 5883 | |
| 5884 | if (!error.length()) |
| 5885 | result->setArray("types"_s , out_types); |
| 5886 | |
| 5887 | if (!error.length()) |
| 5888 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5889 | else |
| 5890 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5891 | } |
| 5892 | |
| 5893 | void RuntimeBackendDispatcher::enableTypeProfiler(long requestId, RefPtr<JSON::Object>&&) |
| 5894 | { |
| 5895 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5896 | if (m_alternateDispatcher) { |
| 5897 | m_alternateDispatcher->enableTypeProfiler(requestId); |
| 5898 | return; |
| 5899 | } |
| 5900 | #endif |
| 5901 | |
| 5902 | ErrorString error; |
| 5903 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5904 | m_agent->enableTypeProfiler(error); |
| 5905 | |
| 5906 | if (!error.length()) |
| 5907 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5908 | else |
| 5909 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5910 | } |
| 5911 | |
| 5912 | void RuntimeBackendDispatcher::disableTypeProfiler(long requestId, RefPtr<JSON::Object>&&) |
| 5913 | { |
| 5914 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5915 | if (m_alternateDispatcher) { |
| 5916 | m_alternateDispatcher->disableTypeProfiler(requestId); |
| 5917 | return; |
| 5918 | } |
| 5919 | #endif |
| 5920 | |
| 5921 | ErrorString error; |
| 5922 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5923 | m_agent->disableTypeProfiler(error); |
| 5924 | |
| 5925 | if (!error.length()) |
| 5926 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5927 | else |
| 5928 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5929 | } |
| 5930 | |
| 5931 | void RuntimeBackendDispatcher::enableControlFlowProfiler(long requestId, RefPtr<JSON::Object>&&) |
| 5932 | { |
| 5933 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5934 | if (m_alternateDispatcher) { |
| 5935 | m_alternateDispatcher->enableControlFlowProfiler(requestId); |
| 5936 | return; |
| 5937 | } |
| 5938 | #endif |
| 5939 | |
| 5940 | ErrorString error; |
| 5941 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5942 | m_agent->enableControlFlowProfiler(error); |
| 5943 | |
| 5944 | if (!error.length()) |
| 5945 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5946 | else |
| 5947 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5948 | } |
| 5949 | |
| 5950 | void RuntimeBackendDispatcher::disableControlFlowProfiler(long requestId, RefPtr<JSON::Object>&&) |
| 5951 | { |
| 5952 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5953 | if (m_alternateDispatcher) { |
| 5954 | m_alternateDispatcher->disableControlFlowProfiler(requestId); |
| 5955 | return; |
| 5956 | } |
| 5957 | #endif |
| 5958 | |
| 5959 | ErrorString error; |
| 5960 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5961 | m_agent->disableControlFlowProfiler(error); |
| 5962 | |
| 5963 | if (!error.length()) |
| 5964 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5965 | else |
| 5966 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5967 | } |
| 5968 | |
| 5969 | void RuntimeBackendDispatcher::getBasicBlocks(long requestId, RefPtr<JSON::Object>&& parameters) |
| 5970 | { |
| 5971 | String in_sourceID = m_backendDispatcher->getString(parameters.get(), "sourceID"_s , nullptr); |
| 5972 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 5973 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Runtime.getBasicBlocks' can't be processed"_s ); |
| 5974 | return; |
| 5975 | } |
| 5976 | |
| 5977 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 5978 | if (m_alternateDispatcher) { |
| 5979 | m_alternateDispatcher->getBasicBlocks(requestId, in_sourceID); |
| 5980 | return; |
| 5981 | } |
| 5982 | #endif |
| 5983 | |
| 5984 | ErrorString error; |
| 5985 | Ref<JSON::Object> result = JSON::Object::create(); |
| 5986 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::BasicBlock>> out_basicBlocks; |
| 5987 | m_agent->getBasicBlocks(error, in_sourceID, out_basicBlocks); |
| 5988 | |
| 5989 | if (!error.length()) |
| 5990 | result->setArray("basicBlocks"_s , out_basicBlocks); |
| 5991 | |
| 5992 | if (!error.length()) |
| 5993 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 5994 | else |
| 5995 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 5996 | } |
| 5997 | |
| 5998 | Ref<ScriptProfilerBackendDispatcher> ScriptProfilerBackendDispatcher::create(BackendDispatcher& backendDispatcher, ScriptProfilerBackendDispatcherHandler* agent) |
| 5999 | { |
| 6000 | return adoptRef(*new ScriptProfilerBackendDispatcher(backendDispatcher, agent)); |
| 6001 | } |
| 6002 | |
| 6003 | ScriptProfilerBackendDispatcher::ScriptProfilerBackendDispatcher(BackendDispatcher& backendDispatcher, ScriptProfilerBackendDispatcherHandler* agent) |
| 6004 | : SupplementalBackendDispatcher(backendDispatcher) |
| 6005 | , m_agent(agent) |
| 6006 | { |
| 6007 | m_backendDispatcher->registerDispatcherForDomain("ScriptProfiler"_s , this); |
| 6008 | } |
| 6009 | |
| 6010 | void ScriptProfilerBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 6011 | { |
| 6012 | Ref<ScriptProfilerBackendDispatcher> protect(*this); |
| 6013 | |
| 6014 | RefPtr<JSON::Object> parameters; |
| 6015 | message->getObject("params"_s , parameters); |
| 6016 | |
| 6017 | if (method == "startTracking" ) |
| 6018 | startTracking(requestId, WTFMove(parameters)); |
| 6019 | else if (method == "stopTracking" ) |
| 6020 | stopTracking(requestId, WTFMove(parameters)); |
| 6021 | else |
| 6022 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'ScriptProfiler." + method + "' was not found" ); |
| 6023 | } |
| 6024 | |
| 6025 | void ScriptProfilerBackendDispatcher::startTracking(long requestId, RefPtr<JSON::Object>&& parameters) |
| 6026 | { |
| 6027 | bool opt_in_includeSamples_valueFound = false; |
| 6028 | bool opt_in_includeSamples = m_backendDispatcher->getBoolean(parameters.get(), "includeSamples"_s , &opt_in_includeSamples_valueFound); |
| 6029 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 6030 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'ScriptProfiler.startTracking' can't be processed"_s ); |
| 6031 | return; |
| 6032 | } |
| 6033 | |
| 6034 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6035 | if (m_alternateDispatcher) { |
| 6036 | m_alternateDispatcher->startTracking(requestId, opt_in_includeSamples_valueFound ? &opt_in_includeSamples : nullptr); |
| 6037 | return; |
| 6038 | } |
| 6039 | #endif |
| 6040 | |
| 6041 | ErrorString error; |
| 6042 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6043 | m_agent->startTracking(error, opt_in_includeSamples_valueFound ? &opt_in_includeSamples : nullptr); |
| 6044 | |
| 6045 | if (!error.length()) |
| 6046 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6047 | else |
| 6048 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6049 | } |
| 6050 | |
| 6051 | void ScriptProfilerBackendDispatcher::stopTracking(long requestId, RefPtr<JSON::Object>&&) |
| 6052 | { |
| 6053 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6054 | if (m_alternateDispatcher) { |
| 6055 | m_alternateDispatcher->stopTracking(requestId); |
| 6056 | return; |
| 6057 | } |
| 6058 | #endif |
| 6059 | |
| 6060 | ErrorString error; |
| 6061 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6062 | m_agent->stopTracking(error); |
| 6063 | |
| 6064 | if (!error.length()) |
| 6065 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6066 | else |
| 6067 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6068 | } |
| 6069 | |
| 6070 | Ref<TargetBackendDispatcher> TargetBackendDispatcher::create(BackendDispatcher& backendDispatcher, TargetBackendDispatcherHandler* agent) |
| 6071 | { |
| 6072 | return adoptRef(*new TargetBackendDispatcher(backendDispatcher, agent)); |
| 6073 | } |
| 6074 | |
| 6075 | TargetBackendDispatcher::TargetBackendDispatcher(BackendDispatcher& backendDispatcher, TargetBackendDispatcherHandler* agent) |
| 6076 | : SupplementalBackendDispatcher(backendDispatcher) |
| 6077 | , m_agent(agent) |
| 6078 | { |
| 6079 | m_backendDispatcher->registerDispatcherForDomain("Target"_s , this); |
| 6080 | } |
| 6081 | |
| 6082 | void TargetBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 6083 | { |
| 6084 | Ref<TargetBackendDispatcher> protect(*this); |
| 6085 | |
| 6086 | RefPtr<JSON::Object> parameters; |
| 6087 | message->getObject("params"_s , parameters); |
| 6088 | |
| 6089 | if (method == "exists" ) |
| 6090 | exists(requestId, WTFMove(parameters)); |
| 6091 | else if (method == "sendMessageToTarget" ) |
| 6092 | sendMessageToTarget(requestId, WTFMove(parameters)); |
| 6093 | else |
| 6094 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Target." + method + "' was not found" ); |
| 6095 | } |
| 6096 | |
| 6097 | void TargetBackendDispatcher::exists(long requestId, RefPtr<JSON::Object>&&) |
| 6098 | { |
| 6099 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6100 | if (m_alternateDispatcher) { |
| 6101 | m_alternateDispatcher->exists(requestId); |
| 6102 | return; |
| 6103 | } |
| 6104 | #endif |
| 6105 | |
| 6106 | ErrorString error; |
| 6107 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6108 | m_agent->exists(error); |
| 6109 | |
| 6110 | if (!error.length()) |
| 6111 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6112 | else |
| 6113 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6114 | } |
| 6115 | |
| 6116 | void TargetBackendDispatcher::sendMessageToTarget(long requestId, RefPtr<JSON::Object>&& parameters) |
| 6117 | { |
| 6118 | String in_targetId = m_backendDispatcher->getString(parameters.get(), "targetId"_s , nullptr); |
| 6119 | String in_message = m_backendDispatcher->getString(parameters.get(), "message"_s , nullptr); |
| 6120 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 6121 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Target.sendMessageToTarget' can't be processed"_s ); |
| 6122 | return; |
| 6123 | } |
| 6124 | |
| 6125 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6126 | if (m_alternateDispatcher) { |
| 6127 | m_alternateDispatcher->sendMessageToTarget(requestId, in_targetId, in_message); |
| 6128 | return; |
| 6129 | } |
| 6130 | #endif |
| 6131 | |
| 6132 | ErrorString error; |
| 6133 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6134 | m_agent->sendMessageToTarget(error, in_targetId, in_message); |
| 6135 | |
| 6136 | if (!error.length()) |
| 6137 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6138 | else |
| 6139 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6140 | } |
| 6141 | |
| 6142 | Ref<TimelineBackendDispatcher> TimelineBackendDispatcher::create(BackendDispatcher& backendDispatcher, TimelineBackendDispatcherHandler* agent) |
| 6143 | { |
| 6144 | return adoptRef(*new TimelineBackendDispatcher(backendDispatcher, agent)); |
| 6145 | } |
| 6146 | |
| 6147 | TimelineBackendDispatcher::TimelineBackendDispatcher(BackendDispatcher& backendDispatcher, TimelineBackendDispatcherHandler* agent) |
| 6148 | : SupplementalBackendDispatcher(backendDispatcher) |
| 6149 | , m_agent(agent) |
| 6150 | { |
| 6151 | m_backendDispatcher->registerDispatcherForDomain("Timeline"_s , this); |
| 6152 | } |
| 6153 | |
| 6154 | void TimelineBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 6155 | { |
| 6156 | Ref<TimelineBackendDispatcher> protect(*this); |
| 6157 | |
| 6158 | RefPtr<JSON::Object> parameters; |
| 6159 | message->getObject("params"_s , parameters); |
| 6160 | |
| 6161 | if (method == "start" ) |
| 6162 | start(requestId, WTFMove(parameters)); |
| 6163 | else if (method == "stop" ) |
| 6164 | stop(requestId, WTFMove(parameters)); |
| 6165 | else if (method == "setAutoCaptureEnabled" ) |
| 6166 | setAutoCaptureEnabled(requestId, WTFMove(parameters)); |
| 6167 | else if (method == "setInstruments" ) |
| 6168 | setInstruments(requestId, WTFMove(parameters)); |
| 6169 | else |
| 6170 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Timeline." + method + "' was not found" ); |
| 6171 | } |
| 6172 | |
| 6173 | void TimelineBackendDispatcher::start(long requestId, RefPtr<JSON::Object>&& parameters) |
| 6174 | { |
| 6175 | bool opt_in_maxCallStackDepth_valueFound = false; |
| 6176 | int opt_in_maxCallStackDepth = m_backendDispatcher->getInteger(parameters.get(), "maxCallStackDepth"_s , &opt_in_maxCallStackDepth_valueFound); |
| 6177 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 6178 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Timeline.start' can't be processed"_s ); |
| 6179 | return; |
| 6180 | } |
| 6181 | |
| 6182 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6183 | if (m_alternateDispatcher) { |
| 6184 | m_alternateDispatcher->start(requestId, opt_in_maxCallStackDepth_valueFound ? &opt_in_maxCallStackDepth : nullptr); |
| 6185 | return; |
| 6186 | } |
| 6187 | #endif |
| 6188 | |
| 6189 | ErrorString error; |
| 6190 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6191 | m_agent->start(error, opt_in_maxCallStackDepth_valueFound ? &opt_in_maxCallStackDepth : nullptr); |
| 6192 | |
| 6193 | if (!error.length()) |
| 6194 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6195 | else |
| 6196 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6197 | } |
| 6198 | |
| 6199 | void TimelineBackendDispatcher::stop(long requestId, RefPtr<JSON::Object>&&) |
| 6200 | { |
| 6201 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6202 | if (m_alternateDispatcher) { |
| 6203 | m_alternateDispatcher->stop(requestId); |
| 6204 | return; |
| 6205 | } |
| 6206 | #endif |
| 6207 | |
| 6208 | ErrorString error; |
| 6209 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6210 | m_agent->stop(error); |
| 6211 | |
| 6212 | if (!error.length()) |
| 6213 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6214 | else |
| 6215 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6216 | } |
| 6217 | |
| 6218 | void TimelineBackendDispatcher::setAutoCaptureEnabled(long requestId, RefPtr<JSON::Object>&& parameters) |
| 6219 | { |
| 6220 | bool in_enabled = m_backendDispatcher->getBoolean(parameters.get(), "enabled"_s , nullptr); |
| 6221 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 6222 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Timeline.setAutoCaptureEnabled' can't be processed"_s ); |
| 6223 | return; |
| 6224 | } |
| 6225 | |
| 6226 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6227 | if (m_alternateDispatcher) { |
| 6228 | m_alternateDispatcher->setAutoCaptureEnabled(requestId, in_enabled); |
| 6229 | return; |
| 6230 | } |
| 6231 | #endif |
| 6232 | |
| 6233 | ErrorString error; |
| 6234 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6235 | m_agent->setAutoCaptureEnabled(error, in_enabled); |
| 6236 | |
| 6237 | if (!error.length()) |
| 6238 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6239 | else |
| 6240 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6241 | } |
| 6242 | |
| 6243 | void TimelineBackendDispatcher::setInstruments(long requestId, RefPtr<JSON::Object>&& parameters) |
| 6244 | { |
| 6245 | RefPtr<JSON::Array> in_instruments = m_backendDispatcher->getArray(parameters.get(), "instruments"_s , nullptr); |
| 6246 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 6247 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Timeline.setInstruments' can't be processed"_s ); |
| 6248 | return; |
| 6249 | } |
| 6250 | |
| 6251 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6252 | if (m_alternateDispatcher) { |
| 6253 | m_alternateDispatcher->setInstruments(requestId, *in_instruments); |
| 6254 | return; |
| 6255 | } |
| 6256 | #endif |
| 6257 | |
| 6258 | ErrorString error; |
| 6259 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6260 | m_agent->setInstruments(error, *in_instruments); |
| 6261 | |
| 6262 | if (!error.length()) |
| 6263 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6264 | else |
| 6265 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6266 | } |
| 6267 | |
| 6268 | Ref<WorkerBackendDispatcher> WorkerBackendDispatcher::create(BackendDispatcher& backendDispatcher, WorkerBackendDispatcherHandler* agent) |
| 6269 | { |
| 6270 | return adoptRef(*new WorkerBackendDispatcher(backendDispatcher, agent)); |
| 6271 | } |
| 6272 | |
| 6273 | WorkerBackendDispatcher::WorkerBackendDispatcher(BackendDispatcher& backendDispatcher, WorkerBackendDispatcherHandler* agent) |
| 6274 | : SupplementalBackendDispatcher(backendDispatcher) |
| 6275 | , m_agent(agent) |
| 6276 | { |
| 6277 | m_backendDispatcher->registerDispatcherForDomain("Worker"_s , this); |
| 6278 | } |
| 6279 | |
| 6280 | void WorkerBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
| 6281 | { |
| 6282 | Ref<WorkerBackendDispatcher> protect(*this); |
| 6283 | |
| 6284 | RefPtr<JSON::Object> parameters; |
| 6285 | message->getObject("params"_s , parameters); |
| 6286 | |
| 6287 | if (method == "enable" ) |
| 6288 | enable(requestId, WTFMove(parameters)); |
| 6289 | else if (method == "disable" ) |
| 6290 | disable(requestId, WTFMove(parameters)); |
| 6291 | else if (method == "initialized" ) |
| 6292 | initialized(requestId, WTFMove(parameters)); |
| 6293 | else if (method == "sendMessageToWorker" ) |
| 6294 | sendMessageToWorker(requestId, WTFMove(parameters)); |
| 6295 | else |
| 6296 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Worker." + method + "' was not found" ); |
| 6297 | } |
| 6298 | |
| 6299 | void WorkerBackendDispatcher::enable(long requestId, RefPtr<JSON::Object>&&) |
| 6300 | { |
| 6301 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6302 | if (m_alternateDispatcher) { |
| 6303 | m_alternateDispatcher->enable(requestId); |
| 6304 | return; |
| 6305 | } |
| 6306 | #endif |
| 6307 | |
| 6308 | ErrorString error; |
| 6309 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6310 | m_agent->enable(error); |
| 6311 | |
| 6312 | if (!error.length()) |
| 6313 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6314 | else |
| 6315 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6316 | } |
| 6317 | |
| 6318 | void WorkerBackendDispatcher::disable(long requestId, RefPtr<JSON::Object>&&) |
| 6319 | { |
| 6320 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6321 | if (m_alternateDispatcher) { |
| 6322 | m_alternateDispatcher->disable(requestId); |
| 6323 | return; |
| 6324 | } |
| 6325 | #endif |
| 6326 | |
| 6327 | ErrorString error; |
| 6328 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6329 | m_agent->disable(error); |
| 6330 | |
| 6331 | if (!error.length()) |
| 6332 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6333 | else |
| 6334 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6335 | } |
| 6336 | |
| 6337 | void WorkerBackendDispatcher::initialized(long requestId, RefPtr<JSON::Object>&& parameters) |
| 6338 | { |
| 6339 | String in_workerId = m_backendDispatcher->getString(parameters.get(), "workerId"_s , nullptr); |
| 6340 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 6341 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Worker.initialized' can't be processed"_s ); |
| 6342 | return; |
| 6343 | } |
| 6344 | |
| 6345 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6346 | if (m_alternateDispatcher) { |
| 6347 | m_alternateDispatcher->initialized(requestId, in_workerId); |
| 6348 | return; |
| 6349 | } |
| 6350 | #endif |
| 6351 | |
| 6352 | ErrorString error; |
| 6353 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6354 | m_agent->initialized(error, in_workerId); |
| 6355 | |
| 6356 | if (!error.length()) |
| 6357 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6358 | else |
| 6359 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6360 | } |
| 6361 | |
| 6362 | void WorkerBackendDispatcher::sendMessageToWorker(long requestId, RefPtr<JSON::Object>&& parameters) |
| 6363 | { |
| 6364 | String in_workerId = m_backendDispatcher->getString(parameters.get(), "workerId"_s , nullptr); |
| 6365 | String in_message = m_backendDispatcher->getString(parameters.get(), "message"_s , nullptr); |
| 6366 | if (m_backendDispatcher->hasProtocolErrors()) { |
| 6367 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Worker.sendMessageToWorker' can't be processed"_s ); |
| 6368 | return; |
| 6369 | } |
| 6370 | |
| 6371 | #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) |
| 6372 | if (m_alternateDispatcher) { |
| 6373 | m_alternateDispatcher->sendMessageToWorker(requestId, in_workerId, in_message); |
| 6374 | return; |
| 6375 | } |
| 6376 | #endif |
| 6377 | |
| 6378 | ErrorString error; |
| 6379 | Ref<JSON::Object> result = JSON::Object::create(); |
| 6380 | m_agent->sendMessageToWorker(error, in_workerId, in_message); |
| 6381 | |
| 6382 | if (!error.length()) |
| 6383 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
| 6384 | else |
| 6385 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
| 6386 | } |
| 6387 | |
| 6388 | } // namespace Inspector |
| 6389 | |