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

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: 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
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3187232839db9b3b9ae7ea6c6adca5f04814a025 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -586,14 +586,27 @@ 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);
+
+ const base::string16 url_scheme = text().substr(scheme.begin, scheme.len);
+
+ // Is the scheme one that might be abused for spoofing purposes?
Peter Kasting 2017/02/06 22:42:28 ALl this code feels a little piecemeal to me; the
+ bool spoofy_scheme = url_scheme == base::UTF8ToUTF16(url::kDataScheme);
Peter Kasting 2017/02/06 22:42:28 Should we just go ahead and include blob: in this?
+
+ // Should the entire URL be deemphasized?
+ bool grey_out_url =
+ (spoofy_scheme ||
+ url_scheme == base::UTF8ToUTF16(extensions::kExtensionScheme));
+
bool grey_base = text_is_url && (host.is_nonempty() || grey_out_url);
+
Peter Kasting 2017/02/06 22:42:28 Nit: I wouldn't add this
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()));
+ } else if (spoofy_scheme) {
+ ApplyColor(location_bar_view_->GetColor(LocationBarView::TEXT),
+ gfx::Range(scheme.begin, scheme.end()));
}
// Emphasize the scheme for security UI display purposes (if necessary).
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698