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