control_v_histogram_recorder.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2021 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. #ifndef ASH_CLIPBOARD_CONTROL_V_HISTOGRAM_RECORDER_H_
  5. #define ASH_CLIPBOARD_CONTROL_V_HISTOGRAM_RECORDER_H_
  6. #include "ash/ash_export.h"
  7. #include "base/time/time.h"
  8. #include "ui/events/event_handler.h"
  9. namespace ui {
  10. class KeyEvent;
  11. } // namespace ui
  12. namespace ash {
  13. // An EventHandler added as a pretarget handler to Shell to record the time
  14. // delay between ui::VKEY_CONTROL and ui::VKEY_V when a user is pasting.
  15. class ControlVHistogramRecorder : public ui::EventHandler {
  16. public:
  17. ControlVHistogramRecorder() = default;
  18. ControlVHistogramRecorder(const ControlVHistogramRecorder&) = delete;
  19. ControlVHistogramRecorder& operator=(const ControlVHistogramRecorder&) =
  20. delete;
  21. ~ControlVHistogramRecorder() override = default;
  22. // ui::EventHandler:
  23. void OnKeyEvent(ui::KeyEvent* event) override;
  24. private:
  25. // The last time a user pressed ui::VKEY_CONTROL. Used to establish a time
  26. // range for user patterns while pressing ui::VKEY_CONTROL + ui::VKEY_V.
  27. base::TimeTicks ctrl_pressed_time_;
  28. };
  29. } // namespace ash
  30. #endif // ASH_CLIPBOARD_CONTROL_V_HISTOGRAM_RECORDER_H_