Commit 533ff0e8 authored by Sara Kato's avatar Sara Kato Committed by Commit Bot

Clean up onAccessibilityEvent() remove unused mojom fields

This CL also removes unused mojom field (WHITELISTED_PACKAGE_NAME_DEPRECATED).
Android side change (ag/9816677)

Test: ArcAccessibilityHelperBridgeTest.* passes
Bug: b/145316954
Change-Id: Ibac294eddbb45077ec4014b8b5c494599d724dd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935636Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Sara Kato <sarakato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721817}
parent 6eb7734f
...@@ -350,16 +350,8 @@ extensions::EventRouter* ArcAccessibilityHelperBridge::GetEventRouter() const { ...@@ -350,16 +350,8 @@ extensions::EventRouter* ArcAccessibilityHelperBridge::GetEventRouter() const {
return extensions::EventRouter::Get(profile_); return extensions::EventRouter::Get(profile_);
} }
void ArcAccessibilityHelperBridge::OnAccessibilityEvent( void ArcAccessibilityHelperBridge::HandleFilterTypeAllEvent(
mojom::AccessibilityEventDataPtr event_data) { mojom::AccessibilityEventDataPtr event_data) {
arc::mojom::AccessibilityFilterType filter_type =
GetFilterTypeForProfile(profile_);
DCHECK(
filter_type !=
arc::mojom::AccessibilityFilterType::WHITELISTED_PACKAGE_NAME_DEPRECATED);
if (filter_type == arc::mojom::AccessibilityFilterType::ALL) {
if (event_data->event_type == if (event_data->event_type ==
arc::mojom::AccessibilityEventType::ANNOUNCEMENT) { arc::mojom::AccessibilityEventType::ANNOUNCEMENT) {
if (!event_data->eventText.has_value()) if (!event_data->eventText.has_value())
...@@ -370,8 +362,7 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent( ...@@ -370,8 +362,7 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent(
extensions::api::accessibility_private::OnAnnounceForAccessibility:: extensions::api::accessibility_private::OnAnnounceForAccessibility::
Create(*(event_data->eventText))); Create(*(event_data->eventText)));
std::unique_ptr<extensions::Event> event(new extensions::Event( std::unique_ptr<extensions::Event> event(new extensions::Event(
extensions::events:: extensions::events::ACCESSIBILITY_PRIVATE_ON_ANNOUNCE_FOR_ACCESSIBILITY,
ACCESSIBILITY_PRIVATE_ON_ANNOUNCE_FOR_ACCESSIBILITY,
extensions::api::accessibility_private::OnAnnounceForAccessibility:: extensions::api::accessibility_private::OnAnnounceForAccessibility::
kEventName, kEventName,
std::move(event_args))); std::move(event_args)));
...@@ -385,8 +376,7 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent( ...@@ -385,8 +376,7 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent(
AXTreeSourceArc* tree_source = nullptr; AXTreeSourceArc* tree_source = nullptr;
bool is_notification_event = event_data->notification_key.has_value(); bool is_notification_event = event_data->notification_key.has_value();
if (is_notification_event) { if (is_notification_event) {
const std::string& notification_key = const std::string& notification_key = event_data->notification_key.value();
event_data->notification_key.value();
// This bridge must receive OnNotificationStateChanged call for the // This bridge must receive OnNotificationStateChanged call for the
// notification_key before this receives an accessibility event for it. // notification_key before this receives an accessibility event for it.
...@@ -451,8 +441,8 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent( ...@@ -451,8 +441,8 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent(
// as the view can take necessary actions, e.g. activate itself, etc. // as the view can take necessary actions, e.g. activate itself, etc.
auto* surface_manager = ArcNotificationSurfaceManager::Get(); auto* surface_manager = ArcNotificationSurfaceManager::Get();
if (surface_manager) { if (surface_manager) {
ArcNotificationSurface* surface = surface_manager->GetArcSurface( ArcNotificationSurface* surface =
event_data->notification_key.value()); surface_manager->GetArcSurface(event_data->notification_key.value());
if (surface) { if (surface) {
surface->GetAttachedHost()->NotifyAccessibilityEvent( surface->GetAttachedHost()->NotifyAccessibilityEvent(
ax::mojom::Event::kTextSelectionChanged, true); ax::mojom::Event::kTextSelectionChanged, true);
...@@ -461,18 +451,33 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent( ...@@ -461,18 +451,33 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent(
} else if (!is_notification_event) { } else if (!is_notification_event) {
UpdateWindowProperties(GetActiveWindow()); UpdateWindowProperties(GetActiveWindow());
} }
}
return; void ArcAccessibilityHelperBridge::HandleFilterTypeFocusEvent(
} mojom::AccessibilityEventDataPtr event_data) {
if (event_data.get()->node_data.size() == 1 &&
if (event_data->event_type != event_data->event_type ==
arc::mojom::AccessibilityEventType::VIEW_FOCUSED) arc::mojom::AccessibilityEventType::VIEW_FOCUSED)
return;
CHECK_EQ(1U, event_data.get()->node_data.size());
DispatchFocusChange(event_data.get()->node_data[0].get(), profile_); DispatchFocusChange(event_data.get()->node_data[0].get(), profile_);
} }
void ArcAccessibilityHelperBridge::OnAccessibilityEvent(
mojom::AccessibilityEventDataPtr event_data) {
arc::mojom::AccessibilityFilterType filter_type =
GetFilterTypeForProfile(profile_);
switch (filter_type) {
case arc::mojom::AccessibilityFilterType::ALL:
HandleFilterTypeAllEvent(std::move(event_data));
break;
case arc::mojom::AccessibilityFilterType::FOCUS:
HandleFilterTypeFocusEvent(std::move(event_data));
break;
case arc::mojom::AccessibilityFilterType::OFF:
break;
}
}
void ArcAccessibilityHelperBridge::OnNotificationStateChanged( void ArcAccessibilityHelperBridge::OnNotificationStateChanged(
const std::string& notification_key, const std::string& notification_key,
arc::mojom::AccessibilityNotificationStateType state) { arc::mojom::AccessibilityNotificationStateType state) {
......
...@@ -141,6 +141,8 @@ class ArcAccessibilityHelperBridge ...@@ -141,6 +141,8 @@ class ArcAccessibilityHelperBridge
void SetExploreByTouchEnabled(bool enabled); void SetExploreByTouchEnabled(bool enabled);
void UpdateTreeIdOfNotificationSurface(const std::string& notification_key, void UpdateTreeIdOfNotificationSurface(const std::string& notification_key,
ui::AXTreeID tree_id); ui::AXTreeID tree_id);
void HandleFilterTypeFocusEvent(mojom::AccessibilityEventDataPtr event_data);
void HandleFilterTypeAllEvent(mojom::AccessibilityEventDataPtr event_data);
AXTreeSourceArc* GetFromTaskId(int32_t task_id); AXTreeSourceArc* GetFromTaskId(int32_t task_id);
AXTreeSourceArc* CreateFromTaskId(int32_t task_id); AXTreeSourceArc* CreateFromTaskId(int32_t task_id);
......
...@@ -306,10 +306,7 @@ enum AccessibilityFilterType { ...@@ -306,10 +306,7 @@ enum AccessibilityFilterType {
FOCUS, FOCUS,
// Send a complete tree from the event source's root for every event. // Send a complete tree from the event source's root for every event.
ALL, ALL
// Send complete subtrees for root nodes with whitelisted package names.
[MinVersion=2] WHITELISTED_PACKAGE_NAME_DEPRECATED
}; };
[Extensible] [Extensible]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment