2016-07-03 12:26:43 +09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Copyright (c) 2016 GitHub, Inc.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Use of this source code is governed by the MIT license that can be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// found in the LICENSE file.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-19 13:46:59 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "shell/browser/ui/drag_util.h"
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 12:26:43 +09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-01-26 16:21:26 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/aura/client/drag_drop_client.h"
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/aura/window.h"
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-04 09:27:05 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/base/clipboard/file_info.h"
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/base/dragdrop/drag_drop_types.h"
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 11:33:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/base/dragdrop/os_exchange_data.h"
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-04 15:08:55 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/display/screen.h"
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-26 15:30:02 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/gfx/geometry/point.h"
							 | 
						
					
						
							
								
									
										
										
										
											2017-06-30 12:57:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/views/button_drag_utils.h"
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "ui/views/widget/widget.h"
							 | 
						
					
						
							
								
									
										
										
										
											2017-06-30 12:57:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "url/gurl.h"
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-19 14:23:04 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								namespace electron {
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 12:26:43 +09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void DragFileItems(const std::vector<base::FilePath>& files,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                   const gfx::Image& icon,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                   gfx::NativeView view) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Set up our OLE machinery
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:58:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  auto data = std::make_unique<ui::OSExchangeData>();
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  button_drag_utils::SetDragImage(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      GURL(), files[0].LossyDisplayName(), icon.AsImageSkia(), nullptr,
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:58:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      *views::Widget::GetTopLevelWidgetForNativeView(view), data.get());
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  std::vector<ui::FileInfo> file_infos;
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-13 10:26:59 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  file_infos.reserve(files.size());
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  for (const base::FilePath& file : files) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-13 10:26:59 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    file_infos.emplace_back(file, base::FilePath());
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:58:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  data->SetFilenames(file_infos);
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  aura::Window* root_window = view->GetRootWindow();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (!root_window || !aura::client::GetDragDropClient(root_window))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return;
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 12:26:43 +09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-04 15:08:55 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  gfx::Point location = display::Screen::GetScreen()->GetCursorScreenPoint();
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 11:33:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // TODO(varunjain): Properly determine and send DragEventSource below.
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  aura::client::GetDragDropClient(root_window)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ->StartDragAndDrop(
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:58:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          std::move(data), root_window, view, location,
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK,
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 11:33:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          ui::mojom::DragEventSource::kMouse);
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 14:34:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-03 12:26:43 +09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-19 14:23:04 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}  // namespace electron
							 |