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

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

Issue 2983193002: Revert of Don't reset the omnibox state on command-return. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | 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) 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
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)
830 return true;
831
827 WindowOpenDisposition disposition = 832 WindowOpenDisposition disposition =
828 ui::WindowOpenDispositionFromNSEvent(event); 833 ui::WindowOpenDispositionFromNSEvent(event);
829 model()->AcceptInput(disposition, false); 834 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();
830 return true; 840 return true;
831 } 841 }
832 842
833 // Option-Return 843 // Option-Return
834 if (cmd == @selector(insertNewlineIgnoringFieldEditor:)) { 844 if (cmd == @selector(insertNewlineIgnoringFieldEditor:)) {
835 model()->AcceptInput(WindowOpenDisposition::NEW_FOREGROUND_TAB, false); 845 model()->AcceptInput(WindowOpenDisposition::NEW_FOREGROUND_TAB, false);
836 return true; 846 return true;
837 } 847 }
838 848
839 // When the user does Control-Enter, the existing content has "www." 849 // When the user does Control-Enter, the existing content has "www."
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 display_text); 1094 display_text);
1085 NSDictionary* notification_info = @{ 1095 NSDictionary* notification_info = @{
1086 NSAccessibilityAnnouncementKey : announcement, 1096 NSAccessibilityAnnouncementKey : announcement,
1087 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) 1097 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh)
1088 }; 1098 };
1089 NSAccessibilityPostNotificationWithUserInfo( 1099 NSAccessibilityPostNotificationWithUserInfo(
1090 [field_ window], 1100 [field_ window],
1091 NSAccessibilityAnnouncementRequestedNotification, 1101 NSAccessibilityAnnouncementRequestedNotification,
1092 notification_info); 1102 notification_info);
1093 } 1103 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698