| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Do nothing here, we don't want to show the Bookmarks context menu when | 116 // Do nothing here, we don't want to show the Bookmarks context menu when |
| 117 // the user right clicks on the "Import bookmarks now" link. | 117 // the user right clicks on the "Import bookmarks now" link. |
| 118 } | 118 } |
| 119 | 119 |
| 120 void BookmarkBarInstructionsView::UpdateColors() { | 120 void BookmarkBarInstructionsView::UpdateColors() { |
| 121 // We don't always have a theme provider (ui tests, for example). | 121 // We don't always have a theme provider (ui tests, for example). |
| 122 const ui::ThemeProvider* theme_provider = GetThemeProvider(); | 122 const ui::ThemeProvider* theme_provider = GetThemeProvider(); |
| 123 if (!theme_provider) | 123 if (!theme_provider) |
| 124 return; | 124 return; |
| 125 updated_colors_ = true; | 125 updated_colors_ = true; |
| 126 SkColor text_color = | 126 SkColor text_color = theme_provider->GetColor( |
| 127 theme_provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); | 127 ThemeProperties::COLOR_BOOKMARK_BAR_INSTRUCTIONS_TEXT); |
| 128 instructions_->SetEnabledColor(text_color); | 128 instructions_->SetEnabledColor(text_color); |
| 129 if (!import_link_) | 129 if (!import_link_) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 if (!ui::MaterialDesignController::IsModeMaterial()) { | 132 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 133 import_link_->SetEnabledColor(text_color); | 133 import_link_->SetEnabledColor(text_color); |
| 134 } else { | 134 } else { |
| 135 // For MD, use the default link color if it provides enough contrast. If | 135 // For MD, use the default link color if it provides enough contrast. If |
| 136 // contrast is too low, fall back to the bookmark text color and use an | 136 // contrast is too low, fall back to the bookmark text color and use an |
| 137 // underline to make it obvious it's a link. The default color readability | 137 // underline to make it obvious it's a link. The default color readability |
| 138 // code (which only adjusts luminance) doesn't work well in this case. | 138 // code (which only adjusts luminance) doesn't work well in this case. |
| 139 SkColor bg = theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR); | 139 SkColor bg = theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR); |
| 140 SkColor link_color = | 140 SkColor link_color = |
| 141 GetNativeTheme()->GetSystemColor(ui::NativeTheme::kColorId_LinkEnabled); | 141 GetNativeTheme()->GetSystemColor(ui::NativeTheme::kColorId_LinkEnabled); |
| 142 bool link_has_contrast = color_utils::GetContrastRatio(link_color, bg) >= | 142 bool link_has_contrast = color_utils::GetContrastRatio(link_color, bg) >= |
| 143 color_utils::kMinimumReadableContrastRatio; | 143 color_utils::kMinimumReadableContrastRatio; |
| 144 import_link_->SetUnderline(!link_has_contrast); | 144 import_link_->SetUnderline(!link_has_contrast); |
| 145 import_link_->SetEnabledColor(link_has_contrast ? link_color : text_color); | 145 import_link_->SetEnabledColor(link_has_contrast ? link_color : text_color); |
| 146 } | 146 } |
| 147 } | 147 } |
| OLD | NEW |