| 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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 if (select_all || ![field_ currentEditor]) | 958 if (select_all || ![field_ currentEditor]) |
| 959 [[field_ window] makeFirstResponder:field_]; | 959 [[field_ window] makeFirstResponder:field_]; |
| 960 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); | 960 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); |
| 961 } | 961 } |
| 962 } | 962 } |
| 963 | 963 |
| 964 // static | 964 // static |
| 965 NSFont* OmniboxViewMac::GetFieldFont() { | 965 NSFont* OmniboxViewMac::GetFieldFont() { |
| 966 // This value should be kept in sync with InstantPage::InitializeFonts. | 966 // This value should be kept in sync with InstantPage::InitializeFonts. |
| 967 if (chrome::IsInstantExtendedAPIEnabled()) | 967 if (chrome::IsInstantExtendedAPIEnabled()) |
| 968 return [NSFont fontWithName:@"Helvetica" size:16]; | 968 return [NSFont fontWithName:@"Arial" size:16]; |
| 969 | 969 |
| 970 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 970 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 971 return rb.GetFont(ResourceBundle::BaseFont).GetNativeFont(); | 971 return rb.GetFont(ResourceBundle::BaseFont).GetNativeFont(); |
| 972 } | 972 } |
| 973 | 973 |
| 974 int OmniboxViewMac::GetOmniboxTextLength() const { | 974 int OmniboxViewMac::GetOmniboxTextLength() const { |
| 975 return static_cast<int>(GetTextLength()); | 975 return static_cast<int>(GetTextLength()); |
| 976 } | 976 } |
| 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 |