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

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: 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: 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..f56e7315a49cf0632dcb72d14377a88b0b5db2fb 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -31,7 +31,6 @@
#include "components/strings/grit/components_strings.h"
#include "components/toolbar/toolbar_model.h"
#include "content/public/browser/web_contents.h"
-#include "extensions/common/constants.h"
#include "net/base/escape.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/accessibility/ax_action_data.h"
@@ -586,15 +585,22 @@ void OmniboxViewViews::EmphasizeURLComponents() {
url::Component scheme, host;
AutocompleteInput::ParseForEmphasizeComponents(
text(), ChromeAutocompleteSchemeClassifier(profile_), &scheme, &host);
Peter Kasting 2017/02/24 01:53:40 Can we hoist this block and |url_scheme| to GetDee
- 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);
+
+ // Determine if any url components should be visually deemphasized.
+ DEEMPHASIZE_COMPONENTS deemphasize =
+ GetDeemphasis(url_scheme, host.is_nonempty());
+
+ const SkColor emphasized_color =
+ location_bar_view_->GetColor(LocationBarView::TEXT);
+ SetColor(deemphasize == NOTHING ? emphasized_color
+ : location_bar_view_->GetColor(
+ LocationBarView::DEEMPHASIZED_TEXT));
+ if (deemphasize == ALL_BUT_SCHEME)
+ ApplyColor(emphasized_color, gfx::Range(scheme.begin, scheme.end()));
+ else if (deemphasize == ALL_BUT_HOST)
+ ApplyColor(emphasized_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

Powered by Google App Engine
This is Rietveld 408576698