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

Side by Side Diff: ui/accessibility/ax_tree_id_registry.h

Issue 2640123004: Initial support for native accessibility in ARC (Closed)
Patch Set: |window| can be nullptr Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CONTENT_BROWSER_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_ 5 #ifndef UI_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_
6 #define CONTENT_BROWSER_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_ 6 #define UI_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "ui/accessibility/ax_export.h"
12 13
13 namespace base { 14 namespace base {
14 template <typename T> 15 template <typename T>
15 struct DefaultSingletonTraits; 16 struct DefaultSingletonTraits;
16 } // namespace base 17 } // namespace base
17 18
18 namespace content { 19 namespace ui {
19 20
20 // A class which generates a unique id given a process id and frame routing id. 21 // A class which generates a unique id.
21 class AXTreeIDRegistry { 22 class AX_EXPORT AXTreeIDRegistry {
22 public: 23 public:
23 using FrameID = std::pair<int, int>; 24 using FrameID = std::pair<int, int>;
24 25
25 using AXTreeID = int; 26 using AXTreeID = int;
26 27
27 static const AXTreeID kNoAXTreeID; 28 static const AXTreeID kNoAXTreeID;
28 29
29 // Get the single instance of this class. 30 // Get the single instance of this class.
30 static AXTreeIDRegistry* GetInstance(); 31 static AXTreeIDRegistry* GetInstance();
31 32
32 // Obtains a unique id given a |process_id| and |routing_id|. Placeholder 33 // Obtains a unique id given a |process_id| and |routing_id|. Placeholder
33 // for full implementation once out of process iframe accessibility finalizes. 34 // for full implementation once out of process iframe accessibility finalizes.
34 AXTreeID GetOrCreateAXTreeID(int process_id, int routing_id); 35 AXTreeID GetOrCreateAXTreeID(int process_id, int routing_id);
35 FrameID GetFrameID(AXTreeID ax_tree_id); 36 FrameID GetFrameID(AXTreeID ax_tree_id);
36 void RemoveAXTreeID(AXTreeID ax_tree_id); 37 void RemoveAXTreeID(AXTreeID ax_tree_id);
37 38
39 // Create an id not associated with any process.
40 int CreateID();
dmazzoni 2017/02/09 01:18:09 This is great. Should we maybe use this for the D
41
38 private: 42 private:
39 friend struct base::DefaultSingletonTraits<AXTreeIDRegistry>; 43 friend struct base::DefaultSingletonTraits<AXTreeIDRegistry>;
40 44
41 AXTreeIDRegistry(); 45 AXTreeIDRegistry();
42 virtual ~AXTreeIDRegistry(); 46 virtual ~AXTreeIDRegistry();
43 47
44 // Tracks the current unique ax frame id. 48 // Tracks the current unique ax frame id.
45 AXTreeID ax_tree_id_counter_; 49 AXTreeID ax_tree_id_counter_;
46 50
47 // Maps an accessibility tree to its frame via ids. 51 // Maps an accessibility tree to its frame via ids.
48 std::map<AXTreeID, FrameID> ax_tree_to_frame_id_map_; 52 std::map<AXTreeID, FrameID> ax_tree_to_frame_id_map_;
49 53
50 // Maps frames to an accessibility tree via ids. 54 // Maps frames to an accessibility tree via ids.
51 std::map<FrameID, AXTreeID> frame_to_ax_tree_id_map_; 55 std::map<FrameID, AXTreeID> frame_to_ax_tree_id_map_;
52 56
53 DISALLOW_COPY_AND_ASSIGN(AXTreeIDRegistry); 57 DISALLOW_COPY_AND_ASSIGN(AXTreeIDRegistry);
54 }; 58 };
55 59
56 } // namespace content 60 } // namespace ui
57 61
58 #endif // CONTENT_BROWSER_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_ 62 #endif // UI_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698