1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef UI_ACCESSIBILITY_AX_TREE_MANAGER_H_
6 #define UI_ACCESSIBILITY_AX_TREE_MANAGER_H_
7 
8 #include "ui/accessibility/ax_export.h"
9 #include "ui/accessibility/ax_node.h"
10 #include "ui/accessibility/ax_tree_id.h"
11 
12 namespace ui {
13 
14 // Abstract interface for a class that owns an AXTree and manages its
15 // connections to other AXTrees in the same page or desktop (parent and child
16 // trees).
17 class AX_EXPORT AXTreeManager {
18  public:
19   // Returns the AXNode with the given |node_id| from the tree that has the
20   // given |tree_id|. This allows for callers to access nodes outside of their
21   // own tree. Returns nullptr if |tree_id| or |node_id| is not found.
22   virtual AXNode* GetNodeFromTree(const AXTreeID tree_id,
23                                   const AXNode::AXID node_id) const = 0;
24 
25   // Returns the AXNode in the current tree that has the given |node_id|.
26   // Returns nullptr if |node_id| is not found.
27   virtual AXNode* GetNodeFromTree(const AXNode::AXID node_id) const = 0;
28 
29   // Returns the tree id of the tree managed by this AXTreeManager.
30   virtual AXTreeID GetTreeID() const = 0;
31 
32   // Returns the tree id of the parent tree.
33   // Returns AXTreeIDUnknown if this tree doesn't have a parent tree.
34   virtual AXTreeID GetParentTreeID() const = 0;
35 
36   // Returns the AXNode that is at the root of the current tree.
37   virtual AXNode* GetRootAsAXNode() const = 0;
38 
39   // If this tree has a parent tree, returns the node in the parent tree that
40   // hosts the current tree. Returns nullptr if this tree doesn't have a parent
41   // tree.
42   virtual AXNode* GetParentNodeFromParentTreeAsAXNode() const = 0;
43 };
44 
45 }  // namespace ui
46 
47 #endif  // UI_ACCESSIBILITY_AX_TREE_MANAGER_H_
48