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 #include "ui/accessibility/ax_tree_observer.h" 12 13 namespace ui { 14 15 // Abstract interface for a class that owns an AXTree and manages its 16 // connections to other AXTrees in the same page or desktop (parent and child 17 // trees). 18 class AX_EXPORT AXTreeManager { 19 public: 20 // Returns the AXNode with the given |node_id| from the tree that has the 21 // given |tree_id|. This allows for callers to access nodes outside of their 22 // own tree. Returns nullptr if |tree_id| or |node_id| is not found. 23 virtual AXNode* GetNodeFromTree(const AXTreeID tree_id, 24 const AXNode::AXID node_id) const = 0; 25 26 // Returns the AXNode in the current tree that has the given |node_id|. 27 // Returns nullptr if |node_id| is not found. 28 virtual AXNode* GetNodeFromTree(const AXNode::AXID node_id) const = 0; 29 AddObserver(AXTreeObserver * observer)30 virtual void AddObserver(AXTreeObserver* observer) {} RemoveObserver(AXTreeObserver * observer)31 virtual void RemoveObserver(AXTreeObserver* observer) {} 32 33 // Returns the tree id of the tree managed by this AXTreeManager. 34 virtual AXTreeID GetTreeID() const = 0; 35 36 // Returns the tree id of the parent tree. 37 // Returns AXTreeIDUnknown if this tree doesn't have a parent tree. 38 virtual AXTreeID GetParentTreeID() const = 0; 39 40 // Returns the AXNode that is at the root of the current tree. 41 virtual AXNode* GetRootAsAXNode() const = 0; 42 43 // If this tree has a parent tree, returns the node in the parent tree that 44 // hosts the current tree. Returns nullptr if this tree doesn't have a parent 45 // tree. 46 virtual AXNode* GetParentNodeFromParentTreeAsAXNode() const = 0; 47 }; 48 49 } // namespace ui 50 51 #endif // UI_ACCESSIBILITY_AX_TREE_MANAGER_H_ 52