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/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 !model()->is_keyword_hint() && enableTabAutocomplete) { | 686 !model()->is_keyword_hint() && enableTabAutocomplete) { |
687 model()->OnUpOrDownKeyPressed(1); | 687 model()->OnUpOrDownKeyPressed(1); |
688 return true; | 688 return true; |
689 } | 689 } |
690 } | 690 } |
691 | 691 |
692 if (cmd == @selector(moveRight:)) { | 692 if (cmd == @selector(moveRight:)) { |
693 // Only commit suggested text if the cursor is all the way to the right and | 693 // Only commit suggested text if the cursor is all the way to the right and |
694 // there is no selection. | 694 // there is no selection. |
695 if (suggest_text_.length() > 0 && IsCaretAtEnd()) { | 695 if (suggest_text_.length() > 0 && IsCaretAtEnd()) { |
696 model()->CommitSuggestedText(true); | 696 model()->CommitSuggestedText(); |
697 return true; | 697 return true; |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 if (cmd == @selector(scrollPageDown:)) { | 701 if (cmd == @selector(scrollPageDown:)) { |
702 model()->OnUpOrDownKeyPressed(model()->result().size()); | 702 model()->OnUpOrDownKeyPressed(model()->result().size()); |
703 return true; | 703 return true; |
704 } | 704 } |
705 | 705 |
706 if (cmd == @selector(scrollPageUp:)) { | 706 if (cmd == @selector(scrollPageUp:)) { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 | 975 |
976 NSUInteger OmniboxViewMac::GetTextLength() const { | 976 NSUInteger OmniboxViewMac::GetTextLength() const { |
977 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 977 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
978 [[field_ stringValue] length]; | 978 [[field_ stringValue] length]; |
979 } | 979 } |
980 | 980 |
981 bool OmniboxViewMac::IsCaretAtEnd() const { | 981 bool OmniboxViewMac::IsCaretAtEnd() const { |
982 const NSRange selection = GetSelectedRange(); | 982 const NSRange selection = GetSelectedRange(); |
983 return NSMaxRange(selection) == GetTextLength(); | 983 return NSMaxRange(selection) == GetTextLength(); |
984 } | 984 } |
OLD | NEW |