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/memory/ptr_util.h" |
7 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
8 #include "base/win/win_util.h" | 9 #include "base/win/win_util.h" |
9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
10 #include "ui/aura/window_tree_host.h" | 11 #include "ui/aura/window_tree_host.h" |
11 #include "ui/base/dragdrop/drag_drop_types.h" | 12 #include "ui/base/dragdrop/drag_drop_types.h" |
12 #include "ui/base/dragdrop/drop_target_event.h" | 13 #include "ui/base/dragdrop/drop_target_event.h" |
13 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 14 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
14 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
15 #include "ui/wm/public/drag_drop_client.h" | 16 #include "ui/wm/public/drag_drop_client.h" |
16 #include "ui/wm/public/drag_drop_delegate.h" | 17 #include "ui/wm/public/drag_drop_delegate.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 target_window_->AddObserver(this); | 142 target_window_->AddObserver(this); |
142 target_window_changed = true; | 143 target_window_changed = true; |
143 } | 144 } |
144 *delegate = NULL; | 145 *delegate = NULL; |
145 if (!target_window_) | 146 if (!target_window_) |
146 return; | 147 return; |
147 *delegate = aura::client::GetDragDropDelegate(target_window_); | 148 *delegate = aura::client::GetDragDropDelegate(target_window_); |
148 if (!*delegate) | 149 if (!*delegate) |
149 return; | 150 return; |
150 | 151 |
151 data->reset(new OSExchangeData(new OSExchangeDataProviderWin(data_object))); | 152 data->reset(new OSExchangeData( |
| 153 base::MakeUnique<OSExchangeDataProviderWin>(data_object))); |
152 location = root_location; | 154 location = root_location; |
153 aura::Window::ConvertPointToTarget(root_window_, target_window_, &location); | 155 aura::Window::ConvertPointToTarget(root_window_, target_window_, &location); |
154 event->reset(new ui::DropTargetEvent( | 156 event->reset(new ui::DropTargetEvent( |
155 *(data->get()), | 157 *(data->get()), |
156 location, | 158 location, |
157 root_location, | 159 root_location, |
158 ui::DragDropTypes::DropEffectToDragOperation(effect))); | 160 ui::DragDropTypes::DropEffectToDragOperation(effect))); |
159 (*event)->set_flags(ConvertKeyStateToAuraEventFlags(key_state)); | 161 (*event)->set_flags(ConvertKeyStateToAuraEventFlags(key_state)); |
160 if (target_window_changed) | 162 if (target_window_changed) |
161 (*delegate)->OnDragEntered(*event->get()); | 163 (*delegate)->OnDragEntered(*event->get()); |
162 } | 164 } |
163 | 165 |
164 void DesktopDropTargetWin::NotifyDragLeave() { | 166 void DesktopDropTargetWin::NotifyDragLeave() { |
165 if (!target_window_) | 167 if (!target_window_) |
166 return; | 168 return; |
167 DragDropDelegate* delegate = | 169 DragDropDelegate* delegate = |
168 aura::client::GetDragDropDelegate(target_window_); | 170 aura::client::GetDragDropDelegate(target_window_); |
169 if (delegate) | 171 if (delegate) |
170 delegate->OnDragExited(); | 172 delegate->OnDragExited(); |
171 target_window_->RemoveObserver(this); | 173 target_window_->RemoveObserver(this); |
172 target_window_ = NULL; | 174 target_window_ = NULL; |
173 } | 175 } |
174 | 176 |
175 } // namespace views | 177 } // namespace views |
OLD | NEW |