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

Side by Side Diff: chrome/browser/chromeos/arc/focus_highlight/arc_focus_highlight_bridge.cc

Issue 2559663002: Support focus highlight in Android window (Closed)
Patch Set: Move focus_highlight from components/arc to c/b/chromeos/arc Created 4 years 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 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/focus_highlight/arc_focus_highlight_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 #include "ui/gfx/geometry/rect.h"
12
13 namespace arc {
14
15 ArcFocusHighlightBridge::ArcFocusHighlightBridge(
16 ArcBridgeService* bridge_service)
17 : ArcService(bridge_service), binding_(this) {
18 bridge_service->focus_highlight()->AddObserver(this);
19 }
20
21 ArcFocusHighlightBridge::~ArcFocusHighlightBridge() {
22 arc_bridge_service()->focus_highlight()->RemoveObserver(this);
23 }
24
25 void ArcFocusHighlightBridge::OnInstanceReady() {
26 auto* instance =
27 arc_bridge_service()->focus_highlight()->GetInstanceForMethod("Init");
28 DCHECK(instance);
29 instance->Init(binding_.CreateInterfacePtrAndBind());
30 }
31
32 void ArcFocusHighlightBridge::OnInstanceClosed() {}
Luis Héctor Chávez 2016/12/07 17:58:56 You don't seem to need this. Let's remove it.
yawano 2017/01/11 10:31:33 Done.
33
34 void ArcFocusHighlightBridge::OnViewFocused(const gfx::Rect& rect) {
35 chromeos::AccessibilityManager* accessibility_manager =
36 chromeos::AccessibilityManager::Get();
37
38 if (!accessibility_manager ||
39 !accessibility_manager->IsFocusHighlightEnabled()) {
40 return;
41 }
42
43 exo::WMHelper* wmHelper = exo::WMHelper::GetInstance();
44 aura::Window* focused_window = wmHelper->GetFocusedWindow();
45 if (!focused_window) {
Luis Héctor Chávez 2016/12/07 17:58:56 nit: elide the braces.
yawano 2017/01/11 10:31:32 Done.
46 return;
47 }
48
49 const gfx::Rect& window_bounds = focused_window->GetBoundsInScreen();
50
51 gfx::Rect bounds_in_screen = rect;
52 bounds_in_screen.Offset(window_bounds.x(), window_bounds.y());
kinaba 2016/12/08 04:07:44 Does this work as expected on Samus (a device with
53
54 accessibility_manager->OnViewFocusedInArc(bounds_in_screen);
55 }
56
57 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698