Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: chrome/browser/download/drag_download_item_views.cc

Issue 23271005: Move DragDownload() out of download_util.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: drag_download_item Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/download/download_util.h" 5 #include "chrome/browser/download/drag_download_item.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/public/browser/download_item.h" 9 #include "content/public/browser/download_item.h"
10 #include "net/base/mime_util.h" 10 #include "net/base/mime_util.h"
11 #include "net/base/net_util.h" 11 #include "net/base/net_util.h"
12 #include "ui/gfx/image/image.h"
13 #include "ui/gfx/point.h"
14 #include "url/gurl.h"
15
16 #if defined(TOOLKIT_VIEWS)
17 #include "ui/base/dragdrop/drag_drop_types.h" 12 #include "ui/base/dragdrop/drag_drop_types.h"
18 #include "ui/base/dragdrop/drag_utils.h" 13 #include "ui/base/dragdrop/drag_utils.h"
19 #include "ui/base/dragdrop/os_exchange_data.h" 14 #include "ui/base/dragdrop/os_exchange_data.h"
15 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/point.h"
20 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
21 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
22 #endif 19 #include "url/gurl.h"
23
24 #if defined(TOOLKIT_GTK)
25 #include "chrome/browser/ui/gtk/custom_drag.h"
26 #endif // defined(TOOLKIT_GTK)
27 20
28 #if defined(OS_WIN) && !defined(USE_AURA) 21 #if defined(OS_WIN) && !defined(USE_AURA)
29 #include "ui/base/dragdrop/drag_source_win.h" 22 #include "ui/base/dragdrop/drag_source_win.h"
30 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" 23 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
31 #endif 24 #endif
32 25
33 #if defined(USE_AURA) 26 #if defined(USE_AURA)
34 #include "ui/aura/client/drag_drop_client.h" 27 #include "ui/aura/client/drag_drop_client.h"
35 #include "ui/aura/root_window.h" 28 #include "ui/aura/root_window.h"
36 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
37 #endif 30 #endif
38 31
39 namespace download_util { 32 void DragDownloadItem(const content::DownloadItem* download,
40 33 gfx::Image* icon,
41 using content::DownloadItem; 34 gfx::NativeView view) {
42
43 #if defined(TOOLKIT_VIEWS)
44 // Download dragging
45 void DragDownload(const DownloadItem* download,
46 gfx::Image* icon,
47 gfx::NativeView view) {
48 DCHECK(download); 35 DCHECK(download);
49 DCHECK_EQ(DownloadItem::COMPLETE, download->GetState()); 36 DCHECK_EQ(content::DownloadItem::COMPLETE, download->GetState());
50 37
51 // Set up our OLE machinery 38 // Set up our OLE machinery
52 ui::OSExchangeData data; 39 ui::OSExchangeData data;
53 40
54 if (icon) { 41 if (icon) {
55 drag_utils::CreateDragImageForFile( 42 drag_utils::CreateDragImageForFile(
56 download->GetFileNameToReportUser(), icon->ToImageSkia(), &data); 43 download->GetFileNameToReportUser(), icon->ToImageSkia(), &data);
57 } 44 }
58 45
59 const base::FilePath full_path = download->GetTargetFilePath(); 46 const base::FilePath full_path = download->GetTargetFilePath();
(...skipping 24 matching lines...) Expand all
84 location, 71 location,
85 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK, 72 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK,
86 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 73 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
87 #else // We are on WIN without AURA 74 #else // We are on WIN without AURA
88 // We cannot use Widget::RunShellDrag on WIN since the |view| is backed by a 75 // We cannot use Widget::RunShellDrag on WIN since the |view| is backed by a
89 // WebContentsViewWin, not a NativeWidgetWin. 76 // WebContentsViewWin, not a NativeWidgetWin.
90 scoped_refptr<ui::DragSourceWin> drag_source(new ui::DragSourceWin); 77 scoped_refptr<ui::DragSourceWin> drag_source(new ui::DragSourceWin);
91 // Run the drag and drop loop 78 // Run the drag and drop loop
92 DWORD effects; 79 DWORD effects;
93 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), 80 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data),
94 drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); 81 drag_source.get(),
82 DROPEFFECT_COPY | DROPEFFECT_LINK,
83 &effects);
95 #endif 84 #endif
96 85
97 #else 86 #else
98 GtkWidget* root = gtk_widget_get_toplevel(view); 87 GtkWidget* root = gtk_widget_get_toplevel(view);
99 if (!root) 88 if (!root)
100 return; 89 return;
101 90
102 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>( 91 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>(
103 views::Widget::GetWidgetForNativeView(root)->native_widget()); 92 views::Widget::GetWidgetForNativeView(root)->native_widget());
104 if (!widget) 93 if (!widget)
105 return; 94 return;
106 95
107 widget->DoDrag(data, 96 widget->DoDrag(data,
108 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); 97 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK);
109 #endif // TOOLKIT_GTK 98 #endif // TOOLKIT_GTK
110 } 99 }
111 #elif defined(USE_X11)
112 void DragDownload(const DownloadItem* download,
113 gfx::Image* icon,
114 gfx::NativeView view) {
115 DownloadItemDrag::BeginDrag(download, icon);
116 }
117 #endif // USE_X11
118
119 } // namespace download_util
OLDNEW
« no previous file with comments | « chrome/browser/download/drag_download_item_gtk.cc ('k') | chrome/browser/extensions/api/downloads/downloads_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698