1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_WEB_CONTENTS_DRAG_SOURCE_H_ 6 #define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_WEB_CONTENTS_DRAG_SOURCE_H_ 7 #pragma once 8 9 #import <Cocoa/Cocoa.h> 10 11 #include "base/memory/scoped_nsobject.h" 12 #include "chrome/browser/bookmarks/bookmark_node_data.h" 13 14 @class TabContentsViewCocoa; 15 16 // A class that handles tracking and event processing for a drag and drop 17 // originating from the content area. Subclasses should implement 18 // fillClipboard and dragImage. 19 @interface WebContentsDragSource : NSObject { 20 @private 21 // Our tab. Weak reference (owns or co-owns us). 22 TabContentsViewCocoa* contentsView_; 23 24 // Our pasteboard. 25 scoped_nsobject<NSPasteboard> pasteboard_; 26 27 // A mask of the allowed drag operations. 28 NSDragOperation dragOperationMask_; 29 } 30 31 // Initialize a DragDataSource object for a drag (originating on the given 32 // contentsView and with the given dropData and pboard). Fill the pasteboard 33 // with data types appropriate for dropData. 34 - (id)initWithContentsView:(TabContentsViewCocoa*)contentsView 35 pasteboard:(NSPasteboard*)pboard 36 dragOperationMask:(NSDragOperation)dragOperationMask; 37 38 // Creates the drag image. Implemented by the subclass. 39 - (NSImage*)dragImage; 40 41 // Put the data being dragged onto the pasteboard. Implemented by the 42 // subclass. 43 - (void)fillPasteboard; 44 45 // Returns a mask of the allowed drag operations. 46 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal; 47 48 // Start the drag (on the originally provided contentsView); can do this right 49 // after -initWithContentsView:.... 50 - (void)startDrag; 51 52 // End the drag and clear the pasteboard; hook up to 53 // -draggedImage:endedAt:operation:. 54 - (void)endDragAt:(NSPoint)screenPoint 55 operation:(NSDragOperation)operation; 56 57 // Drag moved; hook up to -draggedImage:movedTo:. 58 - (void)moveDragTo:(NSPoint)screenPoint; 59 60 @end 61 62 #endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_WEB_CONTENTS_DRAG_SOURCE_H_ 63