| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/aura/mus/drag_drop_controller_mus.h" | 5 #include "ui/aura/mus/drag_drop_controller_mus.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 int DragDropControllerMus::StartDragAndDrop( | 127 int DragDropControllerMus::StartDragAndDrop( |
| 128 const ui::OSExchangeData& data, | 128 const ui::OSExchangeData& data, |
| 129 Window* root_window, | 129 Window* root_window, |
| 130 Window* source_window, | 130 Window* source_window, |
| 131 const gfx::Point& screen_location, | 131 const gfx::Point& screen_location, |
| 132 int drag_operations, | 132 int drag_operations, |
| 133 ui::DragDropTypes::DragEventSource source) { | 133 ui::DragDropTypes::DragEventSource source) { |
| 134 DCHECK(!current_drag_state_); | 134 DCHECK(!current_drag_state_); |
| 135 | 135 |
| 136 // TODO(erg): Pass |cursor_location| and |bitmap| in PerformDragDrop() when | |
| 137 // we start showing an image representation of the drag under he cursor. | |
| 138 | |
| 139 base::RunLoop run_loop; | 136 base::RunLoop run_loop; |
| 140 WindowMus* root_window_mus = WindowMus::Get(root_window); | 137 WindowMus* root_window_mus = WindowMus::Get(root_window); |
| 141 const uint32_t change_id = | 138 const uint32_t change_id = |
| 142 drag_drop_controller_host_->CreateChangeIdForDrag(root_window_mus); | 139 drag_drop_controller_host_->CreateChangeIdForDrag(root_window_mus); |
| 143 CurrentDragState current_drag_state = {root_window_mus->server_id(), | 140 CurrentDragState current_drag_state = {root_window_mus->server_id(), |
| 144 change_id, ui::mojom::kDropEffectNone, | 141 change_id, ui::mojom::kDropEffectNone, |
| 145 data, run_loop.QuitClosure()}; | 142 data, run_loop.QuitClosure()}; |
| 146 base::AutoReset<CurrentDragState*> resetter(¤t_drag_state_, | 143 base::AutoReset<CurrentDragState*> resetter(¤t_drag_state_, |
| 147 ¤t_drag_state); | 144 ¤t_drag_state); |
| 148 | 145 |
| 149 base::MessageLoop* loop = base::MessageLoop::current(); | 146 base::MessageLoop* loop = base::MessageLoop::current(); |
| 150 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); | 147 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); |
| 151 | 148 |
| 149 ui::mojom::DragEventSource mojo_source = ui::mojom::DragEventSource::MOUSE; |
| 150 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) |
| 151 mojo_source = ui::mojom::DragEventSource::TOUCH; |
| 152 |
| 152 std::map<std::string, std::vector<uint8_t>> drag_data = | 153 std::map<std::string, std::vector<uint8_t>> drag_data = |
| 153 static_cast<const aura::OSExchangeDataProviderMus&>(data.provider()) | 154 static_cast<const aura::OSExchangeDataProviderMus&>(data.provider()) |
| 154 .GetData(); | 155 .GetData(); |
| 155 window_tree_->PerformDragDrop(change_id, root_window_mus->server_id(), | 156 window_tree_->PerformDragDrop( |
| 156 mojo::MapToUnorderedMap(drag_data), | 157 change_id, root_window_mus->server_id(), screen_location, |
| 157 drag_operations); | 158 mojo::MapToUnorderedMap(drag_data), |
| 159 *data.provider().GetDragImage().bitmap(), |
| 160 data.provider().GetDragImageOffset(), drag_operations, mojo_source); |
| 158 | 161 |
| 159 run_loop.Run(); | 162 run_loop.Run(); |
| 160 | 163 |
| 161 return current_drag_state.completed_action; | 164 return current_drag_state.completed_action; |
| 162 } | 165 } |
| 163 | 166 |
| 164 void DragDropControllerMus::DragCancel() { | 167 void DragDropControllerMus::DragCancel() { |
| 165 DCHECK(current_drag_state_); | 168 DCHECK(current_drag_state_); |
| 166 // Server will clean up drag and fail the in-flight change. | 169 // Server will clean up drag and fail the in-flight change. |
| 167 window_tree_->CancelDragDrop(current_drag_state_->window_id); | 170 window_tree_->CancelDragDrop(current_drag_state_->window_id); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 std::unique_ptr<ui::DropTargetEvent> event = | 211 std::unique_ptr<ui::DropTargetEvent> event = |
| 209 base::MakeUnique<ui::DropTargetEvent>( | 212 base::MakeUnique<ui::DropTargetEvent>( |
| 210 current_drag_state_ ? current_drag_state_->drag_data | 213 current_drag_state_ ? current_drag_state_->drag_data |
| 211 : *(os_exchange_data_.get()), | 214 : *(os_exchange_data_.get()), |
| 212 location, root_location, effect_bitmask); | 215 location, root_location, effect_bitmask); |
| 213 event->set_flags(event_flags); | 216 event->set_flags(event_flags); |
| 214 return event; | 217 return event; |
| 215 } | 218 } |
| 216 | 219 |
| 217 } // namespace aura | 220 } // namespace aura |
| OLD | NEW |