| Index: components/arc/focus_highlight/arc_focus_highlight_bridge.cc
|
| diff --git a/components/arc/focus_highlight/arc_focus_highlight_bridge.cc b/components/arc/focus_highlight/arc_focus_highlight_bridge.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f36a60b1cc92f9a0bc284d8427c55318108f13e7
|
| --- /dev/null
|
| +++ b/components/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 "components/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() {}
|
| +
|
| +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) {
|
| + 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());
|
| +
|
| + accessibility_manager->OnViewFocusedInArc(bounds_in_screen);
|
| +}
|
| +
|
| +} // namespace arc
|
|
|