OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_DRAG_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_DRAG_H_ |
6 #define CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_DRAG_H_ | 6 #define CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_DRAG_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/browser/ui/gtk/custom_drag.h" | 11 #include "chrome/browser/ui/gtk/custom_drag.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 class DownloadItem; | 14 class DownloadItem; |
15 } | 15 } |
16 | 16 |
17 // Encapsulates functionality for drags of download items. | 17 // Encapsulates functionality for drags of download items. |
18 class DownloadItemDrag : public CustomDrag { | 18 class DownloadItemDrag : public CustomDrag { |
19 public: | 19 public: |
| 20 DownloadItemDrag(const content::DownloadItem* item, gfx::Image* icon); |
| 21 |
20 // Sets |widget| as a source for drags pertaining to |item|. No | 22 // Sets |widget| as a source for drags pertaining to |item|. No |
21 // DownloadItemDrag object is created. | 23 // DownloadItemDrag object is created. |
22 // It is safe to call this multiple times with different values of |icon|. | 24 // It is safe to call this multiple times with different values of |icon|. |
23 static void SetSource(GtkWidget* widget, | 25 static void SetSource(GtkWidget* widget, |
24 const content::DownloadItem* item, | 26 const content::DownloadItem* item, |
25 gfx::Image* icon); | 27 gfx::Image* icon); |
26 | 28 |
27 // Creates a new DownloadItemDrag, the lifetime of which is tied to the | |
28 // system drag. | |
29 static void BeginDrag(const content::DownloadItem* item, gfx::Image* icon); | |
30 | |
31 private: | 29 private: |
32 class DragData; | 30 class DragData; |
33 | 31 |
34 DownloadItemDrag(const content::DownloadItem* item, gfx::Image* icon); | |
35 virtual ~DownloadItemDrag(); | 32 virtual ~DownloadItemDrag(); |
36 | 33 |
37 virtual void OnDragDataGet(GtkWidget* widget, | 34 virtual void OnDragDataGet(GtkWidget* widget, |
38 GdkDragContext* context, | 35 GdkDragContext* context, |
39 GtkSelectionData* selection_data, | 36 GtkSelectionData* selection_data, |
40 guint target_type, | 37 guint target_type, |
41 guint time) OVERRIDE; | 38 guint time) OVERRIDE; |
42 | 39 |
43 scoped_ptr<DragData> drag_data_; | 40 scoped_ptr<DragData> drag_data_; |
44 | 41 |
45 DISALLOW_COPY_AND_ASSIGN(DownloadItemDrag); | 42 DISALLOW_COPY_AND_ASSIGN(DownloadItemDrag); |
46 }; | 43 }; |
47 | 44 |
48 | 45 |
49 #endif // CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_DRAG_H_ | 46 #endif // CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_DRAG_H_ |
OLD | NEW |