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

Side by Side Diff: chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.h

Issue 2826423003: Expand Chrome OS ARC support to create one tree source per package (Closed)
Patch Set: Remove activation observer. Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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
25 namespace views {
26 class View;
27 }
28
20 namespace arc { 29 namespace arc {
21 30
22 using AXTreeArcSerializer = 31 using AXTreeArcSerializer =
23 ui::AXTreeSerializer<mojom::AccessibilityNodeInfoData*, 32 ui::AXTreeSerializer<mojom::AccessibilityNodeInfoData*,
24 ui::AXNodeData, 33 ui::AXNodeData,
25 ui::AXTreeData>; 34 ui::AXTreeData>;
26 35
27 // This class represents the accessibility tree from the focused ARC window. 36 // This class represents the accessibility tree from the focused ARC window.
28 class AXTreeSourceArc 37 class AXTreeSourceArc
29 : public ui::AXTreeSource<mojom::AccessibilityNodeInfoData*, 38 : public ui::AXTreeSource<mojom::AccessibilityNodeInfoData*,
30 ui::AXNodeData, 39 ui::AXNodeData,
31 ui::AXTreeData> { 40 ui::AXTreeData>,
41 public ui::AXHostDelegate {
32 public: 42 public:
33 explicit AXTreeSourceArc(int32_t tree_id); 43 class Delegate {
44 public:
45 virtual void OnAction(const ui::AXActionData& data) const = 0;
46 };
47
48 explicit AXTreeSourceArc(Delegate* delegate);
34 ~AXTreeSourceArc() override; 49 ~AXTreeSourceArc() override;
35 50
36 // Notify automation of an accessibility event. 51 // Notify automation of an accessibility event.
37 void NotifyAccessibilityEvent(mojom::AccessibilityEventData* event_data); 52 void NotifyAccessibilityEvent(mojom::AccessibilityEventData* event_data);
38 53
39 int32_t tree_id() const { return tree_id_; } 54 void Focus(aura::Window* window);
40 55
41 private: 56 private:
57 class FocusStealer;
58
42 // AXTreeSource overrides. 59 // AXTreeSource overrides.
43 bool GetTreeData(ui::AXTreeData* data) const override; 60 bool GetTreeData(ui::AXTreeData* data) const override;
44 mojom::AccessibilityNodeInfoData* GetRoot() const override; 61 mojom::AccessibilityNodeInfoData* GetRoot() const override;
45 mojom::AccessibilityNodeInfoData* GetFromId(int32_t id) const override; 62 mojom::AccessibilityNodeInfoData* GetFromId(int32_t id) const override;
46 int32_t GetId(mojom::AccessibilityNodeInfoData* node) const override; 63 int32_t GetId(mojom::AccessibilityNodeInfoData* node) const override;
47 void GetChildren(mojom::AccessibilityNodeInfoData* node, 64 void GetChildren(mojom::AccessibilityNodeInfoData* node,
48 std::vector<mojom::AccessibilityNodeInfoData*>* out_children) 65 std::vector<mojom::AccessibilityNodeInfoData*>* out_children)
49 const override; 66 const override;
50 mojom::AccessibilityNodeInfoData* GetParent( 67 mojom::AccessibilityNodeInfoData* GetParent(
51 mojom::AccessibilityNodeInfoData* node) const override; 68 mojom::AccessibilityNodeInfoData* node) const override;
52 bool IsValid(mojom::AccessibilityNodeInfoData* node) const override; 69 bool IsValid(mojom::AccessibilityNodeInfoData* node) const override;
53 bool IsEqual(mojom::AccessibilityNodeInfoData* node1, 70 bool IsEqual(mojom::AccessibilityNodeInfoData* node1,
54 mojom::AccessibilityNodeInfoData* node2) const override; 71 mojom::AccessibilityNodeInfoData* node2) const override;
55 mojom::AccessibilityNodeInfoData* GetNull() const override; 72 mojom::AccessibilityNodeInfoData* GetNull() const override;
56 void SerializeNode(mojom::AccessibilityNodeInfoData* node, 73 void SerializeNode(mojom::AccessibilityNodeInfoData* node,
57 ui::AXNodeData* out_data) const override; 74 ui::AXNodeData* out_data) const override;
58 75
76 // AXHostDelegate overrides.
77 void PerformAction(const ui::AXActionData& data) override;
78
59 // Resets tree state. 79 // Resets tree state.
60 void Reset(); 80 void Reset();
61 81
62 // The id of this tree.
63 int32_t tree_id_;
64
65 // Maps an AccessibilityNodeInfo to its tree data. 82 // Maps an AccessibilityNodeInfo to its tree data.
66 std::map<int32_t, mojom::AccessibilityNodeInfoData*> tree_map_; 83 std::map<int32_t, mojom::AccessibilityNodeInfoData*> tree_map_;
67 std::map<int32_t, int32_t> parent_map_; 84 std::map<int32_t, int32_t> parent_map_;
68 std::unique_ptr<AXTreeArcSerializer> current_tree_serializer_; 85 std::unique_ptr<AXTreeArcSerializer> current_tree_serializer_;
69 int32_t root_id_; 86 int32_t root_id_;
70 int32_t focused_node_id_; 87 int32_t focused_node_id_;
71 88
89 // A delegate that handles accessibility actions on behalf of this tree. The
90 // delegate is valid during the lifetime of this tree.
91 const Delegate* const delegate_;
92 std::unique_ptr<FocusStealer> focus_stealer_;
93
72 DISALLOW_COPY_AND_ASSIGN(AXTreeSourceArc); 94 DISALLOW_COPY_AND_ASSIGN(AXTreeSourceArc);
73 }; 95 };
74 96
75 } // namespace arc 97 } // namespace arc
76 98
77 #endif // CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_ 99 #endif // CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_AX_TREE_SOURCE_ARC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698