| 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 505 |
| 506 if (!grey_out_url) { | 506 if (!grey_out_url) { |
| 507 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() | 507 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() |
| 508 range:ComponentToNSRange(host)]; | 508 range:ComponentToNSRange(host)]; |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 | 511 |
| 512 // TODO(shess): GTK has this as a member var, figure out why. | 512 // TODO(shess): GTK has this as a member var, figure out why. |
| 513 // [Could it be to not change if no change? If so, I'm guessing | 513 // [Could it be to not change if no change? If so, I'm guessing |
| 514 // AppKit may already handle that.] | 514 // AppKit may already handle that.] |
| 515 const ConnectionSecurityHelper::SecurityLevel security_level = | 515 const ToolbarModel::SecurityLevel security_level = |
| 516 controller()->GetToolbarModel()->GetSecurityLevel(false); | 516 controller()->GetToolbarModel()->GetSecurityLevel(false); |
| 517 | 517 |
| 518 // Emphasize the scheme for security UI display purposes (if necessary). | 518 // Emphasize the scheme for security UI display purposes (if necessary). |
| 519 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && | 519 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
| 520 scheme.is_nonempty() && | 520 scheme.is_nonempty() && (security_level != ToolbarModel::NONE)) { |
| 521 (security_level != ConnectionSecurityHelper::NONE)) { | |
| 522 NSColor* color; | 521 NSColor* color; |
| 523 if (security_level == ConnectionSecurityHelper::EV_SECURE || | 522 if (security_level == ToolbarModel::EV_SECURE || |
| 524 security_level == ConnectionSecurityHelper::SECURE) { | 523 security_level == ToolbarModel::SECURE) { |
| 525 color = SecureSchemeColor(); | 524 color = SecureSchemeColor(); |
| 526 } else if (security_level == ConnectionSecurityHelper::SECURITY_ERROR) { | 525 } else if (security_level == ToolbarModel::SECURITY_ERROR) { |
| 527 color = SecurityErrorSchemeColor(); | 526 color = SecurityErrorSchemeColor(); |
| 528 // Add a strikethrough through the scheme. | 527 // Add a strikethrough through the scheme. |
| 529 [as addAttribute:NSStrikethroughStyleAttributeName | 528 [as addAttribute:NSStrikethroughStyleAttributeName |
| 530 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] | 529 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] |
| 531 range:ComponentToNSRange(scheme)]; | 530 range:ComponentToNSRange(scheme)]; |
| 532 } else if (security_level == ConnectionSecurityHelper::SECURITY_WARNING) { | 531 } else if (security_level == ToolbarModel::SECURITY_WARNING) { |
| 533 color = BaseTextColor(); | 532 color = BaseTextColor(); |
| 534 } else { | 533 } else { |
| 535 NOTREACHED(); | 534 NOTREACHED(); |
| 536 color = BaseTextColor(); | 535 color = BaseTextColor(); |
| 537 } | 536 } |
| 538 [as addAttribute:NSForegroundColorAttributeName value:color | 537 [as addAttribute:NSForegroundColorAttributeName value:color |
| 539 range:ComponentToNSRange(scheme)]; | 538 range:ComponentToNSRange(scheme)]; |
| 540 } | 539 } |
| 541 } | 540 } |
| 542 | 541 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 | 1008 |
| 1010 NSUInteger OmniboxViewMac::GetTextLength() const { | 1009 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1011 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1010 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1012 [[field_ stringValue] length]; | 1011 [[field_ stringValue] length]; |
| 1013 } | 1012 } |
| 1014 | 1013 |
| 1015 bool OmniboxViewMac::IsCaretAtEnd() const { | 1014 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1016 const NSRange selection = GetSelectedRange(); | 1015 const NSRange selection = GetSelectedRange(); |
| 1017 return NSMaxRange(selection) == GetTextLength(); | 1016 return NSMaxRange(selection) == GetTextLength(); |
| 1018 } | 1017 } |
| OLD | NEW |