Chromium Code Reviews| Index: content/browser/frame_host/frame_accessibility.h |
| diff --git a/content/browser/frame_host/frame_accessibility.h b/content/browser/frame_host/frame_accessibility.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..253ba19b0544fa04058e9324de1f2269af445568 |
| --- /dev/null |
| +++ b/content/browser/frame_host/frame_accessibility.h |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_ACCESSIBILITY_H_ |
| +#define CONTENT_BROWSER_FRAME_HOST_FRAME_ACCESSIBILITY_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/singleton.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +class RenderFrameHostImpl; |
| + |
| +// 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
|
| +// and guest frames into a single tree for accessibility. This class is only |
| +// used if accessibility is enabled. |
| +class CONTENT_EXPORT FrameAccessibility { |
| + public: |
| + static FrameAccessibility* GetInstance(); |
| + |
| + // Add a mapping between an accessibility node of |parent_frame_host| |
| + // and the child frame with the given frame tree node id, in the same |
| + // frame tree. |
| + void AddChildFrame(RenderFrameHostImpl* parent_frame_host, |
| + int accessibility_node_id, |
| + int64 child_frame_tree_node_id); |
| + |
| + // Add a mapping between an accessibility node of |parent_frame_host| |
| + // and the main frame of the guest Webcontents with the given |
| + // browser plugin instance id. |
| + void AddGuestWebContents(RenderFrameHostImpl* parent_frame_host, |
| + int accessibility_node_id, |
| + int browser_plugin_instance_id); |
| + |
| + // This is called when a RenderFrameHostImpl is deleted, so invalid |
| + // mappings can be removed from this data structure. |
| + void OnRenderFrameHostDestroyed(RenderFrameHostImpl* render_frame_host); |
| + |
| + // Given a parent RenderFrameHostImpl and an accessibility node id, look up |
| + // a child frame or guest frame that was previously associated with this |
| + // frame and node id. If a mapping exists, return the resulting frame if |
| + // it's valid. If it doesn't resolve to a valid RenderFrameHostImpl, |
| + // returns NULL. |
| + RenderFrameHostImpl* GetChild(RenderFrameHostImpl* parent_frame_host, |
| + int accessibility_node_id); |
| + |
| + // Given a RenderFrameHostImpl, check the mapping table to see if it's |
| + // the child of a node in some other frame. If so, return true and |
| + // set the parent frame and accessibility node id in the parent frame, |
| + // otherwise return false. |
| + bool GetParent(RenderFrameHostImpl* child_frame_host, |
| + RenderFrameHostImpl** out_parent_frame_host, |
| + int* out_accessibility_node_id); |
| + |
| + private: |
| + FrameAccessibility(); |
| + virtual ~FrameAccessibility(); |
| + |
| + struct ChildFrameMapping { |
| + ChildFrameMapping(); |
| + |
| + RenderFrameHostImpl* parent_frame_host; |
| + int accessibility_node_id; |
| + int64 child_frame_tree_node_id; |
| + int browser_plugin_instance_id; |
| + }; |
| + |
| + std::vector<ChildFrameMapping> mappings_; |
| + |
| + friend struct DefaultSingletonTraits<FrameAccessibility>; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_FRAME_HOST_FRAME_ACCESSIBILITY_H_ |