Android: Store language .pak files in res/raw rather than assets
[chromium-blink-merge.git] / content / browser / web_contents / touch_editable_impl_aura.h
blobd7516f67b48aed9b261860ab65d56035c7b8eb34
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/geometry/point.h"
16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/native_widget_types.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 ~TouchEditableImplAura() override;
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 virtual void OverscrollStarted();
42 virtual void OverscrollCompleted();
44 // Overridden from RenderWidgetHostViewAura::TouchEditingClient.
45 void StartTouchEditing() override;
46 void EndTouchEditing(bool quick) override;
47 void OnSelectionOrCursorChanged(const ui::SelectionBound& anchor,
48 const ui::SelectionBound& focus) override;
49 void OnTextInputTypeChanged(ui::TextInputType type) override;
50 bool HandleInputEvent(const ui::Event* event) override;
51 void GestureEventAck(int gesture_event_type) override;
52 void DidStopFlinging() override;
53 void OnViewDestroyed() override;
55 // Overridden from ui::TouchEditable:
56 void SelectRect(const gfx::Point& start, const gfx::Point& end) override;
57 void MoveCaretTo(const gfx::Point& point) override;
58 void GetSelectionEndPoints(ui::SelectionBound* anchor,
59 ui::SelectionBound* focus) override;
60 gfx::Rect GetBounds() override;
61 gfx::NativeView GetNativeView() const override;
62 void ConvertPointToScreen(gfx::Point* point) override;
63 void ConvertPointFromScreen(gfx::Point* point) override;
64 bool DrawsHandles() override;
65 void OpenContextMenu(const gfx::Point& anchor) override;
66 bool IsCommandIdChecked(int command_id) const override;
67 bool IsCommandIdEnabled(int command_id) const override;
68 bool GetAcceleratorForCommandId(int command_id,
69 ui::Accelerator* accelerator) override;
70 void ExecuteCommand(int command_id, int event_flags) override;
71 void DestroyTouchSelection() override;
73 protected:
74 TouchEditableImplAura();
76 private:
77 friend class TouchEditableImplAuraTest;
79 // A convenience function that is called after scroll/fling/overscroll ends to
80 // re-activate touch selection if necessary.
81 void StartTouchEditingIfNecessary();
83 void Cleanup();
85 // Bounds for the selection.
86 ui::SelectionBound selection_anchor_;
87 ui::SelectionBound selection_focus_;
89 // The current text input type.
90 ui::TextInputType text_input_type_;
92 RenderWidgetHostViewAura* rwhva_;
93 scoped_ptr<ui::TouchEditingControllerDeprecated> touch_selection_controller_;
95 // True if |rwhva_| is currently handling a gesture that could result in a
96 // change in selection (long press, double tap or triple tap).
97 bool selection_gesture_in_process_;
99 // Set to true if handles are hidden when user is scrolling. Used to determine
100 // whether to re-show handles after a scrolling session.
101 bool handles_hidden_due_to_scroll_;
103 // Keep track of scrolls/overscrolls in progress.
104 bool scroll_in_progress_;
105 bool overscroll_in_progress_;
107 // Used to track if a textfield was focused when the current tap gesture
108 // happened.
109 bool textfield_was_focused_on_tap_;
111 DISALLOW_COPY_AND_ASSIGN(TouchEditableImplAura);
114 } // namespace content
116 #endif // CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_