OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_drag_drop_client_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" |
6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" |
7 #include "base/tracked_objects.h" | 8 #include "base/tracked_objects.h" |
8 #include "ui/base/dragdrop/drag_drop_types.h" | 9 #include "ui/base/dragdrop/drag_drop_types.h" |
9 #include "ui/base/dragdrop/drag_source_win.h" | 10 #include "ui/base/dragdrop/drag_source_win.h" |
10 #include "ui/base/dragdrop/drop_target_event.h" | 11 #include "ui/base/dragdrop/drop_target_event.h" |
11 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 12 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
12 #include "ui/views/widget/desktop_aura/desktop_drop_target_win.h" | 13 #include "ui/views/widget/desktop_aura/desktop_drop_target_win.h" |
13 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" | 14 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" |
14 | 15 |
15 namespace views { | 16 namespace views { |
16 | 17 |
(...skipping 21 matching lines...) Expand all Loading... |
38 drag_drop_in_progress_ = true; | 39 drag_drop_in_progress_ = true; |
39 drag_operation_ = operation; | 40 drag_operation_ = operation; |
40 | 41 |
41 base::WeakPtr<DesktopDragDropClientWin> alive(weak_factory_.GetWeakPtr()); | 42 base::WeakPtr<DesktopDragDropClientWin> alive(weak_factory_.GetWeakPtr()); |
42 | 43 |
43 drag_source_ = new ui::DragSourceWin; | 44 drag_source_ = new ui::DragSourceWin; |
44 scoped_refptr<ui::DragSourceWin> drag_source_copy = drag_source_; | 45 scoped_refptr<ui::DragSourceWin> drag_source_copy = drag_source_; |
45 | 46 |
46 DWORD effect; | 47 DWORD effect; |
47 | 48 |
| 49 UMA_HISTOGRAM_ENUMERATION("Event.DragDrop.Start", source, |
| 50 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
| 51 |
48 // Use task stopwatch to exclude the drag-drop time current task, if any. | 52 // Use task stopwatch to exclude the drag-drop time current task, if any. |
49 tracked_objects::TaskStopwatch stopwatch; | 53 tracked_objects::TaskStopwatch stopwatch; |
50 stopwatch.Start(); | 54 stopwatch.Start(); |
51 HRESULT result = DoDragDrop( | 55 HRESULT result = DoDragDrop( |
52 ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_.get(), | 56 ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_.get(), |
53 ui::DragDropTypes::DragOperationToDropEffect(operation), &effect); | 57 ui::DragDropTypes::DragOperationToDropEffect(operation), &effect); |
54 stopwatch.Stop(); | 58 stopwatch.Stop(); |
55 | 59 |
56 if (alive) | 60 if (alive) |
57 drag_drop_in_progress_ = false; | 61 drag_drop_in_progress_ = false; |
58 | 62 |
59 if (result != DRAGDROP_S_DROP) | 63 if (result != DRAGDROP_S_DROP) |
60 effect = DROPEFFECT_NONE; | 64 effect = DROPEFFECT_NONE; |
61 | 65 |
62 return ui::DragDropTypes::DropEffectToDragOperation(effect); | 66 int drag_operation = ui::DragDropTypes::DropEffectToDragOperation(effect); |
| 67 |
| 68 if (drag_operation == ui::DragDropTypes::DRAG_NONE) { |
| 69 UMA_HISTOGRAM_ENUMERATION("Event.DragDrop.Cancel", source, |
| 70 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
| 71 } else { |
| 72 UMA_HISTOGRAM_ENUMERATION("Event.DragDrop.Drop", source, |
| 73 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
| 74 } |
| 75 |
| 76 return drag_operation; |
63 } | 77 } |
64 | 78 |
65 void DesktopDragDropClientWin::DragUpdate(aura::Window* target, | 79 void DesktopDragDropClientWin::DragUpdate(aura::Window* target, |
66 const ui::LocatedEvent& event) { | 80 const ui::LocatedEvent& event) { |
67 } | 81 } |
68 | 82 |
69 void DesktopDragDropClientWin::Drop(aura::Window* target, | 83 void DesktopDragDropClientWin::Drop(aura::Window* target, |
70 const ui::LocatedEvent& event) { | 84 const ui::LocatedEvent& event) { |
71 } | 85 } |
72 | 86 |
73 void DesktopDragDropClientWin::DragCancel() { | 87 void DesktopDragDropClientWin::DragCancel() { |
74 drag_source_->CancelDrag(); | 88 drag_source_->CancelDrag(); |
75 drag_operation_ = 0; | 89 drag_operation_ = 0; |
76 } | 90 } |
77 | 91 |
78 bool DesktopDragDropClientWin::IsDragDropInProgress() { | 92 bool DesktopDragDropClientWin::IsDragDropInProgress() { |
79 return drag_drop_in_progress_; | 93 return drag_drop_in_progress_; |
80 } | 94 } |
81 | 95 |
82 void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window) { | 96 void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window) { |
83 if (drop_target_.get()) { | 97 if (drop_target_.get()) { |
84 RevokeDragDrop(window); | 98 RevokeDragDrop(window); |
85 drop_target_ = NULL; | 99 drop_target_ = NULL; |
86 } | 100 } |
87 } | 101 } |
88 | 102 |
89 } // namespace views | 103 } // namespace views |
OLD | NEW |