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