| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "components/arc/common/accessibility_helper.mojom.h" | 12 #include "components/arc/common/accessibility_helper.mojom.h" |
| 13 #include "ui/accessibility/ax_host_delegate.h" |
| 13 #include "ui/accessibility/ax_node.h" | 14 #include "ui/accessibility/ax_node.h" |
| 14 #include "ui/accessibility/ax_node_data.h" | 15 #include "ui/accessibility/ax_node_data.h" |
| 15 #include "ui/accessibility/ax_tree_data.h" | 16 #include "ui/accessibility/ax_tree_data.h" |
| 16 #include "ui/accessibility/ax_tree_serializer.h" | 17 #include "ui/accessibility/ax_tree_serializer.h" |
| 17 #include "ui/accessibility/ax_tree_source.h" | 18 #include "ui/accessibility/ax_tree_source.h" |
| 18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
| 19 | 20 |
| 21 namespace aura { |
| 22 class Window; |
| 23 } |
| 24 |
| 20 namespace arc { | 25 namespace arc { |
| 21 | 26 |
| 22 using AXTreeArcSerializer = | 27 using AXTreeArcSerializer = |
| 23 ui::AXTreeSerializer<mojom::AccessibilityNodeInfoData*, | 28 ui::AXTreeSerializer<mojom::AccessibilityNodeInfoData*, |
| 24 ui::AXNodeData, | 29 ui::AXNodeData, |
| 25 ui::AXTreeData>; | 30 ui::AXTreeData>; |
| 26 | 31 |
| 27 // This class represents the accessibility tree from the focused ARC window. | 32 // This class represents the accessibility tree from the focused ARC window. |
| 28 class AXTreeSourceArc | 33 class AXTreeSourceArc |
| 29 : public ui::AXTreeSource<mojom::AccessibilityNodeInfoData*, | 34 : public ui::AXTreeSource<mojom::AccessibilityNodeInfoData*, |
| 30 ui::AXNodeData, | 35 ui::AXNodeData, |
| 31 ui::AXTreeData> { | 36 ui::AXTreeData>, |
| 37 public ui::AXHostDelegate { |
| 32 public: | 38 public: |
| 33 explicit AXTreeSourceArc(int32_t tree_id); | 39 class Delegate { |
| 40 public: |
| 41 virtual void OnAction(const ui::AXActionData& data) const = 0; |
| 42 }; |
| 43 |
| 44 explicit AXTreeSourceArc(Delegate* delegate); |
| 34 ~AXTreeSourceArc() override; | 45 ~AXTreeSourceArc() override; |
| 35 | 46 |
| 36 // Notify automation of an accessibility event. | 47 // Notify automation of an accessibility event. |
| 37 void NotifyAccessibilityEvent(mojom::AccessibilityEventData* event_data); | 48 void NotifyAccessibilityEvent(mojom::AccessibilityEventData* event_data); |
| 38 | 49 |
| 39 int32_t tree_id() const { return tree_id_; } | 50 void Focus(aura::Window* window); |
| 40 | 51 |
| 41 private: | 52 private: |
| 53 class FocusStealer; |
| 54 |
| 42 // AXTreeSource overrides. | 55 // AXTreeSource overrides. |
| 43 bool GetTreeData(ui::AXTreeData* data) const override; | 56 bool GetTreeData(ui::AXTreeData* data) const override; |
| 44 mojom::AccessibilityNodeInfoData* GetRoot() const override; | 57 mojom::AccessibilityNodeInfoData* GetRoot() const override; |
| 45 mojom::AccessibilityNodeInfoData* GetFromId(int32_t id) const override; | 58 mojom::AccessibilityNodeInfoData* GetFromId(int32_t id) const override; |
| 46 int32_t GetId(mojom::AccessibilityNodeInfoData* node) const override; | 59 int32_t GetId(mojom::AccessibilityNodeInfoData* node) const override; |
| 47 void GetChildren(mojom::AccessibilityNodeInfoData* node, | 60 void GetChildren(mojom::AccessibilityNodeInfoData* node, |
| 48 std::vector<mojom::AccessibilityNodeInfoData*>* out_children) | 61 std::vector<mojom::AccessibilityNodeInfoData*>* out_children) |
| 49 const override; | 62 const override; |
| 50 mojom::AccessibilityNodeInfoData* GetParent( | 63 mojom::AccessibilityNodeInfoData* GetParent( |
| 51 mojom::AccessibilityNodeInfoData* node) const override; | 64 mojom::AccessibilityNodeInfoData* node) const override; |
| 52 bool IsValid(mojom::AccessibilityNodeInfoData* node) const override; | 65 bool IsValid(mojom::AccessibilityNodeInfoData* node) const override; |
| 53 bool IsEqual(mojom::AccessibilityNodeInfoData* node1, | 66 bool IsEqual(mojom::AccessibilityNodeInfoData* node1, |
| 54 mojom::AccessibilityNodeInfoData* node2) const override; | 67 mojom::AccessibilityNodeInfoData* node2) const override; |
| 55 mojom::AccessibilityNodeInfoData* GetNull() const override; | 68 mojom::AccessibilityNodeInfoData* GetNull() const override; |
| 56 void SerializeNode(mojom::AccessibilityNodeInfoData* node, | 69 void SerializeNode(mojom::AccessibilityNodeInfoData* node, |
| 57 ui::AXNodeData* out_data) const override; | 70 ui::AXNodeData* out_data) const override; |
| 58 | 71 |
| 72 // AXHostDelegate overrides. |
| 73 void PerformAction(const ui::AXActionData& data) override; |
| 74 |
| 59 // Resets tree state. | 75 // Resets tree state. |
| 60 void Reset(); | 76 void Reset(); |
| 61 | 77 |
| 62 // The id of this tree. | |
| 63 int32_t tree_id_; | |
| 64 | |
| 65 // Maps an AccessibilityNodeInfo to its tree data. | 78 // Maps an AccessibilityNodeInfo to its tree data. |
| 66 std::map<int32_t, mojom::AccessibilityNodeInfoData*> tree_map_; | 79 std::map<int32_t, mojom::AccessibilityNodeInfoData*> tree_map_; |
| 67 std::map<int32_t, int32_t> parent_map_; | 80 std::map<int32_t, int32_t> parent_map_; |
| 68 std::unique_ptr<AXTreeArcSerializer> current_tree_serializer_; | 81 std::unique_ptr<AXTreeArcSerializer> current_tree_serializer_; |
| 69 int32_t root_id_; | 82 int32_t root_id_; |
| 70 int32_t focused_node_id_; | 83 int32_t focused_node_id_; |
| 71 | 84 |
| 85 // A delegate that handles accessibility actions on behalf of this tree. The |
| 86 // delegate is valid during the lifetime of this tree. |
| 87 const Delegate* const delegate_; |
| 88 std::unique_ptr<FocusStealer> focus_stealer_; |
| 89 |
| 72 DISALLOW_COPY_AND_ASSIGN(AXTreeSourceArc); | 90 DISALLOW_COPY_AND_ASSIGN(AXTreeSourceArc); |
| 73 }; | 91 }; |
| 74 | 92 |
| 75 } // namespace arc | 93 } // namespace arc |
| 76 | 94 |
| 77 #endif // CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ | 95 #endif // CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ |
| OLD | NEW |