| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 drive::DownloadHandler::GetForProfile(profile); | 53 drive::DownloadHandler::GetForProfile(profile); |
| 54 if (drive_download_handler && | 54 if (drive_download_handler && |
| 55 drive_download_handler->IsDriveDownload(download)) | 55 drive_download_handler->IsDriveDownload(download)) |
| 56 full_path = drive_download_handler->GetCacheFilePath(download); | 56 full_path = drive_download_handler->GetCacheFilePath(download); |
| 57 #endif | 57 #endif |
| 58 std::vector<ui::FileInfo> file_infos; | 58 std::vector<ui::FileInfo> file_infos; |
| 59 file_infos.push_back( | 59 file_infos.push_back( |
| 60 ui::FileInfo(full_path, download->GetFileNameToReportUser())); | 60 ui::FileInfo(full_path, download->GetFileNameToReportUser())); |
| 61 data.SetFilenames(file_infos); | 61 data.SetFilenames(file_infos); |
| 62 | 62 |
| 63 #if !defined(TOOLKIT_GTK) | |
| 64 #if defined(USE_AURA) | 63 #if defined(USE_AURA) |
| 65 aura::Window* root_window = view->GetRootWindow(); | 64 aura::Window* root_window = view->GetRootWindow(); |
| 66 if (!root_window || !aura::client::GetDragDropClient(root_window)) | 65 if (!root_window || !aura::client::GetDragDropClient(root_window)) |
| 67 return; | 66 return; |
| 68 | 67 |
| 69 gfx::Point location = gfx::Screen::GetScreenFor(view)->GetCursorScreenPoint(); | 68 gfx::Point location = gfx::Screen::GetScreenFor(view)->GetCursorScreenPoint(); |
| 70 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. | 69 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. |
| 71 aura::client::GetDragDropClient(root_window)->StartDragAndDrop( | 70 aura::client::GetDragDropClient(root_window)->StartDragAndDrop( |
| 72 data, | 71 data, |
| 73 root_window, | 72 root_window, |
| 74 view, | 73 view, |
| 75 location, | 74 location, |
| 76 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK, | 75 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK, |
| 77 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); | 76 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); |
| 78 #else // We are on WIN without AURA | 77 #else // We are on WIN without AURA |
| 79 // We cannot use Widget::RunShellDrag on WIN since the |view| is backed by a | 78 // We cannot use Widget::RunShellDrag on WIN since the |view| is backed by a |
| 80 // WebContentsViewWin, not a NativeWidgetWin. | 79 // WebContentsViewWin, not a NativeWidgetWin. |
| 81 scoped_refptr<ui::DragSourceWin> drag_source(new ui::DragSourceWin); | 80 scoped_refptr<ui::DragSourceWin> drag_source(new ui::DragSourceWin); |
| 82 // Run the drag and drop loop | 81 // Run the drag and drop loop |
| 83 DWORD effects; | 82 DWORD effects; |
| 84 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), | 83 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), |
| 85 drag_source.get(), | 84 drag_source.get(), |
| 86 DROPEFFECT_COPY | DROPEFFECT_LINK, | 85 DROPEFFECT_COPY | DROPEFFECT_LINK, |
| 87 &effects); | 86 &effects); |
| 88 #endif | 87 #endif |
| 89 | |
| 90 #else | |
| 91 GtkWidget* root = gtk_widget_get_toplevel(view); | |
| 92 if (!root) | |
| 93 return; | |
| 94 | |
| 95 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>( | |
| 96 views::Widget::GetWidgetForNativeView(root)->native_widget()); | |
| 97 if (!widget) | |
| 98 return; | |
| 99 | |
| 100 widget->DoDrag(data, | |
| 101 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); | |
| 102 #endif // TOOLKIT_GTK | |
| 103 } | 88 } |
| OLD | NEW |