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

Unified Diff: chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.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/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..58f8803c740e6eebc6f61731289d47d54eb7cc85 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;
@@ -364,8 +392,11 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node,
return;
out_data->id = node->id;
+ using AXIntListProperty = arc::mojom::AccessibilityIntListProperty;
using AXIntProperty = arc::mojom::AccessibilityIntProperty;
+ using AXStringListProperty = arc::mojom::AccessibilityStringListProperty;
using AXStringProperty = arc::mojom::AccessibilityStringProperty;
+
std::string text;
if (GetStringProperty(node, AXStringProperty::TEXT, &text))
out_data->SetName(text);
@@ -397,6 +428,25 @@ 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;
+ if (GetIntListProperty(node, AXIntListProperty::CUSTOM_ACTION_IDS,
+ &custom_action_ids)) {
+ std::vector<std::string> custom_action_descriptions;
+
+ CHECK(GetStringListProperty(
+ node, AXStringListProperty::CUSTOM_ACTION_DESCRIPTIONS,
+ &custom_action_descriptions));
+ CHECK(!custom_action_ids.empty());
+ CHECK_EQ(custom_action_ids.size(), custom_action_descriptions.size());
+
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698