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

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 2641003002: Show scheme in black and content in gray for data: protocol urls (Closed)
Patch Set: Address review feedback 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/views/omnibox/omnibox_view_views.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index 0f22b6ee6e9593c66759e2e7ab82f406c59e5b0f..a86b4f3ef8529533b262842d9511cbdb575247d7 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -586,16 +586,41 @@ void OmniboxViewViews::EmphasizeURLComponents() {
url::Component scheme, host;
AutocompleteInput::ParseForEmphasizeComponents(
text(), ChromeAutocompleteSchemeClassifier(profile_), &scheme, &host);
- bool grey_out_url = text().substr(scheme.begin, scheme.len) ==
- base::UTF8ToUTF16(extensions::kExtensionScheme);
- bool grey_base = text_is_url && (host.is_nonempty() || grey_out_url);
- SetColor(location_bar_view_->GetColor(
- grey_base ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT));
- if (grey_base && !grey_out_url) {
- ApplyColor(location_bar_view_->GetColor(LocationBarView::TEXT),
- gfx::Range(host.begin, host.end()));
+
+ const base::string16 url_scheme = 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 (text_is_url) {
+ // 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;
}
+ const SkColor color = location_bar_view_->GetColor(LocationBarView::TEXT);
Peter Kasting 2017/02/23 01:30:43 Nit: Wonder if this would be clearer as |emphasize
+ SetColor(deemphasize == NOTHING ? color
+ : location_bar_view_->GetColor(
+ LocationBarView::DEEMPHASIZED_TEXT));
+ if (deemphasize == ALL_BUT_SCHEME)
+ ApplyColor(color, gfx::Range(scheme.begin, scheme.end()));
+ else if (deemphasize == ALL_BUT_HOST)
+ ApplyColor(color, gfx::Range(host.begin, host.end()));
+
// Emphasize the scheme for security UI display purposes (if necessary).
// Note that we check CurrentTextIsURL() because if we're replacing search
// URLs with search terms, we may have a non-URL even when the user is not

Powered by Google App Engine
This is Rietveld 408576698