| 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" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 drive::DownloadHandler::GetForProfile(profile); | 52 drive::DownloadHandler::GetForProfile(profile); |
| 53 if (drive_download_handler && | 53 if (drive_download_handler && |
| 54 drive_download_handler->IsDriveDownload(download)) | 54 drive_download_handler->IsDriveDownload(download)) |
| 55 full_path = drive_download_handler->GetCacheFilePath(download); | 55 full_path = drive_download_handler->GetCacheFilePath(download); |
| 56 #endif | 56 #endif |
| 57 std::vector<ui::OSExchangeData::FileInfo> file_infos; | 57 std::vector<ui::OSExchangeData::FileInfo> file_infos; |
| 58 file_infos.push_back(ui::OSExchangeData::FileInfo( | 58 file_infos.push_back(ui::OSExchangeData::FileInfo( |
| 59 full_path, download->GetFileNameToReportUser())); | 59 full_path, download->GetFileNameToReportUser())); |
| 60 data.SetFilenames(file_infos); | 60 data.SetFilenames(file_infos); |
| 61 | 61 |
| 62 // Add URL so that we can load supported files when dragged to WebContents. | |
| 63 data.SetURL(net::FilePathToFileURL(full_path), | |
| 64 download->GetFileNameToReportUser().LossyDisplayName()); | |
| 65 | |
| 66 #if !defined(TOOLKIT_GTK) | 62 #if !defined(TOOLKIT_GTK) |
| 67 #if defined(USE_AURA) | 63 #if defined(USE_AURA) |
| 68 aura::Window* root_window = view->GetRootWindow(); | 64 aura::Window* root_window = view->GetRootWindow(); |
| 69 if (!root_window || !aura::client::GetDragDropClient(root_window)) | 65 if (!root_window || !aura::client::GetDragDropClient(root_window)) |
| 70 return; | 66 return; |
| 71 | 67 |
| 72 gfx::Point location = gfx::Screen::GetScreenFor(view)->GetCursorScreenPoint(); | 68 gfx::Point location = gfx::Screen::GetScreenFor(view)->GetCursorScreenPoint(); |
| 73 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. | 69 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. |
| 74 aura::client::GetDragDropClient(root_window)->StartDragAndDrop( | 70 aura::client::GetDragDropClient(root_window)->StartDragAndDrop( |
| 75 data, | 71 data, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 97 | 93 |
| 98 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>( | 94 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>( |
| 99 views::Widget::GetWidgetForNativeView(root)->native_widget()); | 95 views::Widget::GetWidgetForNativeView(root)->native_widget()); |
| 100 if (!widget) | 96 if (!widget) |
| 101 return; | 97 return; |
| 102 | 98 |
| 103 widget->DoDrag(data, | 99 widget->DoDrag(data, |
| 104 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); | 100 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); |
| 105 #endif // TOOLKIT_GTK | 101 #endif // TOOLKIT_GTK |
| 106 } | 102 } |
| OLD | NEW |