[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / web_contents / web_drag_source_mac.h
blobf1ccc4df16bc1ac64cac3c92001b3404fce19eab
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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/files/file_path.h"
8 #include "base/mac/scoped_cftyperef.h"
9 #include "base/mac/scoped_nsobject.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/common/content_export.h"
12 #include "url/gurl.h"
14 namespace content {
15 class WebContentsImpl;
16 struct DropData;
19 // A class that handles tracking and event processing for a drag and drop
20 // originating from the content area.
21 CONTENT_EXPORT
22 @interface WebDragSource : NSObject {
23 @private
24 // Our contents. Weak reference (owns or co-owns us).
25 content::WebContentsImpl* contents_;
27 // The view from which the drag was initiated. Weak reference.
28 NSView* contentsView_;
30 // Our drop data. Should only be initialized once.
31 scoped_ptr<content::DropData> dropData_;
33 // The image to show as drag image. Can be nil.
34 base::scoped_nsobject<NSImage> dragImage_;
36 // The offset to draw |dragImage_| at.
37 NSPoint imageOffset_;
39 // Our pasteboard.
40 base::scoped_nsobject<NSPasteboard> pasteboard_;
42 // A mask of the allowed drag operations.
43 NSDragOperation dragOperationMask_;
45 // The file name to be saved to for a drag-out download.
46 base::FilePath downloadFileName_;
48 // The URL to download from for a drag-out download.
49 GURL downloadURL_;
51 // The file UTI associated with the file drag, if any.
52 base::ScopedCFTypeRef<CFStringRef> fileUTI_;
55 // Initialize a WebDragSource object for a drag (originating on the given
56 // contentsView and with the given dropData and pboard). Fill the pasteboard
57 // with data types appropriate for dropData.
58 - (id)initWithContents:(content::WebContentsImpl*)contents
59 view:(NSView*)contentsView
60 dropData:(const content::DropData*)dropData
61 image:(NSImage*)image
62 offset:(NSPoint)offset
63 pasteboard:(NSPasteboard*)pboard
64 dragOperationMask:(NSDragOperation)dragOperationMask;
66 // Call when the web contents is gone.
67 - (void)clearWebContentsView;
69 // Returns a mask of the allowed drag operations.
70 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
72 // Call when asked to do a lazy write to the pasteboard; hook up to
73 // -pasteboard:provideDataForType: (on the contentsView).
74 - (void)lazyWriteToPasteboard:(NSPasteboard*)pboard
75 forType:(NSString*)type;
77 // Start the drag (on the originally provided contentsView); can do this right
78 // after -initWithContentsView:....
79 - (void)startDrag;
81 // End the drag and clear the pasteboard; hook up to
82 // -draggedImage:endedAt:operation:.
83 - (void)endDragAt:(NSPoint)screenPoint
84 operation:(NSDragOperation)operation;
86 // Call to drag a promised file to the given path (should be called before
87 // -endDragAt:...); hook up to -namesOfPromisedFilesDroppedAtDestination:.
88 // Returns the file name (not including path) of the file deposited (or which
89 // will be deposited).
90 - (NSString*)dragPromisedFileTo:(NSString*)path;
92 @end