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 #import "base/mac/scoped_nsobject.h" | |
11 #include "base/macros.h" | |
12 #include "base/run_loop.h" | |
tapted
2016/06/02 00:24:51
nit: move to .mm? You might need #include "base/ca
spqchan
2016/06/02 22:01:19
Done.
| |
13 #include "ui/base/dragdrop/drag_drop_types.h" | |
14 #include "ui/views/views_export.h" | |
15 #include "ui/views/widget/drop_helper.h" | |
16 | |
17 // This class acts as a bridge between NSPasteboardItem and OSExchangeData by | |
18 // implementing NSPasteboardItemDataProvider and writing data from | |
19 // OSExchangeData into the pasteboard. | |
20 VIEWS_EXPORT | |
21 @interface CocoaDragDropDataProvider : NSObject<NSPasteboardItemDataProvider> | |
22 - (id)initWithData:(const ui::OSExchangeData&)data; | |
23 @end | |
24 | |
25 namespace gfx { | |
26 class Point; | |
27 } | |
28 | |
29 namespace ui { | |
30 class OSExchangeData; | |
31 } | |
32 | |
33 namespace views { | |
34 namespace test { | |
35 class CocoaDragDropTest; | |
36 } | |
37 | |
38 class BridgedNativeWidget; | |
39 class DropHelper; | |
tapted
2016/06/02 00:24:51
nit: forward-declare
class View;
so we're not re
spqchan
2016/06/02 22:01:19
Done.
| |
40 | |
41 // Implements drag and drop on MacViews. This class acts as a bridge between | |
42 // the Views and native system's drag and drop. This class mimics | |
43 // DesktopDragDropClientAuraX11. | |
44 class VIEWS_EXPORT DragDropClientMac { | |
45 public: | |
46 explicit DragDropClientMac(BridgedNativeWidget* bridge, View* root_view); | |
47 ~DragDropClientMac(); | |
48 | |
49 // Initiates a drag and drop session. Returns the drag operation that was | |
50 // applied at the end of the drag drop session. | |
51 void StartDragAndDrop(View* view, | |
52 const ui::OSExchangeData& data, | |
53 int operation, | |
54 ui::DragDropTypes::DragEventSource source); | |
55 | |
56 // Called when mouse is dragged during a drag and drop. | |
57 NSDragOperation DragUpdate(id<NSDraggingInfo>); | |
58 | |
59 // Called when mouse is released during a drag and drop. | |
60 NSDragOperation Drop(id<NSDraggingInfo> sender); | |
61 | |
62 // Called when the drag and drop session has ended. | |
63 void EndDrag(); | |
64 | |
65 DropHelper* drop_helper() { return drop_helper_.get(); } | |
66 | |
67 private: | |
68 friend class test::CocoaDragDropTest; | |
69 | |
70 // Converts the given NSPoint to the coordinate system in Views. | |
71 gfx::Point LocationInView(NSPoint point) const; | |
72 | |
73 // Provides the data for the drag and drop session. | |
74 base::scoped_nsobject<CocoaDragDropDataProvider> data_source_; | |
75 | |
76 // Used to handle drag and drop with Views. | |
77 std::unique_ptr<DropHelper> drop_helper_; | |
78 | |
79 // The drag and drop operation. | |
80 int operation_; | |
81 | |
82 // The bridge between the content view and the drag drop client. | |
83 BridgedNativeWidget* bridge_; // Weak. Owns |this|. | |
84 | |
85 // The closure for the drag and drop's run loop. | |
86 base::Closure quit_closure_; | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(DragDropClientMac); | |
89 }; | |
90 | |
91 } // namespace views | |
92 | |
93 #endif // UI_VIEWS_COCOA_DRAG_DROP_CLIENT_MAC_H_ | |
OLD | NEW |