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

Unified Diff: chrome/browser/extensions/api/automation_internal/automation_internal_api.cc

Issue 203753002: Implement actions for Automation API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lots of style cleanup. Created 6 years, 9 months 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
Index: chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
diff --git a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
index f48c91b5640360699270b7d8f10f71c0eeb45d8e..5f542e3cbc026e0f22dba8ac38707b86be486cbb 100644
--- a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
+++ b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
@@ -18,8 +18,10 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
+#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/event_router.h"
@@ -73,14 +75,17 @@ class AutomationWebContentsObserver
for (; iter != details.end(); iter++) {
scoped_ptr<base::ListValue> args(new base::ListValue());
const content::AXEventNotificationDetails& event = *iter;
+ int process_id = event.process_id;
int routing_id = event.routing_id;
base::DictionaryValue* axTreeUpdate = new base::DictionaryValue();
// TODO(dtseng): These strings should be auto-generated by the IDL
// compiler.
- axTreeUpdate->Set("routing_id",
+ axTreeUpdate->Set("processID",
+ base::Value::CreateIntegerValue(process_id));
+ axTreeUpdate->Set("routingID",
base::Value::CreateIntegerValue(routing_id));
- axTreeUpdate->SetString("event_type", ToString(iter->event_type));
+ axTreeUpdate->SetString("eventType", ToString(iter->event_type));
not at google - send to devlin 2014/04/03 18:57:13 you should be able to construct these arguments wi
aboxhall 2014/04/03 19:06:31 This seems outside of scope for this change.
not at google - send to devlin 2014/04/03 19:08:02 fair enough.
David Tseng 2014/04/03 23:05:19 I have this pretty much ready for am putting it of
not at google - send to devlin 2014/04/04 16:30:57 You're saying that with the current code you go a
David Tseng 2014/04/04 17:02:26 Correct. Yes I think that's true, and if
base::ListValue* nodes = new base::ListValue();
axTreeUpdate->Set("nodes", nodes);
for (size_t i = 0; i < event.nodes.size(); i++) {
@@ -126,7 +131,7 @@ class AutomationWebContentsObserver
std::pair<ui::AXBoolAttribute, bool> attr = node.bool_attributes[i];
bool_attributes->SetBoolean(ToString(attr.first), attr.second);
}
- axNodeData->Set("bool_attributes", bool_attributes);
+ axNodeData->Set("boolAttributes", bool_attributes);
}
if (!node.float_attributes.empty()) {
@@ -135,7 +140,7 @@ class AutomationWebContentsObserver
std::pair<ui::AXFloatAttribute, float> attr = node.float_attributes[i];
float_attributes->SetDouble(ToString(attr.first), attr.second);
}
- axNodeData->Set("float_attributes", float_attributes);
+ axNodeData->Set("floatAttributes", float_attributes);
}
if (!node.html_attributes.empty()) {
@@ -144,7 +149,7 @@ class AutomationWebContentsObserver
std::pair<std::string, std::string> attr = node.html_attributes[i];
html_attributes->SetString(attr.first, attr.second);
}
- axNodeData->Set("html_attributes", html_attributes);
+ axNodeData->Set("htmlAttributes", html_attributes);
}
if (!node.int_attributes.empty()) {
@@ -153,7 +158,7 @@ class AutomationWebContentsObserver
std::pair<ui::AXIntAttribute, int> attr = node.int_attributes[i];
int_attributes->SetInteger(ToString(attr.first), attr.second);
}
- axNodeData->Set("int_attributes", int_attributes);
+ axNodeData->Set("intAttributes", int_attributes);
}
if (!node.intlist_attributes.empty()) {
@@ -166,7 +171,7 @@ class AutomationWebContentsObserver
intlist->AppendInteger(attr.second[j]);
intlist_attributes->Set(ToString(attr.first), intlist);
}
- axNodeData->Set("intlist_attributes", intlist_attributes);
+ axNodeData->Set("intlistAttributes", intlist_attributes);
}
if (!node.string_attributes.empty()) {
@@ -176,14 +181,14 @@ class AutomationWebContentsObserver
node.string_attributes[i];
string_attributes->SetString(ToString(attr.first), attr.second);
}
- axNodeData->Set("string_attributes", string_attributes);
+ axNodeData->Set("stringAttributes", string_attributes);
}
base::ListValue* child_ids = new base::ListValue();
for (size_t i = 0; i < node.child_ids.size(); ++i) {
child_ids->AppendInteger(node.child_ids[i]);
}
- axNodeData->Set("child_ids", child_ids);
+ axNodeData->Set("childIDs", child_ids);
nodes->Append(axNodeData);
}
@@ -219,10 +224,46 @@ bool AutomationInternalEnableCurrentTabFunction::RunImpl() {
rwh->EnableTreeOnlyAccessibilityMode();
results_ = api::automation_internal::EnableCurrentTab::Results::Create(
- rwh->GetRoutingID());
+ rwh->GetProcess()->GetID(), rwh->GetRoutingID());
SendResponse(true);
return true;
}
+bool AutomationInternalPerformActionFunction::RunImpl() {
+ using api::automation_internal::PerformAction::Params;
+ scoped_ptr<Params> params(Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ content::RenderWidgetHost* rwh =
+ content::RenderWidgetHost::FromID(params->args.process_id,
+ params->args.routing_id);
+
+ switch (params->args.action_type) {
+ case api::automation_internal::ACTION_TYPE_DO_DEFAULT:
+ rwh->AccessibilityDoDefaultAction(params->args.automation_node_id);
+ break;
+ case api::automation_internal::ACTION_TYPE_FOCUS:
+ rwh->AccessibilitySetFocus(params->args.automation_node_id);
+ break;
+ case api::automation_internal::ACTION_TYPE_MAKE_VISIBLE:
+ rwh->AccessibilityScrollToMakeVisible(params->args.automation_node_id,
+ gfx::Rect());
+ break;
+ case api::automation_internal::ACTION_TYPE_SET_SELECTION: {
+ extensions::api::automation_internal::SetSelectionParams selection_params;
+ EXTENSION_FUNCTION_VALIDATE(
+ extensions::api::automation_internal::SetSelectionParams::Populate(
+ params->opt_args.additional_properties, &selection_params));
+ rwh->AccessibilitySetTextSelection(params->args.automation_node_id,
+ selection_params.start_index,
+ selection_params.end_index);
+ break;
+ }
+ default:
+ NOTREACHED();
+ }
+ return true;
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698