Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: content/browser/devtools/protocol/devtools_protocol_handler_impl.cc

Issue 683733010: NOT FOR COMMIT: Generated code for 642263004 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@singleUse
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/devtools/protocol/devtools_protocol_handler_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/devtools/protocol/devtools_protocol_handler_impl.cc
diff --git a/content/browser/devtools/protocol/devtools_protocol_handler_impl.cc b/content/browser/devtools/protocol/devtools_protocol_handler_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db234846e26516b94dd71513a7bc8426469b9061
--- /dev/null
+++ b/content/browser/devtools/protocol/devtools_protocol_handler_impl.cc
@@ -0,0 +1,1047 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// THIS FILE IS AUTOGENERATED. DO NOT EDIT.
+// Generated by
+// content/public/browser/devtools_protocol_handler_generator.py from
+// third_party/WebKit/Source/devtools/protocol.json
+
+#include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h"
+
+#include "base/bind.h"
+#include "content/browser/devtools/protocol/dom_handler.h"
+#include "content/browser/devtools/protocol/input_handler.h"
+#include "content/browser/devtools/protocol/inspector_handler.h"
+#include "content/browser/devtools/protocol/network_handler.h"
+#include "content/browser/devtools/protocol/page_handler.h"
+#include "content/browser/devtools/protocol/power_handler.h"
+#include "content/browser/devtools/protocol/tracing_handler.h"
+#include "content/browser/devtools/protocol/worker_handler.h"
+
+namespace content {
+
+DevToolsProtocolHandlerImpl::DevToolsProtocolHandlerImpl()
+ : inspector_handler_(nullptr),
+ page_handler_(nullptr),
+ network_handler_(nullptr),
+ dom_handler_(nullptr),
+ worker_handler_(nullptr),
+ input_handler_(nullptr),
+ tracing_handler_(nullptr),
+ power_handler_(nullptr) {
+}
+
+DevToolsProtocolHandlerImpl::~DevToolsProtocolHandlerImpl() {
+}
+
+namespace {
+
+typedef DevToolsProtocolClient::ResponseStatus ResponseStatus;
+
+bool CreateCommonResponse(
+ scoped_refptr<DevToolsProtocol::Command> command,
+ const DevToolsProtocolClient::Response& response,
+ scoped_refptr<DevToolsProtocol::Response>* protocol_response) {
+ switch (response.status()) {
+ case ResponseStatus::RESPONSE_STATUS_FALLTHROUGH:
+ *protocol_response = nullptr;
+ break;
+ case ResponseStatus::RESPONSE_STATUS_OK:
+ return false;
+ case ResponseStatus::RESPONSE_STATUS_INVALID_PARAMS:
+ *protocol_response = command->InvalidParamResponse(response.message());
+ break;
+ case ResponseStatus::RESPONSE_STATUS_INTERNAL_ERROR:
+ *protocol_response = command->InternalErrorResponse(response.message());
+ break;
+ case ResponseStatus::RESPONSE_STATUS_SERVER_ERROR:
+ *protocol_response = command->ServerErrorResponse(response.message());
+ break;
+ }
+ return true;
+}
+
+} // namespace
+
+void DevToolsProtocolHandlerImpl::SetInspectorHandler(
+ devtools::inspector::InspectorHandler* inspector_handler) {
+ DCHECK(!inspector_handler_);
+ inspector_handler_ = inspector_handler;
+ inspector_handler_->SetClient(make_scoped_ptr(
+ new devtools::inspector::Client(
+ base::Bind(&DevToolsProtocolHandlerImpl::SendRawMessage,
+ base::Unretained(this)))));
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageEnable(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ Response response = page_handler_->Enable();
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageDisable(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ Response response = page_handler_->Disable();
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageReload(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ bool in_ignore_cache = false;
+ bool ignore_cache_found = params && params->GetBoolean(
+ "ignoreCache",
+ &in_ignore_cache);
+ std::string in_script_to_evaluate_on_load;
+ bool script_to_evaluate_on_load_found = params && params->GetString(
+ "scriptToEvaluateOnLoad",
+ &in_script_to_evaluate_on_load);
+ std::string in_script_preprocessor;
+ bool script_preprocessor_found = params && params->GetString(
+ "scriptPreprocessor",
+ &in_script_preprocessor);
+ Response response = page_handler_->Reload(
+ ignore_cache_found ? &in_ignore_cache : nullptr,
+ script_to_evaluate_on_load_found ? &in_script_to_evaluate_on_load : nullptr,
+ script_preprocessor_found ? &in_script_preprocessor : nullptr);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageNavigate(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ std::string in_url;
+ if (!params || !params->GetString("url", &in_url))
+ return command->InvalidParamResponse("url");
+ devtools::page::FrameId out_frame_id;
+ Response response = page_handler_->Navigate(
+ in_url,
+ &out_frame_id);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ result->SetString("frameId", out_frame_id);
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageGetNavigationHistory(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ int out_current_index = 0;
+ devtools::ListBuilder<devtools::page::NavigationEntry> out_entries;
+ Response response = page_handler_->GetNavigationHistory(
+ &out_current_index,
+ &out_entries);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ result->SetInteger("currentIndex", out_current_index);
+ result->Set("entries",
+ devtools::ListBuilder<devtools::page::NavigationEntry>::ToValue(out_entries.Pass()).release());
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageNavigateToHistoryEntry(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ int in_entry_id = 0;
+ if (!params || !params->GetInteger("entryId", &in_entry_id))
+ return command->InvalidParamResponse("entryId");
+ Response response = page_handler_->NavigateToHistoryEntry(
+ in_entry_id);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageSetGeolocationOverride(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ double in_latitude = 0.0;
+ bool latitude_found = params && params->GetDouble(
+ "latitude",
+ &in_latitude);
+ double in_longitude = 0.0;
+ bool longitude_found = params && params->GetDouble(
+ "longitude",
+ &in_longitude);
+ double in_accuracy = 0.0;
+ bool accuracy_found = params && params->GetDouble(
+ "accuracy",
+ &in_accuracy);
+ Response response = page_handler_->SetGeolocationOverride(
+ latitude_found ? &in_latitude : nullptr,
+ longitude_found ? &in_longitude : nullptr,
+ accuracy_found ? &in_accuracy : nullptr);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageClearGeolocationOverride(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ Response response = page_handler_->ClearGeolocationOverride();
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageSetTouchEmulationEnabled(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ bool in_enabled = false;
+ if (!params || !params->GetBoolean("enabled", &in_enabled))
+ return command->InvalidParamResponse("enabled");
+ Response response = page_handler_->SetTouchEmulationEnabled(
+ in_enabled);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageCaptureScreenshot(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ return page_handler_->CaptureScreenshot(
+ command);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageCanScreencast(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ bool out_result = false;
+ Response response = page_handler_->CanScreencast(
+ &out_result);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ result->SetBoolean("result", out_result);
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageCanEmulate(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ bool out_result = false;
+ Response response = page_handler_->CanEmulate(
+ &out_result);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ result->SetBoolean("result", out_result);
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageStartScreencast(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ std::string in_format;
+ bool format_found = params && params->GetString(
+ "format",
+ &in_format);
+ int in_quality = 0;
+ bool quality_found = params && params->GetInteger(
+ "quality",
+ &in_quality);
+ int in_max_width = 0;
+ bool max_width_found = params && params->GetInteger(
+ "maxWidth",
+ &in_max_width);
+ int in_max_height = 0;
+ bool max_height_found = params && params->GetInteger(
+ "maxHeight",
+ &in_max_height);
+ Response response = page_handler_->StartScreencast(
+ format_found ? &in_format : nullptr,
+ quality_found ? &in_quality : nullptr,
+ max_width_found ? &in_max_width : nullptr,
+ max_height_found ? &in_max_height : nullptr);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageStopScreencast(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ Response response = page_handler_->StopScreencast();
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageHandleJavaScriptDialog(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ bool in_accept = false;
+ if (!params || !params->GetBoolean("accept", &in_accept))
+ return command->InvalidParamResponse("accept");
+ std::string in_prompt_text;
+ bool prompt_text_found = params && params->GetString(
+ "promptText",
+ &in_prompt_text);
+ Response response = page_handler_->HandleJavaScriptDialog(
+ in_accept,
+ prompt_text_found ? &in_prompt_text : nullptr);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageQueryUsageAndQuota(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ std::string in_security_origin;
+ if (!params || !params->GetString("securityOrigin", &in_security_origin))
+ return command->InvalidParamResponse("securityOrigin");
+ return page_handler_->QueryUsageAndQuota(
+ in_security_origin,
+ command);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPageSetColorPickerEnabled(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ bool in_enabled = false;
+ if (!params || !params->GetBoolean("enabled", &in_enabled))
+ return command->InvalidParamResponse("enabled");
+ Response response = page_handler_->SetColorPickerEnabled(
+ in_enabled);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+void DevToolsProtocolHandlerImpl::SetPageHandler(
+ devtools::page::PageHandler* page_handler) {
+ DCHECK(!page_handler_);
+ page_handler_ = page_handler;
+ RegisterCommandHandler(
+ "Page.enable",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageEnable,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.disable",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageDisable,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.reload",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageReload,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.navigate",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageNavigate,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.getNavigationHistory",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageGetNavigationHistory,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.navigateToHistoryEntry",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageNavigateToHistoryEntry,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.setGeolocationOverride",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageSetGeolocationOverride,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.clearGeolocationOverride",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageClearGeolocationOverride,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.setTouchEmulationEnabled",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageSetTouchEmulationEnabled,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.captureScreenshot",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageCaptureScreenshot,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.canScreencast",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageCanScreencast,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.canEmulate",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageCanEmulate,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.startScreencast",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageStartScreencast,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.stopScreencast",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageStopScreencast,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.handleJavaScriptDialog",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageHandleJavaScriptDialog,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.queryUsageAndQuota",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageQueryUsageAndQuota,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Page.setColorPickerEnabled",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPageSetColorPickerEnabled,
+ base::Unretained(this)));
+ page_handler_->SetClient(make_scoped_ptr(
+ new devtools::page::Client(
+ base::Bind(&DevToolsProtocolHandlerImpl::SendRawMessage,
+ base::Unretained(this)))));
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnNetworkClearBrowserCache(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ Response response = network_handler_->ClearBrowserCache();
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnNetworkClearBrowserCookies(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ Response response = network_handler_->ClearBrowserCookies();
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnNetworkCanEmulateNetworkConditions(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ bool out_result = false;
+ Response response = network_handler_->CanEmulateNetworkConditions(
+ &out_result);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ result->SetBoolean("result", out_result);
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnNetworkEmulateNetworkConditions(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ bool in_offline = false;
+ if (!params || !params->GetBoolean("offline", &in_offline))
+ return command->InvalidParamResponse("offline");
+ double in_latency = 0.0;
+ if (!params || !params->GetDouble("latency", &in_latency))
+ return command->InvalidParamResponse("latency");
+ double in_download_throughput = 0.0;
+ if (!params || !params->GetDouble("downloadThroughput", &in_download_throughput))
+ return command->InvalidParamResponse("downloadThroughput");
+ double in_upload_throughput = 0.0;
+ if (!params || !params->GetDouble("uploadThroughput", &in_upload_throughput))
+ return command->InvalidParamResponse("uploadThroughput");
+ Response response = network_handler_->EmulateNetworkConditions(
+ in_offline,
+ in_latency,
+ in_download_throughput,
+ in_upload_throughput);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+void DevToolsProtocolHandlerImpl::SetNetworkHandler(
+ devtools::network::NetworkHandler* network_handler) {
+ DCHECK(!network_handler_);
+ network_handler_ = network_handler;
+ RegisterCommandHandler(
+ "Network.clearBrowserCache",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnNetworkClearBrowserCache,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Network.clearBrowserCookies",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnNetworkClearBrowserCookies,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Network.canEmulateNetworkConditions",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnNetworkCanEmulateNetworkConditions,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Network.emulateNetworkConditions",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnNetworkEmulateNetworkConditions,
+ base::Unretained(this)));
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnDOMSetFileInputFiles(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ int in_node_id = 0;
+ if (!params || !params->GetInteger("nodeId", &in_node_id))
+ return command->InvalidParamResponse("nodeId");
+ base::ListValue* list_files = nullptr;
+ if (!params || !params->GetList("files", &list_files))
+ return command->InvalidParamResponse("files");
+ std::vector<std::string> in_files;
+ for (base::ListValue::const_iterator it =
+ list_files->begin(); it != list_files->end(); ++it) {
+ std::string item;
+ if (!(*it)->GetAsString(&item))
+ return command->InvalidParamResponse("files");
+ in_files.push_back(item);
+ }
+ Response response = dom_handler_->SetFileInputFiles(
+ in_node_id,
+ in_files);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+void DevToolsProtocolHandlerImpl::SetDOMHandler(
+ devtools::dom::DOMHandler* dom_handler) {
+ DCHECK(!dom_handler_);
+ dom_handler_ = dom_handler;
+ RegisterCommandHandler(
+ "DOM.setFileInputFiles",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnDOMSetFileInputFiles,
+ base::Unretained(this)));
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnWorkerDisconnectFromWorker(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ int in_worker_id = 0;
+ if (!params || !params->GetInteger("workerId", &in_worker_id))
+ return command->InvalidParamResponse("workerId");
+ Response response = worker_handler_->DisconnectFromWorker(
+ in_worker_id);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+void DevToolsProtocolHandlerImpl::SetWorkerHandler(
+ devtools::worker::WorkerHandler* worker_handler) {
+ DCHECK(!worker_handler_);
+ worker_handler_ = worker_handler;
+ RegisterCommandHandler(
+ "Worker.disconnectFromWorker",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnWorkerDisconnectFromWorker,
+ base::Unretained(this)));
+ worker_handler_->SetClient(make_scoped_ptr(
+ new devtools::worker::Client(
+ base::Bind(&DevToolsProtocolHandlerImpl::SendRawMessage,
+ base::Unretained(this)))));
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnInputEmulateTouchFromMouseEvent(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ std::string in_type;
+ if (!params || !params->GetString("type", &in_type))
+ return command->InvalidParamResponse("type");
+ int in_x = 0;
+ if (!params || !params->GetInteger("x", &in_x))
+ return command->InvalidParamResponse("x");
+ int in_y = 0;
+ if (!params || !params->GetInteger("y", &in_y))
+ return command->InvalidParamResponse("y");
+ double in_timestamp = 0.0;
+ if (!params || !params->GetDouble("timestamp", &in_timestamp))
+ return command->InvalidParamResponse("timestamp");
+ std::string in_button;
+ if (!params || !params->GetString("button", &in_button))
+ return command->InvalidParamResponse("button");
+ double in_delta_x = 0.0;
+ bool delta_x_found = params && params->GetDouble(
+ "deltaX",
+ &in_delta_x);
+ double in_delta_y = 0.0;
+ bool delta_y_found = params && params->GetDouble(
+ "deltaY",
+ &in_delta_y);
+ int in_modifiers = 0;
+ bool modifiers_found = params && params->GetInteger(
+ "modifiers",
+ &in_modifiers);
+ int in_click_count = 0;
+ bool click_count_found = params && params->GetInteger(
+ "clickCount",
+ &in_click_count);
+ Response response = input_handler_->EmulateTouchFromMouseEvent(
+ in_type,
+ in_x,
+ in_y,
+ in_timestamp,
+ in_button,
+ delta_x_found ? &in_delta_x : nullptr,
+ delta_y_found ? &in_delta_y : nullptr,
+ modifiers_found ? &in_modifiers : nullptr,
+ click_count_found ? &in_click_count : nullptr);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+void DevToolsProtocolHandlerImpl::SetInputHandler(
+ devtools::input::InputHandler* input_handler) {
+ DCHECK(!input_handler_);
+ input_handler_ = input_handler;
+ RegisterCommandHandler(
+ "Input.emulateTouchFromMouseEvent",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnInputEmulateTouchFromMouseEvent,
+ base::Unretained(this)));
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnTracingStart(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ base::DictionaryValue* params = command->params();
+ std::string in_categories;
+ bool categories_found = params && params->GetString(
+ "categories",
+ &in_categories);
+ std::string in_options;
+ bool options_found = params && params->GetString(
+ "options",
+ &in_options);
+ double in_buffer_usage_reporting_interval = 0.0;
+ bool buffer_usage_reporting_interval_found = params && params->GetDouble(
+ "bufferUsageReportingInterval",
+ &in_buffer_usage_reporting_interval);
+ return tracing_handler_->Start(
+ categories_found ? &in_categories : nullptr,
+ options_found ? &in_options : nullptr,
+ buffer_usage_reporting_interval_found ? &in_buffer_usage_reporting_interval : nullptr,
+ command);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnTracingEnd(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ return tracing_handler_->End(
+ command);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnTracingGetCategories(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ return tracing_handler_->GetCategories(
+ command);
+}
+
+void DevToolsProtocolHandlerImpl::SetTracingHandler(
+ devtools::tracing::TracingHandler* tracing_handler) {
+ DCHECK(!tracing_handler_);
+ tracing_handler_ = tracing_handler;
+ RegisterCommandHandler(
+ "Tracing.start",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnTracingStart,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Tracing.end",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnTracingEnd,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Tracing.getCategories",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnTracingGetCategories,
+ base::Unretained(this)));
+ tracing_handler_->SetClient(make_scoped_ptr(
+ new devtools::tracing::Client(
+ base::Bind(&DevToolsProtocolHandlerImpl::SendRawMessage,
+ base::Unretained(this)))));
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPowerStart(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ Response response = power_handler_->Start();
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPowerEnd(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ Response response = power_handler_->End();
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPowerCanProfilePower(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ bool out_result = false;
+ Response response = power_handler_->CanProfilePower(
+ &out_result);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ result->SetBoolean("result", out_result);
+ return command->SuccessResponse(result);
+}
+
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocolHandlerImpl::OnPowerGetAccuracyLevel(
+ scoped_refptr<DevToolsProtocol::Command> command) {
+ std::string out_result;
+ Response response = power_handler_->GetAccuracyLevel(
+ &out_result);
+ scoped_refptr<DevToolsProtocol::Response> protocol_response;
+ if (CreateCommonResponse(command, response, &protocol_response))
+ return protocol_response;
+ base::DictionaryValue* result = new base::DictionaryValue();
+ result->SetString("result", out_result);
+ return command->SuccessResponse(result);
+}
+
+void DevToolsProtocolHandlerImpl::SetPowerHandler(
+ devtools::power::PowerHandler* power_handler) {
+ DCHECK(!power_handler_);
+ power_handler_ = power_handler;
+ RegisterCommandHandler(
+ "Power.start",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPowerStart,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Power.end",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPowerEnd,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Power.canProfilePower",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPowerCanProfilePower,
+ base::Unretained(this)));
+ RegisterCommandHandler(
+ "Power.getAccuracyLevel",
+ base::Bind(
+ &DevToolsProtocolHandlerImpl::OnPowerGetAccuracyLevel,
+ base::Unretained(this)));
+ power_handler_->SetClient(make_scoped_ptr(
+ new devtools::power::Client(
+ base::Bind(&DevToolsProtocolHandlerImpl::SendRawMessage,
+ base::Unretained(this)))));
+}
+
+namespace devtools {
+
+ListBuilderBase::ListBuilderBase()
+ : list_(new base::ListValue) {
+}
+
+ListBuilderBase::ListBuilderBase(scoped_ptr<base::ListValue> list)
+ : list_(list.Pass()) {
+}
+
+// static
+scoped_ptr<base::ListValue> ListBuilderBase::ToValue(
+ ListBuilderBase src) {
+ return src.list_.Pass();
+}
+
+namespace inspector {
+
+Client::Client(const RawMessageCallback& raw_message_callback)
+ : DevToolsProtocolClient(raw_message_callback) {
+}
+
+Client::~Client() {
+}
+
+void Client::Detached(
+ DetachedParams params) {
+ SendNotification("Inspector.detached",
+ DetachedParams::ToValue(params.Pass()).Pass());
+}
+
+void Client::TargetCrashed(
+ TargetCrashedParams params) {
+ SendNotification("Inspector.targetCrashed",
+ TargetCrashedParams::ToValue(params.Pass()).Pass());
+}
+
+} // namespace inspector
+
+namespace page {
+namespace start_screencast {
+const char kFormatJpeg[] = "jpeg";
+const char kFormatPng[] = "png";
+} // namespace start_screencast
+} // namespace page
+
+namespace page {
+namespace usage_item {
+const char kIdFilesystem[] = "filesystem";
+const char kIdDatabase[] = "database";
+const char kIdAppcache[] = "appcache";
+const char kIdIndexeddatabase[] = "indexeddatabase";
+} // namespace usage_item
+} // namespace page
+
+namespace page {
+
+Client::Client(const RawMessageCallback& raw_message_callback)
+ : DevToolsProtocolClient(raw_message_callback) {
+}
+
+Client::~Client() {
+}
+
+void Client::SendCaptureScreenshotResponse(
+ scoped_refptr<DevToolsProtocol::Command> command,
+ CaptureScreenshotResponse params) {
+ SendAsyncResponse(
+ command->SuccessResponse(
+ CaptureScreenshotResponse::ToValue(params.Pass()).release()));
+}
+
+void Client::SendQueryUsageAndQuotaResponse(
+ scoped_refptr<DevToolsProtocol::Command> command,
+ QueryUsageAndQuotaResponse params) {
+ SendAsyncResponse(
+ command->SuccessResponse(
+ QueryUsageAndQuotaResponse::ToValue(params.Pass()).release()));
+}
+
+void Client::ScreencastFrame(
+ ScreencastFrameParams params) {
+ SendNotification("Page.screencastFrame",
+ ScreencastFrameParams::ToValue(params.Pass()).Pass());
+}
+
+void Client::ScreencastVisibilityChanged(
+ ScreencastVisibilityChangedParams params) {
+ SendNotification("Page.screencastVisibilityChanged",
+ ScreencastVisibilityChangedParams::ToValue(params.Pass()).Pass());
+}
+
+void Client::ColorPicked(
+ ColorPickedParams params) {
+ SendNotification("Page.colorPicked",
+ ColorPickedParams::ToValue(params.Pass()).Pass());
+}
+
+void Client::InterstitialShown(
+ InterstitialShownParams params) {
+ SendNotification("Page.interstitialShown",
+ InterstitialShownParams::ToValue(params.Pass()).Pass());
+}
+
+void Client::InterstitialHidden(
+ InterstitialHiddenParams params) {
+ SendNotification("Page.interstitialHidden",
+ InterstitialHiddenParams::ToValue(params.Pass()).Pass());
+}
+
+} // namespace page
+
+namespace worker {
+
+Client::Client(const RawMessageCallback& raw_message_callback)
+ : DevToolsProtocolClient(raw_message_callback) {
+}
+
+Client::~Client() {
+}
+
+void Client::DisconnectedFromWorker(
+ DisconnectedFromWorkerParams params) {
+ SendNotification("Worker.disconnectedFromWorker",
+ DisconnectedFromWorkerParams::ToValue(params.Pass()).Pass());
+}
+
+} // namespace worker
+
+namespace input {
+namespace emulate_touch_from_mouse_event {
+const char kTypeMousePressed[] = "mousePressed";
+const char kTypeMouseReleased[] = "mouseReleased";
+const char kTypeMouseMoved[] = "mouseMoved";
+const char kTypeMouseWheel[] = "mouseWheel";
+} // namespace emulate_touch_from_mouse_event
+} // namespace input
+
+namespace input {
+namespace emulate_touch_from_mouse_event {
+const char kButtonNone[] = "none";
+const char kButtonLeft[] = "left";
+const char kButtonMiddle[] = "middle";
+const char kButtonRight[] = "right";
+} // namespace emulate_touch_from_mouse_event
+} // namespace input
+
+namespace tracing {
+
+Client::Client(const RawMessageCallback& raw_message_callback)
+ : DevToolsProtocolClient(raw_message_callback) {
+}
+
+Client::~Client() {
+}
+
+void Client::SendStartResponse(
+ scoped_refptr<DevToolsProtocol::Command> command,
+ StartResponse params) {
+ SendAsyncResponse(
+ command->SuccessResponse(
+ StartResponse::ToValue(params.Pass()).release()));
+}
+
+void Client::SendEndResponse(
+ scoped_refptr<DevToolsProtocol::Command> command,
+ EndResponse params) {
+ SendAsyncResponse(
+ command->SuccessResponse(
+ EndResponse::ToValue(params.Pass()).release()));
+}
+
+void Client::SendGetCategoriesResponse(
+ scoped_refptr<DevToolsProtocol::Command> command,
+ GetCategoriesResponse params) {
+ SendAsyncResponse(
+ command->SuccessResponse(
+ GetCategoriesResponse::ToValue(params.Pass()).release()));
+}
+
+void Client::DataCollected(
+ DataCollectedParams params) {
+ SendNotification("Tracing.dataCollected",
+ DataCollectedParams::ToValue(params.Pass()).Pass());
+}
+
+void Client::TracingComplete(
+ TracingCompleteParams params) {
+ SendNotification("Tracing.tracingComplete",
+ TracingCompleteParams::ToValue(params.Pass()).Pass());
+}
+
+void Client::BufferUsage(
+ BufferUsageParams params) {
+ SendNotification("Tracing.bufferUsage",
+ BufferUsageParams::ToValue(params.Pass()).Pass());
+}
+
+} // namespace tracing
+
+namespace power {
+namespace get_accuracy_level {
+const char kResultHigh[] = "high";
+const char kResultModerate[] = "moderate";
+const char kResultLow[] = "low";
+} // namespace get_accuracy_level
+} // namespace power
+
+namespace power {
+
+Client::Client(const RawMessageCallback& raw_message_callback)
+ : DevToolsProtocolClient(raw_message_callback) {
+}
+
+Client::~Client() {
+}
+
+void Client::DataAvailable(
+ DataAvailableParams params) {
+ SendNotification("Power.dataAvailable",
+ DataAvailableParams::ToValue(params.Pass()).Pass());
+}
+
+} // namespace power
+
+} // namespace devtools
+
+} // namespace content
« no previous file with comments | « content/browser/devtools/protocol/devtools_protocol_handler_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698