| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/widget/desktop_aura/desktop_drop_target_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_drop_target_win.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" |
| 7 #include "base/win/win_util.h" | 8 #include "base/win/win_util.h" |
| 8 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 9 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
| 10 #include "ui/base/dragdrop/drag_drop_types.h" | 11 #include "ui/base/dragdrop/drag_drop_types.h" |
| 11 #include "ui/base/dragdrop/drop_target_event.h" | 12 #include "ui/base/dragdrop/drop_target_event.h" |
| 12 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 13 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
| 13 #include "ui/events/event_constants.h" | 14 #include "ui/events/event_constants.h" |
| 14 #include "ui/wm/public/drag_drop_client.h" | 15 #include "ui/wm/public/drag_drop_client.h" |
| 15 #include "ui/wm/public/drag_drop_delegate.h" | 16 #include "ui/wm/public/drag_drop_delegate.h" |
| 16 | 17 |
| 18 using aura::client::DragDropClient; |
| 17 using aura::client::DragDropDelegate; | 19 using aura::client::DragDropDelegate; |
| 18 using ui::OSExchangeData; | 20 using ui::OSExchangeData; |
| 19 using ui::OSExchangeDataProviderWin; | 21 using ui::OSExchangeDataProviderWin; |
| 20 | 22 |
| 21 namespace views { | 23 namespace views { |
| 22 | 24 |
| 23 DesktopDropTargetWin::DesktopDropTargetWin(aura::Window* root_window, | 25 DesktopDropTargetWin::DesktopDropTargetWin(aura::Window* root_window, |
| 24 HWND window) | 26 HWND window) |
| 25 : ui::DropTargetWin(window), | 27 : ui::DropTargetWin(window), |
| 26 root_window_(root_window), | 28 root_window_(root_window), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 67 |
| 66 DWORD DesktopDropTargetWin::OnDrop(IDataObject* data_object, | 68 DWORD DesktopDropTargetWin::OnDrop(IDataObject* data_object, |
| 67 DWORD key_state, | 69 DWORD key_state, |
| 68 POINT position, | 70 POINT position, |
| 69 DWORD effect) { | 71 DWORD effect) { |
| 70 int drag_operation = ui::DragDropTypes::DRAG_NONE; | 72 int drag_operation = ui::DragDropTypes::DRAG_NONE; |
| 71 scoped_ptr<OSExchangeData> data; | 73 scoped_ptr<OSExchangeData> data; |
| 72 scoped_ptr<ui::DropTargetEvent> event; | 74 scoped_ptr<ui::DropTargetEvent> event; |
| 73 DragDropDelegate* delegate; | 75 DragDropDelegate* delegate; |
| 74 Translate(data_object, key_state, position, effect, &data, &event, &delegate); | 76 Translate(data_object, key_state, position, effect, &data, &event, &delegate); |
| 75 if (delegate) | 77 if (delegate) { |
| 76 drag_operation = delegate->OnPerformDrop(*event); | 78 drag_operation = delegate->OnPerformDrop(*event); |
| 79 DragDropClient* client = aura::client::GetDragDropClient(root_window_); |
| 80 if (client && !client->IsDragDropInProgress() && |
| 81 drag_operation != ui::DragDropTypes::DRAG_NONE) { |
| 82 UMA_HISTOGRAM_COUNTS("DragDrop.ExternalOriginDrop", 1); |
| 83 } |
| 84 } |
| 77 if (target_window_) { | 85 if (target_window_) { |
| 78 target_window_->RemoveObserver(this); | 86 target_window_->RemoveObserver(this); |
| 79 target_window_ = NULL; | 87 target_window_ = NULL; |
| 80 } | 88 } |
| 81 return ui::DragDropTypes::DragOperationToDropEffect(drag_operation); | 89 return ui::DragDropTypes::DragOperationToDropEffect(drag_operation); |
| 82 } | 90 } |
| 83 | 91 |
| 84 void DesktopDropTargetWin::OnWindowDestroyed(aura::Window* window) { | 92 void DesktopDropTargetWin::OnWindowDestroyed(aura::Window* window) { |
| 85 DCHECK(window == target_window_); | 93 DCHECK(window == target_window_); |
| 86 target_window_ = NULL; | 94 target_window_ = NULL; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return; | 146 return; |
| 139 DragDropDelegate* delegate = | 147 DragDropDelegate* delegate = |
| 140 aura::client::GetDragDropDelegate(target_window_); | 148 aura::client::GetDragDropDelegate(target_window_); |
| 141 if (delegate) | 149 if (delegate) |
| 142 delegate->OnDragExited(); | 150 delegate->OnDragExited(); |
| 143 target_window_->RemoveObserver(this); | 151 target_window_->RemoveObserver(this); |
| 144 target_window_ = NULL; | 152 target_window_ = NULL; |
| 145 } | 153 } |
| 146 | 154 |
| 147 } // namespace views | 155 } // namespace views |
| OLD | NEW |