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