Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / web_contents / touch_editable_impl_aura.h
blobdd19e8e4de6a0dc2e900d7edacc0ae91ca55748f
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 TouchEditableImplAuraTest;
26 // Aura specific implementation of ui::TouchEditable for a RenderWidgetHostView.
27 class CONTENT_EXPORT TouchEditableImplAura
28 : public ui::TouchEditable,
29 public NON_EXPORTED_BASE(RenderWidgetHostViewAura::TouchEditingClient) {
30 public:
31 virtual ~TouchEditableImplAura();
33 static TouchEditableImplAura* Create();
35 void AttachToView(RenderWidgetHostViewAura* view);
37 // Updates the |touch_selection_controller_| or ends touch editing session
38 // depending on the current selection and cursor state.
39 void UpdateEditingController();
41 void OverscrollStarted();
42 void OverscrollCompleted();
44 // Overridden from RenderWidgetHostViewAura::TouchEditingClient.
45 virtual void StartTouchEditing() OVERRIDE;
46 virtual void EndTouchEditing(bool quick) OVERRIDE;
47 virtual void OnSelectionOrCursorChanged(const gfx::Rect& anchor,
48 const gfx::Rect& focus) OVERRIDE;
49 virtual void OnTextInputTypeChanged(ui::TextInputType type) OVERRIDE;
50 virtual bool HandleInputEvent(const ui::Event* event) OVERRIDE;
51 virtual void GestureEventAck(int gesture_event_type) OVERRIDE;
52 virtual void OnViewDestroyed() OVERRIDE;
54 // Overridden from ui::TouchEditable:
55 virtual void SelectRect(const gfx::Point& start,
56 const gfx::Point& end) OVERRIDE;
57 virtual void MoveCaretTo(const gfx::Point& point) OVERRIDE;
58 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) OVERRIDE;
59 virtual gfx::Rect GetBounds() OVERRIDE;
60 virtual gfx::NativeView GetNativeView() const OVERRIDE;
61 virtual void ConvertPointToScreen(gfx::Point* point) OVERRIDE;
62 virtual void ConvertPointFromScreen(gfx::Point* point) OVERRIDE;
63 virtual bool DrawsHandles() OVERRIDE;
64 virtual void OpenContextMenu(const gfx::Point& anchor) OVERRIDE;
65 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
66 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
67 virtual bool GetAcceleratorForCommandId(
68 int command_id,
69 ui::Accelerator* accelerator) OVERRIDE;
70 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
71 virtual void DestroyTouchSelection() OVERRIDE;
73 protected:
74 TouchEditableImplAura();
76 private:
77 friend class TouchEditableImplAuraTest;
79 void Cleanup();
81 // Rectangles for the selection anchor and focus.
82 gfx::Rect selection_anchor_rect_;
83 gfx::Rect selection_focus_rect_;
85 // The current text input type.
86 ui::TextInputType text_input_type_;
88 RenderWidgetHostViewAura* rwhva_;
89 scoped_ptr<ui::TouchSelectionController> touch_selection_controller_;
91 // True if |rwhva_| is currently handling a gesture that could result in a
92 // change in selection (long press, double tap or triple tap).
93 bool selection_gesture_in_process_;
95 // Set to true if handles are hidden when user is scrolling. Used to determine
96 // whether to re-show handles after a scrolling session.
97 bool handles_hidden_due_to_scroll_;
99 // Keeps track of when the user is scrolling.
100 bool scroll_in_progress_;
102 // Set to true when the page starts an overscroll.
103 bool overscroll_in_progress_;
105 // Used to track if a textfield was focused when the current tap gesture
106 // happened.
107 bool textfield_was_focused_on_tap_;
109 DISALLOW_COPY_AND_ASSIGN(TouchEditableImplAura);
112 } // namespace content
114 #endif // CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_