| 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/download/drag_download_item.h" | 5 #include "chrome/browser/download/drag_download_item.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "content/public/browser/download_item.h" | 10 #include "content/public/browser/download_item.h" |
| 11 #include "net/base/mime_util.h" | 11 #include "net/base/mime_util.h" |
| 12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 13 #include "ui/base/dragdrop/drag_drop_types.h" | 13 #include "ui/base/dragdrop/drag_drop_types.h" |
| 14 #include "ui/base/dragdrop/drag_utils.h" | 14 #include "ui/base/dragdrop/drag_utils.h" |
| 15 #include "ui/base/dragdrop/file_info.h" |
| 15 #include "ui/base/dragdrop/os_exchange_data.h" | 16 #include "ui/base/dragdrop/os_exchange_data.h" |
| 16 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 17 #include "ui/gfx/image/image_skia.h" | 18 #include "ui/gfx/image/image_skia.h" |
| 18 #include "ui/gfx/point.h" | 19 #include "ui/gfx/point.h" |
| 19 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 20 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 22 | 23 |
| 23 #if defined(USE_AURA) | 24 #if defined(USE_AURA) |
| 24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 47 base::FilePath full_path = download->GetTargetFilePath(); | 48 base::FilePath full_path = download->GetTargetFilePath(); |
| 48 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
| 49 // Overwrite |full_path| with drive cache file path when appropriate. | 50 // Overwrite |full_path| with drive cache file path when appropriate. |
| 50 Profile* profile = Profile::FromBrowserContext(download->GetBrowserContext()); | 51 Profile* profile = Profile::FromBrowserContext(download->GetBrowserContext()); |
| 51 drive::DownloadHandler* drive_download_handler = | 52 drive::DownloadHandler* drive_download_handler = |
| 52 drive::DownloadHandler::GetForProfile(profile); | 53 drive::DownloadHandler::GetForProfile(profile); |
| 53 if (drive_download_handler && | 54 if (drive_download_handler && |
| 54 drive_download_handler->IsDriveDownload(download)) | 55 drive_download_handler->IsDriveDownload(download)) |
| 55 full_path = drive_download_handler->GetCacheFilePath(download); | 56 full_path = drive_download_handler->GetCacheFilePath(download); |
| 56 #endif | 57 #endif |
| 57 std::vector<ui::OSExchangeData::FileInfo> file_infos; | 58 std::vector<ui::FileInfo> file_infos; |
| 58 file_infos.push_back(ui::OSExchangeData::FileInfo( | 59 file_infos.push_back( |
| 59 full_path, download->GetFileNameToReportUser())); | 60 ui::FileInfo(full_path, download->GetFileNameToReportUser())); |
| 60 data.SetFilenames(file_infos); | 61 data.SetFilenames(file_infos); |
| 61 | 62 |
| 62 // Add URL so that we can load supported files when dragged to WebContents. | 63 // Add URL so that we can load supported files when dragged to WebContents. |
| 63 data.SetURL(net::FilePathToFileURL(full_path), | 64 data.SetURL(net::FilePathToFileURL(full_path), |
| 64 download->GetFileNameToReportUser().LossyDisplayName()); | 65 download->GetFileNameToReportUser().LossyDisplayName()); |
| 65 | 66 |
| 66 #if !defined(TOOLKIT_GTK) | 67 #if !defined(TOOLKIT_GTK) |
| 67 #if defined(USE_AURA) | 68 #if defined(USE_AURA) |
| 68 aura::Window* root_window = view->GetRootWindow(); | 69 aura::Window* root_window = view->GetRootWindow(); |
| 69 if (!root_window || !aura::client::GetDragDropClient(root_window)) | 70 if (!root_window || !aura::client::GetDragDropClient(root_window)) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 97 | 98 |
| 98 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>( | 99 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>( |
| 99 views::Widget::GetWidgetForNativeView(root)->native_widget()); | 100 views::Widget::GetWidgetForNativeView(root)->native_widget()); |
| 100 if (!widget) | 101 if (!widget) |
| 101 return; | 102 return; |
| 102 | 103 |
| 103 widget->DoDrag(data, | 104 widget->DoDrag(data, |
| 104 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); | 105 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); |
| 105 #endif // TOOLKIT_GTK | 106 #endif // TOOLKIT_GTK |
| 106 } | 107 } |
| OLD | NEW |