time_to_click_recorder.cc 765 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2018 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. #include "ash/system/tray/time_to_click_recorder.h"
  5. #include "ui/events/event.h"
  6. #include "ui/views/view.h"
  7. namespace ash {
  8. TimeToClickRecorder::TimeToClickRecorder(Delegate* delegate,
  9. views::View* target_view)
  10. : delegate_(delegate) {
  11. target_view->AddPreTargetHandler(this);
  12. }
  13. void TimeToClickRecorder::OnEvent(ui::Event* event) {
  14. // Ignore if the event is neither click nor tap.
  15. if (event->type() != ui::ET_MOUSE_PRESSED &&
  16. event->type() != ui::ET_GESTURE_TAP) {
  17. return;
  18. }
  19. delegate_->RecordTimeToClick();
  20. }
  21. } // namespace ash