Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / content / browser / web_contents / touch_editable_impl_aura.h
blob332a053460384bc1df60d2b085f529b6b6348754
1 // Copyright (c) 2013 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_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_
8 #include <deque>
9 #include <map>
10 #include <queue>
12 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
13 #include "ui/aura/window_observer.h"
14 #include "ui/base/touch/touch_editing_controller.h"
15 #include "ui/gfx/native_widget_types.h"
16 #include "ui/gfx/point.h"
17 #include "ui/gfx/rect.h"
19 namespace ui {
20 class Accelerator;
23 namespace content {
24 class RenderFrameHost;
25 class TouchEditableImplAuraTest;
27 // Aura specific implementation of ui::TouchEditable for a RenderWidgetHostView.
28 class CONTENT_EXPORT TouchEditableImplAura
29 : public ui::TouchEditable,
30 public NON_EXPORTED_BASE(RenderWidgetHostViewAura::TouchEditingClient) {
31 public:
32 virtual ~TouchEditableImplAura();
34 static TouchEditableImplAura* Create();
36 void AttachToView(RenderWidgetHostViewAura* view);
38 // Updates the |touch_selection_controller_| or ends touch editing session
39 // depending on the current selection and cursor state.
40 void UpdateEditingController();
42 void OverscrollStarted();
43 void OverscrollCompleted();
45 // Overridden from RenderWidgetHostViewAura::TouchEditingClient.
46 virtual void StartTouchEditing() OVERRIDE;
47 virtual void EndTouchEditing(bool quick) OVERRIDE;
48 virtual void OnSelectionOrCursorChanged(const gfx::Rect& anchor,
49 const gfx::Rect& focus) OVERRIDE;
50 virtual void OnTextInputTypeChanged(ui::TextInputType type) OVERRIDE;
51 virtual bool HandleInputEvent(const ui::Event* event) OVERRIDE;
52 virtual void GestureEventAck(int gesture_event_type) OVERRIDE;
53 virtual void OnViewDestroyed() OVERRIDE;
55 // Overridden from ui::TouchEditable:
56 virtual void SelectRect(const gfx::Point& start,
57 const gfx::Point& end) OVERRIDE;
58 virtual void MoveCaretTo(const gfx::Point& point) OVERRIDE;
59 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) OVERRIDE;
60 virtual gfx::Rect GetBounds() OVERRIDE;
61 virtual gfx::NativeView GetNativeView() const OVERRIDE;
62 virtual void ConvertPointToScreen(gfx::Point* point) OVERRIDE;
63 virtual void ConvertPointFromScreen(gfx::Point* point) OVERRIDE;
64 virtual bool DrawsHandles() OVERRIDE;
65 virtual void OpenContextMenu(const gfx::Point& anchor) OVERRIDE;
66 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
67 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
68 virtual bool GetAcceleratorForCommandId(
69 int command_id,
70 ui::Accelerator* accelerator) OVERRIDE;
71 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
73 protected:
74 TouchEditableImplAura();
76 private:
77 friend class TouchEditableImplAuraTest;
79 void Cleanup();
81 RenderFrameHost* GetFocusedFrame();
83 // Rectangles for the selection anchor and focus.
84 gfx::Rect selection_anchor_rect_;
85 gfx::Rect selection_focus_rect_;
87 // The current text input type.
88 ui::TextInputType text_input_type_;
90 RenderWidgetHostViewAura* rwhva_;
91 scoped_ptr<ui::TouchSelectionController> touch_selection_controller_;
93 // True if |rwhva_| is currently handling a gesture that could result in a
94 // change in selection (long press, double tap or triple tap).
95 bool selection_gesture_in_process_;
97 // Set to true if handles are hidden when user is scrolling. Used to determine
98 // whether to re-show handles after a scrolling session.
99 bool handles_hidden_due_to_scroll_;
101 // Keeps track of when the user is scrolling.
102 bool scroll_in_progress_;
104 // Set to true when the page starts an overscroll.
105 bool overscroll_in_progress_;
107 // Used to track if the current tap gesture is on a focused textfield.
108 bool is_tap_on_focused_textfield_;
110 // When we receive ack for a ET_GESTURE_TAP, we do not know if the ack is for
111 // a tap or a double tap (we only get the event type in the ack). So we have
112 // this queue to keep track of the the tap count so that we can distinguish
113 // between double and single tap when we get the ack.
114 std::queue<int> tap_gesture_tap_count_queue_;
116 DISALLOW_COPY_AND_ASSIGN(TouchEditableImplAura);
119 } // namespace content
121 #endif // CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_