| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/common/accessibility_node_data.h" |
| 14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 16 #include "webkit/glue/webaccessibility.h" | |
| 17 | 17 |
| 18 class BrowserAccessibility; | 18 class BrowserAccessibility; |
| 19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 20 class BrowserAccessibilityManagerWin; | 20 class BrowserAccessibilityManagerWin; |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 using webkit_glue::WebAccessibility; | |
| 24 | |
| 25 struct AccessibilityHostMsg_NotificationParams; | 23 struct AccessibilityHostMsg_NotificationParams; |
| 26 | 24 |
| 27 // Class that can perform actions on behalf of the BrowserAccessibilityManager. | 25 // Class that can perform actions on behalf of the BrowserAccessibilityManager. |
| 28 class CONTENT_EXPORT BrowserAccessibilityDelegate { | 26 class CONTENT_EXPORT BrowserAccessibilityDelegate { |
| 29 public: | 27 public: |
| 30 virtual ~BrowserAccessibilityDelegate() {} | 28 virtual ~BrowserAccessibilityDelegate() {} |
| 31 virtual void SetAccessibilityFocus(int acc_obj_id) = 0; | 29 virtual void SetAccessibilityFocus(int acc_obj_id) = 0; |
| 32 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0; | 30 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0; |
| 33 virtual void AccessibilityScrollToMakeVisible( | 31 virtual void AccessibilityScrollToMakeVisible( |
| 34 int acc_obj_id, gfx::Rect subfocus) = 0; | 32 int acc_obj_id, gfx::Rect subfocus) = 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 49 virtual BrowserAccessibility* Create(); | 47 virtual BrowserAccessibility* Create(); |
| 50 }; | 48 }; |
| 51 | 49 |
| 52 // Manages a tree of BrowserAccessibility objects. | 50 // Manages a tree of BrowserAccessibility objects. |
| 53 class CONTENT_EXPORT BrowserAccessibilityManager { | 51 class CONTENT_EXPORT BrowserAccessibilityManager { |
| 54 public: | 52 public: |
| 55 // Creates the platform specific BrowserAccessibilityManager. Ownership passes | 53 // Creates the platform specific BrowserAccessibilityManager. Ownership passes |
| 56 // to the caller. | 54 // to the caller. |
| 57 static BrowserAccessibilityManager* Create( | 55 static BrowserAccessibilityManager* Create( |
| 58 gfx::NativeView parent_view, | 56 gfx::NativeView parent_view, |
| 59 const WebAccessibility& src, | 57 const content::AccessibilityNodeData& src, |
| 60 BrowserAccessibilityDelegate* delegate, | 58 BrowserAccessibilityDelegate* delegate, |
| 61 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); | 59 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); |
| 62 | 60 |
| 63 // Creates the platform specific BrowserAccessibilityManager. Ownership passes | 61 // Creates the platform specific BrowserAccessibilityManager. Ownership passes |
| 64 // to the caller. | 62 // to the caller. |
| 65 static BrowserAccessibilityManager* CreateEmptyDocument( | 63 static BrowserAccessibilityManager* CreateEmptyDocument( |
| 66 gfx::NativeView parent_view, | 64 gfx::NativeView parent_view, |
| 67 WebAccessibility::State state, | 65 content::AccessibilityNodeData::State state, |
| 68 BrowserAccessibilityDelegate* delegate, | 66 BrowserAccessibilityDelegate* delegate, |
| 69 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); | 67 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); |
| 70 | 68 |
| 71 virtual ~BrowserAccessibilityManager(); | 69 virtual ~BrowserAccessibilityManager(); |
| 72 | 70 |
| 73 // Type is enum AccessibilityNotification. | 71 // Type is enum AccessibilityNotification. |
| 74 // We pass it as int so that we don't include the message declaration | 72 // We pass it as int so that we don't include the message declaration |
| 75 // header here. | 73 // header here. |
| 76 virtual void NotifyAccessibilityEvent( | 74 virtual void NotifyAccessibilityEvent( |
| 77 int type, | 75 int type, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 BrowserAccessibilityManagerWin* ToBrowserAccessibilityManagerWin(); | 134 BrowserAccessibilityManagerWin* ToBrowserAccessibilityManagerWin(); |
| 137 #endif | 135 #endif |
| 138 | 136 |
| 139 // Return the object that has focus, if it's a descandant of the | 137 // Return the object that has focus, if it's a descandant of the |
| 140 // given root (inclusive). Does not make a new reference. | 138 // given root (inclusive). Does not make a new reference. |
| 141 BrowserAccessibility* GetFocus(BrowserAccessibility* root); | 139 BrowserAccessibility* GetFocus(BrowserAccessibility* root); |
| 142 | 140 |
| 143 protected: | 141 protected: |
| 144 BrowserAccessibilityManager( | 142 BrowserAccessibilityManager( |
| 145 gfx::NativeView parent_view, | 143 gfx::NativeView parent_view, |
| 146 const WebAccessibility& src, | 144 const content::AccessibilityNodeData& src, |
| 147 BrowserAccessibilityDelegate* delegate, | 145 BrowserAccessibilityDelegate* delegate, |
| 148 BrowserAccessibilityFactory* factory); | 146 BrowserAccessibilityFactory* factory); |
| 149 | 147 |
| 150 private: | 148 private: |
| 151 // Update an accessibility node with an updated WebAccessibility node | 149 // Update an accessibility node with an updated AccessibilityNodeData node |
| 152 // received from the renderer process. When |include_children| is true | 150 // received from the renderer process. When |include_children| is true |
| 153 // the node's children will also be updated, otherwise only the node | 151 // the node's children will also be updated, otherwise only the node |
| 154 // itself is updated. | 152 // itself is updated. |
| 155 void UpdateNode(const WebAccessibility& src, bool include_children); | 153 void UpdateNode(const content::AccessibilityNodeData& src, |
| 154 bool include_children); |
| 156 | 155 |
| 157 // Recursively build a tree of BrowserAccessibility objects from | 156 // Recursively build a tree of BrowserAccessibility objects from |
| 158 // the WebAccessibility tree received from the renderer process. | 157 // the AccessibilityNodeData tree received from the renderer process. |
| 159 BrowserAccessibility* CreateAccessibilityTree( | 158 BrowserAccessibility* CreateAccessibilityTree( |
| 160 BrowserAccessibility* parent, | 159 BrowserAccessibility* parent, |
| 161 const WebAccessibility& src, | 160 const content::AccessibilityNodeData& src, |
| 162 int index_in_parent, | 161 int index_in_parent, |
| 163 bool send_show_events); | 162 bool send_show_events); |
| 164 | 163 |
| 165 protected: | 164 protected: |
| 166 // The next unique id for a BrowserAccessibility instance. | 165 // The next unique id for a BrowserAccessibility instance. |
| 167 static int32 next_child_id_; | 166 static int32 next_child_id_; |
| 168 | 167 |
| 169 // The parent view. | 168 // The parent view. |
| 170 gfx::NativeView parent_view_; | 169 gfx::NativeView parent_view_; |
| 171 | 170 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 184 // we use internally here. | 183 // we use internally here. |
| 185 base::hash_map<int32, int32> renderer_id_to_child_id_map_; | 184 base::hash_map<int32, int32> renderer_id_to_child_id_map_; |
| 186 | 185 |
| 187 // A mapping from child IDs to BrowserAccessibility objects. | 186 // A mapping from child IDs to BrowserAccessibility objects. |
| 188 base::hash_map<int32, BrowserAccessibility*> child_id_map_; | 187 base::hash_map<int32, BrowserAccessibility*> child_id_map_; |
| 189 | 188 |
| 190 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); | 189 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
| 191 }; | 190 }; |
| 192 | 191 |
| 193 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 192 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| OLD | NEW |