OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "app/gfx/native_widget_types.h" | 10 #include "app/gfx/native_widget_types.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/gfx/point.h" |
13 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
14 #include "base/string16.h" | 15 #include "base/string16.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" |
17 | 19 |
18 class TabContents; | 20 class TabContents; |
19 class TabContentsView; | 21 class TabContentsView; |
20 struct WebDropData; | 22 struct WebDropData; |
21 | 23 |
22 // TabContentsDragSource takes care of managing the drag from a TabContents | 24 // TabContentsDragSource takes care of managing the drag from a TabContents |
23 // with Gtk. | 25 // with Gtk. |
24 class TabContentsDragSource : public MessageLoopForUI::Observer { | 26 class TabContentsDragSource : public MessageLoopForUI::Observer { |
25 public: | 27 public: |
26 explicit TabContentsDragSource(TabContentsView* tab_contents_view); | 28 explicit TabContentsDragSource(TabContentsView* tab_contents_view); |
27 ~TabContentsDragSource(); | 29 ~TabContentsDragSource(); |
28 | 30 |
29 TabContents* tab_contents() const; | 31 TabContents* tab_contents() const; |
30 | 32 |
31 // Starts a drag for the tab contents this TabContentsDragSource was | 33 // Starts a drag for the tab contents this TabContentsDragSource was |
32 // created for. | 34 // created for. |
33 void StartDragging(const WebDropData& drop_data, | 35 void StartDragging(const WebDropData& drop_data, |
34 GdkEventButton* last_mouse_down); | 36 GdkEventButton* last_mouse_down, |
| 37 const SkBitmap& image, |
| 38 const gfx::Point& image_offset); |
35 | 39 |
36 // MessageLoop::Observer implementation: | 40 // MessageLoop::Observer implementation: |
37 virtual void WillProcessEvent(GdkEvent* event); | 41 virtual void WillProcessEvent(GdkEvent* event); |
38 virtual void DidProcessEvent(GdkEvent* event); | 42 virtual void DidProcessEvent(GdkEvent* event); |
39 | 43 |
40 private: | 44 private: |
41 static gboolean OnDragFailedThunk(GtkWidget* widget, | 45 static gboolean OnDragFailedThunk(GtkWidget* widget, |
42 GdkDragContext* drag_context, | 46 GdkDragContext* drag_context, |
43 GtkDragResult result, | 47 GtkDragResult result, |
44 TabContentsDragSource* handler) { | 48 TabContentsDragSource* handler) { |
(...skipping 27 matching lines...) Expand all Loading... |
72 | 76 |
73 gfx::NativeView GetContentNativeView() const; | 77 gfx::NativeView GetContentNativeView() const; |
74 | 78 |
75 // The view we're manging the drag for. | 79 // The view we're manging the drag for. |
76 TabContentsView* tab_contents_view_; | 80 TabContentsView* tab_contents_view_; |
77 | 81 |
78 // The drop data for the current drag (for drags that originate in the render | 82 // The drop data for the current drag (for drags that originate in the render |
79 // view). Non-NULL iff there is a current drag. | 83 // view). Non-NULL iff there is a current drag. |
80 scoped_ptr<WebDropData> drop_data_; | 84 scoped_ptr<WebDropData> drop_data_; |
81 | 85 |
| 86 // The image used for depicting the drag, and the offset between the cursor |
| 87 // and the top left pixel. |
| 88 SkBitmap drag_image_; |
| 89 gfx::Point image_offset_; |
| 90 |
82 // The mime type for the file contents of the current drag (if any). | 91 // The mime type for the file contents of the current drag (if any). |
83 GdkAtom drag_file_mime_type_; | 92 GdkAtom drag_file_mime_type_; |
84 | 93 |
85 // Whether the current drag has failed. Meaningless if we are not the source | 94 // Whether the current drag has failed. Meaningless if we are not the source |
86 // for a current drag. | 95 // for a current drag. |
87 bool drag_failed_; | 96 bool drag_failed_; |
88 | 97 |
89 // This is the widget we use to initiate drags. Since we don't use the | 98 // This is the widget we use to initiate drags. Since we don't use the |
90 // renderer widget, we can persist drags even when our contents is switched | 99 // renderer widget, we can persist drags even when our contents is switched |
91 // out. | 100 // out. |
92 GtkWidget* drag_widget_; | 101 GtkWidget* drag_widget_; |
93 | 102 |
94 // The file mime type for a drag-out download. | 103 // The file mime type for a drag-out download. |
95 string16 wide_download_mime_type_; | 104 string16 wide_download_mime_type_; |
96 | 105 |
97 // The file name to be saved to for a drag-out download. | 106 // The file name to be saved to for a drag-out download. |
98 FilePath download_file_name_; | 107 FilePath download_file_name_; |
99 | 108 |
100 // The URL to download from for a drag-out download. | 109 // The URL to download from for a drag-out download. |
101 GURL download_url_; | 110 GURL download_url_; |
102 | 111 |
103 DISALLOW_COPY_AND_ASSIGN(TabContentsDragSource); | 112 DISALLOW_COPY_AND_ASSIGN(TabContentsDragSource); |
104 }; | 113 }; |
105 | 114 |
106 #endif // CHROME_BROWSER_GTK_TAB_CONTENTS_DRAG_SOURCE_H_ | 115 #endif // CHROME_BROWSER_GTK_TAB_CONTENTS_DRAG_SOURCE_H_ |
OLD | NEW |