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 "ash/login/ui/hover_notifier.h"
6 
7 #include "ui/views/view.h"
8 
9 namespace ash {
10 
HoverNotifier(views::View * target_view,const OnHover & on_hover)11 HoverNotifier::HoverNotifier(views::View* target_view, const OnHover& on_hover)
12     : target_view_(target_view), on_hover_(on_hover) {
13   target_view_->AddPreTargetHandler(this);
14   on_hover_.Run(target_view_->IsMouseHovered());
15 }
16 
~HoverNotifier()17 HoverNotifier::~HoverNotifier() {
18   target_view_->RemovePreTargetHandler(this);
19 }
20 
OnEvent(ui::Event * event)21 void HoverNotifier::OnEvent(ui::Event* event) {
22   bool has_hover = target_view_->IsMouseHovered();
23   if (has_hover == had_hover_)
24     return;
25 
26   had_hover_ = has_hover;
27   on_hover_.Run(has_hover);
28 }
29 
30 }  // namespace ash
31