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"
13 #include "ui/views/widget/drop_target_win.h"
17 DesktopDragDropClientWin::DesktopDragDropClientWin(
18 aura::Window* root_window,
20 : drag_drop_in_progress_(false),
22 drop_target_ = new DesktopDropTargetWin(root_window, window);
25 DesktopDragDropClientWin::~DesktopDragDropClientWin() {
28 int DesktopDragDropClientWin::StartDragAndDrop(
29 const ui::OSExchangeData& data,
30 aura::Window* root_window,
31 aura::Window* source_window,
32 const gfx::Point& root_location,
34 ui::DragDropTypes::DragEventSource source) {
35 drag_drop_in_progress_ = true;
36 drag_operation_ = operation;
38 drag_source_ = new ui::DragSourceWin;
40 HRESULT result = DoDragDrop(
41 ui::OSExchangeDataProviderWin::GetIDataObject(data),
43 ui::DragDropTypes::DragOperationToDropEffect(operation),
46 drag_drop_in_progress_ = false;
48 if (result != DRAGDROP_S_DROP)
49 effect = DROPEFFECT_NONE;
51 return ui::DragDropTypes::DropEffectToDragOperation(effect);
54 void DesktopDragDropClientWin::DragUpdate(aura::Window* target,
55 const ui::LocatedEvent& event) {
58 void DesktopDragDropClientWin::Drop(aura::Window* target,
59 const ui::LocatedEvent& event) {
62 void DesktopDragDropClientWin::DragCancel() {
63 drag_source_->CancelDrag();
67 bool DesktopDragDropClientWin::IsDragDropInProgress() {
68 return drag_drop_in_progress_;
71 void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window) {
72 if (drop_target_.get()) {
73 RevokeDragDrop(window);