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 { | |
22 class FocusStealer; | |
23 } | |
24 | |
25 namespace aura { | |
26 class Window; | |
27 } | |
28 | |
29 namespace views { | |
30 class View; | |
31 } | |
32 | |
20 namespace arc { | 33 namespace arc { |
21 | 34 |
22 using AXTreeArcSerializer = | 35 using AXTreeArcSerializer = |
23 ui::AXTreeSerializer<mojom::AccessibilityNodeInfoData*, | 36 ui::AXTreeSerializer<mojom::AccessibilityNodeInfoData*, |
24 ui::AXNodeData, | 37 ui::AXNodeData, |
25 ui::AXTreeData>; | 38 ui::AXTreeData>; |
26 | 39 |
27 // This class represents the accessibility tree from the focused ARC window. | 40 // This class represents the accessibility tree from the focused ARC window. |
28 class AXTreeSourceArc | 41 class AXTreeSourceArc |
29 : public ui::AXTreeSource<mojom::AccessibilityNodeInfoData*, | 42 : public ui::AXTreeSource<mojom::AccessibilityNodeInfoData*, |
30 ui::AXNodeData, | 43 ui::AXNodeData, |
31 ui::AXTreeData> { | 44 ui::AXTreeData>, |
45 public ui::AXHostDelegate { | |
32 public: | 46 public: |
33 explicit AXTreeSourceArc(int32_t tree_id); | 47 class Delegate { |
48 public: | |
49 virtual void OnAction(const ui::AXActionData& data) = 0; | |
50 }; | |
51 | |
52 explicit AXTreeSourceArc(Delegate* delegate); | |
34 ~AXTreeSourceArc() override; | 53 ~AXTreeSourceArc() override; |
35 | 54 |
36 // Notify automation of an accessibility event. | 55 // Notify automation of an accessibility event. |
37 void NotifyAccessibilityEvent(mojom::AccessibilityEventData* event_data); | 56 void NotifyAccessibilityEvent(mojom::AccessibilityEventData* event_data); |
38 | 57 |
39 int32_t tree_id() const { return tree_id_; } | 58 void Focus(aura::Window* window); |
40 | 59 |
41 private: | 60 private: |
42 // AXTreeSource overrides. | 61 // AXTreeSource overrides. |
43 bool GetTreeData(ui::AXTreeData* data) const override; | 62 bool GetTreeData(ui::AXTreeData* data) const override; |
44 mojom::AccessibilityNodeInfoData* GetRoot() const override; | 63 mojom::AccessibilityNodeInfoData* GetRoot() const override; |
45 mojom::AccessibilityNodeInfoData* GetFromId(int32_t id) const override; | 64 mojom::AccessibilityNodeInfoData* GetFromId(int32_t id) const override; |
46 int32_t GetId(mojom::AccessibilityNodeInfoData* node) const override; | 65 int32_t GetId(mojom::AccessibilityNodeInfoData* node) const override; |
47 void GetChildren(mojom::AccessibilityNodeInfoData* node, | 66 void GetChildren(mojom::AccessibilityNodeInfoData* node, |
48 std::vector<mojom::AccessibilityNodeInfoData*>* out_children) | 67 std::vector<mojom::AccessibilityNodeInfoData*>* out_children) |
49 const override; | 68 const override; |
50 mojom::AccessibilityNodeInfoData* GetParent( | 69 mojom::AccessibilityNodeInfoData* GetParent( |
51 mojom::AccessibilityNodeInfoData* node) const override; | 70 mojom::AccessibilityNodeInfoData* node) const override; |
52 bool IsValid(mojom::AccessibilityNodeInfoData* node) const override; | 71 bool IsValid(mojom::AccessibilityNodeInfoData* node) const override; |
53 bool IsEqual(mojom::AccessibilityNodeInfoData* node1, | 72 bool IsEqual(mojom::AccessibilityNodeInfoData* node1, |
54 mojom::AccessibilityNodeInfoData* node2) const override; | 73 mojom::AccessibilityNodeInfoData* node2) const override; |
55 mojom::AccessibilityNodeInfoData* GetNull() const override; | 74 mojom::AccessibilityNodeInfoData* GetNull() const override; |
56 void SerializeNode(mojom::AccessibilityNodeInfoData* node, | 75 void SerializeNode(mojom::AccessibilityNodeInfoData* node, |
57 ui::AXNodeData* out_data) const override; | 76 ui::AXNodeData* out_data) const override; |
58 | 77 |
78 // AXHostDelegate overrides. | |
79 void PerformAction(const ui::AXActionData& data) override; | |
80 | |
59 // Resets tree state. | 81 // Resets tree state. |
60 void Reset(); | 82 void Reset(); |
61 | 83 |
62 // The id of this tree. | |
63 int32_t tree_id_; | |
64 | |
65 // Maps an AccessibilityNodeInfo to its tree data. | 84 // Maps an AccessibilityNodeInfo to its tree data. |
66 std::map<int32_t, mojom::AccessibilityNodeInfoData*> tree_map_; | 85 std::map<int32_t, mojom::AccessibilityNodeInfoData*> tree_map_; |
67 std::map<int32_t, int32_t> parent_map_; | 86 std::map<int32_t, int32_t> parent_map_; |
68 std::unique_ptr<AXTreeArcSerializer> current_tree_serializer_; | 87 std::unique_ptr<AXTreeArcSerializer> current_tree_serializer_; |
69 int32_t root_id_; | 88 int32_t root_id_; |
70 int32_t focused_node_id_; | 89 int32_t focused_node_id_; |
90 Delegate* delegate_; | |
Luis Héctor Chávez
2017/04/25 15:27:00
nit: Delegate* const delegate_;
Also mention what
David Tseng
2017/04/25 22:48:02
Done.
| |
91 std::unique_ptr<FocusStealer> focus_stealer_; | |
Luis Héctor Chávez
2017/04/25 15:27:00
nit: As hidehiko@ mentioned previously, please mak
David Tseng
2017/04/25 22:48:03
Forward declared as a private nested class.
| |
71 | 92 |
72 DISALLOW_COPY_AND_ASSIGN(AXTreeSourceArc); | 93 DISALLOW_COPY_AND_ASSIGN(AXTreeSourceArc); |
73 }; | 94 }; |
74 | 95 |
75 } // namespace arc | 96 } // namespace arc |
76 | 97 |
77 #endif // CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ | 98 #endif // CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ |
OLD | NEW |