15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_COCOA_URL_DROP_TARGET_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_COCOA_URL_DROP_TARGET_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#import <Cocoa/Cocoa.h>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@protocol URLDropTarget;
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@protocol URLDropTargetController;
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Object which coordinates the dropping of URLs on a given view, sending data
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and updates to a controller.
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@interface URLDropTargetHandler : NSObject {
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) @private
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  NSView<URLDropTarget>* view_;  // weak
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns an array of drag types that can be handled.
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (NSArray*)handledDragTypes;
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Initialize the given view, which must implement the |URLDropTarget| (below),
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to accept drops of URLs.
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (id)initWithView:(NSView<URLDropTarget>*)view;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The owner view should implement the following methods by calling the
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |URLDropTargetHandler|'s version, and leave the others to the default
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// implementation provided by |NSView|/|NSWindow|.
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender;
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender;
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)draggingExited:(id<NSDraggingInfo>)sender;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end  // @interface URLDropTargetHandler
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Protocol which views that are URL drop targets and use |URLDropTargetHandler|
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// must implement.
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@protocol URLDropTarget
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns the controller which handles the drop.
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (id<URLDropTargetController>)urlDropController;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The following, which come from |NSDraggingDestination|, must be implemented
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// by calling the |URLDropTargetHandler|'s implementations.
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender;
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)draggingExited:(id<NSDraggingInfo>)sender;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end  // @protocol URLDropTarget
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Protocol for the controller which handles the actual drop data/drop updates.
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@protocol URLDropTargetController
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Determines whether the given drag and drop operation contains content that
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// is supported by the web view. In particular, if the content is a local file
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// URL, this checks if it is of a type that can be shown in the tab contents.
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info;
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The given URLs (an |NSArray| of |NSString|s) were dropped in the given view
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// at the given point (in that view's coordinates).
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point;
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The given text was dropped in the given view at the given point (in that
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// view's coordinates).
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point;
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Dragging is in progress over the owner view (at the given point, in view
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// coordinates) and any indicator of location -- e.g., an arrow -- should be
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// updated/shown.
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Dragging is over, and any indicator should be hidden.
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)hideDropURLsIndicatorInView:(NSView*)view;
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end  // @protocol URLDropTargetController
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_COCOA_URL_DROP_TARGET_H_
80