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