Deleted check for if Aes128Gcm12Encrypter::IsSupported or not beacuse we
[chromium-blink-merge.git] / ash / drag_drop / drag_drop_controller.h
blob6471db249bf640375a712db3dc3b60c2b9642ee4
1 // Copyright (c) 2012 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 ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_
6 #define ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "base/callback.h"
10 #include "base/memory/weak_ptr.h"
11 #include "ui/aura/client/drag_drop_client.h"
12 #include "ui/aura/window_observer.h"
13 #include "ui/base/dragdrop/os_exchange_data.h"
14 #include "ui/events/event_constants.h"
15 #include "ui/events/event_handler.h"
16 #include "ui/gfx/animation/animation_delegate.h"
17 #include "ui/gfx/rect.h"
19 namespace aura {
20 class RootWindow;
21 class Window;
24 namespace gfx {
25 class LinearAnimation;
28 namespace ash {
30 namespace test {
31 class DragDropControllerTest;
34 namespace internal {
36 class DragDropTracker;
37 class DragDropTrackerDelegate;
38 class DragImageView;
40 class ASH_EXPORT DragDropController
41 : public aura::client::DragDropClient,
42 public ui::EventHandler,
43 public gfx::AnimationDelegate,
44 public aura::WindowObserver {
45 public:
46 DragDropController();
47 virtual ~DragDropController();
49 void set_should_block_during_drag_drop(bool should_block_during_drag_drop) {
50 should_block_during_drag_drop_ = should_block_during_drag_drop;
53 // Overridden from aura::client::DragDropClient:
54 virtual int StartDragAndDrop(
55 const ui::OSExchangeData& data,
56 aura::RootWindow* root_window,
57 aura::Window* source_window,
58 const gfx::Point& root_location,
59 int operation,
60 ui::DragDropTypes::DragEventSource source) OVERRIDE;
61 virtual void DragUpdate(aura::Window* target,
62 const ui::LocatedEvent& event) OVERRIDE;
63 virtual void Drop(aura::Window* target,
64 const ui::LocatedEvent& event) OVERRIDE;
65 virtual void DragCancel() OVERRIDE;
66 virtual bool IsDragDropInProgress() OVERRIDE;
68 // Overridden from ui::EventHandler:
69 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
70 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
71 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
72 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
74 // Overridden from aura::WindowObserver.
75 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
77 protected:
78 // Helper method to create a LinearAnimation object that will run the drag
79 // cancel animation. Caller take ownership of the returned object. Protected
80 // for testing.
81 virtual gfx::LinearAnimation* CreateCancelAnimation(
82 int duration,
83 int frame_rate,
84 gfx::AnimationDelegate* delegate);
86 // Actual implementation of |DragCancel()|. protected for testing.
87 virtual void DoDragCancel(int drag_cancel_animation_duration_ms);
89 private:
90 friend class ash::test::DragDropControllerTest;
92 // Overridden from gfx::AnimationDelegate:
93 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
94 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
95 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE;
97 // Helper method to start drag widget flying back animation.
98 void StartCanceledAnimation(int animation_duration_ms);
100 // Helper method to forward |pending_log_tap_| event to |drag_source_window_|.
101 void ForwardPendingLongTap();
103 // Helper method to reset everything.
104 void Cleanup();
106 scoped_ptr<DragImageView> drag_image_;
107 gfx::Vector2d drag_image_offset_;
108 const ui::OSExchangeData* drag_data_;
109 int drag_operation_;
111 // Window that is currently under the drag cursor.
112 aura::Window* drag_window_;
114 // Starting and final bounds for the drag image for the drag cancel animation.
115 gfx::Rect drag_image_initial_bounds_for_cancel_animation_;
116 gfx::Rect drag_image_final_bounds_for_cancel_animation_;
118 scoped_ptr<gfx::LinearAnimation> cancel_animation_;
120 // Window that started the drag.
121 aura::Window* drag_source_window_;
123 // Indicates whether the caller should be blocked on a drag/drop session.
124 // Only be used for tests.
125 bool should_block_during_drag_drop_;
127 // Closure for quitting nested message loop.
128 base::Closure quit_closure_;
130 scoped_ptr<ash::internal::DragDropTracker> drag_drop_tracker_;
131 scoped_ptr<DragDropTrackerDelegate> drag_drop_window_delegate_;
133 ui::DragDropTypes::DragEventSource current_drag_event_source_;
135 // Holds a synthetic long tap event to be sent to the |drag_source_window_|.
136 // See comment in OnGestureEvent() on why we need this.
137 scoped_ptr<ui::GestureEvent> pending_long_tap_;
139 base::WeakPtrFactory<DragDropController> weak_factory_;
141 DISALLOW_COPY_AND_ASSIGN(DragDropController);
144 } // namespace internal
145 } // namespace ash
147 #endif // ASH_DRAG_DROP_DRAG_DROP_CONTROLLER_H_