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

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

Issue 2641003002: Show scheme in black and content in gray for data: protocol urls (Closed)
Patch Set: Hoist deemphasis logic Created 3 years, 10 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 cd2b95faefb8470578fb8128da5b00a47359f88f..f239ea57b2dfdd1fc09b236e4baeabec92a51612 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -563,27 +563,32 @@ void OmniboxViewMac::ApplyTextAttributes(
value:@"en_US_POSIX"
range:as_entire_string];
- [attributedString addAttribute:NSForegroundColorAttributeName
- value:HostTextColor(in_dark_mode)
- range:as_entire_string];
-
url::Component scheme, host;
AutocompleteInput::ParseForEmphasizeComponents(
display_text, ChromeAutocompleteSchemeClassifier(profile_), &scheme,
&host);
- bool grey_out_url = display_text.substr(scheme.begin, scheme.len) ==
- base::UTF8ToUTF16(extensions::kExtensionScheme);
- if (model()->CurrentTextIsURL() &&
- (host.is_nonempty() || grey_out_url)) {
- [attributedString addAttribute:NSForegroundColorAttributeName
- value:BaseTextColor(in_dark_mode)
- range:as_entire_string];
- if (!grey_out_url) {
- [attributedString addAttribute:NSForegroundColorAttributeName
- value:HostTextColor(in_dark_mode)
- range:ComponentToNSRange(host)];
- }
+ const base::string16 url_scheme =
+ display_text.substr(scheme.begin, scheme.len);
+
+ // Determine if any url components should be visually deemphasized.
+ DEEMPHASIZE_COMPONENTS deemphasize =
+ GetDeemphasis(url_scheme, host.is_nonempty());
+
+ [attributedString
+ addAttribute:NSForegroundColorAttributeName
+ value:(deemphasize == NOTHING) ? HostTextColor(in_dark_mode)
+ : BaseTextColor(in_dark_mode)
+ range:as_entire_string];
+
+ if (deemphasize == ALL_BUT_SCHEME) {
+ [attributedString addAttribute:NSForegroundColorAttributeName
+ value:HostTextColor(in_dark_mode)
+ range:ComponentToNSRange(scheme)];
+ } else if (deemphasize == ALL_BUT_HOST) {
+ [attributedString addAttribute:NSForegroundColorAttributeName
+ value:HostTextColor(in_dark_mode)
+ range:ComponentToNSRange(host)];
}
// TODO(shess): GTK has this as a member var, figure out why.

Powered by Google App Engine
This is Rietveld 408576698