OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ | |
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ | |
7 | |
8 #include <gtk/gtk.h> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/files/file_path.h" | |
12 #include "base/strings/string16.h" | |
13 #include "content/common/content_export.h" | |
14 #include "content/public/browser/web_contents.h" | |
15 #include "third_party/WebKit/public/web/WebDragOperation.h" | |
16 #include "ui/base/gtk/gtk_signal.h" | |
17 #include "ui/base/gtk/gtk_signal_registrar.h" | |
18 #include "ui/gfx/native_widget_types.h" | |
19 #include "ui/gfx/vector2d.h" | |
20 #include "url/gurl.h" | |
21 | |
22 class SkBitmap; | |
23 | |
24 namespace content { | |
25 | |
26 class RenderViewHostImpl; | |
27 class WebContentsImpl; | |
28 struct DropData; | |
29 | |
30 // WebDragSourceGtk takes care of managing the drag from a WebContents | |
31 // with Gtk. | |
32 class CONTENT_EXPORT WebDragSourceGtk { | |
33 public: | |
34 explicit WebDragSourceGtk(WebContents* web_contents); | |
35 virtual ~WebDragSourceGtk(); | |
36 | |
37 // Starts a drag for the WebContents this WebDragSourceGtk was created for. | |
38 // Returns false if the drag could not be started. | |
39 bool StartDragging(const DropData& drop_data, | |
40 blink::WebDragOperationsMask allowed_ops, | |
41 GdkEventButton* last_mouse_down, | |
42 const SkBitmap& image, | |
43 const gfx::Vector2d& image_offset); | |
44 | |
45 private: | |
46 CHROMEGTK_CALLBACK_2(WebDragSourceGtk, gboolean, OnDragFailed, | |
47 GdkDragContext*, GtkDragResult); | |
48 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, void, OnDragBegin, | |
49 GdkDragContext*); | |
50 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, void, OnDragEnd, | |
51 GdkDragContext*); | |
52 CHROMEGTK_CALLBACK_4(WebDragSourceGtk, void, OnDragDataGet, | |
53 GdkDragContext*, GtkSelectionData*, guint, guint); | |
54 CHROMEGTK_CALLBACK_1(WebDragSourceGtk, gboolean, OnDragIconExpose, | |
55 GdkEventExpose*); | |
56 | |
57 gfx::NativeView GetContentNativeView() const; | |
58 | |
59 // The tab we're manging the drag for. | |
60 WebContentsImpl* web_contents_; | |
61 | |
62 // The drop data for the current drag (for drags that originate in the render | |
63 // view). Non-NULL iff there is a current drag. | |
64 scoped_ptr<DropData> drop_data_; | |
65 | |
66 // The image used for depicting the drag, and the offset between the cursor | |
67 // and the top left pixel. | |
68 GdkPixbuf* drag_pixbuf_; | |
69 gfx::Vector2d image_offset_; | |
70 | |
71 // The mime type for the file contents of the current drag (if any). | |
72 GdkAtom drag_file_mime_type_; | |
73 | |
74 // Whether the current drag has failed. Meaningless if we are not the source | |
75 // for a current drag. | |
76 bool drag_failed_; | |
77 | |
78 // This is the widget we use to initiate drags. Since we don't use the | |
79 // renderer widget, we can persist drags even when our contents is switched | |
80 // out. We can't use an OwnedWidgetGtk because the GtkInvisible widget | |
81 // initialization code sinks the reference. | |
82 GtkWidget* drag_widget_; | |
83 | |
84 // Context created once drag starts. A NULL value indicates that there is | |
85 // no drag currently in progress. | |
86 GdkDragContext* drag_context_; | |
87 | |
88 // The file mime type for a drag-out download. | |
89 base::string16 wide_download_mime_type_; | |
90 | |
91 // The file name to be saved to for a drag-out download. | |
92 base::FilePath download_file_name_; | |
93 | |
94 // The URL to download from for a drag-out download. | |
95 GURL download_url_; | |
96 | |
97 // The widget that provides visual feedback for the drag. We can't use | |
98 // an OwnedWidgetGtk because the GtkWindow initialization code sinks | |
99 // the reference. | |
100 GtkWidget* drag_icon_; | |
101 | |
102 ui::GtkSignalRegistrar signals_; | |
103 | |
104 DISALLOW_COPY_AND_ASSIGN(WebDragSourceGtk); | |
105 }; | |
106 | |
107 } // namespace content | |
108 | |
109 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_GTK_H_ | |
OLD | NEW |