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 #ifndef ASH_LOGIN_UI_HOVER_NOTIFIER_H_ 6 #define ASH_LOGIN_UI_HOVER_NOTIFIER_H_ 7 8 #include <string> 9 10 #include "base/callback.h" 11 #include "ui/events/event_handler.h" 12 13 namespace views { 14 class View; 15 } 16 17 namespace ash { 18 19 // Runs a callback whenever a view has gained or lost mouse hover. 20 // TODO(jdufault): see if we can replace this class with views::MouseWatcher. 21 class HoverNotifier : public ui::EventHandler { 22 public: 23 using OnHover = base::RepeatingCallback<void(bool has_hover)>; 24 25 HoverNotifier(views::View* target_view, const OnHover& on_hover); 26 ~HoverNotifier() override; 27 28 // ui::EventHandler: 29 void OnEvent(ui::Event* event) override; 30 31 private: 32 bool had_hover_ = false; 33 views::View* target_view_ = nullptr; 34 OnHover on_hover_; 35 36 DISALLOW_COPY_AND_ASSIGN(HoverNotifier); 37 }; 38 39 } // namespace ash 40 41 #endif // ASH_LOGIN_UI_HOVER_NOTIFIER_H_ 42