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 "services/ui/ws/drag_controller.h" | 5 #include "services/ui/ws/drag_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "services/ui/public/interfaces/cursor.mojom.h" | 10 #include "services/ui/public/interfaces/cursor.mojom.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // on each return message. | 39 // on each return message. |
40 DropEffectBitmask bitmask = 0u; | 40 DropEffectBitmask bitmask = 0u; |
41 }; | 41 }; |
42 | 42 |
43 DragController::DragController( | 43 DragController::DragController( |
44 DragCursorUpdater* cursor_updater, | 44 DragCursorUpdater* cursor_updater, |
45 DragSource* source, | 45 DragSource* source, |
46 ServerWindow* source_window, | 46 ServerWindow* source_window, |
47 DragTargetConnection* source_connection, | 47 DragTargetConnection* source_connection, |
48 int32_t drag_pointer, | 48 int32_t drag_pointer, |
49 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, | 49 const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data, |
50 DropEffectBitmask drag_operations) | 50 DropEffectBitmask drag_operations) |
51 : source_(source), | 51 : source_(source), |
52 cursor_updater_(cursor_updater), | 52 cursor_updater_(cursor_updater), |
53 drag_operations_(drag_operations), | 53 drag_operations_(drag_operations), |
54 drag_pointer_id_(drag_pointer), | 54 drag_pointer_id_(drag_pointer), |
55 current_cursor_(ui::mojom::Cursor::NO_DROP), | 55 current_cursor_(ui::mojom::Cursor::NO_DROP), |
56 source_window_(source_window), | 56 source_window_(source_window), |
57 source_connection_(source_connection), | 57 source_connection_(source_connection), |
58 mime_data_(std::move(mime_data)), | 58 mime_data_(mime_data), |
59 weak_factory_(this) { | 59 weak_factory_(this) { |
60 SetCurrentTargetWindow(nullptr); | 60 SetCurrentTargetWindow(nullptr); |
61 EnsureWindowObserved(source_window_); | 61 EnsureWindowObserved(source_window_); |
62 } | 62 } |
63 | 63 |
64 DragController::~DragController() { | 64 DragController::~DragController() { |
65 for (auto& pair : window_state_) { | 65 for (auto& pair : window_state_) { |
66 if (pair.second.observed) | 66 if (pair.second.observed) |
67 pair.first->RemoveObserver(this); | 67 pair.first->RemoveObserver(this); |
68 } | 68 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 209 } |
210 | 210 |
211 void DragController::QueueOperation(ServerWindow* window, | 211 void DragController::QueueOperation(ServerWindow* window, |
212 OperationType type, | 212 OperationType type, |
213 uint32_t event_flags, | 213 uint32_t event_flags, |
214 const gfx::Point& screen_position) { | 214 const gfx::Point& screen_position) { |
215 // If this window doesn't have the mime data, send it. | 215 // If this window doesn't have the mime data, send it. |
216 DragTargetConnection* connection = source_->GetDragTargetForWindow(window); | 216 DragTargetConnection* connection = source_->GetDragTargetForWindow(window); |
217 if (connection != source_connection_ && | 217 if (connection != source_connection_ && |
218 !base::ContainsKey(called_on_drag_mime_types_, connection)) { | 218 !base::ContainsKey(called_on_drag_mime_types_, connection)) { |
219 connection->PerformOnDragDropStart(mime_data_.Clone()); | 219 connection->PerformOnDragDropStart(mime_data_); |
220 called_on_drag_mime_types_.insert(connection); | 220 called_on_drag_mime_types_.insert(connection); |
221 } | 221 } |
222 | 222 |
223 WindowState& state = window_state_[window]; | 223 WindowState& state = window_state_[window]; |
224 // Set the queued operation to the incoming. | 224 // Set the queued operation to the incoming. |
225 state.queued_operation = {type, event_flags, screen_position}; | 225 state.queued_operation = {type, event_flags, screen_position}; |
226 | 226 |
227 if (state.waiting_on_reply == OperationType::NONE) { | 227 if (state.waiting_on_reply == OperationType::NONE) { |
228 // Send the operation immediately. | 228 // Send the operation immediately. |
229 DispatchOperation(window, &state); | 229 DispatchOperation(window, &state); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 324 |
325 if (source_window_ == window) { | 325 if (source_window_ == window) { |
326 source_window_ = nullptr; | 326 source_window_ = nullptr; |
327 // Our source window is being deleted, fail the drag. | 327 // Our source window is being deleted, fail the drag. |
328 MessageDragCompleted(false, ui::mojom::kDropEffectNone); | 328 MessageDragCompleted(false, ui::mojom::kDropEffectNone); |
329 } | 329 } |
330 } | 330 } |
331 | 331 |
332 } // namespace ws | 332 } // namespace ws |
333 } // namespace ui | 333 } // namespace ui |
OLD | NEW |