Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_ACCESSIBILITY_H_ | |
| 6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_ACCESSIBILITY_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/singleton.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 class RenderFrameHostImpl; | |
| 17 | |
| 18 // This singleton class maintains the mappings necessary to link child frames | |
|
Charlie Reis
2014/09/11 21:46:21
Are there any potential issues with this being a s
dmazzoni
2014/09/12 07:34:34
Good idea. The best place to check for this is jus
| |
| 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(); | |
| 24 | |
| 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); | |
| 31 | |
| 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); | |
| 38 | |
| 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); | |
| 42 | |
| 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); | |
| 50 | |
| 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); | |
| 58 | |
| 59 private: | |
| 60 FrameAccessibility(); | |
| 61 virtual ~FrameAccessibility(); | |
| 62 | |
| 63 struct ChildFrameMapping { | |
| 64 ChildFrameMapping(); | |
| 65 | |
| 66 RenderFrameHostImpl* parent_frame_host; | |
| 67 int accessibility_node_id; | |
| 68 int64 child_frame_tree_node_id; | |
| 69 int browser_plugin_instance_id; | |
| 70 }; | |
| 71 | |
| 72 std::vector<ChildFrameMapping> mappings_; | |
| 73 | |
| 74 friend struct DefaultSingletonTraits<FrameAccessibility>; | |
| 75 }; | |
| 76 | |
| 77 } // namespace content | |
| 78 | |
| 79 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_ACCESSIBILITY_H_ | |
| OLD | NEW |