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

Unified Diff: chrome/renderer/extensions/automation_internal_custom_bindings.cc

Issue 2873373005: Add custom action support (Closed)
Patch Set: Migrate to DataObjectBuilder. Created 3 years, 6 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/renderer/extensions/automation_internal_custom_bindings.cc
diff --git a/chrome/renderer/extensions/automation_internal_custom_bindings.cc b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
index ce09ccf05b082f754c313902a1966c4ba8d95778..cb26e431e744906cd2bfd03b4ab865eeb0761616 100644
--- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc
+++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
@@ -694,6 +694,35 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings(
ui::AX_TEXT_STYLE_LINE_THROUGH) != 0;
result.Set(v8::Boolean::New(isolate, value));
});
+ RouteNodeIDFunction(
+ "GetCustomActions",
+ [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
+ TreeCache* cache, ui::AXNode* node) {
+ const std::vector<int32_t>& custom_action_ids =
+ node->data().GetIntListAttribute(ui::AX_ATTR_CUSTOM_ACTION_IDS);
+ if (custom_action_ids.empty()) {
+ result.SetUndefined();
+ return;
+ }
+
+ const std::vector<std::string>& custom_action_descriptions =
+ node->data().GetStringListAttribute(
+ ui::AX_ATTR_CUSTOM_ACTION_DESCRIPTIONS);
+ if (custom_action_ids.size() != custom_action_descriptions.size()) {
+ NOTREACHED();
+ return;
+ }
+
+ v8::Local<v8::Array> custom_actions(
+ v8::Array::New(isolate, custom_action_ids.size()));
+ for (size_t i = 0; i < custom_action_ids.size(); i++) {
+ gin::DataObjectBuilder custom_action(isolate);
+ custom_action.Set("id", custom_action_ids[i]);
+ custom_action.Set("description", custom_action_descriptions[i]);
+ custom_actions->Set(static_cast<uint32_t>(i), custom_action.Build());
+ }
+ result.Set(custom_actions);
+ });
RouteNodeIDFunction("GetChecked", [](v8::Isolate* isolate,
v8::ReturnValue<v8::Value> result,
TreeCache* cache, ui::AXNode* node) {

Powered by Google App Engine
This is Rietveld 408576698