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 // This file implements utility functions for eliding and formatting UI text. | 5 // This file implements utility functions for eliding and formatting UI text. |
6 // | 6 // |
7 // Note that several of the functions declared in text_elider.h are implemented | 7 // Note that several of the functions declared in text_elider.h are implemented |
8 // in this file using helper classes in an unnamed namespace. | 8 // in this file using helper classes in an unnamed namespace. |
9 | 9 |
10 #include "ui/base/text/text_elider.h" | 10 #include "ui/base/text/text_elider.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 final_elided_url_string += BuildPathFromComponents(string16(), | 391 final_elided_url_string += BuildPathFromComponents(string16(), |
392 url_path_elements, url_filename, 1); | 392 url_path_elements, url_filename, 1); |
393 } else { | 393 } else { |
394 final_elided_url_string += url_path; | 394 final_elided_url_string += url_path; |
395 } | 395 } |
396 | 396 |
397 return ElideText(final_elided_url_string, font, available_pixel_width, | 397 return ElideText(final_elided_url_string, font, available_pixel_width, |
398 ELIDE_AT_END); | 398 ELIDE_AT_END); |
399 } | 399 } |
400 | 400 |
401 string16 ElideFilename(const FilePath& filename, | 401 string16 ElideFilename(const base::FilePath& filename, |
402 const gfx::Font& font, | 402 const gfx::Font& font, |
403 int available_pixel_width) { | 403 int available_pixel_width) { |
404 #if defined(OS_WIN) | 404 #if defined(OS_WIN) |
405 string16 filename_utf16 = filename.value(); | 405 string16 filename_utf16 = filename.value(); |
406 string16 extension = filename.Extension(); | 406 string16 extension = filename.Extension(); |
407 string16 rootname = filename.BaseName().RemoveExtension().value(); | 407 string16 rootname = filename.BaseName().RemoveExtension().value(); |
408 #elif defined(OS_POSIX) | 408 #elif defined(OS_POSIX) |
409 string16 filename_utf16 = WideToUTF16(base::SysNativeMBToWide( | 409 string16 filename_utf16 = WideToUTF16(base::SysNativeMBToWide( |
410 filename.value())); | 410 filename.value())); |
411 string16 extension = WideToUTF16(base::SysNativeMBToWide( | 411 string16 extension = WideToUTF16(base::SysNativeMBToWide( |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 index = char_iterator.getIndex(); | 1122 index = char_iterator.getIndex(); |
1123 } else { | 1123 } else { |
1124 // String has leading whitespace, return the elide string. | 1124 // String has leading whitespace, return the elide string. |
1125 return kElideString; | 1125 return kElideString; |
1126 } | 1126 } |
1127 } | 1127 } |
1128 return string.substr(0, index) + kElideString; | 1128 return string.substr(0, index) + kElideString; |
1129 } | 1129 } |
1130 | 1130 |
1131 } // namespace ui | 1131 } // namespace ui |
OLD | NEW |