OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ |
| 6 #define SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ |
| 7 |
| 8 #include "base/bind.h" |
| 9 #include "mojo/public/cpp/bindings/array.h" |
| 10 #include "mojo/public/cpp/bindings/map.h" |
| 11 #include "mojo/public/cpp/bindings/string.h" |
| 12 #include "ui/gfx/geometry/point.h" |
| 13 |
| 14 namespace ui { |
| 15 namespace ws { |
| 16 |
| 17 class ServerWindow; |
| 18 |
| 19 // An abstract connection which can respond to drag/drop target requests. |
| 20 // |
| 21 // The methods in this class send drag and drop messages to the client and |
| 22 // return their results through the passed in callback. From the point of view |
| 23 // of the client, the lifecycle of receiving messages are in the following |
| 24 // order: |
| 25 class DragTargetConnection { |
| 26 public: |
| 27 virtual ~DragTargetConnection() {} |
| 28 |
| 29 // On the first time that the pointer enters a window offered by this |
| 30 // connection, we send this start message with the |mime_data| of the |
| 31 // drag so that we only send this data over the connection once. We send the |
| 32 // mime data first because clients may read the payload at any time, |
| 33 // including during the enter message. |
| 34 // |
| 35 // (As an optimization, on the server side, we don't send this message to the |
| 36 // source window of the drag; the client library has already done the |
| 37 // equivalent in ui::WindowDropTarget to minimize the load of inter-process |
| 38 // communication.) |
| 39 virtual void PerformOnDragDropStart( |
| 40 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) = 0; |
| 41 |
| 42 // Next, on each time that the mouse cursor moves from one |window| to |
| 43 // another, we send a DragEnter message. The value returned by |callback| is |
| 44 // a bitmask of drop operations that can be performed at this location, in |
| 45 // terms of the ui::mojom::kDropEffect{None,Move,Copy,Link} constants. |
| 46 virtual void PerformOnDragEnter( |
| 47 const ServerWindow* window, |
| 48 uint32_t key_state, |
| 49 const gfx::Point& cursor_offset, |
| 50 uint32_t effect_bitmask, |
| 51 const base::Callback<void(uint32_t)>& callback) = 0; |
| 52 |
| 53 // For each mouse move after the initial DragEnter message, we call DragOver |
| 54 // to change the mouse location and to update what drop operations can be |
| 55 // performed. |
| 56 virtual void PerformOnDragOver( |
| 57 const ServerWindow* window, |
| 58 uint32_t key_state, |
| 59 const gfx::Point& cursor_offset, |
| 60 uint32_t effect_bitmask, |
| 61 const base::Callback<void(uint32_t)>& callback) = 0; |
| 62 |
| 63 // If the mouse cursor leaves |window|, send an DragLeave message. |
| 64 virtual void PerformOnDragLeave(const ServerWindow* window) = 0; |
| 65 |
| 66 // If the user releases the pointer over a window, send a DragDrop message, |
| 67 // which signals that the client should complete the drag. The return value |
| 68 // is which operation was performed; a non-zero callback value means the drag |
| 69 // was accepted and completed. |
| 70 virtual void PerformOnCompleteDrop( |
| 71 const ServerWindow* window, |
| 72 uint32_t key_state, |
| 73 const gfx::Point& cursor_offset, |
| 74 uint32_t effect_bitmask, |
| 75 const base::Callback<void(uint32_t)>& callback) = 0; |
| 76 |
| 77 // Finally, regardless of which window accepted (or rejected) the drop, we |
| 78 // send a done message to each connection that we sent a start message |
| 79 // to. This message is used to clear cached data from the drag. |
| 80 // |
| 81 // (Again, we don't send this message to the source window as we didn't send |
| 82 // a DragStart message; the client library handles the equivalent at its |
| 83 // layer.) |
| 84 virtual void PerformOnDragDropDone() = 0; |
| 85 }; |
| 86 |
| 87 } // namespace ws |
| 88 } // namespace ui |
| 89 |
| 90 #endif // SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ |
OLD | NEW |