Index: content/browser/accessibility/frame_tree_accessibility.h |
diff --git a/content/browser/accessibility/frame_tree_accessibility.h b/content/browser/accessibility/frame_tree_accessibility.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2b16b64826a0babca2ef099d0fab30cba3d9238f |
--- /dev/null |
+++ b/content/browser/accessibility/frame_tree_accessibility.h |
@@ -0,0 +1,83 @@ |
+// Copyright (c) 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_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_ |
+#define CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/containers/hash_tables.h" |
+#include "base/memory/singleton.h" |
+#include "content/browser/accessibility/browser_accessibility_manager.h" |
+#include "content/common/content_export.h" |
+ |
+#if defined(COMPILER_GCC) |
+namespace BASE_HASH_NAMESPACE { |
+ |
+template<> |
+struct hash<content::BrowserAccessibilityDelegate*> { |
+ std::size_t operator()(content::BrowserAccessibilityDelegate* const& ptr) |
+ const { |
+ return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
+ } |
+}; |
+ |
+} // namespace __gnu_cxx |
aboxhall
2014/05/06 15:41:27
BASE_HASH_NAMESPACE?
|
+ |
+#elif defined(COMPILER_MSVC) |
+namespace stdext { |
+ |
+template<> |
+inline size_t hash_value(content::BrowserAccessibilityDelegate* const& ptr) { |
+ return hash_value(reinterpret_cast<size_t>(ptr)); |
+} |
+ |
+} // namespace stdext |
+ |
+#endif // COMPILER |
+ |
+namespace content { |
+ |
+extern const uint32 kNoFrameId; |
+ |
+// This singleton manages relationships between accessibility trees that are |
+// nested in other accessibility trees, due to a <webview> element or |
+// an out-of-process iframe. Every accessible frame is identified by its |
+// host BrowserAccessibilityDelegate and given a unique id. |
+class CONTENT_EXPORT FrameTreeAccessibility { |
+ public: |
+ // Get the single instance of this class. |
+ static FrameTreeAccessibility* GetInstance(); |
+ |
+ // The class that implements BrowserAccessibilityDelegate registers each |
+ // frame on creation and unregisters it on deletion, and associates a |
+ // BrowserAccessibilityManager with a frame. |
+ void OnFrameCreated(BrowserAccessibilityDelegate* frame); |
+ void OnFrameDeleted(BrowserAccessibilityDelegate* frame); |
+ void SetFrameAccessibilityManager(BrowserAccessibilityDelegate* frame, |
+ BrowserAccessibilityManager* manager); |
+ |
+ // When a node in an accessible tree contains a reference to an accessible |
+ // frame, it can be looked up here. Note that it's not safe to hold onto a |
+ // reference to a BrowserAccessibilityDelegate or BrowserAccessibilityManager |
+ // because they could be subsequently deleted. |
+ uint32 GetFrameId(BrowserAccessibilityDelegate* frame); |
+ BrowserAccessibilityDelegate* FindFrameById(uint32 id); |
+ BrowserAccessibilityManager* FindAccessibilityManagerById(uint32 id); |
+ |
+ protected: |
+ FrameTreeAccessibility(); |
+ ~FrameTreeAccessibility(); |
+ |
+ private: |
+ uint32 next_id_; |
+ base::hash_map<BrowserAccessibilityDelegate*, uint32> frame_to_id_; |
+ base::hash_map<uint32, BrowserAccessibilityDelegate*> id_to_frame_; |
+ base::hash_map<uint32, BrowserAccessibilityManager*> id_to_manager_; |
+ |
+ friend struct DefaultSingletonTraits<FrameTreeAccessibility>; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_ |