Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: ui/views/cocoa/drag_drop_client_mac.h

Issue 1964283002: MacViews: Implemented Drag & Drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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>
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"
18
19 class DropHelper;
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
27 - (id)initWithData:(const ui::OSExchangeData&)data;
28
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_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698