| 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 ConnectionSecurityStatus::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() && |
| 539 (security_level != ConnectionSecurityHelper::NONE)) { | 539 (security_level != ConnectionSecurityStatus::NONE)) { |
| 540 NSColor* color; | 540 NSColor* color; |
| 541 if (security_level == ConnectionSecurityHelper::EV_SECURE || | 541 if (security_level == ConnectionSecurityStatus::EV_SECURE || |
| 542 security_level == ConnectionSecurityHelper::SECURE) { | 542 security_level == ConnectionSecurityStatus::SECURE) { |
| 543 color = SecureSchemeColor(); | 543 color = SecureSchemeColor(); |
| 544 } else if (security_level == ConnectionSecurityHelper::SECURITY_ERROR) { | 544 } else if (security_level == ConnectionSecurityStatus::SECURITY_ERROR) { |
| 545 color = SecurityErrorSchemeColor(); | 545 color = SecurityErrorSchemeColor(); |
| 546 // Add a strikethrough through the scheme. | 546 // Add a strikethrough through the scheme. |
| 547 [as addAttribute:NSStrikethroughStyleAttributeName | 547 [as addAttribute:NSStrikethroughStyleAttributeName |
| 548 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] | 548 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] |
| 549 range:ComponentToNSRange(scheme)]; | 549 range:ComponentToNSRange(scheme)]; |
| 550 } else if (security_level == ConnectionSecurityHelper::SECURITY_WARNING) { | 550 } else if (security_level == ConnectionSecurityStatus::SECURITY_WARNING) { |
| 551 color = BaseTextColor(); | 551 color = BaseTextColor(); |
| 552 } else { | 552 } else { |
| 553 NOTREACHED(); | 553 NOTREACHED(); |
| 554 color = BaseTextColor(); | 554 color = BaseTextColor(); |
| 555 } | 555 } |
| 556 [as addAttribute:NSForegroundColorAttributeName value:color | 556 [as addAttribute:NSForegroundColorAttributeName value:color |
| 557 range:ComponentToNSRange(scheme)]; | 557 range:ComponentToNSRange(scheme)]; |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 | 560 |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 | 1058 |
| 1059 NSUInteger OmniboxViewMac::GetTextLength() const { | 1059 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1060 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1060 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1061 [[field_ stringValue] length]; | 1061 [[field_ stringValue] length]; |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 bool OmniboxViewMac::IsCaretAtEnd() const { | 1064 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1065 const NSRange selection = GetSelectedRange(); | 1065 const NSRange selection = GetSelectedRange(); |
| 1066 return NSMaxRange(selection) == GetTextLength(); | 1066 return NSMaxRange(selection) == GetTextLength(); |
| 1067 } | 1067 } |
| OLD | NEW |