Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / views / widget / desktop_aura / desktop_drop_target_win.h
blob73dc15f4b4c09c932278008a1cdd424bd69fe934
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 UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTIOP_DROP_TARGET_WIN_H_
6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTIOP_DROP_TARGET_WIN_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/aura/window_observer.h"
10 #include "ui/base/dragdrop/drop_target_win.h"
12 namespace aura {
13 namespace client {
14 class DragDropDelegate;
18 namespace ui {
19 class DropTargetEvent;
20 class OSExchangeData;
23 namespace views {
25 // DesktopDropTargetWin takes care of managing drag and drop for
26 // DesktopWindowTreeHostWin. It converts Windows OLE drop messages into
27 // aura::client::DragDropDelegate calls.
28 class DesktopDropTargetWin : public ui::DropTargetWin,
29 public aura::WindowObserver {
30 public:
31 DesktopDropTargetWin(aura::Window* root_window, HWND window);
32 ~DesktopDropTargetWin() override;
34 private:
35 // ui::DropTargetWin implementation:
36 DWORD OnDragEnter(IDataObject* data_object,
37 DWORD key_state,
38 POINT position,
39 DWORD effect) override;
40 DWORD OnDragOver(IDataObject* data_object,
41 DWORD key_state,
42 POINT position,
43 DWORD effect) override;
44 void OnDragLeave(IDataObject* data_object) override;
45 DWORD OnDrop(IDataObject* data_object,
46 DWORD key_state,
47 POINT position,
48 DWORD effect) override;
50 // aura::WindowObserver implementation:
51 void OnWindowDestroyed(aura::Window* window) override;
53 // Common functionality for the ui::DropTargetWin methods to translate from
54 // COM data types to Aura ones.
55 void Translate(IDataObject* data_object,
56 DWORD key_state,
57 POINT cursor_position,
58 DWORD effect,
59 scoped_ptr<ui::OSExchangeData>* data,
60 scoped_ptr<ui::DropTargetEvent>* event,
61 aura::client::DragDropDelegate** delegate);
63 void NotifyDragLeave();
65 // The root window associated with this drop target.
66 aura::Window* root_window_;
68 // The Aura window that is currently under the cursor. We need to manually
69 // keep track of this because Windows will only call our drag enter method
70 // once when the user enters the associated HWND. But inside that HWND there
71 // could be multiple aura windows, so we need to generate drag enter events
72 // for them.
73 aura::Window* target_window_;
75 DISALLOW_COPY_AND_ASSIGN(DesktopDropTargetWin);
78 } // namespace views
80 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTIOP_DROP_TARGET_WIN_H_