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 #include "chrome/browser/ui/gtk/download/download_item_drag.h" | 5 #include "chrome/browser/ui/gtk/download/download_item_drag.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/download/drag_download_item.h" | 9 #include "chrome/browser/download/drag_download_item.h" |
10 #include "content/public/browser/download_item.h" | 10 #include "content/public/browser/download_item.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // DownloadItemDrag ------------------------------------------------------------ | 102 // DownloadItemDrag ------------------------------------------------------------ |
103 | 103 |
104 // static | 104 // static |
105 void DownloadItemDrag::SetSource(GtkWidget* widget, | 105 void DownloadItemDrag::SetSource(GtkWidget* widget, |
106 const DownloadItem* item, | 106 const DownloadItem* item, |
107 gfx::Image* icon) { | 107 gfx::Image* icon) { |
108 scoped_ptr<DragData> drag_data(new DragData(item)); | 108 scoped_ptr<DragData> drag_data(new DragData(item)); |
109 DragData::AttachToWidget(drag_data.Pass(), widget, icon); | 109 DragData::AttachToWidget(drag_data.Pass(), widget, icon); |
110 } | 110 } |
111 | 111 |
112 // static | |
113 void DownloadItemDrag::BeginDrag(const DownloadItem* item, gfx::Image* icon) { | |
114 new DownloadItemDrag(item, icon); | |
115 } | |
116 | |
117 DownloadItemDrag::DownloadItemDrag(const DownloadItem* item, gfx::Image* icon) | 112 DownloadItemDrag::DownloadItemDrag(const DownloadItem* item, gfx::Image* icon) |
118 : CustomDrag(icon, kDownloadItemCodeMask, kDownloadItemDragAction), | 113 : CustomDrag(icon, kDownloadItemCodeMask, kDownloadItemDragAction), |
119 drag_data_(new DragData(item)) {} | 114 drag_data_(new DragData(item)) {} |
120 | 115 |
121 DownloadItemDrag::~DownloadItemDrag() {} | 116 DownloadItemDrag::~DownloadItemDrag() {} |
122 | 117 |
123 void DownloadItemDrag::OnDragDataGet(GtkWidget* widget, | 118 void DownloadItemDrag::OnDragDataGet(GtkWidget* widget, |
124 GdkDragContext* context, | 119 GdkDragContext* context, |
125 GtkSelectionData* selection_data, | 120 GtkSelectionData* selection_data, |
126 guint target_type, | 121 guint target_type, |
127 guint time) { | 122 guint time) { |
128 drag_data_->OnDragDataGet(widget, context, selection_data, target_type, time); | 123 drag_data_->OnDragDataGet(widget, context, selection_data, target_type, time); |
129 } | 124 } |
130 | 125 |
131 void DragDownloadItem(const content::DownloadItem* download, | 126 void DragDownloadItem(const content::DownloadItem* download, |
132 gfx::Image* icon, | 127 gfx::Image* icon, |
133 gfx::NativeView view) { | 128 gfx::NativeView view) { |
134 DownloadItemDrag::BeginDrag(download, icon); | 129 // This starts the drag process, the lifetime of this object is tied to the |
| 130 // system drag. |
| 131 new DownloadItemDrag(download, icon); |
135 } | 132 } |
OLD | NEW |