| OLD | NEW |
| 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/base/dragdrop/drag_utils.h" | 5 #include "ui/base/dragdrop/drag_utils.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void CreateDragImageForFile(const FilePath& file_name, | 86 void CreateDragImageForFile(const FilePath& file_name, |
| 87 const gfx::ImageSkia* icon, | 87 const gfx::ImageSkia* icon, |
| 88 ui::OSExchangeData* data_object) { | 88 ui::OSExchangeData* data_object) { |
| 89 DCHECK(icon); | 89 DCHECK(icon); |
| 90 DCHECK(data_object); | 90 DCHECK(data_object); |
| 91 gfx::CanvasImageSource* source = new FileDragImageSource(file_name, *icon); | 91 gfx::CanvasImageSource* source = new FileDragImageSource(file_name, *icon); |
| 92 gfx::Size size = source->size(); | 92 gfx::Size size = source->size(); |
| 93 // ImageSkia takes ownership of |source|. | 93 // ImageSkia takes ownership of |source|. |
| 94 gfx::ImageSkia image = gfx::ImageSkia(source, size); | 94 gfx::ImageSkia image = gfx::ImageSkia(source, size); |
| 95 | 95 |
| 96 SetDragImageOnDataObject(image, size, | 96 gfx::Vector2d cursor_offset(size.width() / 2, kLinkDragImageVPadding); |
| 97 gfx::Point(size.width() / 2, kLinkDragImageVPadding), | 97 SetDragImageOnDataObject(image, size, cursor_offset, data_object); |
| 98 data_object); | |
| 99 } | 98 } |
| 100 | 99 |
| 101 void SetDragImageOnDataObject(const gfx::Canvas& canvas, | 100 void SetDragImageOnDataObject(const gfx::Canvas& canvas, |
| 102 const gfx::Size& size, | 101 const gfx::Size& size, |
| 103 const gfx::Point& cursor_offset, | 102 const gfx::Vector2d& cursor_offset, |
| 104 ui::OSExchangeData* data_object) { | 103 ui::OSExchangeData* data_object) { |
| 105 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep()); | 104 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep()); |
| 106 SetDragImageOnDataObject(image, size, cursor_offset, data_object); | 105 SetDragImageOnDataObject(image, size, cursor_offset, data_object); |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace drag_utils | 108 } // namespace drag_utils |
| OLD | NEW |