| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 return model()->AcceptKeyword(KeywordModeEntryMethod::TAB); | 810 return model()->AcceptKeyword(KeywordModeEntryMethod::TAB); |
| 811 } | 811 } |
| 812 | 812 |
| 813 // |-noop:| is sent when the user presses Cmd+Return. Override the no-op | 813 // |-noop:| is sent when the user presses Cmd+Return. Override the no-op |
| 814 // behavior with the proper WindowOpenDisposition. | 814 // behavior with the proper WindowOpenDisposition. |
| 815 NSEvent* event = [NSApp currentEvent]; | 815 NSEvent* event = [NSApp currentEvent]; |
| 816 if (cmd == @selector(insertNewline:) || | 816 if (cmd == @selector(insertNewline:) || |
| 817 (cmd == @selector(noop:) && | 817 (cmd == @selector(noop:) && |
| 818 ([event type] == NSKeyDown || [event type] == NSKeyUp) && | 818 ([event type] == NSKeyDown || [event type] == NSKeyUp) && |
| 819 [event keyCode] == kVK_Return)) { | 819 [event keyCode] == kVK_Return)) { |
| 820 // If the user hasn't entered any text in keyword search mode, we need to |
| 821 // return early in order to avoid cancelling the search. |
| 822 if (GetTextLength() == 0) |
| 823 return true; |
| 824 |
| 820 WindowOpenDisposition disposition = | 825 WindowOpenDisposition disposition = |
| 821 ui::WindowOpenDispositionFromNSEvent(event); | 826 ui::WindowOpenDispositionFromNSEvent(event); |
| 822 model()->AcceptInput(disposition, false); | 827 model()->AcceptInput(disposition, false); |
| 823 // Opening a URL in a background tab should also revert the omnibox contents | 828 // Opening a URL in a background tab should also revert the omnibox contents |
| 824 // to their original state. We cannot do a blanket revert in OpenURL() | 829 // to their original state. We cannot do a blanket revert in OpenURL() |
| 825 // because middle-clicks also open in a new background tab, but those should | 830 // because middle-clicks also open in a new background tab, but those should |
| 826 // not revert the omnibox text. | 831 // not revert the omnibox text. |
| 827 RevertAll(); | 832 RevertAll(); |
| 828 return true; | 833 return true; |
| 829 } | 834 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 display_text); | 1087 display_text); |
| 1083 NSDictionary* notification_info = @{ | 1088 NSDictionary* notification_info = @{ |
| 1084 NSAccessibilityAnnouncementKey : announcement, | 1089 NSAccessibilityAnnouncementKey : announcement, |
| 1085 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1090 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
| 1086 }; | 1091 }; |
| 1087 NSAccessibilityPostNotificationWithUserInfo( | 1092 NSAccessibilityPostNotificationWithUserInfo( |
| 1088 [field_ window], | 1093 [field_ window], |
| 1089 NSAccessibilityAnnouncementRequestedNotification, | 1094 NSAccessibilityAnnouncementRequestedNotification, |
| 1090 notification_info); | 1095 notification_info); |
| 1091 } | 1096 } |
| OLD | NEW |