Implement text selection widgets for controlling text selection on touch
interface. We want this functionality on views textfields as well as the
webpage. This CL lays out the ground work and implements the text selection
interface for view textfield. In a later CL, I intend to implement the
TextSelection Interface for RenderWidgetHostViewViews.

BUG=none
TEST=none


Review URL: http://codereview.chromium.org/7465045

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95186 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/views/touchui/touch_selection_controller_impl.h b/views/touchui/touch_selection_controller_impl.h
new file mode 100644
index 0000000..f5d83f4
--- /dev/null
+++ b/views/touchui/touch_selection_controller_impl.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 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 VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_
+#define VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_
+#pragma once
+
+#include "ui/gfx/point.h"
+#include "views/touchui/touch_selection_controller.h"
+#include "views/view.h"
+
+namespace views {
+
+// Touch specific implementation of TouchSelectionController. Responsible for
+// displaying selection handles and menu elements relevant in a touch interface.
+class TouchSelectionControllerImpl : public TouchSelectionController {
+ public:
+  // Use TextSelectionController::create().
+  explicit TouchSelectionControllerImpl(TouchSelectionClientView* client_view);
+
+  virtual ~TouchSelectionControllerImpl();
+
+  // TextSelectionController.
+  virtual void SelectionChanged(const gfx::Point& p1,
+                                const gfx::Point& p2) OVERRIDE;
+
+  virtual void ClientViewLostFocus() OVERRIDE;
+
+ private:
+  class SelectionHandleView;
+
+  // Callback to inform the client view that the selection handle has been
+  // dragged, hence selection may need to be updated.
+  void SelectionHandleDragged(int x);
+
+  // Convenience method to convert a point from a selection handle's coordinate
+  // system to that of the client view.
+  void ConvertPointToClientView(SelectionHandleView* source, gfx::Point* point);
+
+  TouchSelectionClientView* client_view_;
+  scoped_ptr<SelectionHandleView> selection_handle_1_;
+  scoped_ptr<SelectionHandleView> selection_handle_2_;
+
+  // Pointer to the SelectionHandleView being dragged during a drag session.
+  SelectionHandleView* dragging_handle_;
+
+  DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImpl);
+};
+
+}  // namespace views
+
+#endif  // VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_