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 #ifndef SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ | 5 #ifndef SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ |
6 #define SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ | 6 #define SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ |
7 | 7 |
| 8 #include <string> |
| 9 #include <unordered_map> |
| 10 |
8 #include "base/bind.h" | 11 #include "base/bind.h" |
9 #include "mojo/public/cpp/bindings/array.h" | 12 #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 #include "ui/gfx/geometry/point.h" |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 namespace ws { | 16 namespace ws { |
16 | 17 |
17 class ServerWindow; | 18 class ServerWindow; |
18 | 19 |
19 // An abstract connection which can respond to drag/drop target requests. | 20 // An abstract connection which can respond to drag/drop target requests. |
20 // | 21 // |
21 // The methods in this class send drag and drop messages to the client and | 22 // 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 // 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 // of the client, the lifecycle of receiving messages are in the following |
24 // order: | 25 // order: |
25 class DragTargetConnection { | 26 class DragTargetConnection { |
26 public: | 27 public: |
27 virtual ~DragTargetConnection() {} | 28 virtual ~DragTargetConnection() {} |
28 | 29 |
29 // On the first time that the pointer enters a window offered by this | 30 // 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 // 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 // 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 // mime data first because clients may read the payload at any time, |
33 // including during the enter message. | 34 // including during the enter message. |
34 // | 35 // |
35 // (As an optimization, on the server side, we don't send this message to the | 36 // (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 // 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 // equivalent in ui::WindowDropTarget to minimize the load of inter-process |
38 // communication.) | 39 // communication.) |
39 virtual void PerformOnDragDropStart( | 40 virtual void PerformOnDragDropStart( |
40 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) = 0; | 41 std::unordered_map<std::string, std::vector<uint8_t>> mime_data) = 0; |
41 | 42 |
42 // Next, on each time that the mouse cursor moves from one |window| to | 43 // 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 // 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 // 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 // terms of the ui::mojom::kDropEffect{None,Move,Copy,Link} constants. |
46 virtual void PerformOnDragEnter( | 47 virtual void PerformOnDragEnter( |
47 const ServerWindow* window, | 48 const ServerWindow* window, |
48 uint32_t key_state, | 49 uint32_t key_state, |
49 const gfx::Point& cursor_offset, | 50 const gfx::Point& cursor_offset, |
50 uint32_t effect_bitmask, | 51 uint32_t effect_bitmask, |
(...skipping 30 matching lines...) Expand all Loading... |
81 // (Again, we don't send this message to the source window as we didn't send | 82 // (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 // a DragStart message; the client library handles the equivalent at its |
83 // layer.) | 84 // layer.) |
84 virtual void PerformOnDragDropDone() = 0; | 85 virtual void PerformOnDragDropDone() = 0; |
85 }; | 86 }; |
86 | 87 |
87 } // namespace ws | 88 } // namespace ws |
88 } // namespace ui | 89 } // namespace ui |
89 | 90 |
90 #endif // SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ | 91 #endif // SERVICES_UI_WS_DRAG_TARGET_CONNECTION_H_ |
OLD | NEW |