| 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 523 |
| 524 if (!grey_out_url) { | 524 if (!grey_out_url) { |
| 525 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() | 525 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() |
| 526 range:ComponentToNSRange(host)]; | 526 range:ComponentToNSRange(host)]; |
| 527 } | 527 } |
| 528 } | 528 } |
| 529 | 529 |
| 530 // TODO(shess): GTK has this as a member var, figure out why. | 530 // TODO(shess): GTK has this as a member var, figure out why. |
| 531 // [Could it be to not change if no change? If so, I'm guessing | 531 // [Could it be to not change if no change? If so, I'm guessing |
| 532 // AppKit may already handle that.] | 532 // AppKit may already handle that.] |
| 533 const ConnectionSecurityHelper::SecurityLevel security_level = | 533 const connection_security::SecurityLevel security_level = |
| 534 controller()->GetToolbarModel()->GetSecurityLevel(false); | 534 controller()->GetToolbarModel()->GetSecurityLevel(false); |
| 535 | 535 |
| 536 // Emphasize the scheme for security UI display purposes (if necessary). | 536 // Emphasize the scheme for security UI display purposes (if necessary). |
| 537 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && | 537 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
| 538 scheme.is_nonempty() && | 538 scheme.is_nonempty() && (security_level != connection_security::NONE)) { |
| 539 (security_level != ConnectionSecurityHelper::NONE)) { | |
| 540 NSColor* color; | 539 NSColor* color; |
| 541 if (security_level == ConnectionSecurityHelper::EV_SECURE || | 540 if (security_level == connection_security::EV_SECURE || |
| 542 security_level == ConnectionSecurityHelper::SECURE) { | 541 security_level == connection_security::SECURE) { |
| 543 color = SecureSchemeColor(); | 542 color = SecureSchemeColor(); |
| 544 } else if (security_level == ConnectionSecurityHelper::SECURITY_ERROR) { | 543 } else if (security_level == connection_security::SECURITY_ERROR) { |
| 545 color = SecurityErrorSchemeColor(); | 544 color = SecurityErrorSchemeColor(); |
| 546 // Add a strikethrough through the scheme. | 545 // Add a strikethrough through the scheme. |
| 547 [as addAttribute:NSStrikethroughStyleAttributeName | 546 [as addAttribute:NSStrikethroughStyleAttributeName |
| 548 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] | 547 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] |
| 549 range:ComponentToNSRange(scheme)]; | 548 range:ComponentToNSRange(scheme)]; |
| 550 } else if (security_level == ConnectionSecurityHelper::SECURITY_WARNING) { | 549 } else if (security_level == connection_security::SECURITY_WARNING) { |
| 551 color = BaseTextColor(); | 550 color = BaseTextColor(); |
| 552 } else { | 551 } else { |
| 553 NOTREACHED(); | 552 NOTREACHED(); |
| 554 color = BaseTextColor(); | 553 color = BaseTextColor(); |
| 555 } | 554 } |
| 556 [as addAttribute:NSForegroundColorAttributeName value:color | 555 [as addAttribute:NSForegroundColorAttributeName value:color |
| 557 range:ComponentToNSRange(scheme)]; | 556 range:ComponentToNSRange(scheme)]; |
| 558 } | 557 } |
| 559 } | 558 } |
| 560 | 559 |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 | 1057 |
| 1059 NSUInteger OmniboxViewMac::GetTextLength() const { | 1058 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1060 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1059 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1061 [[field_ stringValue] length]; | 1060 [[field_ stringValue] length]; |
| 1062 } | 1061 } |
| 1063 | 1062 |
| 1064 bool OmniboxViewMac::IsCaretAtEnd() const { | 1063 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1065 const NSRange selection = GetSelectedRange(); | 1064 const NSRange selection = GetSelectedRange(); |
| 1066 return NSMaxRange(selection) == GetTextLength(); | 1065 return NSMaxRange(selection) == GetTextLength(); |
| 1067 } | 1066 } |
| OLD | NEW |