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