Fix Debug building on Windows
[platform/framework/web/crosswalk-tizen.git] / atom / browser / ui / drag_util_views.cc
1 // Copyright (c) 2016 GitHub, Inc.
2 // Use of this source code is governed by the MIT license that can be
3 // found in the LICENSE file.
4
5 #include "atom/browser/ui/drag_util.h"
6
7 #include "ui/aura/window.h"
8 #include "ui/base/dragdrop/drag_drop_types.h"
9 #include "ui/base/dragdrop/drag_utils.h"
10 #include "ui/base/dragdrop/file_info.h"
11 #include "ui/base/dragdrop/os_exchange_data.h"
12 #include "ui/display/screen.h"
13 #include "ui/gfx/geometry/point.h"
14 #include "ui/views/widget/widget.h"
15 #include "ui/aura/client/drag_drop_client.h"
16
17 namespace atom {
18
19 void DragFileItems(const std::vector<base::FilePath>& files,
20                    const gfx::Image& icon,
21                    gfx::NativeView view) {
22   // Set up our OLE machinery
23   ui::OSExchangeData data;
24
25   drag_utils::CreateDragImageForFile(files[0], icon.AsImageSkia(), &data);
26
27   std::vector<ui::FileInfo> file_infos;
28   for (const base::FilePath& file : files) {
29     file_infos.push_back(ui::FileInfo(file, base::FilePath()));
30   }
31   data.SetFilenames(file_infos);
32
33   aura::Window* root_window = view->GetRootWindow();
34   if (!root_window || !aura::client::GetDragDropClient(root_window))
35     return;
36
37   gfx::Point location = display::Screen::GetScreen()->GetCursorScreenPoint();
38   // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below.
39   aura::client::GetDragDropClient(root_window)->StartDragAndDrop(
40       data,
41       root_window,
42       view,
43       location,
44       ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK,
45       ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
46 }
47
48 }  // namespace atom