| 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..23c92b8e8914b09c877d7a7eb1090b4762381767 100644
|
| --- a/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
|
| +++ b/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
|
| @@ -48,44 +48,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;
|
| }
|
|
|
| @@ -101,7 +76,7 @@ void AccessibilityEventRouterViews::HandleAccessibilityEvent(
|
| base::Bind(
|
| &AccessibilityEventRouterViews::DispatchNotificationOnViewStorageId,
|
| view_storage_id,
|
| - notification_type));
|
| + event_type));
|
| }
|
|
|
| void AccessibilityEventRouterViews::HandleMenuItemFocused(
|
| @@ -124,8 +99,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(
|
| @@ -144,7 +119,7 @@ void AccessibilityEventRouterViews::Observe(
|
|
|
| void AccessibilityEventRouterViews::DispatchNotificationOnViewStorageId(
|
| 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);
|
| @@ -157,7 +132,7 @@ void AccessibilityEventRouterViews::DispatchNotificationOnViewStorageId(
|
| }
|
|
|
| void AccessibilityEventRouterViews::DispatchAccessibilityNotification(
|
| - views::View* view, chrome::NotificationType type) {
|
| + 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 +155,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 +211,35 @@ void AccessibilityEventRouterViews::DispatchAccessibilityNotification(
|
| // static
|
| void AccessibilityEventRouterViews::SendButtonNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| AccessibilityButtonInfo info(
|
| profile, GetViewName(view), GetViewContext(view));
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(type, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendLinkNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| AccessibilityLinkInfo info(profile, GetViewName(view), GetViewContext(view));
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(type, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendMenuNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| AccessibilityMenuInfo info(profile, GetViewName(view));
|
| - SendAccessibilityNotification(type, &info);
|
| + SendMenuAccessibilityNotification(type, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendMenuItemNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| std::string name = GetViewName(view);
|
| std::string context = GetViewContext(view);
|
| @@ -286,13 +263,13 @@ void AccessibilityEventRouterViews::SendMenuItemNotification(
|
|
|
| AccessibilityMenuItemInfo info(
|
| profile, name, context, has_submenu, index, count);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(type, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendTextfieldNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -303,13 +280,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(type, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendComboboxNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -318,13 +295,13 @@ void AccessibilityEventRouterViews::SendComboboxNotification(
|
| std::string context = GetViewContext(view);
|
| AccessibilityComboBoxInfo info(
|
| profile, name, context, value, state.index, state.count);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(type, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendCheckboxNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -336,13 +313,13 @@ void AccessibilityEventRouterViews::SendCheckboxNotification(
|
| name,
|
| context,
|
| state.state == ui::AccessibilityTypes::STATE_CHECKED);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(type, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendWindowNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -358,13 +335,13 @@ void AccessibilityEventRouterViews::SendWindowNotification(
|
| window_text = UTF16ToUTF8(state.name);
|
|
|
| AccessibilityWindowInfo info(profile, window_text);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendWindowAccessibilityNotification(type, &info);
|
| }
|
|
|
| // static
|
| void AccessibilityEventRouterViews::SendSliderNotification(
|
| views::View* view,
|
| - int type,
|
| + ui::AccessibilityTypes::Event type,
|
| Profile* profile) {
|
| ui::AccessibleViewState state;
|
| view->GetAccessibleState(&state);
|
| @@ -377,7 +354,7 @@ void AccessibilityEventRouterViews::SendSliderNotification(
|
| name,
|
| context,
|
| value);
|
| - SendAccessibilityNotification(type, &info);
|
| + SendControlAccessibilityNotification(type, &info);
|
| }
|
|
|
| // static
|
|
|