Chromium Code Reviews| Index: chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc |
| diff --git a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc |
| index bd69baf4d4a8853c389ae6e41e323d1c4a4ee855..37b1fe0293408abbf3393838e0998ffb511b3ee2 100644 |
| --- a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc |
| +++ b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc |
| @@ -115,6 +115,34 @@ bool GetStringProperty(arc::mojom::AccessibilityNodeInfoData* node, |
| return true; |
| } |
| +bool GetIntListProperty(arc::mojom::AccessibilityNodeInfoData* node, |
| + arc::mojom::AccessibilityIntListProperty prop, |
| + std::vector<int32_t>* out_value) { |
| + if (!node->int_list_properties) |
| + return false; |
| + |
| + auto it = node->int_list_properties->find(prop); |
| + if (it == node->int_list_properties->end()) |
| + return false; |
| + |
| + *out_value = it->second; |
| + return true; |
| +} |
| + |
| +bool GetStringListProperty(arc::mojom::AccessibilityNodeInfoData* node, |
| + arc::mojom::AccessibilityStringListProperty prop, |
| + std::vector<std::string>* out_value) { |
| + if (!node->string_list_properties) |
| + return false; |
| + |
| + auto it = node->string_list_properties->find(prop); |
| + if (it == node->string_list_properties->end()) |
| + return false; |
| + |
| + *out_value = it->second; |
| + return true; |
| +} |
| + |
| void PopulateAXRole(arc::mojom::AccessibilityNodeInfoData* node, |
| ui::AXNodeData* out_data) { |
| std::string class_name; |
| @@ -366,6 +394,9 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, |
| using AXIntProperty = arc::mojom::AccessibilityIntProperty; |
| using AXStringProperty = arc::mojom::AccessibilityStringProperty; |
| + using AXIntListProperty = arc::mojom::AccessibilityIntListProperty; |
|
David Tseng
2017/06/15 16:02:24
nit: sort alphabetically
yawano
2017/06/16 02:24:02
Done.
|
| + using AXStringListProperty = arc::mojom::AccessibilityStringListProperty; |
| + |
| std::string text; |
| if (GetStringProperty(node, AXStringProperty::TEXT, &text)) |
| out_data->SetName(text); |
| @@ -397,6 +428,23 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, |
| if (GetIntProperty(node, AXIntProperty::TEXT_SELECTION_END, &val) && val >= 0) |
| out_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, val); |
| + |
| + // Custom actions. |
| + std::vector<int32_t> custom_action_ids; |
| + std::vector<std::string> custom_action_descriptions; |
| + if (GetIntListProperty(node, AXIntListProperty::CUSTOM_ACTION_IDS, |
| + &custom_action_ids) && |
| + GetStringListProperty(node, |
| + AXStringListProperty::CUSTOM_ACTION_DESCRIPTIONS, |
| + &custom_action_descriptions) && |
| + !custom_action_ids.empty() && |
| + custom_action_ids.size() == custom_action_descriptions.size()) { |
|
David Tseng
2017/06/15 16:02:24
Should we CHECK here for all of the three conditio
yawano
2017/06/16 02:24:02
Yes, we should never get inputs which fail those c
|
| + out_data->AddAction(ui::AX_ACTION_CUSTOM_ACTION); |
| + out_data->AddIntListAttribute(ui::AX_ATTR_CUSTOM_ACTION_IDS, |
| + custom_action_ids); |
| + out_data->AddStringListAttribute(ui::AX_ATTR_CUSTOM_ACTION_DESCRIPTIONS, |
| + custom_action_descriptions); |
| + } |
| } |
| void AXTreeSourceArc::PerformAction(const ui::AXActionData& data) { |