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

Unified Diff: components/omnibox/browser/omnibox_view.cc

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: components/omnibox/browser/omnibox_view.cc
diff --git a/components/omnibox/browser/omnibox_view.cc b/components/omnibox/browser/omnibox_view.cc
index 8fe1c80e70e143dbc7b5732afc759ea50e1d9b3f..ddb9214c097adea0fa4d9b458c7ce20545c0fdcc 100644
--- a/components/omnibox/browser/omnibox_view.cc
+++ b/components/omnibox/browser/omnibox_view.cc
@@ -185,3 +185,29 @@ void OmniboxView::TextChanged() {
if (model_.get())
model_->OnChanged();
}
+
+OmniboxView::DEEMPHASIZE_COMPONENTS OmniboxView::GetDeemphasis(
+ const base::string16& url_scheme,
+ const bool has_host) const {
+ OmniboxView::DEEMPHASIZE_COMPONENTS deemphasize = NOTHING;
Peter Kasting 2017/02/24 01:53:40 Nit: Can remove this variable, change assignments
+
+ // This constant is copied from extensions/common/constants.h to avoid
+ // complicated dependencies.
Peter Kasting 2017/02/24 01:53:40 Urgh. Can we not have extensions/common/ in compo
+ const char kExtensionScheme[] = "chrome-extension";
+
+ 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(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 (has_host)
+ deemphasize = ALL_BUT_HOST;
+ }
+
+ return deemphasize;
+}
« components/omnibox/browser/omnibox_view.h ('K') | « components/omnibox/browser/omnibox_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698