diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 12:11:49 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 12:11:49 +0000 |
commit | ffa4e448cf15245002c286ea781717426aa3eff4 (patch) | |
tree | ca251556ea039f07dfc5a4bb96817aaaac8c656a /ui | |
parent | 186b661f7383039cecfb392643349eb0c5fce2a8 (diff) | |
download | chromium_src-ffa4e448cf15245002c286ea781717426aa3eff4.zip chromium_src-ffa4e448cf15245002c286ea781717426aa3eff4.tar.gz chromium_src-ffa4e448cf15245002c286ea781717426aa3eff4.tar.bz2 |
aura: Enable touch initiated drag and drop.
Touch drag/drop in aura follows the following rules:
1. Initiate drag on long press gesture. Give the user a visual cue by showing
a scaled up drag image.
2. Do not initiate dnd if there is no drag image.
3. If, after initiating a drag, the user lifts up their finger without moving,
cancel the drag and show a context menu (this is implemented using the long tap
gesture).
BUG=114755
Review URL: https://chromiumcodereview.appspot.com/11368131
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169901 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/ui_base_switches.cc | 2 | ||||
-rw-r--r-- | ui/base/ui_base_switches.h | 1 | ||||
-rw-r--r-- | ui/views/view.cc | 14 |
3 files changed, 17 insertions, 0 deletions
diff --git a/ui/base/ui_base_switches.cc b/ui/base/ui_base_switches.cc index bddd721..c412f72 100644 --- a/ui/base/ui_base_switches.cc +++ b/ui/base/ui_base_switches.cc @@ -91,4 +91,6 @@ const char kDisableCoreAnimationPlugins[] = const char kTouchDevices[] = "touch-devices"; #endif +const char kEnableTouchDragDrop[] = "enable-touch-drag-drop"; + } // namespace switches diff --git a/ui/base/ui_base_switches.h b/ui/base/ui_base_switches.h index 352de96..ebf3042 100644 --- a/ui/base/ui_base_switches.h +++ b/ui/base/ui_base_switches.h @@ -49,6 +49,7 @@ UI_EXPORT extern const char kDisableCoreAnimationPlugins[]; UI_EXPORT extern const char kTouchDevices[]; #endif +UI_EXPORT extern const char kEnableTouchDragDrop[]; } // namespace switches #endif // UI_BASE_UI_BASE_SWITCHES_H_ diff --git a/ui/views/view.cc b/ui/views/view.cc index fdf8c12..5c96c3c 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -9,6 +9,7 @@ #include <algorithm> #include <cmath> +#include "base/command_line.h" #include "base/debug/trace_event.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -18,6 +19,7 @@ #include "third_party/skia/include/core/SkRect.h" #include "ui/base/accessibility/accessibility_types.h" #include "ui/base/dragdrop/drag_drop_types.h" +#include "ui/base/ui_base_switches.h" #include "ui/compositor/compositor.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator.h" @@ -2002,8 +2004,20 @@ ui::EventResult View::ProcessGestureEvent(ui::GestureEvent* event) { if (status != ui::ER_UNHANDLED) return status; + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableTouchDragDrop)) { + if (event->type() == ui::ET_GESTURE_LONG_PRESS && + (!drag_controller_ || drag_controller_->CanStartDragForView( + this, event->location(), event->location()))) { + if (DoDrag(*event, event->location(), + ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)) + return ui::ER_CONSUMED; + } + } + if (context_menu_controller_ && (event->type() == ui::ET_GESTURE_LONG_PRESS || + event->type() == ui::ET_GESTURE_LONG_TAP || event->type() == ui::ET_GESTURE_TWO_FINGER_TAP)) { gfx::Point location(event->location()); ConvertPointToScreen(this, &location); |