cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / content / browser / frame_host / frame_accessibility.h
blob253ba19b0544fa04058e9324de1f2269af445568
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_FRAME_HOST_FRAME_ACCESSIBILITY_H_
6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_ACCESSIBILITY_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/singleton.h"
12 #include "content/common/content_export.h"
14 namespace content {
16 class RenderFrameHostImpl;
18 // This singleton class maintains the mappings necessary to link child frames
19 // and guest frames into a single tree for accessibility. This class is only
20 // used if accessibility is enabled.
21 class CONTENT_EXPORT FrameAccessibility {
22 public:
23 static FrameAccessibility* GetInstance();
25 // Add a mapping between an accessibility node of |parent_frame_host|
26 // and the child frame with the given frame tree node id, in the same
27 // frame tree.
28 void AddChildFrame(RenderFrameHostImpl* parent_frame_host,
29 int accessibility_node_id,
30 int64 child_frame_tree_node_id);
32 // Add a mapping between an accessibility node of |parent_frame_host|
33 // and the main frame of the guest Webcontents with the given
34 // browser plugin instance id.
35 void AddGuestWebContents(RenderFrameHostImpl* parent_frame_host,
36 int accessibility_node_id,
37 int browser_plugin_instance_id);
39 // This is called when a RenderFrameHostImpl is deleted, so invalid
40 // mappings can be removed from this data structure.
41 void OnRenderFrameHostDestroyed(RenderFrameHostImpl* render_frame_host);
43 // Given a parent RenderFrameHostImpl and an accessibility node id, look up
44 // a child frame or guest frame that was previously associated with this
45 // frame and node id. If a mapping exists, return the resulting frame if
46 // it's valid. If it doesn't resolve to a valid RenderFrameHostImpl,
47 // returns NULL.
48 RenderFrameHostImpl* GetChild(RenderFrameHostImpl* parent_frame_host,
49 int accessibility_node_id);
51 // Given a RenderFrameHostImpl, check the mapping table to see if it's
52 // the child of a node in some other frame. If so, return true and
53 // set the parent frame and accessibility node id in the parent frame,
54 // otherwise return false.
55 bool GetParent(RenderFrameHostImpl* child_frame_host,
56 RenderFrameHostImpl** out_parent_frame_host,
57 int* out_accessibility_node_id);
59 private:
60 FrameAccessibility();
61 virtual ~FrameAccessibility();
63 struct ChildFrameMapping {
64 ChildFrameMapping();
66 RenderFrameHostImpl* parent_frame_host;
67 int accessibility_node_id;
68 int64 child_frame_tree_node_id;
69 int browser_plugin_instance_id;
72 std::vector<ChildFrameMapping> mappings_;
74 friend struct DefaultSingletonTraits<FrameAccessibility>;
77 } // namespace content
79 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_ACCESSIBILITY_H_