| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 #import <Cocoa/Cocoa.h> | |
| 6 | |
| 7 #include "base/file_path.h" | |
| 8 #include "base/memory/scoped_nsobject.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "googleurl/src/gurl.h" | |
| 11 | |
| 12 class WebContentsImpl; | |
| 13 struct WebDropData; | |
| 14 | |
| 15 // A class that handles tracking and event processing for a drag and drop | |
| 16 // originating from the content area. | |
| 17 @interface WebDragSource : NSObject { | |
| 18 @private | |
| 19 // Our contents. Weak reference (owns or co-owns us). | |
| 20 WebContentsImpl* contents_; | |
| 21 | |
| 22 // The view from which the drag was initiated. Weak reference. | |
| 23 NSView* contentsView_; | |
| 24 | |
| 25 // Our drop data. Should only be initialized once. | |
| 26 scoped_ptr<WebDropData> dropData_; | |
| 27 | |
| 28 // The image to show as drag image. Can be nil. | |
| 29 scoped_nsobject<NSImage> dragImage_; | |
| 30 | |
| 31 // The offset to draw |dragImage_| at. | |
| 32 NSPoint imageOffset_; | |
| 33 | |
| 34 // Our pasteboard. | |
| 35 scoped_nsobject<NSPasteboard> pasteboard_; | |
| 36 | |
| 37 // A mask of the allowed drag operations. | |
| 38 NSDragOperation dragOperationMask_; | |
| 39 | |
| 40 // The file name to be saved to for a drag-out download. | |
| 41 FilePath downloadFileName_; | |
| 42 | |
| 43 // The URL to download from for a drag-out download. | |
| 44 GURL downloadURL_; | |
| 45 | |
| 46 // The file extension associated with the file drag, if any. | |
| 47 NSString* fileExtension_; | |
| 48 } | |
| 49 | |
| 50 // Initialize a WebDragSource object for a drag (originating on the given | |
| 51 // contentsView and with the given dropData and pboard). Fill the pasteboard | |
| 52 // with data types appropriate for dropData. | |
| 53 - (id)initWithContents:(WebContentsImpl*)contents | |
| 54 view:(NSView*)contentsView | |
| 55 dropData:(const WebDropData*)dropData | |
| 56 image:(NSImage*)image | |
| 57 offset:(NSPoint)offset | |
| 58 pasteboard:(NSPasteboard*)pboard | |
| 59 dragOperationMask:(NSDragOperation)dragOperationMask; | |
| 60 | |
| 61 // Returns a mask of the allowed drag operations. | |
| 62 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal; | |
| 63 | |
| 64 // Call when asked to do a lazy write to the pasteboard; hook up to | |
| 65 // -pasteboard:provideDataForType: (on the contentsView). | |
| 66 - (void)lazyWriteToPasteboard:(NSPasteboard*)pboard | |
| 67 forType:(NSString*)type; | |
| 68 | |
| 69 // Start the drag (on the originally provided contentsView); can do this right | |
| 70 // after -initWithContentsView:.... | |
| 71 - (void)startDrag; | |
| 72 | |
| 73 // End the drag and clear the pasteboard; hook up to | |
| 74 // -draggedImage:endedAt:operation:. | |
| 75 - (void)endDragAt:(NSPoint)screenPoint | |
| 76 operation:(NSDragOperation)operation; | |
| 77 | |
| 78 // Drag moved; hook up to -draggedImage:movedTo:. | |
| 79 - (void)moveDragTo:(NSPoint)screenPoint; | |
| 80 | |
| 81 // Call to drag a promised file to the given path (should be called before | |
| 82 // -endDragAt:...); hook up to -namesOfPromisedFilesDroppedAtDestination:. | |
| 83 // Returns the file name (not including path) of the file deposited (or which | |
| 84 // will be deposited). | |
| 85 - (NSString*)dragPromisedFileTo:(NSString*)path; | |
| 86 | |
| 87 @end | |
| OLD | NEW |