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 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_DEST_WIN_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_DEST_WIN_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/common/content_export.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
11 #include "ui/base/dragdrop/drop_target.h"
12 #include "webkit/glue/webdropdata.h"
15 class InterstitialDropTarget
;
18 class WebDragDestDelegate
;
20 // A helper object that provides drop capabilities to a WebContentsImpl. The
21 // DropTarget handles drags that enter the region of the WebContents by
22 // passing on the events to the renderer.
23 class CONTENT_EXPORT WebDragDest
: public ui::DropTarget
{
25 // Create a new WebDragDest associating it with the given HWND and
27 WebDragDest(HWND source_hwnd
, WebContents
* contents
);
28 virtual ~WebDragDest();
30 WebDropData
* current_drop_data() const { return drop_data_
.get(); }
32 void set_drag_cursor(WebKit::WebDragOperation op
) {
36 WebDragDestDelegate
* delegate() const { return delegate_
; }
37 void set_delegate(WebDragDestDelegate
* d
) { delegate_
= d
; }
40 virtual DWORD
OnDragEnter(IDataObject
* data_object
,
42 POINT cursor_position
,
45 virtual DWORD
OnDragOver(IDataObject
* data_object
,
47 POINT cursor_position
,
50 virtual void OnDragLeave(IDataObject
* data_object
);
52 virtual DWORD
OnDrop(IDataObject
* data_object
,
54 POINT cursor_position
,
58 // Our associated WebContents.
59 WebContents
* web_contents_
;
61 // We keep track of the render view host we're dragging over. If it changes
62 // during a drag, we need to re-send the DragEnter message. WARNING:
63 // this pointer should never be dereferenced. We only use it for comparing
65 RenderViewHost
* current_rvh_
;
67 // Used to determine what cursor we should display when dragging over web
68 // content area. This can be updated async during a drag operation.
69 WebKit::WebDragOperation drag_cursor_
;
71 // A special drop target handler for when we try to d&d while an interstitial
73 scoped_ptr
<InterstitialDropTarget
> interstitial_drop_target_
;
75 // A delegate that can receive drag information about drag events.
76 WebDragDestDelegate
* delegate_
;
78 // The data for the current drag, or NULL if |context_| is NULL.
79 scoped_ptr
<WebDropData
> drop_data_
;
81 DISALLOW_COPY_AND_ASSIGN(WebDragDest
);
84 } // namespace content
86 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_DEST_WIN_H_