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_COCOA_DRAG_DROP_CLIENT_MAC_H_ | |
6 #define UI_VIEWS_COCOA_DRAG_DROP_CLIENT_MAC_H_ | |
7 | |
8 #import <Cocoa/Cocoa.h> | |
9 | |
10 #include <memory> | |
11 #include <vector> | |
tapted
2016/05/31 11:49:58
remove? (seems unused)
spqchan
2016/05/31 23:06:12
Done.
| |
12 | |
13 #import "base/mac/scoped_nsobject.h" | |
14 #include "base/macros.h" | |
15 #include "ui/base/dragdrop/drag_drop_types.h" | |
16 #include "ui/views/views_export.h" | |
17 #include "ui/views/widget/drop_helper.h" | |
tapted
2016/05/31 11:49:58
remove? (forward declare should work - see below).
spqchan
2016/05/31 23:06:12
Done.
| |
18 | |
19 class DropHelper; | |
tapted
2016/05/31 11:49:58
should this be in namespace views {?
spqchan
2016/05/31 23:06:12
Done.
| |
20 | |
21 // This class acts as a bridge between NSPasteboardItem and OSExchangeData by | |
22 // implementing NSPasteboardItemDataProvider and writing data from | |
23 // OSExchangeData into the pasteboard. | |
24 VIEWS_EXPORT | |
25 @interface CocoaDragDropDataProvider : NSObject<NSPasteboardItemDataProvider> | |
26 | |
tapted
2016/05/31 11:49:58
nit: remove blank line
spqchan
2016/05/31 23:06:12
Done.
| |
27 - (id)initWithData:(const ui::OSExchangeData&)data; | |
28 | |
tapted
2016/05/31 11:49:58
nit: remove blank line
spqchan
2016/05/31 23:06:12
Done.
| |
29 @end | |
30 | |
31 namespace gfx { | |
32 class Point; | |
33 } | |
34 | |
35 namespace ui { | |
36 class OSExchangeData; | |
37 } | |
38 | |
39 namespace views { | |
40 namespace test { | |
41 class CocoaDragDropTest; | |
42 } | |
43 | |
44 class BridgedNativeWidget; | |
45 | |
46 // Implements drag and drop on MacViews. This class acts as a bridge between | |
47 // the Views and native system's drag and drop. This class mimics | |
48 // DesktopDragDropClientAuraX11. | |
49 class VIEWS_EXPORT DragDropClientMac { | |
50 public: | |
51 explicit DragDropClientMac(BridgedNativeWidget* view); | |
52 ~DragDropClientMac(); | |
53 | |
54 // Initiates a drag and drop session. Returns the drag operation that was | |
55 // applied at the end of the drag drop session. | |
56 void StartDragAndDrop(View* view, | |
57 const ui::OSExchangeData& data, | |
58 const gfx::Point& location, | |
59 int operation, | |
60 ui::DragDropTypes::DragEventSource source); | |
61 | |
62 // Called when mouse is dragged during a drag and drop. | |
63 NSDragOperation DragUpdate(id<NSDraggingInfo>); | |
64 | |
65 // Called when mouse is released during a drag and drop. | |
66 NSDragOperation Drop(id<NSDraggingInfo> sender); | |
67 | |
68 // Called when the drag and drop session has ended. | |
69 void EndDrag(); | |
70 | |
71 // Calls when the the views::View bridged by the content view is set or | |
72 // cleared. | |
73 void SetRootView(View* view); | |
74 | |
75 private: | |
76 friend class test::CocoaDragDropTest; | |
77 | |
78 // Converts the given NSPoint to the coordinate system in Views. | |
79 gfx::Point LocationInView(NSPoint point) const; | |
80 | |
81 // Provides the data for the drag and drop session. | |
82 base::scoped_nsobject<CocoaDragDropDataProvider> data_source_; | |
83 | |
84 // Used to handle drag and drop with Views. | |
85 std::unique_ptr<DropHelper> drop_helper_; | |
86 | |
87 // The drag and drop operation. | |
88 int operation_; | |
89 | |
90 // The source of the drag. | |
91 View* view_; | |
tapted
2016/05/31 11:49:58
This seems unused -- can we remove it? In fact nei
spqchan
2016/05/31 23:06:12
Done.
| |
92 | |
93 // The bridge between the content view and the drag drop client. | |
94 BridgedNativeWidget* bridge_; // Weak. Owns |this|. | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(DragDropClientMac); | |
97 }; | |
98 | |
99 } // namespace views | |
100 | |
101 #endif // UI_VIEWS_COCOA_DRAG_DROP_CLIENT_MAC_H_ | |
OLD | NEW |