| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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/arc_accessibility_helper_bri
dge.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 #include "ui/gfx/geometry/rect.h" |
| 12 |
| 13 namespace arc { |
| 14 |
| 15 ArcAccessibilityHelperBridge::ArcAccessibilityHelperBridge( |
| 16 ArcBridgeService* bridge_service) |
| 17 : ArcService(bridge_service), binding_(this) { |
| 18 arc_bridge_service()->accessibility_helper()->AddObserver(this); |
| 19 } |
| 20 |
| 21 ArcAccessibilityHelperBridge::~ArcAccessibilityHelperBridge() { |
| 22 arc_bridge_service()->accessibility_helper()->RemoveObserver(this); |
| 23 } |
| 24 |
| 25 void ArcAccessibilityHelperBridge::OnInstanceReady() { |
| 26 auto* instance = ARC_GET_INSTANCE_FOR_METHOD( |
| 27 arc_bridge_service()->accessibility_helper(), Init); |
| 28 DCHECK(instance); |
| 29 instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 30 } |
| 31 |
| 32 void ArcAccessibilityHelperBridge::OnAccessibilityEvent( |
| 33 mojom::AccessibilityEventType event_type, |
| 34 mojom::AccessibilityNodeInfoDataPtr event_source) { |
| 35 if (event_type != mojom::AccessibilityEventType::VIEW_FOCUSED || |
| 36 event_source.is_null()) { |
| 37 return; |
| 38 } |
| 39 |
| 40 chromeos::AccessibilityManager* accessibility_manager = |
| 41 chromeos::AccessibilityManager::Get(); |
| 42 |
| 43 if (!accessibility_manager || |
| 44 !accessibility_manager->IsFocusHighlightEnabled()) { |
| 45 return; |
| 46 } |
| 47 |
| 48 exo::WMHelper* wmHelper = exo::WMHelper::GetInstance(); |
| 49 |
| 50 aura::Window* focused_window = wmHelper->GetFocusedWindow(); |
| 51 if (!focused_window) |
| 52 return; |
| 53 |
| 54 aura::Window* toplevel_window = focused_window->GetToplevelWindow(); |
| 55 |
| 56 gfx::Rect bounds_in_screen = gfx::ScaleToEnclosingRect( |
| 57 event_source.get()->boundsInScreen, |
| 58 1.0f / toplevel_window->layer()->device_scale_factor()); |
| 59 |
| 60 accessibility_manager->OnViewFocusedInArc(bounds_in_screen); |
| 61 } |
| 62 |
| 63 } // namespace arc |
| OLD | NEW |