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_
10 #include "base/stl_util.h"
13 struct DefaultSingletonTraits
;
17 // A class which generates a unique id given a process id and frame routing id.
18 class AXTreeIDRegistry
{
20 typedef std::pair
<int, int> FrameID
;
24 static const AXTreeID kNoAXTreeID
;
26 // Get the single instance of this class.
27 static AXTreeIDRegistry
* GetInstance();
29 // Obtains a unique id given a |process_id| and |routing_id|. Placeholder
30 // for full implementation once out of process iframe accessibility finalizes.
31 AXTreeID
GetOrCreateAXTreeID(int process_id
, int routing_id
);
32 FrameID
GetFrameID(AXTreeID ax_tree_id
);
33 void RemoveAXTreeID(AXTreeID ax_tree_id
);
36 friend struct DefaultSingletonTraits
<AXTreeIDRegistry
>;
39 virtual ~AXTreeIDRegistry();
41 // Tracks the current unique ax frame id.
42 AXTreeID ax_tree_id_counter_
;
44 // Maps an accessibility tree to its frame via ids.
45 std::map
<AXTreeID
, FrameID
> ax_tree_to_frame_id_map_
;
47 // Maps frames to an accessibility tree via ids.
48 std::map
<FrameID
, AXTreeID
> frame_to_ax_tree_id_map_
;
50 DISALLOW_COPY_AND_ASSIGN(AXTreeIDRegistry
);
53 } // namespace content
55 #endif // CONTENT_BROWSER_ACCESSIBILITY_AX_TREE_ID_REGISTRY_H_