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 namespace client { 14 class DragDropDelegate; 15 } 16 } 17 18 namespace ui { 19 class DropTargetEvent; 20 class OSExchangeData; 21 } 22 23 namespace views { 24 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 virtual ~DesktopDropTargetWin(); 33 34 private: 35 // ui::DropTargetWin implementation: 36 virtual DWORD OnDragEnter(IDataObject* data_object, 37 DWORD key_state, 38 POINT position, 39 DWORD effect) OVERRIDE; 40 virtual DWORD OnDragOver(IDataObject* data_object, 41 DWORD key_state, 42 POINT position, 43 DWORD effect) OVERRIDE; 44 virtual void OnDragLeave(IDataObject* data_object) OVERRIDE; 45 virtual DWORD OnDrop(IDataObject* data_object, 46 DWORD key_state, 47 POINT position, 48 DWORD effect) OVERRIDE; 49 50 // aura::WindowObserver implementation: 51 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; 52 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); 62 63 void NotifyDragLeave(); 64 65 // The root window associated with this drop target. 66 aura::Window* root_window_; 67 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_; 74 75 DISALLOW_COPY_AND_ASSIGN(DesktopDropTargetWin); 76 }; 77 78 } // namespace views 79 80 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTIOP_DROP_TARGET_WIN_H_ 81