Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2432)

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 1935663002: New origin security indicator icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments, and get the colors right on Mac OS X. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698