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