desktop_drag_drop_client_win.cc revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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/os_exchange_data_provider_win.h" 10#include "ui/views/widget/desktop_aura/desktop_drop_target_win.h" 11#include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h" 12#include "ui/views/widget/drop_target_win.h" 13 14namespace views { 15 16DesktopDragDropClientWin::DesktopDragDropClientWin( 17 aura::RootWindow* root_window, 18 HWND window) 19 : drag_drop_in_progress_(false), 20 drag_operation_(0) { 21 drop_target_ = new DesktopDropTargetWin(root_window, window); 22} 23 24DesktopDragDropClientWin::~DesktopDragDropClientWin() { 25} 26 27int DesktopDragDropClientWin::StartDragAndDrop( 28 const ui::OSExchangeData& data, 29 aura::RootWindow* 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; 36 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); 44 45 drag_drop_in_progress_ = false; 46 47 if (result != DRAGDROP_S_DROP) 48 effect = DROPEFFECT_NONE; 49 50 return ui::DragDropTypes::DropEffectToDragOperation(effect); 51} 52 53void DesktopDragDropClientWin::DragUpdate(aura::Window* target, 54 const ui::LocatedEvent& event) { 55} 56 57void DesktopDragDropClientWin::Drop(aura::Window* target, 58 const ui::LocatedEvent& event) { 59} 60 61void DesktopDragDropClientWin::DragCancel() { 62 drag_source_->CancelDrag(); 63 drag_operation_ = 0; 64} 65 66bool DesktopDragDropClientWin::IsDragDropInProgress() { 67 return drag_drop_in_progress_; 68} 69 70void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window) { 71 if (drop_target_.get()) { 72 RevokeDragDrop(window); 73 drop_target_ = NULL; 74 } 75} 76 77} // namespace views 78