Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: ui/views/drag_utils.cc

Issue 191723003: Nukes USE_AURA ifdefs from views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/drag_utils.h" 5 #include "ui/views/drag_utils.h"
6 6
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/size.h"
9
10 #if defined(USE_AURA)
11 #include "ui/aura/client/drag_drop_client.h" 7 #include "ui/aura/client/drag_drop_client.h"
12 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
13 #include "ui/aura/window_event_dispatcher.h" 9 #include "ui/aura/window_event_dispatcher.h"
10 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/display.h" 11 #include "ui/gfx/display.h"
15 #include "ui/gfx/screen.h" 12 #include "ui/gfx/screen.h"
13 #include "ui/gfx/size.h"
16 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
17 #elif defined(OS_WIN)
18 #include "ui/base/dragdrop/drag_drop_types.h"
19 #include "ui/base/dragdrop/drag_source_win.h"
20 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
21 #else
22 #error
23 #endif
24 15
25 float GetDeviceScaleForNativeView(views::Widget* widget) { 16 float GetDeviceScaleForNativeView(views::Widget* widget) {
26 float device_scale = 1.0f; 17 float device_scale = 1.0f;
27 #if defined(USE_AURA)
28 // The following code should work on other platforms as well. But we do not 18 // The following code should work on other platforms as well. But we do not
29 // yet care about device scale factor on other platforms. So to keep drag and 19 // yet care about device scale factor on other platforms. So to keep drag and
30 // drop behavior on other platforms un-touched, we wrap this in the #if guard. 20 // drop behavior on other platforms un-touched, we wrap this in the #if guard.
31 if (widget && widget->GetNativeView()) { 21 if (widget && widget->GetNativeView()) {
32 gfx::NativeView view = widget->GetNativeView(); 22 gfx::NativeView view = widget->GetNativeView();
33 gfx::Display display = gfx::Screen::GetScreenFor(view)-> 23 gfx::Display display = gfx::Screen::GetScreenFor(view)->
34 GetDisplayNearestWindow(view); 24 GetDisplayNearestWindow(view);
35 device_scale = display.device_scale_factor(); 25 device_scale = display.device_scale_factor();
36 } 26 }
37 #endif
38 return device_scale; 27 return device_scale;
39 } 28 }
40 29
41 namespace views { 30 namespace views {
42 31
43 void RunShellDrag(gfx::NativeView view, 32 void RunShellDrag(gfx::NativeView view,
44 const ui::OSExchangeData& data, 33 const ui::OSExchangeData& data,
45 const gfx::Point& location, 34 const gfx::Point& location,
46 int operation, 35 int operation,
47 ui::DragDropTypes::DragEventSource source) { 36 ui::DragDropTypes::DragEventSource source) {
48 #if defined(USE_AURA)
49 gfx::Point root_location(location); 37 gfx::Point root_location(location);
50 aura::Window* root_window = view->GetRootWindow(); 38 aura::Window* root_window = view->GetRootWindow();
51 aura::Window::ConvertPointToTarget(view, root_window, &root_location); 39 aura::Window::ConvertPointToTarget(view, root_window, &root_location);
52 if (aura::client::GetDragDropClient(root_window)) { 40 if (aura::client::GetDragDropClient(root_window)) {
53 aura::client::GetDragDropClient(root_window)->StartDragAndDrop( 41 aura::client::GetDragDropClient(root_window)->StartDragAndDrop(
54 data, root_window, view, root_location, operation, source); 42 data, root_window, view, root_location, operation, source);
55 } 43 }
56 #elif defined(OS_WIN)
57 scoped_refptr<ui::DragSourceWin> drag_source(new ui::DragSourceWin);
msw 2014/03/08 01:04:50 nit: I think we can remove DragSourceWin, DesktopD
sky 2014/03/08 01:30:28 I'm keeping this to just the ui/views changes now.
58 DWORD effects;
59 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data),
60 drag_source,
61 ui::DragDropTypes::DragOperationToDropEffect(operation),
62 &effects);
63 #endif
64 } 44 }
65 45
66 gfx::Canvas* GetCanvasForDragImage(views::Widget* widget, 46 gfx::Canvas* GetCanvasForDragImage(views::Widget* widget,
67 const gfx::Size& canvas_size) { 47 const gfx::Size& canvas_size) {
68 float device_scale = GetDeviceScaleForNativeView(widget); 48 float device_scale = GetDeviceScaleForNativeView(widget);
69 return new gfx::Canvas(canvas_size, device_scale, false); 49 return new gfx::Canvas(canvas_size, device_scale, false);
70 } 50 }
71 51
72 } // namespace views 52 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698