| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/arc/accessibility_helper/arc_accessibility_hel
per_bridge.h" |
| 6 |
| 7 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 8 #include "components/arc/arc_bridge_service.h" |
| 9 #include "components/exo/wm_helper.h" |
| 10 #include "ui/aura/window.h" |
| 11 |
| 12 namespace arc { |
| 13 |
| 14 ArcAccessibilityHelperBridge::ArcAccessibilityHelperBridge( |
| 15 ArcBridgeService* bridge_service) |
| 16 : ArcService(bridge_service), binding_(this) { |
| 17 bridge_service->accessibility_helper()->AddObserver(this); |
| 18 } |
| 19 |
| 20 ArcAccessibilityHelperBridge::~ArcAccessibilityHelperBridge() { |
| 21 arc_bridge_service()->accessibility_helper()->RemoveObserver(this); |
| 22 } |
| 23 |
| 24 void ArcAccessibilityHelperBridge::OnInstanceReady() { |
| 25 auto* instance = ARC_GET_INSTANCE_FOR_METHOD( |
| 26 arc_bridge_service()->accessibility_helper(), Init); |
| 27 DCHECK(instance); |
| 28 instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 29 } |
| 30 |
| 31 void ArcAccessibilityHelperBridge::OnAccessibilityEvent( |
| 32 mojom::AccessibilityEventType eventType, |
| 33 mojom::AccessibilityNodeInfoDataPtr eventSource) { |
| 34 if (eventType != mojom::AccessibilityEventType::VIEW_FOCUSED || |
| 35 eventSource.is_null()) { |
| 36 return; |
| 37 } |
| 38 |
| 39 chromeos::AccessibilityManager* accessibility_manager = |
| 40 chromeos::AccessibilityManager::Get(); |
| 41 |
| 42 if (!accessibility_manager || |
| 43 !accessibility_manager->IsFocusHighlightEnabled()) { |
| 44 return; |
| 45 } |
| 46 |
| 47 exo::WMHelper* wmHelper = exo::WMHelper::GetInstance(); |
| 48 |
| 49 aura::Window* focused_window = wmHelper->GetFocusedWindow(); |
| 50 if (!focused_window) |
| 51 return; |
| 52 |
| 53 aura::Window* toplevel_window = focused_window->GetToplevelWindow(); |
| 54 |
| 55 gfx::Rect bounds_in_screen = gfx::ScaleToEnclosingRect( |
| 56 eventSource.get()->boundsInScreen, |
| 57 1 / toplevel_window->layer()->device_scale_factor()); |
| 58 |
| 59 const gfx::Rect& window_bounds = toplevel_window->GetBoundsInScreen(); |
| 60 bounds_in_screen.Offset(window_bounds.x(), window_bounds.y()); |
| 61 |
| 62 accessibility_manager->OnViewFocusedInArc(bounds_in_screen); |
| 63 } |
| 64 |
| 65 } // namespace arc |
| OLD | NEW |