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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 6982011: Strip leading "javascript:" schemas from text pasted or dropped into the omnibox. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
6 6
7 #include <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 8
9 #include "app/mac/nsimage_cache.h" 9 #include "app/mac/nsimage_cache.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 } 928 }
929 929
930 void OmniboxViewMac::OnPaste() { 930 void OmniboxViewMac::OnPaste() {
931 // This code currently expects |field_| to be focussed. 931 // This code currently expects |field_| to be focussed.
932 DCHECK([field_ currentEditor]); 932 DCHECK([field_ currentEditor]);
933 933
934 string16 text = GetClipboardText(g_browser_process->clipboard()); 934 string16 text = GetClipboardText(g_browser_process->clipboard());
935 if (text.empty()) { 935 if (text.empty()) {
936 return; 936 return;
937 } 937 }
938
939 StripJavascriptSchema(text, &text);
Peter Kasting 2011/05/10 23:27:42 Do this in GetClipboardText(), not here.
Cris Neckar 2011/05/11 21:42:36 Done.
938 NSString* s = base::SysUTF16ToNSString(text); 940 NSString* s = base::SysUTF16ToNSString(text);
939 941
940 // -shouldChangeTextInRange:* and -didChangeText are documented in 942 // -shouldChangeTextInRange:* and -didChangeText are documented in
941 // NSTextView as things you need to do if you write additional 943 // NSTextView as things you need to do if you write additional
942 // user-initiated editing functions. They cause the appropriate 944 // user-initiated editing functions. They cause the appropriate
943 // delegate methods to be called. 945 // delegate methods to be called.
944 // TODO(shess): It would be nice to separate the Cocoa-specific code 946 // TODO(shess): It would be nice to separate the Cocoa-specific code
945 // from the Chrome-specific code. 947 // from the Chrome-specific code.
946 NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); 948 NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]);
947 const NSRange selectedRange = GetSelectedRange(); 949 const NSRange selectedRange = GetSelectedRange();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1110
1109 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) { 1111 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) {
1110 DCHECK(pos <= GetTextLength()); 1112 DCHECK(pos <= GetTextLength());
1111 SetSelectedRange(NSMakeRange(pos, pos)); 1113 SetSelectedRange(NSMakeRange(pos, pos));
1112 } 1114 }
1113 1115
1114 bool OmniboxViewMac::IsCaretAtEnd() const { 1116 bool OmniboxViewMac::IsCaretAtEnd() const {
1115 const NSRange selection = GetSelectedRange(); 1117 const NSRange selection = GetSelectedRange();
1116 return selection.length == 0 && selection.location == GetTextLength(); 1118 return selection.length == 0 && selection.location == GetTextLength();
1117 } 1119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698