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

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

Powered by Google App Engine
This is Rietveld 408576698