Index: chrome/browser/views/accessibility_event_router_views.h |
=================================================================== |
--- chrome/browser/views/accessibility_event_router_views.h (revision 55065) |
+++ chrome/browser/views/accessibility_event_router_views.h (working copy) |
@@ -9,6 +9,7 @@ |
#include <string> |
#include "base/basictypes.h" |
+#include "base/gtest_prod_util.h" |
#include "base/hash_tables.h" |
#include "base/singleton.h" |
#include "base/task.h" |
@@ -18,16 +19,10 @@ |
class Profile; |
-// Allows us to use (View*) and (FocusManager*) in a hash_map with gcc. |
+// Allows us to use (View*) in a hash_map with gcc. |
#if defined(COMPILER_GCC) |
namespace __gnu_cxx { |
template<> |
-struct hash<views::FocusManager*> { |
- size_t operator()(views::FocusManager* focus_manager) const { |
- return reinterpret_cast<size_t>(focus_manager); |
- } |
-}; |
-template<> |
struct hash<views::View*> { |
size_t operator()(views::View* view) const { |
return reinterpret_cast<size_t>(view); |
@@ -51,23 +46,18 @@ |
// |
// You can use Profile::PauseAccessibilityEvents to prevent a flurry |
// of accessibility events when a window is being created or initialized. |
-class AccessibilityEventRouterViews |
- : public views::FocusChangeListener { |
+class AccessibilityEventRouterViews { |
public: |
// Internal information about a particular view to override the |
// information we get directly from the view. |
struct ViewInfo { |
- ViewInfo() : ignore(false), focus_manager(NULL) {} |
+ ViewInfo() : ignore(false) {} |
// If nonempty, will use this name instead of the view's label. |
std::string name; |
// If true, will ignore this widget and not send accessibility events. |
bool ignore; |
- |
- // The focus manager that this view is part of - saved because |
- // GetFocusManager may not succeed while a view is being deleted. |
- views::FocusManager* focus_manager; |
}; |
// Get the single instance of this class. |
@@ -94,11 +84,18 @@ |
// Forget all information about this view. |
void RemoveView(views::View* view); |
- // Implementation of views::FocusChangeListener: |
- virtual void FocusWillChange( |
- views::View* focused_before, views::View* focused_now); |
+ // Handle an accessibility event generated by a view. |
+ void HandleAccessibilityEvent( |
+ views::View* view, AccessibilityTypes::Event event_type); |
private: |
+ AccessibilityEventRouterViews(); |
+ virtual ~AccessibilityEventRouterViews(); |
+ |
+ friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; |
+ FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest, |
+ TestFocusNotification); |
+ |
// Given a view, determine if it's part of a view tree that's mapped to |
// a profile and if so, if it's marked as accessible. |
void FindView(views::View* view, Profile** profile, bool* is_accessible); |
@@ -119,12 +116,19 @@ |
views::View* view, NotificationType type, Profile* profile); |
void SendMenuNotification( |
views::View* view, NotificationType type, Profile* profile); |
+ void SendMenuItemNotification( |
+ views::View* view, NotificationType type, Profile* profile); |
- private: |
- AccessibilityEventRouterViews(); |
- virtual ~AccessibilityEventRouterViews(); |
+ // Return true if it's an event on a menu. |
+ bool IsMenuEvent(views::View* view, NotificationType type); |
- friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; |
+ // Recursively explore all menu items of |menu| and return in |count| |
+ // the total number of items, and in |index| the 0-based index of |
+ // |item|, if found. Initialize |count| to zero before calling this |
+ // method. |index| will be unchanged if the item is not found, so |
+ // initialize it to -1 to detect this case. |
+ void RecursiveGetMenuItemIndexAndCount( |
+ views::View* menu, views::View* item, int* index, int* count); |
// The set of all view tree roots; only descendants of these will generate |
// accessibility notifications. |
@@ -133,8 +137,10 @@ |
// Extra information about specific views. |
base::hash_map<views::View*, ViewInfo> view_info_map_; |
- // Count of the number of references to each focus manager. |
- base::hash_map<views::FocusManager*, int> focus_manager_ref_count_; |
+ // The profile associated with the most recent window event - used to |
+ // figure out where to route a few events that can't be directly traced |
+ // to a window with a profile (like menu events). |
+ Profile* most_recent_profile_; |
// Used to defer handling of some events until the next time |
// through the event loop. |