Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
index 9783982c981bc6c1ea248ec0a057f2a0c7473af6..153b021113d1b3b6f0957740cd1c51b9922f60ee 100644 |
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
@@ -175,6 +175,35 @@ NSColor* OmniboxViewMac::BaseTextColor(bool in_dark_mode) { |
return skia::SkColorToCalibratedNSColor(BaseTextColorSkia(in_dark_mode)); |
} |
+// static |
+SkColor OmniboxViewMac::GetSecureTextColorSkia( |
+ security_state::SecurityStateModel::SecurityLevel security_level, |
+ bool in_dark_mode) { |
+ return skia::NSDeviceColorToSkColor( |
+ GetSecureTextColor(security_level, in_dark_mode)); |
+} |
+ |
+// static |
+NSColor* OmniboxViewMac::GetSecureTextColor( |
+ security_state::SecurityStateModel::SecurityLevel security_level, |
+ bool in_dark_mode) { |
+ NSColor* color; |
+ if (security_level == security_state::SecurityStateModel::EV_SECURE || |
+ security_level == security_state::SecurityStateModel::SECURE) { |
+ color = SecureSchemeColor(in_dark_mode); |
+ } else if (security_level == |
+ security_state::SecurityStateModel::SECURITY_ERROR) { |
+ color = SecurityErrorSchemeColor(in_dark_mode); |
+ } else if (security_level == |
+ security_state::SecurityStateModel::SECURITY_WARNING) { |
+ color = SecurityWarningSchemeColor(in_dark_mode); |
+ } else { |
+ NOTREACHED(); |
+ color = BaseTextColor(in_dark_mode); |
Evan Stade
2016/05/19 17:58:49
I'm often told not to handle NOTREACHED
Peter Kasting
2016/05/19 18:36:19
Yeah. And in general looking at this makes it cle
palmer
2016/05/19 18:40:40
This is borrowed from the pre-existing code (compa
Peter Kasting
2016/05/19 18:43:21
Please do fix, here and/or there, as possible.
palmer
2016/05/19 19:55:44
Fixed here in Cocoa.
The Views code by estade/est
|
+ } |
+ return color; |
+} |
+ |
OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, |
Profile* profile, |
CommandUpdater* command_updater, |
@@ -598,23 +627,12 @@ void OmniboxViewMac::ApplyTextAttributes( |
if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
scheme.is_nonempty() && |
(security_level != security_state::SecurityStateModel::NONE)) { |
- NSColor* color; |
- if (security_level == security_state::SecurityStateModel::EV_SECURE || |
- security_level == security_state::SecurityStateModel::SECURE) { |
- color = SecureSchemeColor(in_dark_mode); |
- } else if (security_level == |
- security_state::SecurityStateModel::SECURITY_ERROR) { |
- color = SecurityErrorSchemeColor(in_dark_mode); |
+ NSColor* color = GetSecureTextColor(security_level, in_dark_mode); |
Evan Stade
2016/05/19 17:58:49
no need for this local var
palmer
2016/05/19 18:40:40
Done.
|
+ if (security_level == security_state::SecurityStateModel::SECURITY_ERROR) { |
// Add a strikethrough through the scheme. |
[attributedString addAttribute:NSStrikethroughStyleAttributeName |
value:[NSNumber numberWithInt:NSUnderlineStyleSingle] |
range:ComponentToNSRange(scheme)]; |
- } else if (security_level == |
- security_state::SecurityStateModel::SECURITY_WARNING) { |
- color = SecurityWarningSchemeColor(in_dark_mode); |
- } else { |
- NOTREACHED(); |
- color = BaseTextColor(in_dark_mode); |
} |
[attributedString addAttribute:NSForegroundColorAttributeName |
value:color |