OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ |
6 #define CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ | 6 #define CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
16 #include "ui/base/gtk/gtk_signal.h" | 16 #include "ui/base/gtk/gtk_signal.h" |
17 #include "webkit/glue/webdropdata.h" | 17 #include "webkit/glue/webdropdata.h" |
18 | 18 |
| 19 class RenderViewHostImpl; |
| 20 |
19 namespace content { | 21 namespace content { |
20 | 22 |
21 class WebContents; | 23 class WebContents; |
22 class WebDragDestDelegate; | 24 class WebDragDestDelegate; |
23 | 25 |
24 // A helper class that handles DnD for drops in the renderer. In GTK parlance, | 26 // A helper class that handles DnD for drops in the renderer. In GTK parlance, |
25 // this handles destination-side DnD, but not source-side DnD. | 27 // this handles destination-side DnD, but not source-side DnD. |
26 class CONTENT_EXPORT WebDragDestGtk { | 28 class CONTENT_EXPORT WebDragDestGtk { |
27 public: | 29 public: |
28 WebDragDestGtk(WebContents* web_contents, GtkWidget* widget); | 30 WebDragDestGtk(WebContents* web_contents, GtkWidget* widget); |
29 ~WebDragDestGtk(); | 31 ~WebDragDestGtk(); |
30 | 32 |
31 // This is called when the renderer responds to a drag motion event. We must | 33 // This is called when the renderer responds to a drag motion event. We must |
32 // update the system drag cursor. | 34 // update the system drag cursor. |
33 void UpdateDragStatus(WebKit::WebDragOperation operation); | 35 void UpdateDragStatus(WebKit::WebDragOperation operation); |
34 | 36 |
35 // Informs the renderer when a system drag has left the render view. | 37 // Informs the renderer when a system drag has left the render view. |
36 // See OnDragLeave(). | 38 // See OnDragLeave(). |
37 void DragLeave(); | 39 void DragLeave(); |
38 | 40 |
39 WebDragDestDelegate* delegate() const { return delegate_; } | 41 WebDragDestDelegate* delegate() const { return delegate_; } |
40 void set_delegate(WebDragDestDelegate* delegate) { delegate_ = delegate; } | 42 void set_delegate(WebDragDestDelegate* delegate) { delegate_ = delegate; } |
41 | 43 |
42 private: | 44 private: |
| 45 RenderViewHostImpl* GetRenderViewHost() const; |
| 46 |
43 // Called when a system drag crosses over the render view. As there is no drag | 47 // Called when a system drag crosses over the render view. As there is no drag |
44 // enter event, we treat it as an enter event (and not a regular motion event) | 48 // enter event, we treat it as an enter event (and not a regular motion event) |
45 // when |context_| is NULL. | 49 // when |context_| is NULL. |
46 CHROMEGTK_CALLBACK_4(WebDragDestGtk, gboolean, OnDragMotion, GdkDragContext*, | 50 CHROMEGTK_CALLBACK_4(WebDragDestGtk, gboolean, OnDragMotion, GdkDragContext*, |
47 gint, gint, guint); | 51 gint, gint, guint); |
48 | 52 |
49 // We make a series of requests for the drag data when the drag first enters | 53 // We make a series of requests for the drag data when the drag first enters |
50 // the render view. This is the callback that is used to give us the data | 54 // the render view. This is the callback that is used to give us the data |
51 // for each individual target. When |data_requests_| reaches 0, we know we | 55 // for each individual target. When |data_requests_| reaches 0, we know we |
52 // have attained all the data, and we can finally tell the renderer about the | 56 // have attained all the data, and we can finally tell the renderer about the |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 WebDragDestDelegate* delegate_; | 100 WebDragDestDelegate* delegate_; |
97 | 101 |
98 base::WeakPtrFactory<WebDragDestGtk> method_factory_; | 102 base::WeakPtrFactory<WebDragDestGtk> method_factory_; |
99 | 103 |
100 DISALLOW_COPY_AND_ASSIGN(WebDragDestGtk); | 104 DISALLOW_COPY_AND_ASSIGN(WebDragDestGtk); |
101 }; | 105 }; |
102 | 106 |
103 } // namespace content | 107 } // namespace content |
104 | 108 |
105 #endif // CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ | 109 #endif // CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ |
OLD | NEW |