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