| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // store existing state before anyone tries to setup the new | 202 // store existing state before anyone tries to setup the new |
| 203 // state. Anyhow, it would look something like this. | 203 // state. Anyhow, it would look something like this. |
| 204 #if 0 | 204 #if 0 |
| 205 [[field_ window] makeFirstResponder:field_]; | 205 [[field_ window] makeFirstResponder:field_]; |
| 206 [[field_ currentEditor] setSelectedRange:state->selection]; | 206 [[field_ currentEditor] setSelectedRange:state->selection]; |
| 207 #endif | 207 #endif |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 void OmniboxViewMac::Update() { | 211 void OmniboxViewMac::Update() { |
| 212 if (chrome::ShouldDisplayOriginChipV2()) { | 212 if (chrome::ShouldDisplayOriginChip()) { |
| 213 NSDictionary* placeholder_attributes = @{ | 213 NSDictionary* placeholder_attributes = @{ |
| 214 NSFontAttributeName : GetFieldFont(gfx::Font::NORMAL), | 214 NSFontAttributeName : GetFieldFont(gfx::Font::NORMAL), |
| 215 NSForegroundColorAttributeName : [NSColor disabledControlTextColor] | 215 NSForegroundColorAttributeName : [NSColor disabledControlTextColor] |
| 216 }; | 216 }; |
| 217 base::scoped_nsobject<NSMutableAttributedString> placeholder_text( | 217 base::scoped_nsobject<NSMutableAttributedString> placeholder_text( |
| 218 [[NSMutableAttributedString alloc] | 218 [[NSMutableAttributedString alloc] |
| 219 initWithString:base::SysUTF16ToNSString(GetHintText()) | 219 initWithString:base::SysUTF16ToNSString(GetHintText()) |
| 220 attributes:placeholder_attributes]); | 220 attributes:placeholder_attributes]); |
| 221 [[field_ cell] setPlaceholderAttributedString:placeholder_text]; | 221 [[field_ cell] setPlaceholderAttributedString:placeholder_text]; |
| 222 } | 222 } |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 | 1013 |
| 1014 NSUInteger OmniboxViewMac::GetTextLength() const { | 1014 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1015 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1015 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1016 [[field_ stringValue] length]; | 1016 [[field_ stringValue] length]; |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 bool OmniboxViewMac::IsCaretAtEnd() const { | 1019 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1020 const NSRange selection = GetSelectedRange(); | 1020 const NSRange selection = GetSelectedRange(); |
| 1021 return NSMaxRange(selection) == GetTextLength(); | 1021 return NSMaxRange(selection) == GetTextLength(); |
| 1022 } | 1022 } |
| OLD | NEW |