| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/chrome/common/string_util.h" | 5 #include "ios/chrome/common/string_util.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_block.h" | 10 #include "base/mac/scoped_block.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ArrayFilterProcedure filter = ^(id object, NSUInteger index, BOOL* stop) { | 109 ArrayFilterProcedure filter = ^(id object, NSUInteger index, BOOL* stop) { |
| 110 return [object isEqualToString:@""]; | 110 return [object isEqualToString:@""]; |
| 111 }; | 111 }; |
| 112 [spaceSeparatedCompoments | 112 [spaceSeparatedCompoments |
| 113 removeObjectsAtIndexes:[spaceSeparatedCompoments | 113 removeObjectsAtIndexes:[spaceSeparatedCompoments |
| 114 indexesOfObjectsPassingTest:filter]]; | 114 indexesOfObjectsPassingTest:filter]]; |
| 115 cleanString = [spaceSeparatedCompoments componentsJoinedByString:@" "]; | 115 cleanString = [spaceSeparatedCompoments componentsJoinedByString:@" "]; |
| 116 return cleanString; | 116 return cleanString; |
| 117 } | 117 } |
| 118 | 118 |
| 119 std::string CleanStringForDisplay(std::string dirty, BOOL removeGraphicChars) { | 119 std::string CleanStringForDisplay(const std::string& dirty, |
| 120 BOOL removeGraphicChars) { |
| 120 return base::SysNSStringToUTF8(CleanNSStringForDisplay( | 121 return base::SysNSStringToUTF8(CleanNSStringForDisplay( |
| 121 base::SysUTF8ToNSString(dirty), removeGraphicChars)); | 122 base::SysUTF8ToNSString(dirty), removeGraphicChars)); |
| 122 } | 123 } |
| 123 | 124 |
| 124 NSString* SubstringOfWidth(NSString* string, | 125 NSString* SubstringOfWidth(NSString* string, |
| 125 NSDictionary* attributes, | 126 NSDictionary* attributes, |
| 126 CGFloat targetWidth, | 127 CGFloat targetWidth, |
| 127 BOOL trailing) { | 128 BOOL trailing) { |
| 128 if (![string length]) | 129 if (![string length]) |
| 129 return nil; | 130 return nil; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 else { | 169 else { |
| 169 substring = getSubstring.get()(characters - increment); | 170 substring = getSubstring.get()(characters - increment); |
| 170 break; // Growing the string, found the right size. | 171 break; // Growing the string, found the right size. |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 prevWidth = thisWidth; | 174 prevWidth = thisWidth; |
| 174 } while (characters > 0 && characters < [string length]); | 175 } while (characters > 0 && characters < [string length]); |
| 175 | 176 |
| 176 return substring; | 177 return substring; |
| 177 } | 178 } |
| OLD | NEW |