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