Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / renderer_host / input / touch_selection_controller_client_aura.h
blobbb9dd6665f626340cd11ed76c5746407fc2caf20
1 // Copyright 2015 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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_CLIENT_AURA_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_CLIENT_AURA_H_
8 #include "base/timer/timer.h"
9 #include "content/common/content_export.h"
10 #include "ui/touch_selection/touch_selection_controller.h"
11 #include "ui/touch_selection/touch_selection_menu_runner.h"
13 namespace content {
14 class RenderWidgetHostViewAura;
16 // An implementation of |TouchSelectionControllerClient| to be used in Aura's
17 // implementation of touch selection for contents.
18 class CONTENT_EXPORT TouchSelectionControllerClientAura
19 : public ui::TouchSelectionControllerClient,
20 public ui::TouchSelectionMenuClient {
21 public:
22 explicit TouchSelectionControllerClientAura(RenderWidgetHostViewAura* rwhva);
23 ~TouchSelectionControllerClientAura() override;
25 // Called when |rwhva_|'s window is moved, to update the quick menu's
26 // position.
27 void OnWindowMoved();
29 // Called on first touch down/last touch up to hide/show the quick menu.
30 void OnTouchDown();
31 void OnTouchUp();
33 // Called when touch scroll starts/completes to hide/show touch handles and
34 // the quick menu.
35 void OnScrollStarted();
36 void OnScrollCompleted();
38 private:
39 friend class TestTouchSelectionControllerClientAura;
40 class EnvPreTargetHandler;
42 bool IsQuickMenuAllowed() const;
43 void ShowQuickMenu();
44 void UpdateQuickMenu();
46 // ui::TouchSelectionControllerClient:
47 bool SupportsAnimation() const override;
48 void SetNeedsAnimate() override;
49 void MoveCaret(const gfx::PointF& position) override;
50 void MoveRangeSelectionExtent(const gfx::PointF& extent) override;
51 void SelectBetweenCoordinates(const gfx::PointF& base,
52 const gfx::PointF& extent) override;
53 void OnSelectionEvent(ui::SelectionEventType event) override;
54 scoped_ptr<ui::TouchHandleDrawable> CreateDrawable() override;
56 // ui::TouchSelectionMenuClient:
57 bool IsCommandIdEnabled(int command_id) const override;
58 void ExecuteCommand(int command_id, int event_flags) override;
59 void RunContextMenu() override;
61 // Not owned, non-null for the lifetime of this object.
62 RenderWidgetHostViewAura* rwhva_;
64 base::Timer quick_menu_timer_;
65 bool touch_down_;
66 bool scroll_in_progress_;
67 bool handle_drag_in_progress_;
69 bool show_quick_menu_immediately_for_test_;
71 // A pre-target event handler for aura::Env which deactivates touch selection
72 // on mouse and keyboard events.
73 scoped_ptr<EnvPreTargetHandler> env_pre_target_handler_;
75 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerClientAura);
78 } // namespace content
80 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_CLIENT_AURA_H_