1 // Copyright (c) 2012 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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string16.h"
9 #include "content/common/content_export.h"
10 #include "content/public/common/drop_data.h"
14 class WebContentsImpl
;
15 class WebDragDestDelegate
;
18 // A typedef for a RenderViewHost used for comparison purposes only.
19 typedef content::RenderViewHost
* RenderViewHostIdentifier
;
21 // A class that handles tracking and event processing for a drag and drop
22 // over the content area. Assumes something else initiates the drag, this is
23 // only for processing during a drag.
25 @interface WebDragDest
: NSObject
{
27 // Our associated WebContentsImpl. Weak reference.
28 content::WebContentsImpl
* webContents_
;
31 content::WebDragDestDelegate
* delegate_
;
33 // Updated asynchronously during a drag to tell us whether or not we should
35 NSDragOperation currentOperation_
;
37 // Keep track of the render view host we're dragging over. If it changes
38 // during a drag, we need to re-send the DragEnter message.
39 RenderViewHostIdentifier currentRVH_
;
41 // The data for the current drag, or NULL if none is in progress.
42 scoped_ptr
<content::DropData
> dropData_
;
44 // True if the drag has been canceled.
48 // |contents| is the WebContentsImpl representing this tab, used to communicate
49 // drag&drop messages to WebCore and handle navigation on a successful drop
51 - (id
)initWithWebContentsImpl
:(content::WebContentsImpl
*)contents
;
53 - (content::DropData
*)currentDropData
;
55 - (void)setDragDelegate
:(content::WebDragDestDelegate
*)delegate
;
57 // Sets the current operation negotiated by the source and destination,
58 // which determines whether or not we should allow the drop. Takes effect the
59 // next time |-draggingUpdated:| is called.
60 - (void)setCurrentOperation
:(NSDragOperation
)operation
;
62 // Messages to send during the tracking of a drag, ususally upon receiving
63 // calls from the view system. Communicates the drag messages to WebCore.
64 - (NSDragOperation
)draggingEntered
:(id
<NSDraggingInfo
>)info
66 - (void)draggingExited
:(id
<NSDraggingInfo
>)info
;
67 - (NSDragOperation
)draggingUpdated
:(id
<NSDraggingInfo
>)info
69 - (BOOL
)performDragOperation
:(id
<NSDraggingInfo
>)info
74 // Public use only for unit tests.
75 @interface
WebDragDest(Testing
)
76 // Given |data|, which should not be nil, fill it in using the contents of the
78 - (void)populateDropData
:(content::DropData
*)data
79 fromPasteboard
:(NSPasteboard
*)pboard
;
80 // Given a point in window coordinates and a view in that window, return a
81 // flipped point in the coordinate system of |view|.
82 - (NSPoint
)flipWindowPointToView
:(const NSPoint
&)windowPoint
84 // Given a point in window coordinates and a view in that window, return a
85 // flipped point in screen coordinates.
86 - (NSPoint
)flipWindowPointToScreen
:(const NSPoint
&)windowPoint