OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 | 9 |
10 struct WebDropData; | 10 struct WebDropData; |
11 @class TabContentsViewCocoa; | 11 @class TabContentsViewCocoa; |
12 | 12 |
13 // A class that handles tracking and event processing for a drag and drop | 13 // A class that handles tracking and event processing for a drag and drop |
14 // originating from the content area. | 14 // originating from the content area. |
15 @interface WebDragSource : NSObject { | 15 @interface WebDragSource : NSObject { |
16 @private | 16 @private |
17 // Our tab. Weak reference (owns or co-owns us). | 17 // Our tab. Weak reference (owns or co-owns us). |
18 TabContentsViewCocoa* contentsView_; | 18 TabContentsViewCocoa* contentsView_; |
19 | 19 |
20 // Our drop data. Should only be initialized once. | 20 // Our drop data. Should only be initialized once. |
21 scoped_ptr<WebDropData> dropData_; | 21 scoped_ptr<WebDropData> dropData_; |
22 | 22 |
23 // Our pasteboard. | 23 // Our pasteboard. |
24 scoped_nsobject<NSPasteboard> pasteboard_; | 24 scoped_nsobject<NSPasteboard> pasteboard_; |
| 25 |
| 26 // A mask of the allowed drag operations. |
| 27 NSDragOperation dragOperationMask_; |
25 } | 28 } |
26 | 29 |
27 // Initialize a WebDragSource object for a drag (originating on the given | 30 // Initialize a WebDragSource object for a drag (originating on the given |
28 // contentsView and with the given dropData and pboard). Fill the pasteboard | 31 // contentsView and with the given dropData and pboard). Fill the pasteboard |
29 // with data types appropriate for dropData. | 32 // with data types appropriate for dropData. |
30 - (id)initWithContentsView:(TabContentsViewCocoa*)contentsView | 33 - (id)initWithContentsView:(TabContentsViewCocoa*)contentsView |
31 dropData:(const WebDropData*)dropData | 34 dropData:(const WebDropData*)dropData |
32 pasteboard:(NSPasteboard*)pboard; | 35 pasteboard:(NSPasteboard*)pboard |
| 36 dragOperationMask:(NSDragOperation)dragOperationMask; |
| 37 |
| 38 // Returns a mask of the allowed drag operations. |
| 39 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal; |
33 | 40 |
34 // Call when asked to do a lazy write to the pasteboard; hook up to | 41 // Call when asked to do a lazy write to the pasteboard; hook up to |
35 // -pasteboard:provideDataForType: (on the contentsView). | 42 // -pasteboard:provideDataForType: (on the contentsView). |
36 - (void)lazyWriteToPasteboard:(NSPasteboard*)pboard | 43 - (void)lazyWriteToPasteboard:(NSPasteboard*)pboard |
37 forType:(NSString*)type; | 44 forType:(NSString*)type; |
38 | 45 |
39 // Start the drag (on the originally provided contentsView); can do this right | 46 // Start the drag (on the originally provided contentsView); can do this right |
40 // after -initWithContentsView:.... | 47 // after -initWithContentsView:.... |
41 - (void)startDrag; | 48 - (void)startDrag; |
42 | 49 |
43 // End the drag and clear the pasteboard; hook up to | 50 // End the drag and clear the pasteboard; hook up to |
44 // -draggedImage:endedAt:operation:. | 51 // -draggedImage:endedAt:operation:. |
45 - (void)endDragAt:(NSPoint)screenPoint | 52 - (void)endDragAt:(NSPoint)screenPoint |
46 isCancelled:(BOOL)cancelled; | 53 operation:(NSDragOperation)operation; |
47 | 54 |
48 // Drag moved; hook up to -draggedImage:movedTo:. | 55 // Drag moved; hook up to -draggedImage:movedTo:. |
49 - (void)moveDragTo:(NSPoint)screenPoint; | 56 - (void)moveDragTo:(NSPoint)screenPoint; |
50 | 57 |
51 // Call to drag a promised file to the given path (should be called before | 58 // Call to drag a promised file to the given path (should be called before |
52 // -endDragAt:...); hook up to -namesOfPromisedFilesDroppedAtDestination:. | 59 // -endDragAt:...); hook up to -namesOfPromisedFilesDroppedAtDestination:. |
53 // Returns the file name (not including path) of the file deposited (or which | 60 // Returns the file name (not including path) of the file deposited (or which |
54 // will be deposited). | 61 // will be deposited). |
55 - (NSString*)dragPromisedFileTo:(NSString*)path; | 62 - (NSString*)dragPromisedFileTo:(NSString*)path; |
56 | 63 |
57 @end | 64 @end |
OLD | NEW |