OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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_TAB_CONTENTS_WEB_DROP_TARGET_WIN_H_ | |
6 #define CHROME_BROWSER_TAB_CONTENTS_WEB_DROP_TARGET_WIN_H_ | |
7 #pragma once | |
8 | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | |
11 #include "ui/base/dragdrop/drop_target.h" | |
12 | |
13 class InterstitialDropTarget; | |
14 class RenderViewHost; | |
15 | |
16 namespace content { | |
17 class WebContents; | |
18 class WebDragDestDelegate; | |
19 } | |
20 | |
21 // A helper object that provides drop capabilities to a TabContents. The | |
22 // DropTarget handles drags that enter the region of the WebContents by | |
23 // passing on the events to the renderer. | |
24 class WebDropTarget : public ui::DropTarget { | |
25 public: | |
26 // Create a new WebDropTarget associating it with the given HWND and | |
27 // WebContents. | |
28 WebDropTarget(HWND source_hwnd, content::WebContents* contents); | |
29 virtual ~WebDropTarget(); | |
30 | |
31 void set_drag_cursor(WebKit::WebDragOperation op) { | |
32 drag_cursor_ = op; | |
33 } | |
34 | |
35 content::WebDragDestDelegate* delegate() const { return delegate_; } | |
36 void set_delegate(content::WebDragDestDelegate* d) { delegate_ = d; } | |
37 | |
38 protected: | |
39 virtual DWORD OnDragEnter(IDataObject* data_object, | |
40 DWORD key_state, | |
41 POINT cursor_position, | |
42 DWORD effect); | |
43 | |
44 virtual DWORD OnDragOver(IDataObject* data_object, | |
45 DWORD key_state, | |
46 POINT cursor_position, | |
47 DWORD effect); | |
48 | |
49 virtual void OnDragLeave(IDataObject* data_object); | |
50 | |
51 virtual DWORD OnDrop(IDataObject* data_object, | |
52 DWORD key_state, | |
53 POINT cursor_position, | |
54 DWORD effect); | |
55 | |
56 private: | |
57 // Our associated WebContents. | |
58 content::WebContents* web_contents_; | |
59 | |
60 // We keep track of the render view host we're dragging over. If it changes | |
61 // during a drag, we need to re-send the DragEnter message. WARNING: | |
62 // this pointer should never be dereferenced. We only use it for comparing | |
63 // pointers. | |
64 RenderViewHost* current_rvh_; | |
65 | |
66 // Used to determine what cursor we should display when dragging over web | |
67 // content area. This can be updated async during a drag operation. | |
68 WebKit::WebDragOperation drag_cursor_; | |
69 | |
70 // A special drop target handler for when we try to d&d while an interstitial | |
71 // page is showing. | |
72 scoped_ptr<InterstitialDropTarget> interstitial_drop_target_; | |
73 | |
74 // A delegate that can receive drag information about drag events. | |
75 content::WebDragDestDelegate* delegate_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(WebDropTarget); | |
78 }; | |
79 | |
80 #endif // CHROME_BROWSER_TAB_CONTENTS_WEB_DROP_TARGET_WIN_H_ | |
OLD | NEW |