Chromium Code Reviews| 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..a9415e130ce48fe3c19a85fb4bcb62cb1333714e 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" |
| @@ -564,6 +563,26 @@ int OmniboxViewViews::GetOmniboxTextLength() const { |
| return static_cast<int>(text().length()); |
| } |
| +void OmniboxViewViews::SetEmphasis(bool emphasize, gfx::Range range) { |
| + SkColor color = location_bar_view_->GetColor( |
| + emphasize ? LocationBarView::TEXT : LocationBarView::DEEMPHASIZED_TEXT); |
| + if (range.IsValid()) |
| + ApplyColor(color, range); |
| + else |
| + SetColor(color); |
| +} |
| + |
| +void OmniboxViewViews::UpdateSchemeEmphasis(gfx::Range range) { |
| + SetStyle(gfx::DIAGONAL_STRIKE, false); |
| + if (range.IsValid()) { |
| + const SkColor security_color = |
| + location_bar_view_->GetSecureTextColor(security_level_); |
| + const bool strike = (security_level_ == security_state::DANGEROUS); |
|
Peter Kasting
2017/03/01 02:39:10
Nit: () unnecessary
elawrence
2017/03/01 21:49:01
Done.
|
| + ApplyColor(security_color, range); |
| + ApplyStyle(gfx::DIAGONAL_STRIKE, strike, range); |
| + } |
| +} |
| + |
| void OmniboxViewViews::EmphasizeURLComponents() { |
| if (!location_bar_view_) |
| return; |
| @@ -577,40 +596,7 @@ void OmniboxViewViews::EmphasizeURLComponents() { |
| ? gfx::DIRECTIONALITY_FORCE_LTR |
| : gfx::DIRECTIONALITY_FROM_TEXT); |
| - // See whether the contents are a URL with a non-empty host portion, which we |
| - // should emphasize. To check for a URL, rather than using the type returned |
| - // by Parse(), ask the model, which will check the desired page transition for |
| - // this input. This can tell us whether an UNKNOWN input string is going to |
| - // be treated as a search or a navigation, and is the same method the Paste |
| - // And Go system uses. |
| - 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())); |
| - } |
| - |
| - // 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 |
| - // editing; and in some cases, e.g. for "site:foo.com" searches, the parser |
| - // may have incorrectly identified a qualifier as a scheme. |
| - SetStyle(gfx::DIAGONAL_STRIKE, false); |
| - if (!model()->user_input_in_progress() && text_is_url && |
| - scheme.is_nonempty() && (security_level_ != security_state::NONE)) { |
| - SkColor security_color = |
| - location_bar_view_->GetSecureTextColor(security_level_); |
| - const bool strike = (security_level_ == security_state::DANGEROUS); |
| - const gfx::Range scheme_range(scheme.begin, scheme.end()); |
| - ApplyColor(security_color, scheme_range); |
| - ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); |
| - } |
| + ApplyEmphasis(text(), ChromeAutocompleteSchemeClassifier(profile_)); |
| } |
| bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { |