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 UI_VIEWS_MUS_DROP_TARGET_MUS_H_ | |
6 #define UI_VIEWS_MUS_DROP_TARGET_MUS_H_ | |
7 | |
8 #include <map> | |
9 #include <memory> | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/macros.h" | |
14 #include "services/ui/public/cpp/window_drop_target.h" | |
15 #include "ui/aura/window_observer.h" | |
16 | |
17 namespace aura { | |
18 class Window; | |
19 | |
20 namespace client { | |
21 class DragDropDelegate; | |
22 } | |
23 } | |
24 | |
25 namespace ui { | |
26 class DropTargetEvent; | |
27 class OSExchangeData; | |
28 } | |
29 | |
30 namespace views { | |
31 | |
32 // An adapter class which takes signals from mus' WindowDropTarget, performs | |
33 // targeting on the underlying aura::Window tree, and dispatches them to the | |
34 // aura DragDropDelegate of the targeted aura::Window. | |
35 class DropTargetMus : public ui::WindowDropTarget, public aura::WindowObserver { | |
36 public: | |
37 explicit DropTargetMus(aura::Window* root_window); | |
38 ~DropTargetMus() override; | |
39 | |
40 private: | |
41 // Common functionality for the WindowDropTarget methods to translate from | |
42 // mus data types to Aura ones. This method takes in mus messages and | |
43 // performs the common tasks of keeping track of which aura window (along | |
44 // with enter/leave messages at that layer), doing coordinate translation, | |
45 // and creation of ui layer event objects that get dispatched to aura/views. | |
46 void Translate(uint32_t key_state, | |
47 const gfx::Point& screen_location, | |
48 uint32_t effect_bitmask, | |
49 std::unique_ptr<ui::DropTargetEvent>* event, | |
50 aura::client::DragDropDelegate** delegate); | |
51 | |
52 void NotifyDragExited(); | |
53 | |
54 // Overridden from ui::WindowDropTarget: | |
55 void OnDragDropStart( | |
56 std::map<std::string, std::vector<uint8_t>> mime_data) override; | |
57 uint32_t OnDragEnter(uint32_t key_state, | |
58 const gfx::Point& position, | |
59 uint32_t effect_bitmask) override; | |
60 uint32_t OnDragOver(uint32_t key_state, | |
61 const gfx::Point& position, | |
62 uint32_t effect_bitmask) override; | |
63 void OnDragLeave() override; | |
64 uint32_t OnCompleteDrop(uint32_t key_state, | |
65 const gfx::Point& position, | |
66 uint32_t effect_bitmask) override; | |
67 void OnDragDropDone() override; | |
68 | |
69 // Overridden from aura::WindowObserver: | |
70 void OnWindowDestroyed(aura::Window* window) override; | |
71 | |
72 // The root window associated with this drop target. | |
73 aura::Window* root_window_; | |
74 | |
75 // The Aura window that is currently under the cursor. We need to manually | |
76 // keep track of this because mus will only call our drag enter method once | |
77 // when the user enters the associated mus::Window. But inside mus there | |
78 // could be multiple aura windows, so we need to generate drag enter events | |
79 // for them. | |
80 aura::Window* target_window_; | |
81 | |
82 // The entire drag data payload. We receive this during the drag enter event | |
83 // and cache it so we don't send this multiple times. We reset this value on | |
84 // leave or drop. | |
85 std::unique_ptr<ui::OSExchangeData> os_exchange_data_; | |
86 | |
87 DISALLOW_COPY_AND_ASSIGN(DropTargetMus); | |
88 }; | |
89 | |
90 } // namespace views | |
91 | |
92 #endif // UI_VIEWS_MUS_DROP_TARGET_MUS_H_ | |
OLD | NEW |