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