| 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 SecurityStateModel::SecurityLevel security_level = | 547 const security_state::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 != SecurityStateModel::NONE)) { | 552 scheme.is_nonempty() && |
| 553 (security_level != security_state::SecurityStateModel::NONE)) { |
| 553 NSColor* color; | 554 NSColor* color; |
| 554 if (security_level == SecurityStateModel::EV_SECURE || | 555 if (security_level == security_state::SecurityStateModel::EV_SECURE || |
| 555 security_level == SecurityStateModel::SECURE) { | 556 security_level == security_state::SecurityStateModel::SECURE) { |
| 556 color = SecureSchemeColor(); | 557 color = SecureSchemeColor(); |
| 557 } else if (security_level == SecurityStateModel::SECURITY_ERROR) { | 558 } else if (security_level == |
| 559 security_state::SecurityStateModel::SECURITY_ERROR) { |
| 558 color = SecurityErrorSchemeColor(); | 560 color = SecurityErrorSchemeColor(); |
| 559 // Add a strikethrough through the scheme. | 561 // Add a strikethrough through the scheme. |
| 560 [attributedString addAttribute:NSStrikethroughStyleAttributeName | 562 [attributedString addAttribute:NSStrikethroughStyleAttributeName |
| 561 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] | 563 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] |
| 562 range:ComponentToNSRange(scheme)]; | 564 range:ComponentToNSRange(scheme)]; |
| 563 } else if (security_level == SecurityStateModel::SECURITY_WARNING) { | 565 } else if (security_level == |
| 566 security_state::SecurityStateModel::SECURITY_WARNING) { |
| 564 color = BaseTextColor(); | 567 color = BaseTextColor(); |
| 565 } else { | 568 } else { |
| 566 NOTREACHED(); | 569 NOTREACHED(); |
| 567 color = BaseTextColor(); | 570 color = BaseTextColor(); |
| 568 } | 571 } |
| 569 [attributedString addAttribute:NSForegroundColorAttributeName | 572 [attributedString addAttribute:NSForegroundColorAttributeName |
| 570 value:color | 573 value:color |
| 571 range:ComponentToNSRange(scheme)]; | 574 range:ComponentToNSRange(scheme)]; |
| 572 } | 575 } |
| 573 } | 576 } |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 | 1075 |
| 1073 NSUInteger OmniboxViewMac::GetTextLength() const { | 1076 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1074 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1077 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1075 [[field_ stringValue] length]; | 1078 [[field_ stringValue] length]; |
| 1076 } | 1079 } |
| 1077 | 1080 |
| 1078 bool OmniboxViewMac::IsCaretAtEnd() const { | 1081 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1079 const NSRange selection = GetSelectedRange(); | 1082 const NSRange selection = GetSelectedRange(); |
| 1080 return NSMaxRange(selection) == GetTextLength(); | 1083 return NSMaxRange(selection) == GetTextLength(); |
| 1081 } | 1084 } |
| OLD | NEW |