summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/renderer/dom_automation_controller.cc25
-rw-r--r--content/renderer/dom_automation_controller.h8
2 files changed, 33 insertions, 0 deletions
diff --git a/content/renderer/dom_automation_controller.cc b/content/renderer/dom_automation_controller.cc
index 0955a6a..85e2fcd 100644
--- a/content/renderer/dom_automation_controller.cc
+++ b/content/renderer/dom_automation_controller.cc
@@ -21,6 +21,8 @@ DomAutomationController::DomAutomationController()
base::Unretained(this)));
BindCallback("sendJSON", base::Bind(&DomAutomationController::SendJSON,
base::Unretained(this)));
+ BindCallback("sendWithId", base::Bind(&DomAutomationController::SendWithId,
+ base::Unretained(this)));
}
void DomAutomationController::Send(const CppArgumentList& args,
@@ -121,6 +123,29 @@ void DomAutomationController::SendJSON(const CppArgumentList& args,
automation_id_ = MSG_ROUTING_NONE;
}
+void DomAutomationController::SendWithId(const CppArgumentList& args,
+ CppVariant* result) {
+ if (args.size() != 2) {
+ result->SetNull();
+ return;
+ }
+
+ if (!sender_) {
+ NOTREACHED();
+ result->SetNull();
+ return;
+ }
+
+ if (!args[0].isNumber() || args[1].type != NPVariantType_String) {
+ result->SetNull();
+ return;
+ }
+
+ result->Set(sender_->Send(
+ new ViewHostMsg_DomOperationResponse(routing_id_, args[1].ToString(),
+ args[0].ToInt32())));
+}
+
void DomAutomationController::SetAutomationId(
const CppArgumentList& args, CppVariant* result) {
if (args.size() != 1) {
diff --git a/content/renderer/dom_automation_controller.h b/content/renderer/dom_automation_controller.h
index 576e09d..f1b06f4 100644
--- a/content/renderer/dom_automation_controller.h
+++ b/content/renderer/dom_automation_controller.h
@@ -90,6 +90,14 @@ class DomAutomationController : public CppBoundClass {
// This function does not modify/escape the returned string in any way.
void SendJSON(const CppArgumentList& args, CppVariant* result);
+ // Sends a string with a provided Automation Id.
+ // Expects two javascript values; the first must be a number type and will be
+ // used as the Automation Id, the second must be of type NPString.
+ // The function returns true/false to the javascript based on the success
+ // of the send over IPC. It sets the javascript return value to null on
+ // unexpected errors or arguments.
+ void SendWithId(const CppArgumentList& args, CppVariant* result);
+
void SetAutomationId(const CppArgumentList& args, CppVariant* result);
// TODO(vibhor): Implement later