| 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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 return true; | 913 return true; |
| 914 } | 914 } |
| 915 } | 915 } |
| 916 } | 916 } |
| 917 | 917 |
| 918 return false; | 918 return false; |
| 919 } | 919 } |
| 920 | 920 |
| 921 void OmniboxViewMac::OnSetFocus(bool control_down) { | 921 void OmniboxViewMac::OnSetFocus(bool control_down) { |
| 922 model()->OnSetFocus(control_down); | 922 model()->OnSetFocus(control_down); |
| 923 controller()->OnSetFocus(); | 923 // Update the keyword and search hint states. |
| 924 controller()->OnChanged(); |
| 924 } | 925 } |
| 925 | 926 |
| 926 void OmniboxViewMac::OnKillFocus() { | 927 void OmniboxViewMac::OnKillFocus() { |
| 927 // Tell the model to reset itself. | 928 // Tell the model to reset itself. |
| 928 model()->OnWillKillFocus(); | 929 model()->OnWillKillFocus(); |
| 929 model()->OnKillFocus(); | 930 model()->OnKillFocus(); |
| 930 } | 931 } |
| 931 | 932 |
| 932 void OmniboxViewMac::OnMouseDown(NSInteger button_number) { | 933 void OmniboxViewMac::OnMouseDown(NSInteger button_number) { |
| 933 // Restore caret visibility whenever the user clicks in the the omnibox. This | 934 // Restore caret visibility whenever the user clicks in the the omnibox. This |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 | 1134 |
| 1134 NSUInteger OmniboxViewMac::GetTextLength() const { | 1135 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1135 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1136 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1136 [[field_ stringValue] length]; | 1137 [[field_ stringValue] length]; |
| 1137 } | 1138 } |
| 1138 | 1139 |
| 1139 bool OmniboxViewMac::IsCaretAtEnd() const { | 1140 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1140 const NSRange selection = GetSelectedRange(); | 1141 const NSRange selection = GetSelectedRange(); |
| 1141 return NSMaxRange(selection) == GetTextLength(); | 1142 return NSMaxRange(selection) == GetTextLength(); |
| 1142 } | 1143 } |
| OLD | NEW |