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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
817 return model()->AcceptKeyword(KeywordModeEntryMethod::TAB); | 817 return model()->AcceptKeyword(KeywordModeEntryMethod::TAB); |
818 } | 818 } |
819 | 819 |
820 // |-noop:| is sent when the user presses Cmd+Return. Override the no-op | 820 // |-noop:| is sent when the user presses Cmd+Return. Override the no-op |
821 // behavior with the proper WindowOpenDisposition. | 821 // behavior with the proper WindowOpenDisposition. |
822 NSEvent* event = [NSApp currentEvent]; | 822 NSEvent* event = [NSApp currentEvent]; |
823 if (cmd == @selector(insertNewline:) || | 823 if (cmd == @selector(insertNewline:) || |
824 (cmd == @selector(noop:) && | 824 (cmd == @selector(noop:) && |
825 ([event type] == NSKeyDown || [event type] == NSKeyUp) && | 825 ([event type] == NSKeyDown || [event type] == NSKeyUp) && |
826 [event keyCode] == kVK_Return)) { | 826 [event keyCode] == kVK_Return)) { |
827 // If the user hasn't entered any text in keyword search mode, we need to | |
828 // return early in order to avoid cancelling the search. | |
829 if (GetTextLength() == 0) | |
rohitrao (ping after 24h)
2017/05/30 14:41:14
This was a fix you added earlier this month? Now
Justin Donnelly
2017/05/30 15:32:48
Yes, that's correct. This was just to avoid callin
| |
830 return true; | |
831 | |
832 WindowOpenDisposition disposition = | 827 WindowOpenDisposition disposition = |
833 ui::WindowOpenDispositionFromNSEvent(event); | 828 ui::WindowOpenDispositionFromNSEvent(event); |
834 model()->AcceptInput(disposition, false); | 829 model()->AcceptInput(disposition, false); |
835 // Opening a URL in a background tab should also revert the omnibox contents | |
836 // to their original state. We cannot do a blanket revert in OpenURL() | |
837 // because middle-clicks also open in a new background tab, but those should | |
838 // not revert the omnibox text. | |
839 RevertAll(); | |
840 return true; | 830 return true; |
841 } | 831 } |
842 | 832 |
843 // Option-Return | 833 // Option-Return |
844 if (cmd == @selector(insertNewlineIgnoringFieldEditor:)) { | 834 if (cmd == @selector(insertNewlineIgnoringFieldEditor:)) { |
845 model()->AcceptInput(WindowOpenDisposition::NEW_FOREGROUND_TAB, false); | 835 model()->AcceptInput(WindowOpenDisposition::NEW_FOREGROUND_TAB, false); |
846 return true; | 836 return true; |
847 } | 837 } |
848 | 838 |
849 // When the user does Control-Enter, the existing content has "www." | 839 // When the user does Control-Enter, the existing content has "www." |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1094 display_text); | 1084 display_text); |
1095 NSDictionary* notification_info = @{ | 1085 NSDictionary* notification_info = @{ |
1096 NSAccessibilityAnnouncementKey : announcement, | 1086 NSAccessibilityAnnouncementKey : announcement, |
1097 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1087 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
1098 }; | 1088 }; |
1099 NSAccessibilityPostNotificationWithUserInfo( | 1089 NSAccessibilityPostNotificationWithUserInfo( |
1100 [field_ window], | 1090 [field_ window], |
1101 NSAccessibilityAnnouncementRequestedNotification, | 1091 NSAccessibilityAnnouncementRequestedNotification, |
1102 notification_info); | 1092 notification_info); |
1103 } | 1093 } |
OLD | NEW |