| 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 CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H
_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H
_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H
_ | 6 #define CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H
_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "chrome/browser/accessibility/accessibility_events.h" | 13 #include "chrome/browser/accessibility/accessibility_events.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | |
| 15 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 17 #include "ui/base/accessibility/accessibility_types.h" | 16 #include "ui/base/accessibility/accessibility_types.h" |
| 18 | 17 |
| 19 class Profile; | 18 class Profile; |
| 20 | 19 |
| 21 template <typename T> struct DefaultSingletonTraits; | 20 template <typename T> struct DefaultSingletonTraits; |
| 22 | 21 |
| 23 namespace views { | 22 namespace views { |
| 24 class View; | 23 class View; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 62 |
| 64 private: | 63 private: |
| 65 friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; | 64 friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; |
| 66 | 65 |
| 67 FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest, | 66 FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest, |
| 68 TestFocusNotification); | 67 TestFocusNotification); |
| 69 | 68 |
| 70 AccessibilityEventRouterViews(); | 69 AccessibilityEventRouterViews(); |
| 71 virtual ~AccessibilityEventRouterViews(); | 70 virtual ~AccessibilityEventRouterViews(); |
| 72 | 71 |
| 73 // Call DispatchAccessibilityNotification using a view storage id. | 72 // Call DispatchAccessibilityEvent using a view storage id. |
| 74 static void DispatchNotificationOnViewStorageId( | 73 static void DispatchEventOnViewStorageId( |
| 75 int view_storage_id, | 74 int view_storage_id, |
| 76 chrome::NotificationType type); | 75 ui::AccessibilityTypes::Event event); |
| 77 | 76 |
| 78 // Checks the type of the view and calls one of the more specific | 77 // Checks the type of the view and calls one of the more specific |
| 79 // Send*Notification methods, below. | 78 // Send*Notification methods, below. |
| 80 void DispatchAccessibilityNotification( | 79 void DispatchAccessibilityEvent( |
| 81 views::View* view, | 80 views::View* view, |
| 82 chrome::NotificationType type); | 81 ui::AccessibilityTypes::Event event); |
| 83 | 82 |
| 84 // Each of these methods constructs an AccessibilityControlInfo object | 83 // Each of these methods constructs an AccessibilityControlInfo object |
| 85 // and sends a notification of a specific accessibility event. | 84 // and sends a notification of a specific accessibility event. |
| 86 static void SendButtonNotification( | 85 static void SendButtonNotification( |
| 87 views::View* view, | 86 views::View* view, |
| 88 int type, | 87 ui::AccessibilityTypes::Event event, |
| 89 Profile* profile); | 88 Profile* profile); |
| 90 static void SendLinkNotification( | 89 static void SendLinkNotification( |
| 91 views::View* view, | 90 views::View* view, |
| 92 int type, | 91 ui::AccessibilityTypes::Event event, |
| 93 Profile* profile); | 92 Profile* profile); |
| 94 static void SendMenuNotification( | 93 static void SendMenuNotification( |
| 95 views::View* view, | 94 views::View* view, |
| 96 int type, | 95 ui::AccessibilityTypes::Event event, |
| 97 Profile* profile); | 96 Profile* profile); |
| 98 static void SendMenuItemNotification( | 97 static void SendMenuItemNotification( |
| 99 views::View* view, | 98 views::View* view, |
| 100 int type, | 99 ui::AccessibilityTypes::Event event, |
| 101 Profile* profile); | 100 Profile* profile); |
| 102 static void SendTextfieldNotification( | 101 static void SendTextfieldNotification( |
| 103 views::View* view, | 102 views::View* view, |
| 104 int type, | 103 ui::AccessibilityTypes::Event event, |
| 105 Profile* profile); | 104 Profile* profile); |
| 106 static void SendComboboxNotification( | 105 static void SendComboboxNotification( |
| 107 views::View* view, | 106 views::View* view, |
| 108 int type, | 107 ui::AccessibilityTypes::Event event, |
| 109 Profile* profile); | 108 Profile* profile); |
| 110 static void SendCheckboxNotification( | 109 static void SendCheckboxNotification( |
| 111 views::View* view, | 110 views::View* view, |
| 112 int type, | 111 ui::AccessibilityTypes::Event event, |
| 113 Profile* profile); | 112 Profile* profile); |
| 114 static void SendWindowNotification( | 113 static void SendWindowNotification( |
| 115 views::View* view, | 114 views::View* view, |
| 116 int type, | 115 ui::AccessibilityTypes::Event event, |
| 117 Profile* profile); | 116 Profile* profile); |
| 118 static void SendSliderNotification( | 117 static void SendSliderNotification( |
| 119 views::View* view, | 118 views::View* view, |
| 120 int type, | 119 ui::AccessibilityTypes::Event event, |
| 121 Profile* profile); | 120 Profile* profile); |
| 122 | 121 |
| 123 // Return the name of a view. | 122 // Return the name of a view. |
| 124 static std::string GetViewName(views::View* view); | 123 static std::string GetViewName(views::View* view); |
| 125 | 124 |
| 126 // Get the context of a view - the name of the enclosing group, toolbar, etc. | 125 // Get the context of a view - the name of the enclosing group, toolbar, etc. |
| 127 static std::string GetViewContext(views::View* view); | 126 static std::string GetViewContext(views::View* view); |
| 128 | 127 |
| 129 // Return a descendant of this view with a given accessible role, if found. | 128 // Return a descendant of this view with a given accessible role, if found. |
| 130 static views::View* FindDescendantWithAccessibleRole( | 129 static views::View* FindDescendantWithAccessibleRole( |
| 131 views::View* view, | 130 views::View* view, |
| 132 ui::AccessibilityTypes::Role role); | 131 ui::AccessibilityTypes::Role role); |
| 133 | 132 |
| 134 // Return true if it's an event on a menu. | |
| 135 static bool IsMenuEvent(views::View* view, | |
| 136 int type); | |
| 137 | |
| 138 // Recursively explore all menu items of |menu| and return in |count| | 133 // Recursively explore all menu items of |menu| and return in |count| |
| 139 // the total number of items, and in |index| the 0-based index of | 134 // the total number of items, and in |index| the 0-based index of |
| 140 // |item|, if found. Initialize |count| to zero before calling this | 135 // |item|, if found. Initialize |count| to zero before calling this |
| 141 // method. |index| will be unchanged if the item is not found, so | 136 // method. |index| will be unchanged if the item is not found, so |
| 142 // initialize it to -1 to detect this case. | 137 // initialize it to -1 to detect this case. |
| 143 static void RecursiveGetMenuItemIndexAndCount(views::View* menu, | 138 static void RecursiveGetMenuItemIndexAndCount(views::View* menu, |
| 144 views::View* item, | 139 views::View* item, |
| 145 int* index, | 140 int* index, |
| 146 int* count); | 141 int* count); |
| 147 | 142 |
| 148 // Recursively explore the subviews and return the text from the first | 143 // Recursively explore the subviews and return the text from the first |
| 149 // subview with a role of STATIC_TEXT. | 144 // subview with a role of STATIC_TEXT. |
| 150 static std::string RecursiveGetStaticText(views::View* view); | 145 static std::string RecursiveGetStaticText(views::View* view); |
| 151 | 146 |
| 152 // The profile associated with the most recent window event - used to | 147 // The profile associated with the most recent window event - used to |
| 153 // figure out where to route a few events that can't be directly traced | 148 // figure out where to route a few events that can't be directly traced |
| 154 // to a window with a profile (like menu events). | 149 // to a window with a profile (like menu events). |
| 155 Profile* most_recent_profile_; | 150 Profile* most_recent_profile_; |
| 156 | 151 |
| 157 // Notification registrar so we can clear most_recent_profile_ when a | 152 // Notification registrar so we can clear most_recent_profile_ when a |
| 158 // profile is destroyed. | 153 // profile is destroyed. |
| 159 content::NotificationRegistrar registrar_; | 154 content::NotificationRegistrar registrar_; |
| 160 | 155 |
| 161 DISALLOW_COPY_AND_ASSIGN(AccessibilityEventRouterViews); | 156 DISALLOW_COPY_AND_ASSIGN(AccessibilityEventRouterViews); |
| 162 }; | 157 }; |
| 163 | 158 |
| 164 #endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_ACCESSIBILITY_EVENT_ROUTER_VIEW
S_H_ | 159 #endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_ACCESSIBILITY_EVENT_ROUTER_VIEW
S_H_ |
| OLD | NEW |