MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / ui / views / widget / desktop_aura / desktop_drag_drop_client_win.cc
blob26431c1159f19d24c6b5d070ef9a42a7fd59c19e
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"
14 namespace views {
16 DesktopDragDropClientWin::DesktopDragDropClientWin(
17 aura::Window* root_window,
18 HWND window)
19 : drag_drop_in_progress_(false),
20 drag_operation_(0) {
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,
32 int operation,
33 ui::DragDropTypes::DragEventSource source) {
34 drag_drop_in_progress_ = true;
35 drag_operation_ = operation;
37 drag_source_ = new ui::DragSourceWin;
38 DWORD effect;
39 HRESULT result = DoDragDrop(
40 ui::OSExchangeDataProviderWin::GetIDataObject(data),
41 drag_source_,
42 ui::DragDropTypes::DragOperationToDropEffect(operation),
43 &effect);
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();
63 drag_operation_ = 0;
66 bool DesktopDragDropClientWin::IsDragDropInProgress() {
67 return drag_drop_in_progress_;
70 void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window) {
71 if (drop_target_.get()) {
72 RevokeDragDrop(window);
73 drop_target_ = NULL;
77 } // namespace views