Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(762)

Side by Side Diff: chrome/browser/cocoa/autocomplete_text_field_editor.mm

Issue 155790: Properly collapse newlines (and leading/trailing whitespace) from pasted... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" 5 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 9
10 using base::SysNSStringToWide;
11 using base::SysWideToNSString;
12
10 @implementation AutocompleteTextFieldEditor 13 @implementation AutocompleteTextFieldEditor
11 14
12 - (void)copy:(id)sender { 15 - (void)copy:(id)sender {
13 NSPasteboard* pb = [NSPasteboard generalPasteboard]; 16 [self performCopy:[NSPasteboard generalPasteboard]];
14 [self performCopy:pb];
15 } 17 }
16 18
17 - (void)cut:(id)sender { 19 - (void)cut:(id)sender {
18 NSPasteboard* pb = [NSPasteboard generalPasteboard]; 20 [self performCut:[NSPasteboard generalPasteboard]];
19 [self performCut:pb]; 21 }
22
23 - (void)paste:(id)sender {
24 [self performPaste:[NSPasteboard generalPasteboard]];
20 } 25 }
21 26
22 - (void)performCopy:(NSPasteboard*)pb { 27 - (void)performCopy:(NSPasteboard*)pb {
23 [pb declareTypes:[NSArray array] owner:nil]; 28 [pb declareTypes:[NSArray array] owner:nil];
24 [self writeSelectionToPasteboard:pb types: 29 [self writeSelectionToPasteboard:pb types:
25 [NSArray arrayWithObject:NSStringPboardType]]; 30 [NSArray arrayWithObject:NSStringPboardType]];
26 } 31 }
27 32
28 - (void)performCut:(NSPasteboard*)pb { 33 - (void)performCut:(NSPasteboard*)pb {
29 [self performCopy:pb]; 34 [self performCopy:pb];
30 [self delete:nil]; 35 [self delete:nil];
31 } 36 }
32 37
38 // Pastes strip newlines and leading/trailing whitespace (so that split URLs
39 // copied from email, etc. end up as "expected"). Eliminating leading/trailing
40 // whitespace can't be accomplished elsewhere, so we have to intercept the
41 // paste.
42 - (void)performPaste:(NSPasteboard*)pb {
43 NSString* pasteString = [pb stringForType:NSStringPboardType];
44 [self insertText:SysWideToNSString(CollapseWhitespace(SysNSStringToWide(
45 pasteString),true))];
46 }
47
33 @end 48 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_editor.h ('k') | chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698