Chromium Code Reviews| Index: chrome/browser/chromeos/arc/focus_highlight/arc_focus_highlight_bridge.cc |
| diff --git a/chrome/browser/chromeos/arc/focus_highlight/arc_focus_highlight_bridge.cc b/chrome/browser/chromeos/arc/focus_highlight/arc_focus_highlight_bridge.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b406f8a1428bae1870dff24fad08cfeb0594cfd0 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/focus_highlight/arc_focus_highlight_bridge.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/arc/focus_highlight/arc_focus_highlight_bridge.h" |
| + |
| +#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| +#include "components/arc/arc_bridge_service.h" |
| +#include "components/exo/wm_helper.h" |
| +#include "ui/aura/window.h" |
| +#include "ui/gfx/geometry/rect.h" |
| + |
| +namespace arc { |
| + |
| +ArcFocusHighlightBridge::ArcFocusHighlightBridge( |
| + ArcBridgeService* bridge_service) |
| + : ArcService(bridge_service), binding_(this) { |
| + bridge_service->focus_highlight()->AddObserver(this); |
| +} |
| + |
| +ArcFocusHighlightBridge::~ArcFocusHighlightBridge() { |
| + arc_bridge_service()->focus_highlight()->RemoveObserver(this); |
| +} |
| + |
| +void ArcFocusHighlightBridge::OnInstanceReady() { |
| + auto* instance = |
| + arc_bridge_service()->focus_highlight()->GetInstanceForMethod("Init"); |
| + DCHECK(instance); |
| + instance->Init(binding_.CreateInterfacePtrAndBind()); |
| +} |
| + |
| +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.
|
| + |
| +void ArcFocusHighlightBridge::OnViewFocused(const gfx::Rect& rect) { |
| + chromeos::AccessibilityManager* accessibility_manager = |
| + chromeos::AccessibilityManager::Get(); |
| + |
| + if (!accessibility_manager || |
| + !accessibility_manager->IsFocusHighlightEnabled()) { |
| + return; |
| + } |
| + |
| + exo::WMHelper* wmHelper = exo::WMHelper::GetInstance(); |
| + aura::Window* focused_window = wmHelper->GetFocusedWindow(); |
| + 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.
|
| + return; |
| + } |
| + |
| + const gfx::Rect& window_bounds = focused_window->GetBoundsInScreen(); |
| + |
| + gfx::Rect bounds_in_screen = rect; |
| + 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
|
| + |
| + accessibility_manager->OnViewFocusedInArc(bounds_in_screen); |
| +} |
| + |
| +} // namespace arc |