OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
sky
2011/02/07 17:07:11
Can this be nuked?
dmazzoni
2011/02/08 04:00:09
Done.
| |
14 #include "base/singleton.h" | 14 #include "base/singleton.h" |
15 #include "base/task.h" | 15 #include "base/task.h" |
16 #include "chrome/browser/accessibility_events.h" | 16 #include "chrome/browser/accessibility_events.h" |
17 #include "views/accessibility/accessibility_types.h" | 17 #include "views/accessibility/accessibility_types.h" |
18 | 18 |
19 class Profile; | 19 class Profile; |
20 namespace views { | 20 namespace views { |
21 class View; | 21 class View; |
22 } | 22 } |
23 | 23 |
24 // Allows us to use (View*) in a hash_map with gcc. | 24 // Allows us to use (View*) in a hash_map with gcc. |
25 #if defined(COMPILER_GCC) | 25 #if defined(COMPILER_GCC) |
sky
2011/02/07 17:07:11
Can this be nuked?
dmazzoni
2011/02/08 04:00:09
Done.
| |
26 namespace __gnu_cxx { | 26 namespace __gnu_cxx { |
27 template<> | 27 template<> |
28 struct hash<views::View*> { | 28 struct hash<views::View*> { |
29 size_t operator()(views::View* view) const { | 29 size_t operator()(views::View* view) const { |
30 return reinterpret_cast<size_t>(view); | 30 return reinterpret_cast<size_t>(view); |
31 } | 31 } |
32 }; | 32 }; |
33 } // namespace __gnu_cxx | 33 } // namespace __gnu_cxx |
34 #endif // defined(COMPILER_GCC) | 34 #endif // defined(COMPILER_GCC) |
35 | 35 |
(...skipping 22 matching lines...) Expand all Loading... | |
58 // If nonempty, will use this name instead of the view's label. | 58 // If nonempty, will use this name instead of the view's label. |
59 std::string name; | 59 std::string name; |
60 | 60 |
61 // If true, will ignore this widget and not send accessibility events. | 61 // If true, will ignore this widget and not send accessibility events. |
62 bool ignore; | 62 bool ignore; |
63 }; | 63 }; |
64 | 64 |
65 // Get the single instance of this class. | 65 // Get the single instance of this class. |
66 static AccessibilityEventRouterViews* GetInstance(); | 66 static AccessibilityEventRouterViews* GetInstance(); |
67 | 67 |
68 // Start sending accessibility events for this view and all of its | |
69 // descendants. Notifications will go to the specified profile. | |
70 // Returns true on success, false if "view" was already registered. | |
71 // It is the responsibility of the caller to call RemoveViewTree if | |
72 // this view is ever deleted; consider using AccessibleViewHelper. | |
73 bool AddViewTree(views::View* view, Profile* profile); | |
74 | |
75 // Stop sending accessibility events for this view and all of its | |
76 // descendants. | |
77 void RemoveViewTree(views::View* view); | |
78 | |
79 // Don't send any events for this view. | |
80 void IgnoreView(views::View* view); | |
81 | |
82 // Use the following string as the name of this view, instead of the | |
83 // gtk label associated with the view. | |
84 void SetViewName(views::View* view, std::string name); | |
85 | |
86 // Forget all information about this view. | |
87 void RemoveView(views::View* view); | |
88 | |
89 // Handle an accessibility event generated by a view. | 68 // Handle an accessibility event generated by a view. |
90 void HandleAccessibilityEvent( | 69 void HandleAccessibilityEvent( |
91 views::View* view, AccessibilityTypes::Event event_type); | 70 views::View* view, AccessibilityTypes::Event event_type); |
92 | 71 |
93 private: | 72 private: |
94 AccessibilityEventRouterViews(); | 73 AccessibilityEventRouterViews(); |
95 virtual ~AccessibilityEventRouterViews(); | 74 virtual ~AccessibilityEventRouterViews(); |
96 | 75 |
97 friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; | 76 friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; |
98 FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest, | 77 FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest, |
99 TestFocusNotification); | 78 TestFocusNotification); |
100 | 79 |
101 // Given a view, determine if it's part of a view tree that's mapped to | |
102 // a profile and if so, if it's marked as accessible. | |
103 void FindView(views::View* view, Profile** profile, bool* is_accessible); | |
104 | |
105 // Checks the type of the view and calls one of the more specific | 80 // Checks the type of the view and calls one of the more specific |
106 // Send*Notification methods, below. | 81 // Send*Notification methods, below. |
107 void DispatchAccessibilityNotification( | 82 void DispatchAccessibilityNotification( |
108 views::View* view, NotificationType type); | 83 views::View* view, NotificationType type); |
109 | 84 |
110 // Return the name of a view. | 85 // Return the name of a view. |
111 std::string GetViewName(views::View* view); | 86 std::string GetViewName(views::View* view); |
112 | 87 |
113 // Each of these methods constructs an AccessibilityControlInfo object | 88 // Each of these methods constructs an AccessibilityControlInfo object |
114 // and sends a notification of a specific accessibility event. | 89 // and sends a notification of a specific accessibility event. |
(...skipping 12 matching lines...) Expand all Loading... | |
127 bool IsMenuEvent(views::View* view, NotificationType type); | 102 bool IsMenuEvent(views::View* view, NotificationType type); |
128 | 103 |
129 // Recursively explore all menu items of |menu| and return in |count| | 104 // Recursively explore all menu items of |menu| and return in |count| |
130 // the total number of items, and in |index| the 0-based index of | 105 // the total number of items, and in |index| the 0-based index of |
131 // |item|, if found. Initialize |count| to zero before calling this | 106 // |item|, if found. Initialize |count| to zero before calling this |
132 // method. |index| will be unchanged if the item is not found, so | 107 // method. |index| will be unchanged if the item is not found, so |
133 // initialize it to -1 to detect this case. | 108 // initialize it to -1 to detect this case. |
134 void RecursiveGetMenuItemIndexAndCount( | 109 void RecursiveGetMenuItemIndexAndCount( |
135 views::View* menu, views::View* item, int* index, int* count); | 110 views::View* menu, views::View* item, int* index, int* count); |
136 | 111 |
137 // The set of all view tree roots; only descendants of these will generate | |
138 // accessibility notifications. | |
139 base::hash_map<views::View*, Profile*> view_tree_profile_map_; | |
140 | |
141 // Extra information about specific views. | |
142 base::hash_map<views::View*, ViewInfo> view_info_map_; | |
143 | |
144 // The profile associated with the most recent window event - used to | 112 // The profile associated with the most recent window event - used to |
145 // figure out where to route a few events that can't be directly traced | 113 // figure out where to route a few events that can't be directly traced |
146 // to a window with a profile (like menu events). | 114 // to a window with a profile (like menu events). |
147 Profile* most_recent_profile_; | 115 Profile* most_recent_profile_; |
148 | 116 |
149 // Used to defer handling of some events until the next time | 117 // Used to defer handling of some events until the next time |
150 // through the event loop. | 118 // through the event loop. |
151 ScopedRunnableMethodFactory<AccessibilityEventRouterViews> method_factory_; | 119 ScopedRunnableMethodFactory<AccessibilityEventRouterViews> method_factory_; |
152 }; | 120 }; |
153 | 121 |
154 #endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ | 122 #endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ |
OLD | NEW |