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 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h"
7 #include "ui/base/dragdrop/drag_drop_types.h"
8 #include "ui/base/dragdrop/drag_source_win.h"
9 #include "ui/base/dragdrop/drop_target_event.h"
10 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
11 #include "ui/views/widget/desktop_aura/desktop_drop_target_win.h"
12 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
16 DesktopDragDropClientWin::DesktopDragDropClientWin(
17 aura::Window
* root_window
,
19 : drag_drop_in_progress_(false),
21 drop_target_
= new DesktopDropTargetWin(root_window
, window
);
24 DesktopDragDropClientWin::~DesktopDragDropClientWin() {
27 int DesktopDragDropClientWin::StartDragAndDrop(
28 const ui::OSExchangeData
& data
,
29 aura::Window
* root_window
,
30 aura::Window
* source_window
,
31 const gfx::Point
& root_location
,
33 ui::DragDropTypes::DragEventSource source
) {
34 drag_drop_in_progress_
= true;
35 drag_operation_
= operation
;
37 drag_source_
= new ui::DragSourceWin
;
39 HRESULT result
= DoDragDrop(
40 ui::OSExchangeDataProviderWin::GetIDataObject(data
),
42 ui::DragDropTypes::DragOperationToDropEffect(operation
),
45 drag_drop_in_progress_
= false;
47 if (result
!= DRAGDROP_S_DROP
)
48 effect
= DROPEFFECT_NONE
;
50 return ui::DragDropTypes::DropEffectToDragOperation(effect
);
53 void DesktopDragDropClientWin::DragUpdate(aura::Window
* target
,
54 const ui::LocatedEvent
& event
) {
57 void DesktopDragDropClientWin::Drop(aura::Window
* target
,
58 const ui::LocatedEvent
& event
) {
61 void DesktopDragDropClientWin::DragCancel() {
62 drag_source_
->CancelDrag();
66 bool DesktopDragDropClientWin::IsDragDropInProgress() {
67 return drag_drop_in_progress_
;
70 void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window
) {
71 if (drop_target_
.get()) {
72 RevokeDragDrop(window
);