Chromium Code Reviews| 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..00f0b4fac6f8d573711ddd6a31eae412d6846888 100644 |
| --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
| +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
| @@ -563,29 +563,52 @@ 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); |
| + |
| + // As needed, deemphasize parts of the URL to draw attention to |
| + // whatever best represents the "identity" of the URL. |
| + enum Deemphasize { |
| + EVERYTHING, |
| + ALL_BUT_SCHEME, |
| + ALL_BUT_HOST, |
| + NOTHING, |
| + } deemphasize = NOTHING; |
| + |
| + if (model()->CurrentTextIsURL()) { |
| + // Extension IDs are not human-readable, so deemphasize everything to draw |
| + // attention to the human-readable name in the location icon text. |
| + if (url_scheme == base::UTF8ToUTF16(extensions::kExtensionScheme)) |
| + deemphasize = EVERYTHING; |
| + // Data URLs are rarely human-readable and can be used for spoofing, so draw |
| + // attention to the scheme to emphasize "this is just a bunch of data". |
| + else if (url_scheme == base::UTF8ToUTF16(url::kDataScheme)) |
| + deemphasize = ALL_BUT_SCHEME; |
| + // For normal URLs, the host is the best proxy for "identity". |
| + else if (host.is_nonempty()) |
| + deemphasize = ALL_BUT_HOST; |
| } |
| + [attributedString |
| + addAttribute:NSForegroundColorAttributeName |
| + value:(deemphasize == NOTHING) ? HostTextColor(in_dark_mode) |
| + : BaseTextColor(in_dark_mode) |
| + range:as_entire_string]; |
| + |
| + if (deemphasize == ALL_BUT_SCHEME) |
|
Peter Kasting
2017/02/23 01:30:43
Nit: {}
|
| + [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. |
| // [Could it be to not change if no change? If so, I'm guessing |
| // AppKit may already handle that.] |