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

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: Fix off-by-one Created 3 years, 11 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..c96da3aee711d82540cedb9978bfa1949d089f8a 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -571,8 +571,18 @@ void OmniboxViewMac::ApplyTextAttributes(
AutocompleteInput::ParseForEmphasizeComponents(
display_text, ChromeAutocompleteSchemeClassifier(profile_), &scheme,
&host);
- bool grey_out_url = display_text.substr(scheme.begin, scheme.len) ==
- base::UTF8ToUTF16(extensions::kExtensionScheme);
+
+ const base::string16 url_scheme =
+ display_text.substr(scheme.begin, scheme.len);
+
+ // Is the scheme one that might be abused for spoofing purposes?
+ bool spoofy_scheme = url_scheme == base::UTF8ToUTF16(url::kDataScheme);
+
+ // Should the full URL be deemphasized?
+ bool grey_out_url =
+ (spoofy_scheme ||
+ url_scheme == base::UTF8ToUTF16(extensions::kExtensionScheme));
+
if (model()->CurrentTextIsURL() &&
(host.is_nonempty() || grey_out_url)) {
[attributedString addAttribute:NSForegroundColorAttributeName
@@ -583,6 +593,10 @@ void OmniboxViewMac::ApplyTextAttributes(
[attributedString addAttribute:NSForegroundColorAttributeName
value:HostTextColor(in_dark_mode)
range:ComponentToNSRange(host)];
+ } else if (spoofy_scheme) {
+ [attributedString addAttribute:NSForegroundColorAttributeName
+ value:HostTextColor(in_dark_mode)
+ range:ComponentToNSRange(scheme)];
}
}

Powered by Google App Engine
This is Rietveld 408576698