Chromium Code Reviews| Index: chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.mm |
| index a4c4d0c222bca1ade56be713297f1cdd178f6ea9..39a3022064975586b40e1287ac8d6ba1d8b067e3 100644 |
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.mm |
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.mm |
| @@ -88,15 +88,36 @@ |
| } |
| - (IBAction)ok:(id)sender { |
| - NSString* name = [nameField_ stringValue]; |
| BookmarkModel* model = profile_->GetBookmarkModel(); |
| + NSMutableString* name = |
| + [[NSMutableString alloc] initWithString:[nameField_ stringValue]]; |
| + |
| + // Replace occurrences of multiple newlines with single newlines. |
| + while (NSNotFound != [name rangeOfString:@"\n\n"].location) { |
| + [name replaceOccurrencesOfString:@"\n\n" |
| + withString:@"\n" |
| + options:0 |
| + range:NSMakeRange(0, [name length])]; |
| + } |
| + |
| + // Replace single newlines with single spaces. |
| + [name replaceOccurrencesOfString:@"\n" |
| + withString:@" " |
| + options:0 |
| + range:NSMakeRange(0, [name length])]; |
| + |
| + // Make the clean string immutable again and release the mutable object. |
| + NSString* clean_name = [name copy]; |
| + [name release]; |
| + |
| if (node_) { |
| - model->SetTitle(node_, base::SysNSStringToUTF16(name)); |
| + model->SetTitle(node_, base::SysNSStringToUTF16(clean_name)); |
|
Ilya Sherman
2011/11/18 22:51:29
Since I don't think our other platforms can displa
|
| } else { |
| model->AddFolder(parent_, |
| newIndex_, |
| - base::SysNSStringToUTF16(name)); |
| + base::SysNSStringToUTF16(clean_name)); |
| } |
| + |
| [NSApp endSheet:[self window]]; |
| } |