Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / accessibility / ax_tree_id_registry.h
blob7784683395fc450cf10da22dc6f209af2d3de711
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_
6 #define CONTENT_BROWSER_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_
8 #include <map>
10 #include "base/stl_util.h"
11 namespace base {
12 template <typename T>
13 struct DefaultSingletonTraits;
14 } // namespace base
16 namespace content {
18 // A class which generates a unique id given a process id and frame routing id.
19 class AXTreeIDRegistry {
20 public:
21 typedef std::pair<int, int> FrameID;
23 typedef int AXTreeID;
25 static const AXTreeID kNoAXTreeID;
27 // Get the single instance of this class.
28 static AXTreeIDRegistry* GetInstance();
30 // Obtains a unique id given a |process_id| and |routing_id|. Placeholder
31 // for full implementation once out of process iframe accessibility finalizes.
32 AXTreeID GetOrCreateAXTreeID(int process_id, int routing_id);
33 FrameID GetFrameID(AXTreeID ax_tree_id);
34 void RemoveAXTreeID(AXTreeID ax_tree_id);
36 private:
37 friend struct base::DefaultSingletonTraits<AXTreeIDRegistry>;
39 AXTreeIDRegistry();
40 virtual ~AXTreeIDRegistry();
42 // Tracks the current unique ax frame id.
43 AXTreeID ax_tree_id_counter_;
45 // Maps an accessibility tree to its frame via ids.
46 std::map<AXTreeID, FrameID> ax_tree_to_frame_id_map_;
48 // Maps frames to an accessibility tree via ids.
49 std::map<FrameID, AXTreeID> frame_to_ax_tree_id_map_;
51 DISALLOW_COPY_AND_ASSIGN(AXTreeIDRegistry);
54 } // namespace content
56 #endif // CONTENT_BROWSER_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_