| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 range:as_entire_string]; | 448 range:as_entire_string]; |
| 449 | 449 |
| 450 url_parse::Component scheme, host; | 450 url_parse::Component scheme, host; |
| 451 AutocompleteInput::ParseForEmphasizeComponents( | 451 AutocompleteInput::ParseForEmphasizeComponents( |
| 452 display_text, &scheme, &host); | 452 display_text, &scheme, &host); |
| 453 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); | 453 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); |
| 454 if (emphasize) { | 454 if (emphasize) { |
| 455 [as addAttribute:NSForegroundColorAttributeName value:BaseTextColor() | 455 [as addAttribute:NSForegroundColorAttributeName value:BaseTextColor() |
| 456 range:as_entire_string]; | 456 range:as_entire_string]; |
| 457 | 457 |
| 458 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() | 458 if (!toolbar_model()->ShouldNotEmphasizeHost()) { |
| 459 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() |
| 459 range:ComponentToNSRange(host)]; | 460 range:ComponentToNSRange(host)]; |
| 461 } |
| 460 } | 462 } |
| 461 | 463 |
| 462 // TODO(shess): GTK has this as a member var, figure out why. | 464 // TODO(shess): GTK has this as a member var, figure out why. |
| 463 // [Could it be to not change if no change? If so, I'm guessing | 465 // [Could it be to not change if no change? If so, I'm guessing |
| 464 // AppKit may already handle that.] | 466 // AppKit may already handle that.] |
| 465 const ToolbarModel::SecurityLevel security_level = | 467 const ToolbarModel::SecurityLevel security_level = |
| 466 toolbar_model()->GetSecurityLevel(); | 468 toolbar_model()->GetSecurityLevel(); |
| 467 | 469 |
| 468 // Emphasize the scheme for security UI display purposes (if necessary). | 470 // Emphasize the scheme for security UI display purposes (if necessary). |
| 469 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && | 471 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 | 978 |
| 977 NSUInteger OmniboxViewMac::GetTextLength() const { | 979 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 978 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 980 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 979 [[field_ stringValue] length]; | 981 [[field_ stringValue] length]; |
| 980 } | 982 } |
| 981 | 983 |
| 982 bool OmniboxViewMac::IsCaretAtEnd() const { | 984 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 983 const NSRange selection = GetSelectedRange(); | 985 const NSRange selection = GetSelectedRange(); |
| 984 return NSMaxRange(selection) == GetTextLength(); | 986 return NSMaxRange(selection) == GetTextLength(); |
| 985 } | 987 } |
| OLD | NEW |