desktop_drag_drop_client_win.cc revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" 6 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" 14 15namespace views { 16 17DesktopDragDropClientWin::DesktopDragDropClientWin( 18 aura::Window* root_window, 19 HWND window) 20 : drag_drop_in_progress_(false), 21 drag_operation_(0) { 22 drop_target_ = new DesktopDropTargetWin(root_window, window); 23} 24 25DesktopDragDropClientWin::~DesktopDragDropClientWin() { 26} 27 28int DesktopDragDropClientWin::StartDragAndDrop( 29 const ui::OSExchangeData& data, 30 aura::Window* root_window, 31 aura::Window* source_window, 32 const gfx::Point& root_location, 33 int operation, 34 ui::DragDropTypes::DragEventSource source) { 35 drag_drop_in_progress_ = true; 36 drag_operation_ = operation; 37 38 drag_source_ = new ui::DragSourceWin; 39 DWORD effect; 40 HRESULT result = DoDragDrop( 41 ui::OSExchangeDataProviderWin::GetIDataObject(data), 42 drag_source_, 43 ui::DragDropTypes::DragOperationToDropEffect(operation), 44 &effect); 45 46 drag_drop_in_progress_ = false; 47 48 if (result != DRAGDROP_S_DROP) 49 effect = DROPEFFECT_NONE; 50 51 return ui::DragDropTypes::DropEffectToDragOperation(effect); 52} 53 54void DesktopDragDropClientWin::DragUpdate(aura::Window* target, 55 const ui::LocatedEvent& event) { 56} 57 58void DesktopDragDropClientWin::Drop(aura::Window* target, 59 const ui::LocatedEvent& event) { 60} 61 62void DesktopDragDropClientWin::DragCancel() { 63 drag_source_->CancelDrag(); 64 drag_operation_ = 0; 65} 66 67bool DesktopDragDropClientWin::IsDragDropInProgress() { 68 return drag_drop_in_progress_; 69} 70 71void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window) { 72 if (drop_target_.get()) { 73 RevokeDragDrop(window); 74 drop_target_ = NULL; 75 } 76} 77 78} // namespace views 79