diff options
Diffstat (limited to 'chrome/renderer/automation/dom_automation_controller.cc')
-rw-r--r-- | chrome/renderer/automation/dom_automation_controller.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/renderer/automation/dom_automation_controller.cc b/chrome/renderer/automation/dom_automation_controller.cc index 3b7ac43..6c3e8a5 100644 --- a/chrome/renderer/automation/dom_automation_controller.cc +++ b/chrome/renderer/automation/dom_automation_controller.cc @@ -14,6 +14,7 @@ DomAutomationController::DomAutomationController() automation_id_(MSG_ROUTING_NONE) { BindMethod("send", &DomAutomationController::Send); BindMethod("setAutomationId", &DomAutomationController::SetAutomationId); + BindMethod("sendJSON", &DomAutomationController::SendJSON); } void DomAutomationController::Send(const CppArgumentList& args, @@ -86,6 +87,36 @@ void DomAutomationController::Send(const CppArgumentList& args, return; } +void DomAutomationController::SendJSON(const CppArgumentList& args, + CppVariant* result) { + if (args.size() != 1) { + result->SetNull(); + return; + } + + if (automation_id_ == MSG_ROUTING_NONE) { + result->SetNull(); + return; + } + + if (!sender_) { + NOTREACHED(); + result->SetNull(); + return; + } + + if (args[0].type != NPVariantType_String) { + result->SetNull(); + return; + } + + std::string json = args[0].ToString(); + result->Set(sender_->Send( + new ViewHostMsg_DomOperationResponse(routing_id_, json, automation_id_))); + + automation_id_ = MSG_ROUTING_NONE; +} + void DomAutomationController::SetAutomationId( const CppArgumentList& args, CppVariant* result) { if (args.size() != 1) { |