| Index: chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
|
| diff --git a/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc b/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
|
| index dffdb6eb4830d87a1291c24838efd04dd028cf2a..db193beba5c628044f01b73cc6b7066695c4eef3 100644
|
| --- a/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
|
| +++ b/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
|
| @@ -15,7 +15,6 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "content/public/browser/notification_service.h"
|
| -#include "content/public/browser/notification_source.h"
|
| #include "ui/base/accessibility/accessible_view_state.h"
|
| #include "ui/views/controls/menu/menu_item_view.h"
|
| #include "ui/views/controls/menu/submenu_view.h"
|
| @@ -48,44 +47,19 @@ void AccessibilityEventRouterViews::HandleAccessibilityEvent(
|
| return;
|
| }
|
|
|
| - chrome::NotificationType notification_type;
|
| - switch (event_type) {
|
| - case ui::AccessibilityTypes::EVENT_FOCUS:
|
| - notification_type = chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED;
|
| - break;
|
| - case ui::AccessibilityTypes::EVENT_MENUSTART:
|
| - case ui::AccessibilityTypes::EVENT_MENUPOPUPSTART:
|
| - notification_type = chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED;
|
| - break;
|
| - case ui::AccessibilityTypes::EVENT_MENUEND:
|
| - case ui::AccessibilityTypes::EVENT_MENUPOPUPEND:
|
| - notification_type = chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED;
|
| - break;
|
| - case ui::AccessibilityTypes::EVENT_TEXT_CHANGED:
|
| - case ui::AccessibilityTypes::EVENT_SELECTION_CHANGED:
|
| - // These two events should only be sent for views that have focus. This
|
| - // enforces the invariant that we fire events triggered by user action and
|
| - // not by programmatic logic. For example, the location bar can be updated
|
| - // by javascript while the user focus is within some other part of the
|
| - // user interface. In contrast, the other supported events here do not
|
| - // depend on focus. For example, a menu within a menubar can open or close
|
| - // while focus is within the location bar or anywhere else as a result of
|
| - // user action. Note that the below logic can at some point be removed if
|
| - // we pass more information along to the listener such as focused state.
|
| - if (!view->GetFocusManager() ||
|
| - view->GetFocusManager()->GetFocusedView() != view)
|
| - return;
|
| - notification_type = chrome::NOTIFICATION_ACCESSIBILITY_TEXT_CHANGED;
|
| - break;
|
| - case ui::AccessibilityTypes::EVENT_VALUE_CHANGED:
|
| - notification_type = chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_ACTION;
|
| - break;
|
| - case ui::AccessibilityTypes::EVENT_ALERT:
|
| - notification_type = chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_OPENED;
|
| - break;
|
| - case ui::AccessibilityTypes::EVENT_NAME_CHANGED:
|
| - default:
|
| - NOTIMPLEMENTED();
|
| + if (event_type == ui::AccessibilityTypes::EVENT_TEXT_CHANGED ||
|
| + event_type == ui::AccessibilityTypes::EVENT_SELECTION_CHANGED) {
|
| + // These two events should only be sent for views that have focus. This
|
| + // enforces the invariant that we fire events triggered by user action and
|
| + // not by programmatic logic. For example, the location bar can be updated
|
| + // by javascript while the user focus is within some other part of the
|
| + // user interface. In contrast, the other supported events here do not
|
| + // depend on focus. For example, a menu within a menubar can open or close
|
| + // while focus is within the location bar or anywhere else as a result of
|
| + // user action. Note that the below logic can at some point be removed if
|
| + // we pass more information along to the listener such as focused state.
|
| + if (!view->GetFocusManager() ||
|
| + view->GetFocusManager()->GetFocusedView() != view)
|
| return;
|
| }
|
|
|
| @@ -99,9 +73,9 @@ void AccessibilityEventRouterViews::HandleAccessibilityEvent(
|
| base::MessageLoop::current()->PostTask(
|
| FROM_HERE,
|
| base::Bind(
|
| - &AccessibilityEventRouterViews::DispatchNotificationOnViewStorageId,
|
| + &AccessibilityEventRouterViews::DispatchEventOnViewStorageId,
|
| view_storage_id,
|
| - notification_type));
|
| + event_type));
|
| }
|
|
|
| void AccessibilityEventRouterViews::HandleMenuItemFocused(
|
| @@ -124,8 +98,8 @@ void AccessibilityEventRouterViews::HandleMenuItemFocused(
|
| has_submenu,
|
| item_index,
|
| item_count);
|
| - SendAccessibilityNotification(
|
| - chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, &info);
|
| + SendControlAccessibilityNotification(
|
| + ui::AccessibilityTypes::EVENT_FOCUS, &info);
|
| }
|
|
|
| void AccessibilityEventRouterViews::Observe(
|
| @@ -142,9 +116,9 @@ void AccessibilityEventRouterViews::Observe(
|
| // Private methods
|
| //
|
|
|
| -void AccessibilityEventRouterViews::DispatchNotificationOnViewStorageId(
|
| +void AccessibilityEventRouterViews::DispatchEventOnViewStorageId(
|
| int view_storage_id,
|
| - chrome::NotificationType type) {
|
| + ui::AccessibilityTypes::Event type) {
|
| views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
|
| views::View* view = view_storage->RetrieveView(view_storage_id);
|
| view_storage->RemoveView(view_storage_id);
|
| @@ -153,11 +127,11 @@ void AccessibilityEventRouterViews::DispatchNotificationOnViewStorageId(
|
|
|
| AccessibilityEventRouterViews* instance =
|
| AccessibilityEventRouterViews::GetInstance();
|
| - instance->DispatchAccessibilityNotification(view, type);
|
| + instance->DispatchAccessibilityEvent(view, type);
|
| }
|
|
|
| -void AccessibilityEventRouterViews::DispatchAccessibilityNotification(
|
| - views::View* view, chrome::NotificationType type) {
|
| +void AccessibilityEventRouterViews::DispatchAccessibilityEvent(
|
| + views::View* view, ui::AccessibilityTypes::Event type) {
|
| // Get the profile associated with this view. If it's not found, use
|
| // the most recent profile where accessibility events were sent, or
|
| // the default profile.
|
| @@ -180,8 +154,10 @@ void AccessibilityEventRouterViews::DispatchAccessibilityNotification(
|
|
|
| most_recent_profile_ = profile;
|
|
|
| - if (type == chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED ||
|
| - type == chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED) {
|
| + if (type == ui::AccessibilityTypes::EVENT_MENUSTART ||
|
| + type == ui::AccessibilityTypes::EVENT_MENUPOPUPSTART ||
|
| + type == ui::AccessibilityTypes::EVENT_MENUEND ||
|
| + type == ui::AccessibilityTypes::EVENT_MENUPOPUPEND) {
|
| SendMenuNotification(view, type, profile);
|
| return;
|
| }
|
| @@ -234,35 +210,35 @@ void AccessibilityEventRouterViews::DispatchAccessibilityNotification(
|
| // static
|
| void AccessibilityEventRouterViews::SendButtonNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| AccessibilityButtonInfo info(
|
| profile, GetViewName(view), GetViewContext(view));
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendLinkNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| AccessibilityLinkInfo info(profile, GetViewName(view), GetViewContext(view));
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendMenuNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| AccessibilityMenuInfo info(profile, GetViewName(view));
|
| - SendAccessibilityNotification(type, &info);
|
| + SendMenuAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendMenuItemNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| std::string name = GetViewName(view);
|
| std::string context = GetViewContext(view);
|
| @@ -286,13 +262,13 @@ void AccessibilityEventRouterViews::SendMenuItemNotification(
|
|
|
| AccessibilityMenuItemInfo info(
|
| profile, name, context, has_submenu, index, count);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendTextfieldNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -303,13 +279,13 @@ void AccessibilityEventRouterViews::SendTextfieldNotification(
|
| AccessibilityTextBoxInfo info(profile, name, context, password);
|
| std::string value = UTF16ToUTF8(state.value);
|
| info.SetValue(value, state.selection_start, state.selection_end);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendComboboxNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -318,13 +294,13 @@ void AccessibilityEventRouterViews::SendComboboxNotification(
|
| std::string context = GetViewContext(view);
|
| AccessibilityComboBoxInfo info(
|
| profile, name, context, value, state.index, state.count);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendCheckboxNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -336,13 +312,13 @@ void AccessibilityEventRouterViews::SendCheckboxNotification(
|
| name,
|
| context,
|
| state.state == ui::AccessibilityTypes::STATE_CHECKED);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendWindowNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -358,13 +334,13 @@ void AccessibilityEventRouterViews::SendWindowNotification(
|
| window_text = UTF16ToUTF8(state.name);
|
|
|
| AccessibilityWindowInfo info(profile, window_text);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendWindowAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendSliderNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event event,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -377,7 +353,7 @@ void AccessibilityEventRouterViews::SendSliderNotification(
|
| name,
|
| context,
|
| value);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(event, &info);
|
| }
|
|
|
| // static
|
| @@ -444,28 +420,6 @@ views::View* AccessibilityEventRouterViews::FindDescendantWithAccessibleRole(
|
| }
|
|
|
| // static
|
| -bool AccessibilityEventRouterViews::IsMenuEvent(
|
| - views::View* view,
|
| - int type) {
|
| - if (type == chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED ||
|
| - type == chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED)
|
| - return true;
|
| -
|
| - while (view) {
|
| - ui::AccessibleViewState state;
|
| - view->GetAccessibleState(&state);
|
| - ui::AccessibilityTypes::Role role = state.role;
|
| - if (role == ui::AccessibilityTypes::ROLE_MENUITEM ||
|
| - role == ui::AccessibilityTypes::ROLE_MENUPOPUP) {
|
| - return true;
|
| - }
|
| - view = view->parent();
|
| - }
|
| -
|
| - return false;
|
| -}
|
| -
|
| -// static
|
| void AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount(
|
| views::View* menu,
|
| views::View* item,
|
|
|