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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 136 // TODO(erg): Pass |cursor_location| and |bitmap| in PerformDragDrop() when |
137 // we start showing an image representation of the drag under he cursor. | 137 // we start showing an image representation of the drag under he cursor. |
138 | 138 |
139 base::RunLoop run_loop; | 139 base::RunLoop run_loop; |
140 WindowMus* source_window_mus = WindowMus::Get(source_window); | 140 WindowMus* root_window_mus = WindowMus::Get(root_window); |
141 const uint32_t change_id = | 141 const uint32_t change_id = |
142 drag_drop_controller_host_->CreateChangeIdForDrag(source_window_mus); | 142 drag_drop_controller_host_->CreateChangeIdForDrag(root_window_mus); |
143 CurrentDragState current_drag_state = {source_window_mus->server_id(), | 143 CurrentDragState current_drag_state = {root_window_mus->server_id(), |
144 change_id, ui::mojom::kDropEffectNone, | 144 change_id, ui::mojom::kDropEffectNone, |
145 data, run_loop.QuitClosure()}; | 145 data, run_loop.QuitClosure()}; |
146 base::AutoReset<CurrentDragState*> resetter(¤t_drag_state_, | 146 base::AutoReset<CurrentDragState*> resetter(¤t_drag_state_, |
147 ¤t_drag_state); | 147 ¤t_drag_state); |
| 148 |
| 149 base::MessageLoop* loop = base::MessageLoop::current(); |
| 150 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); |
| 151 |
148 std::map<std::string, std::vector<uint8_t>> drag_data = | 152 std::map<std::string, std::vector<uint8_t>> drag_data = |
149 static_cast<const aura::OSExchangeDataProviderMus&>(data.provider()) | 153 static_cast<const aura::OSExchangeDataProviderMus&>(data.provider()) |
150 .GetData(); | 154 .GetData(); |
151 window_tree_->PerformDragDrop(change_id, source_window_mus->server_id(), | 155 window_tree_->PerformDragDrop(change_id, root_window_mus->server_id(), |
152 mojo::MapToUnorderedMap(drag_data), | 156 mojo::MapToUnorderedMap(drag_data), |
153 drag_operations); | 157 drag_operations); |
154 | 158 |
155 base::MessageLoop* loop = base::MessageLoop::current(); | |
156 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); | |
157 run_loop.Run(); | 159 run_loop.Run(); |
158 | 160 |
159 return current_drag_state.completed_action; | 161 return current_drag_state.completed_action; |
160 } | 162 } |
161 | 163 |
162 void DragDropControllerMus::DragCancel() { | 164 void DragDropControllerMus::DragCancel() { |
163 DCHECK(current_drag_state_); | 165 DCHECK(current_drag_state_); |
164 // Server will clean up drag and fail the in-flight change. | 166 // Server will clean up drag and fail the in-flight change. |
165 window_tree_->CancelDragDrop(current_drag_state_->window_id); | 167 window_tree_->CancelDragDrop(current_drag_state_->window_id); |
166 } | 168 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 std::unique_ptr<ui::DropTargetEvent> event = | 208 std::unique_ptr<ui::DropTargetEvent> event = |
207 base::MakeUnique<ui::DropTargetEvent>( | 209 base::MakeUnique<ui::DropTargetEvent>( |
208 current_drag_state_ ? current_drag_state_->drag_data | 210 current_drag_state_ ? current_drag_state_->drag_data |
209 : *(os_exchange_data_.get()), | 211 : *(os_exchange_data_.get()), |
210 location, root_location, effect_bitmask); | 212 location, root_location, effect_bitmask); |
211 event->set_flags(event_flags); | 213 event->set_flags(event_flags); |
212 return event; | 214 return event; |
213 } | 215 } |
214 | 216 |
215 } // namespace aura | 217 } // namespace aura |
OLD | NEW |