Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| index 6b4235d1f1b8bcacf45da01c17582ccdf9de49a4..feafd024ffbd77990f9381664c2b3637e53bea06 100644 |
| --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| @@ -339,37 +339,33 @@ SkColor LocationBarView::GetColor( |
| SkColor LocationBarView::GetSecureTextColor( |
| security_state::SecurityStateModel::SecurityLevel security_level) const { |
| + bool md = ui::MaterialDesignController::IsModeMaterial(); |
| bool inverted = color_utils::IsDark(GetColor(BACKGROUND)); |
| - SkColor color; |
| - switch (security_level) { |
| - case security_state::SecurityStateModel::EV_SECURE: |
| - case security_state::SecurityStateModel::SECURE: |
| - if (ui::MaterialDesignController::IsModeMaterial() && inverted) |
| - return GetColor(TEXT); |
| - color = GetColor(EV_BUBBLE_TEXT_AND_BORDER); |
| - break; |
| - |
| - case security_state::SecurityStateModel::SECURITY_POLICY_WARNING: |
| - return GetColor(DEEMPHASIZED_TEXT); |
| - break; |
| - |
| - case security_state::SecurityStateModel::SECURITY_ERROR: { |
| - bool md = ui::MaterialDesignController::IsModeMaterial(); |
| - if (md && inverted) |
| - return GetColor(TEXT); |
| - color = md ? gfx::kGoogleRed700 : SkColorSetRGB(162, 0, 0); |
| - break; |
| - } |
| - case security_state::SecurityStateModel::SECURITY_WARNING: |
| + if (security_level == security_state::SecurityStateModel::EV_SECURE || |
| + security_level == security_state::SecurityStateModel::SECURE) { |
| + if (md && inverted) |
| return GetColor(TEXT); |
| - break; |
| + return color_utils::GetReadableColor(GetColor(EV_BUBBLE_TEXT_AND_BORDER), |
| + GetColor(BACKGROUND)); |
| + } |
| + |
| + if (security_level == |
| + security_state::SecurityStateModel::SECURITY_POLICY_WARNING) { |
| + return GetColor(DEEMPHASIZED_TEXT); |
| + } |
| - default: |
| - NOTREACHED(); |
| - return gfx::kPlaceholderColor; |
| + if (security_level == security_state::SecurityStateModel::SECURITY_ERROR) { |
| + if (md && inverted) |
| + return GetColor(TEXT); |
| + return color_utils::GetReadableColor( |
| + md ? gfx::kGoogleRed700 : SkColorSetRGB(162, 0, 0), |
| + GetColor(BACKGROUND)); |
| } |
| - return color_utils::GetReadableColor(color, GetColor(BACKGROUND)); |
| + |
| + DCHECK_EQ(security_state::SecurityStateModel::SECURITY_WARNING, |
| + security_level); |
| + return color_utils::GetReadableColor(GetColor(TEXT), GetColor(BACKGROUND)); |
| } |
|
Peter Kasting
2016/05/19 20:36:25
Here's an even shorter way to write this that elim
Peter Kasting
2016/05/19 20:42:53
Even shorter:
if (security_level ==
secur
palmer
2016/05/19 20:59:06
That is good; but: it no longer has the DCHECK_EQ,
Peter Kasting
2016/05/19 21:02:28
I considered that when I wrote it and decided that
|
| void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { |
| @@ -869,9 +865,12 @@ void LocationBarView::RefreshLocationIcon() { |
| icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_IN_CHIP; |
| icon_color = location_icon_view_->GetTextColor(); |
| } else { |
| - icon_id = omnibox_view_->GetVectorIcon( |
| - color_utils::IsDark(GetColor(BACKGROUND))); |
| - icon_color = color_utils::DeriveDefaultIconColor(GetColor(TEXT)); |
| + icon_id = omnibox_view_->GetVectorIcon(); |
| + security_state::SecurityStateModel::SecurityLevel security_level = |
| + GetToolbarModel()->GetSecurityLevel(false); |
| + icon_color = (security_level == security_state::SecurityStateModel::NONE) |
| + ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) |
| + : GetSecureTextColor(security_level); |
| } |
| location_icon_view_->SetImage( |
| gfx::CreateVectorIcon(icon_id, kIconSize, icon_color)); |