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

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

Issue 7634028: Only check the keycode for key events. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/omnibox/omnibox_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 } 839 }
840 840
841 if (model_->AcceptCurrentInstantPreview()) 841 if (model_->AcceptCurrentInstantPreview())
842 return true; 842 return true;
843 } 843 }
844 844
845 // |-noop:| is sent when the user presses Cmd+Return. Override the no-op 845 // |-noop:| is sent when the user presses Cmd+Return. Override the no-op
846 // behavior with the proper WindowOpenDisposition. 846 // behavior with the proper WindowOpenDisposition.
847 NSEvent* event = [NSApp currentEvent]; 847 NSEvent* event = [NSApp currentEvent];
848 if (cmd == @selector(insertNewline:) || 848 if (cmd == @selector(insertNewline:) ||
849 (cmd == @selector(noop:) && [event keyCode] == kVK_Return)) { 849 (cmd == @selector(noop:) &&
850 ([event type] == NSKeyDown || [event type] == NSKeyUp) &&
851 [event keyCode] == kVK_Return)) {
850 WindowOpenDisposition disposition = 852 WindowOpenDisposition disposition =
851 event_utils::WindowOpenDispositionFromNSEvent(event); 853 event_utils::WindowOpenDispositionFromNSEvent(event);
852 model_->AcceptInput(disposition, false); 854 model_->AcceptInput(disposition, false);
853 // Opening a URL in a background tab should also revert the omnibox contents 855 // Opening a URL in a background tab should also revert the omnibox contents
854 // to their original state. We cannot do a blanket revert in OpenURL() 856 // to their original state. We cannot do a blanket revert in OpenURL()
855 // because middle-clicks also open in a new background tab, but those should 857 // because middle-clicks also open in a new background tab, but those should
856 // not revert the omnibox text. 858 // not revert the omnibox text.
857 RevertAll(); 859 RevertAll();
858 return true; 860 return true;
859 } 861 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 1116
1115 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) { 1117 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) {
1116 DCHECK(pos <= GetTextLength()); 1118 DCHECK(pos <= GetTextLength());
1117 SetSelectedRange(NSMakeRange(pos, pos)); 1119 SetSelectedRange(NSMakeRange(pos, pos));
1118 } 1120 }
1119 1121
1120 bool OmniboxViewMac::IsCaretAtEnd() const { 1122 bool OmniboxViewMac::IsCaretAtEnd() const {
1121 const NSRange selection = GetSelectedRange(); 1123 const NSRange selection = GetSelectedRange();
1122 return selection.length == 0 && selection.location == GetTextLength(); 1124 return selection.length == 0 && selection.location == GetTextLength();
1123 } 1125 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/omnibox/omnibox_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698