| 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 #ifndef CHROME_BROWSER_COCOA_URL_DROP_TARGET_H_ | 5 #ifndef CHROME_BROWSER_COCOA_URL_DROP_TARGET_H_ |
| 6 #define CHROME_BROWSER_COCOA_URL_DROP_TARGET_H_ | 6 #define CHROME_BROWSER_COCOA_URL_DROP_TARGET_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 @protocol URLDropTarget; |
| 11 @protocol URLDropTargetController; |
| 12 |
| 13 // Object which coordinates the dropping of URLs on a given view, sending data |
| 14 // and updates to a controller. |
| 10 @interface URLDropTargetHandler : NSObject { | 15 @interface URLDropTargetHandler : NSObject { |
| 11 @private | 16 @private |
| 12 NSView* view_; // weak | 17 NSView<URLDropTarget>* view_; // weak |
| 13 } | 18 } |
| 14 | 19 |
| 15 // Initialize the given view to accept drops of URLs; this requires the view's | 20 // Initialize the given view, which must implement the |URLDropTarget| (below), |
| 16 // window's controller to implement the |URLDropTargetWindowController| protocol | 21 // to accept drops of URLs. |
| 17 // (below). | 22 - (id)initWithView:(NSView<URLDropTarget>*)view; |
| 18 - (id)initWithView:(NSView*)view; | |
| 19 | 23 |
| 20 // The owner view should implement the following methods by calling the | 24 // The owner view should implement the following methods by calling the |
| 21 // |URLDropTargetHandler|'s version, and leave the others to the default | 25 // |URLDropTargetHandler|'s version, and leave the others to the default |
| 22 // implementation provided by |NSView|/|NSWindow|. | 26 // implementation provided by |NSView|/|NSWindow|. |
| 23 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender; | 27 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender; |
| 24 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender; | 28 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender; |
| 25 - (void)draggingExited:(id<NSDraggingInfo>)sender; | 29 - (void)draggingExited:(id<NSDraggingInfo>)sender; |
| 26 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender; | 30 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender; |
| 27 | 31 |
| 28 @end // @interface URLDropTargetHandler | 32 @end // @interface URLDropTargetHandler |
| 29 | 33 |
| 30 @protocol URLDropTargetWindowController | 34 // Protocol which views that are URL drop targets and use |URLDropTargetHandler| |
| 35 // must implement. |
| 36 @protocol URLDropTarget |
| 31 | 37 |
| 32 // The given URLs (an |NSArray| of |NSString|s) were dropped at the given | 38 // Returns the controller which handles the drop. |
| 33 // location (location in window base coordinates). | 39 - (id<URLDropTargetController>)urlDropController; |
| 34 - (void)dropURLs:(NSArray*)urls at:(NSPoint)location; | |
| 35 | 40 |
| 36 // Dragging is in progress over the owner view (at the given location, in window | 41 // The following, which come from |NSDraggingDestination|, must be implemented |
| 37 // base coordinates) and any indicator of location -- e.g., an arrow -- should | 42 // by calling the |URLDropTargetHandler|'s implementations. |
| 38 // be updated/shown. | 43 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender; |
| 39 - (void)indicateDropURLsAt:(NSPoint)location; | 44 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender; |
| 45 - (void)draggingExited:(id<NSDraggingInfo>)sender; |
| 46 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender; |
| 47 |
| 48 @end // @protocol URLDropTarget |
| 49 |
| 50 // Protocol for the controller which handles the actual drop data/drop updates. |
| 51 @protocol URLDropTargetController |
| 52 |
| 53 // The given URLs (an |NSArray| of |NSString|s) were dropped in the given view |
| 54 // at the given point (in that view's coordinates). |
| 55 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point; |
| 56 |
| 57 // Dragging is in progress over the owner view (at the given point, in view |
| 58 // coordinates) and any indicator of location -- e.g., an arrow -- should be |
| 59 // updated/shown. |
| 60 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point; |
| 40 | 61 |
| 41 // Dragging is over, and any indicator should be hidden. | 62 // Dragging is over, and any indicator should be hidden. |
| 42 - (void)hideDropURLsIndicator; | 63 - (void)hideDropURLsIndicatorInView:(NSView*)view; |
| 43 | 64 |
| 44 @end // @protocol URLDropTargetWindowController | 65 @end // @protocol URLDropTargetController |
| 45 | 66 |
| 46 #endif // CHROME_BROWSER_COCOA_URL_DROP_TARGET_H_ | 67 #endif // CHROME_BROWSER_COCOA_URL_DROP_TARGET_H_ |
| OLD | NEW |