 Chromium Code Reviews
 Chromium Code Reviews Issue 2873373005:
  Add custom action support  (Closed)
    
  
    Issue 2873373005:
  Add custom action support  (Closed) 
  | 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 9241f859718a90edfbbbf968647db336ae95b772..17db8342e3de336e911115705720acfbc46d6a49 100644 | 
| --- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc | 
| +++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc | 
| @@ -739,6 +739,38 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( | 
| std::string name_from_str = ui::ToString(name_from); | 
| result.Set(v8::String::NewFromUtf8(isolate, name_from_str.c_str())); | 
| }); | 
| + 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()) { | 
| + result.SetUndefined(); | 
| 
David Tseng
2017/05/16 22:33:23
I would actually NOTREACHED here.
 
yawano
2017/06/02 09:02:38
Done.
 | 
| + 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++) { | 
| + v8::Local<v8::Object> custom_action(v8::Object::New(isolate)); | 
| + SafeSetV8Property(isolate, custom_action, "id", | 
| + v8::Integer::New(isolate, custom_action_ids[i])); | 
| + SafeSetV8Property(isolate, custom_action, "description", | 
| + v8::String::NewFromUtf8( | 
| + isolate, custom_action_descriptions[i].c_str())); | 
| + custom_actions->Set(static_cast<uint32_t>(i), custom_action); | 
| + } | 
| + result.Set(custom_actions); | 
| + }); | 
| RouteNodeIDFunction("GetChecked", [](v8::Isolate* isolate, | 
| v8::ReturnValue<v8::Value> result, | 
| TreeCache* cache, ui::AXNode* node) { |