OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/drag_utils.h" | 5 #include "views/drag_utils.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/os_exchange_data.h" | 8 #include "app/os_exchange_data.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0); | 74 canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0); |
75 | 75 |
76 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
77 // Paint the file name. We inset it one pixel to allow room for the halo. | 77 // Paint the file name. We inset it one pixel to allow room for the halo. |
78 std::wstring name = file_util::GetFilenameFromPath(file_name); | 78 std::wstring name = file_util::GetFilenameFromPath(file_name); |
79 canvas.DrawStringWithHalo(name, font, kFileDragImageTextColor, SK_ColorWHITE, | 79 canvas.DrawStringWithHalo(name, font, kFileDragImageTextColor, SK_ColorWHITE, |
80 1, icon->height() + kLinkDragImageVPadding + 1, | 80 1, icon->height() + kLinkDragImageVPadding + 1, |
81 width - 2, font.height(), | 81 width - 2, font.height(), |
82 gfx::Canvas::TEXT_ALIGN_CENTER); | 82 gfx::Canvas::TEXT_ALIGN_CENTER); |
83 #else | 83 #else |
84 std::wstring name = file_util::GetFilenameFromPath(UTF8ToWide(file_name)); | 84 std::wstring name = FilePath(file_name).BaseName().ToWStringHack(); |
85 canvas.DrawStringInt(name, font, kFileDragImageTextColor, | 85 canvas.DrawStringInt(name, font, kFileDragImageTextColor, |
86 0, icon->height() + kLinkDragImageVPadding, | 86 0, icon->height() + kLinkDragImageVPadding, |
87 width, font.height(), gfx::Canvas::TEXT_ALIGN_CENTER); | 87 width, font.height(), gfx::Canvas::TEXT_ALIGN_CENTER); |
88 #endif | 88 #endif |
89 | 89 |
90 SetDragImageOnDataObject(canvas, gfx::Size(width, height), | 90 SetDragImageOnDataObject(canvas, gfx::Size(width, height), |
91 gfx::Point(width / 2, kLinkDragImageVPadding), | 91 gfx::Point(width / 2, kLinkDragImageVPadding), |
92 data_object); | 92 data_object); |
93 } | 93 } |
94 | 94 |
95 void SetDragImageOnDataObject(const gfx::Canvas& canvas, | 95 void SetDragImageOnDataObject(const gfx::Canvas& canvas, |
96 const gfx::Size& size, | 96 const gfx::Size& size, |
97 const gfx::Point& cursor_offset, | 97 const gfx::Point& cursor_offset, |
98 OSExchangeData* data_object) { | 98 OSExchangeData* data_object) { |
99 SetDragImageOnDataObject( | 99 SetDragImageOnDataObject( |
100 canvas.AsCanvasSkia()->ExtractBitmap(), size, cursor_offset, data_object); | 100 canvas.AsCanvasSkia()->ExtractBitmap(), size, cursor_offset, data_object); |
101 } | 101 } |
102 | 102 |
103 } // namespace drag_utils | 103 } // namespace drag_utils |
OLD | NEW |