| 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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 gfx::NativeView OmniboxViewMac::GetNativeView() const { | 709 gfx::NativeView OmniboxViewMac::GetNativeView() const { |
| 710 return field_; | 710 return field_; |
| 711 } | 711 } |
| 712 | 712 |
| 713 gfx::NativeView OmniboxViewMac::GetRelativeWindowForPopup() const { | 713 gfx::NativeView OmniboxViewMac::GetRelativeWindowForPopup() const { |
| 714 // Not used on mac. | 714 // Not used on mac. |
| 715 NOTREACHED(); | 715 NOTREACHED(); |
| 716 return NULL; | 716 return NULL; |
| 717 } | 717 } |
| 718 | 718 |
| 719 void OmniboxViewMac::SetGrayTextAutocompletion( | |
| 720 const base::string16& suggest_text) { | |
| 721 if (suggest_text == suggest_text_) | |
| 722 return; | |
| 723 suggest_text_ = suggest_text; | |
| 724 [field_ setGrayTextAutocompletion:base::SysUTF16ToNSString(suggest_text) | |
| 725 textColor:SuggestTextColor()]; | |
| 726 } | |
| 727 | |
| 728 base::string16 OmniboxViewMac::GetGrayTextAutocompletion() const { | |
| 729 return suggest_text_; | |
| 730 } | |
| 731 | |
| 732 int OmniboxViewMac::GetTextWidth() const { | 719 int OmniboxViewMac::GetTextWidth() const { |
| 733 // Not used on mac. | 720 // Not used on mac. |
| 734 NOTREACHED(); | 721 NOTREACHED(); |
| 735 return 0; | 722 return 0; |
| 736 } | 723 } |
| 737 | 724 |
| 738 int OmniboxViewMac::GetWidth() const { | 725 int OmniboxViewMac::GetWidth() const { |
| 739 return ceil([field_ bounds].size.width); | 726 return ceil([field_ bounds].size.width); |
| 740 } | 727 } |
| 741 | 728 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 } | 797 } |
| 811 | 798 |
| 812 if ((cmd == @selector(insertTab:) || | 799 if ((cmd == @selector(insertTab:) || |
| 813 cmd == @selector(insertTabIgnoringFieldEditor:)) && | 800 cmd == @selector(insertTabIgnoringFieldEditor:)) && |
| 814 !model()->is_keyword_hint()) { | 801 !model()->is_keyword_hint()) { |
| 815 model()->OnUpOrDownKeyPressed(1); | 802 model()->OnUpOrDownKeyPressed(1); |
| 816 return true; | 803 return true; |
| 817 } | 804 } |
| 818 } | 805 } |
| 819 | 806 |
| 820 if (cmd == @selector(moveRight:)) { | |
| 821 // Only commit suggested text if the cursor is all the way to the right and | |
| 822 // there is no selection. | |
| 823 if (suggest_text_.length() > 0 && IsCaretAtEnd()) { | |
| 824 model()->CommitSuggestedText(); | |
| 825 return true; | |
| 826 } | |
| 827 } | |
| 828 | |
| 829 if (cmd == @selector(scrollPageDown:)) { | 807 if (cmd == @selector(scrollPageDown:)) { |
| 830 model()->OnUpOrDownKeyPressed(model()->result().size()); | 808 model()->OnUpOrDownKeyPressed(model()->result().size()); |
| 831 return true; | 809 return true; |
| 832 } | 810 } |
| 833 | 811 |
| 834 if (cmd == @selector(scrollPageUp:)) { | 812 if (cmd == @selector(scrollPageUp:)) { |
| 835 model()->OnUpOrDownKeyPressed(-model()->result().size()); | 813 model()->OnUpOrDownKeyPressed(-model()->result().size()); |
| 836 return true; | 814 return true; |
| 837 } | 815 } |
| 838 | 816 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 display_text); | 1096 display_text); |
| 1119 NSDictionary* notification_info = @{ | 1097 NSDictionary* notification_info = @{ |
| 1120 NSAccessibilityAnnouncementKey : announcement, | 1098 NSAccessibilityAnnouncementKey : announcement, |
| 1121 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1099 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
| 1122 }; | 1100 }; |
| 1123 NSAccessibilityPostNotificationWithUserInfo( | 1101 NSAccessibilityPostNotificationWithUserInfo( |
| 1124 [field_ window], | 1102 [field_ window], |
| 1125 NSAccessibilityAnnouncementRequestedNotification, | 1103 NSAccessibilityAnnouncementRequestedNotification, |
| 1126 notification_info); | 1104 notification_info); |
| 1127 } | 1105 } |
| OLD | NEW |