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