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