Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: chrome/browser/chromeos/arc/accessibility_helper/arc_accessibility_helper_bridge.cc

Issue 2559663002: Support focus highlight in Android window (Closed)
Patch Set: Fix comments and style. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_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(
Luis Héctor Chávez 2017/01/19 17:17:56 nit: #include "ui/gfx/geometry/rect.h"
yawano 2017/01/20 06:52:30 Done.
56 eventSource.get()->boundsInScreen,
57 1 / toplevel_window->layer()->device_scale_factor());
Luis Héctor Chávez 2017/01/19 17:17:56 nit: maybe 1.0f to avoid the implicit conversion?
yawano 2017/01/20 06:52:30 Done.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698