dtseng | 32ea1736 | 2017-02-25 00:52:27 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_ACCESSIBILITY_AX_HOST_DELEGATE_H_ |
| 6 | #define UI_ACCESSIBILITY_AX_HOST_DELEGATE_H_ |
| 7 | |
| 8 | #include "ui/accessibility/ax_action_data.h" |
| 9 | |
| 10 | namespace ui { |
| 11 | |
| 12 | // Classes that host an accessibility tree in the browser process that also wish |
| 13 | // to become visible to accessibility clients (e.g. for relaying targets to |
| 14 | // source accessibility trees), can subclass this delegate. |
| 15 | // |
| 16 | // Subclasses can use |tree_id| when annotating their |AXNodeData| for clients |
| 17 | // to respond with the appropriate target node id. |
| 18 | class AX_EXPORT AXHostDelegate { |
| 19 | public: |
| 20 | virtual ~AXHostDelegate(); |
| 21 | |
| 22 | // Handle an action from an accessibility client. |
| 23 | virtual void PerformAction(const ui::AXActionData& data) = 0; |
| 24 | |
| 25 | protected: |
| 26 | // A delegate with an automatically assigned tree id. |
| 27 | AXHostDelegate(); |
| 28 | |
| 29 | // A delegate with an explicit tree id. The caller is responsible for ensuring |
| 30 | // the uniqueness of the id. |
| 31 | explicit AXHostDelegate(int32_t tree_id); |
| 32 | |
| 33 | // A tree id appropriate for annotating events sent to an accessibility |
| 34 | // client. |
dtseng | 87ccf7a | 2017-05-12 03:54:30 | [diff] [blame] | 35 | int32_t tree_id() const { return tree_id_; } |
dtseng | 32ea1736 | 2017-02-25 00:52:27 | [diff] [blame] | 36 | |
| 37 | private: |
| 38 | // Register or unregister this class with |AXTreeIDRegistry|. |
| 39 | void UpdateActiveState(bool active); |
| 40 | |
| 41 | int32_t tree_id_; |
| 42 | }; |
| 43 | |
| 44 | } // namespace ui |
| 45 | |
| 46 | #endif // UI_ACCESSIBILITY_AX_HOST_DELEGATE_H_ |