Index: ui/views/mus/drop_target_mus.h |
diff --git a/ui/views/mus/drop_target_mus.h b/ui/views/mus/drop_target_mus.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0a2bffb6df1cb43d25150d3f92361cd6a4582875 |
--- /dev/null |
+++ b/ui/views/mus/drop_target_mus.h |
@@ -0,0 +1,91 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_VIEWS_MUS_DROP_TARGET_MUS_H_ |
+#define UI_VIEWS_MUS_DROP_TARGET_MUS_H_ |
+ |
+#include <map> |
+#include <memory> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "services/ui/public/cpp/window_drop_target.h" |
+#include "ui/aura/window_observer.h" |
+ |
+namespace aura { |
+class RootWindow; |
+class Window; |
+ |
+namespace client { |
+class DragDropDelegate; |
+} |
+} |
+ |
+namespace ui { |
+class DropTargetEvent; |
+class OSExchangeData; |
+} |
+ |
+namespace views { |
+ |
+// An adapter class which takes signals from mus' WindowDropTarget, performs |
+// targeting on the underlying aura::Window tree, and dispatches them to the |
+// aura DragDropDelegate of the targeted aura::Window. |
+class DropTargetMus : public ui::WindowDropTarget, public aura::WindowObserver { |
+ public: |
+ explicit DropTargetMus(aura::Window* root_window); |
+ ~DropTargetMus() override; |
+ |
+ private: |
+ // Common functionality for the ui::DropTargetWin methods to translate from |
sky
2016/09/23 16:14:09
DropTargetWin?
|
+ // mus data types to Aura ones. |
+ void Translate(uint32_t key_state, |
+ const gfx::Point& position, |
sky
2016/09/23 16:14:08
If position is a screen location, please name it a
|
+ uint32_t effect_bitmask, |
+ std::unique_ptr<ui::OSExchangeData>* data, |
+ std::unique_ptr<ui::DropTargetEvent>* event, |
+ aura::client::DragDropDelegate** delegate); |
+ |
+ void NotifyDragLeave(); |
+ |
+ // Overridden from ui::WindowDropTarget: |
+ void OnDragDropStart( |
+ std::map<std::string, std::vector<uint8_t>> mime_data) override; |
sky
2016/09/23 16:14:08
Just noticed this. How come this doesn't take a co
Elliot Glaysher
2016/09/23 21:40:48
To minimize the number of copies of an arbitrarily
|
+ uint32_t OnDragEnter(uint32_t key_state, |
+ const gfx::Point& position, |
+ uint32_t effect_bitmask) override; |
+ uint32_t OnDragOver(uint32_t key_state, |
+ const gfx::Point& position, |
+ uint32_t effect_bitmask) override; |
+ void OnDragLeave() override; |
+ uint32_t OnCompleteDrop(uint32_t key_state, |
+ const gfx::Point& position, |
+ uint32_t effect_bitmask) override; |
+ void OnDragDropDone() override; |
+ |
+ // Overridden from aura::WindowObserver: |
+ void OnWindowDestroyed(aura::Window* window) override; |
+ |
+ // The root window associated with this drop target. |
+ aura::Window* root_window_; |
+ |
+ // The Aura window that is currently under the cursor. We need to manually |
+ // keep track of this because mus will only call our drag enter method once |
+ // when the user enters the associated mus::Window. But inside mus there |
+ // could be multiple aura windows, so we need to generate drag enter events |
+ // for them. |
+ aura::Window* target_window_; |
+ |
+ // The entire drag data payload. We receive this during the drag enter event |
+ // and cache it so we don't send this multiple times. We reset this value on |
+ // leave or drop. |
+ std::map<std::string, std::vector<uint8_t>> mime_data_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DropTargetMus); |
+}; |
+ |
+} // namespace views |
+ |
+#endif // UI_VIEWS_MUS_DROP_TARGET_MUS_H_ |