Chromium Code Reviews| Index: ash/autoclick/common/autoclick_controller_common.h |
| diff --git a/ash/autoclick/common/autoclick_controller_common.h b/ash/autoclick/common/autoclick_controller_common.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a8d0a4947a30bc80c526d324cb9e3f6e4b2ed651 |
| --- /dev/null |
| +++ b/ash/autoclick/common/autoclick_controller_common.h |
| @@ -0,0 +1,90 @@ |
| +// 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. |
| + |
| +#ifndef ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H |
| +#define ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H |
| + |
| +#include "ash/autoclick/common/autoclick_ring_handler.h" |
| +#include "base/macros.h" |
| +#include "base/timer/timer.h" |
| +#include "ui/events/keycodes/keyboard_codes.h" |
| +#include "ui/gfx/geometry/point.h" |
| + |
| +namespace views { |
| +class Widget; |
| +} |
| + |
| +namespace ui { |
| +class MouseEvent; |
| +class KeyEvent; |
| +class TouchEvent; |
| +class GestureEvent; |
| +class ScrollEvent; |
| +} |
| + |
| +namespace ash { |
| + |
| +// Autoclick controller common code for ash and mus. |
| +class AutoclickControllerCommon { |
| + public: |
| + class Delegate { |
| + public: |
| + Delegate() {} |
| + virtual ~Delegate() {} |
| + |
| + // Creates a ring widget at |event_location|. AutoclickControllerCommon |
| + // takes ownership of the created widget. |
| + virtual std::unique_ptr<views::Widget> CreateAutoclickRingWidget( |
| + const gfx::Point& event_location) = 0; |
| + |
| + // Moves |widget| to |event_location|. |
| + virtual void UpdateAutoclickRingWidget( |
| + views::Widget* widget, |
| + const gfx::Point& event_location) = 0; |
| + |
| + // Generates a click with |mouse_event_flags| at |event_location|. |
| + virtual void DoAutoclick(const gfx::Point& event_location, |
| + const int mouse_event_flags) = 0; |
| + |
|
sadrul
2016/08/15 15:25:10
Let's add OnAutoClickCanceled() here too, which wi
riajiang
2016/08/15 17:16:23
Makes sense! Done.
|
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(Delegate); |
| + }; |
| + |
| + AutoclickControllerCommon(base::TimeDelta delay, Delegate* delegate); |
| + ~AutoclickControllerCommon(); |
| + |
| + void HandleMouseEvent(const ui::MouseEvent& event); |
| + void HandleKeyEvent(const ui::KeyEvent& event); |
| + void HandleTouchEvent(const ui::TouchEvent& event); |
| + void HandleGestureEvent(const ui::GestureEvent& event); |
| + void HandleScrollEvent(const ui::ScrollEvent& event); |
| + |
| + void SetAutoclickDelay(const base::TimeDelta delay); |
| + void StopAutoclickTimer(); |
| + void StopGesture(); |
| + bool IsModifierKey(const ui::KeyboardCode key_code); |
| + |
| + private: |
| + void InitClickTimer(); |
| + |
| + void DoAutoclick(); |
| + |
| + void UpdateRingWidget(const gfx::Point& mouse_location); |
| + |
| + base::TimeDelta delay_; |
| + int mouse_event_flags_; |
| + std::unique_ptr<base::Timer> autoclick_timer_; |
| + Delegate* delegate_; |
| + std::unique_ptr<views::Widget> widget_; |
| + // The position in screen coordinates used to determine |
| + // the distance the mouse has moved. |
| + gfx::Point anchor_location_; |
| + std::unique_ptr<AutoclickRingHandler> autoclick_ring_handler_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AutoclickControllerCommon); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H |