| 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..a30e0569b090c4d0e37b11a34682f021713f2cc1
|
| --- /dev/null
|
| +++ b/content/browser/accessibility/frame_tree_accessibility.h
|
| @@ -0,0 +1,81 @@
|
| +// 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
|
| +
|
| +#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 {
|
| +
|
| +// 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.
|
| + int32 GetFrameId(BrowserAccessibilityDelegate* frame);
|
| + BrowserAccessibilityDelegate* FindFrameById(int32 id);
|
| + BrowserAccessibilityManager* FindAccessibilityManagerById(int32 id);
|
| +
|
| + protected:
|
| + FrameTreeAccessibility();
|
| + ~FrameTreeAccessibility();
|
| +
|
| + private:
|
| + int next_id_;
|
| + base::hash_map<BrowserAccessibilityDelegate*, int32> frame_to_id_;
|
| + base::hash_map<int32, BrowserAccessibilityDelegate*> id_to_frame_;
|
| + base::hash_map<int32, BrowserAccessibilityManager*> id_to_manager_;
|
| +
|
| + friend struct DefaultSingletonTraits<FrameTreeAccessibility>;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_
|
|
|