OLD | NEW |
1 // Copyright (c) 2012 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_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "third_party/WebKit/public/web/WebDragOperation.h" | 17 #include "third_party/WebKit/public/web/WebDragOperation.h" |
18 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
19 #include "ui/base/gtk/gtk_signal_registrar.h" | 19 #include "ui/base/gtk/gtk_signal_registrar.h" |
20 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
21 #include "ui/gfx/vector2d.h" | 21 #include "ui/gfx/vector2d.h" |
22 | 22 |
23 class SkBitmap; | 23 class SkBitmap; |
24 struct WebDropData; | |
25 | 24 |
26 namespace content { | 25 namespace content { |
27 | 26 |
28 class RenderViewHostImpl; | 27 class RenderViewHostImpl; |
29 class WebContentsImpl; | 28 class WebContentsImpl; |
| 29 struct DropData; |
30 | 30 |
31 // WebDragSourceGtk takes care of managing the drag from a WebContents | 31 // WebDragSourceGtk takes care of managing the drag from a WebContents |
32 // with Gtk. | 32 // with Gtk. |
33 class CONTENT_EXPORT WebDragSourceGtk : | 33 class CONTENT_EXPORT WebDragSourceGtk : |
34 public base::MessageLoopForUI::Observer { | 34 public base::MessageLoopForUI::Observer { |
35 public: | 35 public: |
36 explicit WebDragSourceGtk(WebContents* web_contents); | 36 explicit WebDragSourceGtk(WebContents* web_contents); |
37 virtual ~WebDragSourceGtk(); | 37 virtual ~WebDragSourceGtk(); |
38 | 38 |
39 // Starts a drag for the WebContents this WebDragSourceGtk was created for. | 39 // Starts a drag for the WebContents this WebDragSourceGtk was created for. |
40 // Returns false if the drag could not be started. | 40 // Returns false if the drag could not be started. |
41 bool StartDragging(const WebDropData& drop_data, | 41 bool StartDragging(const DropData& drop_data, |
42 WebKit::WebDragOperationsMask allowed_ops, | 42 WebKit::WebDragOperationsMask allowed_ops, |
43 GdkEventButton* last_mouse_down, | 43 GdkEventButton* last_mouse_down, |
44 const SkBitmap& image, | 44 const SkBitmap& image, |
45 const gfx::Vector2d& image_offset); | 45 const gfx::Vector2d& image_offset); |
46 | 46 |
47 // MessageLoop::Observer implementation: | 47 // MessageLoop::Observer implementation: |
48 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE; | 48 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE; |
49 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE; | 49 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE; |
50 | 50 |
51 private: | 51 private: |
52 CHROMEGTK_CALLBACK_2(WebDragSourceGtk, gboolean, OnDragFailed, | 52 CHROMEGTK_CALLBACK_2(WebDragSourceGtk, gboolean, OnDragFailed, |
53 GdkDragContext*, GtkDragResult); | 53 GdkDragContext*, GtkDragResult); |
54 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, void, OnDragBegin, | 54 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, void, OnDragBegin, |
55 GdkDragContext*); | 55 GdkDragContext*); |
56 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, void, OnDragEnd, | 56 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, void, OnDragEnd, |
57 GdkDragContext*); | 57 GdkDragContext*); |
58 CHROMEGTK_CALLBACK_4(WebDragSourceGtk, void, OnDragDataGet, | 58 CHROMEGTK_CALLBACK_4(WebDragSourceGtk, void, OnDragDataGet, |
59 GdkDragContext*, GtkSelectionData*, guint, guint); | 59 GdkDragContext*, GtkSelectionData*, guint, guint); |
60 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, gboolean, OnDragIconExpose, | 60 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, gboolean, OnDragIconExpose, |
61 GdkEventExpose*); | 61 GdkEventExpose*); |
62 | 62 |
63 gfx::NativeView GetContentNativeView() const; | 63 gfx::NativeView GetContentNativeView() const; |
64 | 64 |
65 // The tab we're manging the drag for. | 65 // The tab we're manging the drag for. |
66 WebContentsImpl* web_contents_; | 66 WebContentsImpl* web_contents_; |
67 | 67 |
68 // The drop data for the current drag (for drags that originate in the render | 68 // The drop data for the current drag (for drags that originate in the render |
69 // view). Non-NULL iff there is a current drag. | 69 // view). Non-NULL iff there is a current drag. |
70 scoped_ptr<WebDropData> drop_data_; | 70 scoped_ptr<DropData> drop_data_; |
71 | 71 |
72 // The image used for depicting the drag, and the offset between the cursor | 72 // The image used for depicting the drag, and the offset between the cursor |
73 // and the top left pixel. | 73 // and the top left pixel. |
74 GdkPixbuf* drag_pixbuf_; | 74 GdkPixbuf* drag_pixbuf_; |
75 gfx::Vector2d image_offset_; | 75 gfx::Vector2d image_offset_; |
76 | 76 |
77 // The mime type for the file contents of the current drag (if any). | 77 // The mime type for the file contents of the current drag (if any). |
78 GdkAtom drag_file_mime_type_; | 78 GdkAtom drag_file_mime_type_; |
79 | 79 |
80 // Whether the current drag has failed. Meaningless if we are not the source | 80 // Whether the current drag has failed. Meaningless if we are not the source |
(...skipping 25 matching lines...) Expand all Loading... |
106 GtkWidget* drag_icon_; | 106 GtkWidget* drag_icon_; |
107 | 107 |
108 ui::GtkSignalRegistrar signals_; | 108 ui::GtkSignalRegistrar signals_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(WebDragSourceGtk); | 110 DISALLOW_COPY_AND_ASSIGN(WebDragSourceGtk); |
111 }; | 111 }; |
112 | 112 |
113 } // namespace content | 113 } // namespace content |
114 | 114 |
115 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ | 115 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ |
OLD | NEW |