| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/autocomplete/autocomplete_edit_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
| 8 | 8 |
| 9 #include "app/clipboard/clipboard.h" | 9 #include "app/clipboard/clipboard.h" |
| 10 #include "app/gfx/font.h" | 10 #include "app/gfx/font.h" |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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:) && [event keyCode] == kVK_Return)) { | 824 (cmd == @selector(noop:) && [event keyCode] == kVK_Return)) { |
| 825 WindowOpenDisposition disposition = | 825 WindowOpenDisposition disposition = |
| 826 event_utils::WindowOpenDispositionFromNSEvent(event); | 826 event_utils::WindowOpenDispositionFromNSEvent(event); |
| 827 edit_view_->AcceptInput(disposition, false); | 827 edit_view_->AcceptInput(disposition, false); |
| 828 // Opening a URL in a background tab should also revert the omnibox contents |
| 829 // to their original state. We cannot do a blanket revert in OpenURL() |
| 830 // because middle-clicks also open in a new background tab, but those should |
| 831 // not revert the omnibox text. |
| 832 edit_view_->RevertAll(); |
| 828 return YES; | 833 return YES; |
| 829 } | 834 } |
| 830 | 835 |
| 831 // Option-Return | 836 // Option-Return |
| 832 if (cmd == @selector(insertNewlineIgnoringFieldEditor:)) { | 837 if (cmd == @selector(insertNewlineIgnoringFieldEditor:)) { |
| 833 edit_view_->AcceptInput(NEW_FOREGROUND_TAB, false); | 838 edit_view_->AcceptInput(NEW_FOREGROUND_TAB, false); |
| 834 return YES; | 839 return YES; |
| 835 } | 840 } |
| 836 | 841 |
| 837 // When the user does Control-Enter, the existing content has "www." | 842 // When the user does Control-Enter, the existing content has "www." |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 // TODO(shess): Figure out where the selection belongs. On GTK, | 894 // TODO(shess): Figure out where the selection belongs. On GTK, |
| 890 // it's set to the start of the text. | 895 // it's set to the start of the text. |
| 891 } | 896 } |
| 892 | 897 |
| 893 // Signal that we've lost focus when the window resigns key. | 898 // Signal that we've lost focus when the window resigns key. |
| 894 - (void)windowDidResignKey:(NSNotification*)notification { | 899 - (void)windowDidResignKey:(NSNotification*)notification { |
| 895 edit_view_->OnDidResignKey(); | 900 edit_view_->OnDidResignKey(); |
| 896 } | 901 } |
| 897 | 902 |
| 898 @end | 903 @end |
| OLD | NEW |