Chromium Code Reviews| Index: chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc |
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc |
| index 7c5787ba8f851eb515c1e5429bb98fd9bc9a8274..6a88dbd9d0024b8ca5724373ce86ba3f45648896 100644 |
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc |
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc |
| @@ -13,7 +13,9 @@ |
| #include "chrome/grit/generated_resources.h" |
| #include "ui/accessibility/ax_view_state.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +#include "ui/base/resource/material_design/material_design_controller.h" |
| #include "ui/base/theme_provider.h" |
| +#include "ui/native_theme/native_theme.h" |
| #include "ui/views/controls/label.h" |
| #include "ui/views/controls/link.h" |
| @@ -31,8 +33,11 @@ BookmarkBarInstructionsView::BookmarkBarInstructionsView( |
| import_link_(NULL), |
| baseline_(-1), |
| updated_colors_(false) { |
| - instructions_ = new views::Label( |
| - l10n_util::GetStringUTF16(IDS_BOOKMARKS_NO_ITEMS)); |
| + base::string16 instructions_text = |
| + l10n_util::GetStringUTF16(IDS_BOOKMARKS_NO_ITEMS); |
| + if (ui::MaterialDesignController::IsModeMaterial()) |
| + instructions_text += base::ASCIIToUTF16(" "); |
|
sky
2015/10/19 15:38:40
Why do you add a space for material? Might the spa
Evan Stade
2015/10/19 16:49:52
Previously this space was implemented with kViewPa
jungshik at Google
2015/10/23 06:30:19
Sorry for the late reply and thanks for testing in
|
| + instructions_ = new views::Label(instructions_text); |
| instructions_->SetAutoColorReadabilityEnabled(false); |
| AddChildView(instructions_); |
| @@ -62,7 +67,8 @@ gfx::Size BookmarkBarInstructionsView::GetPreferredSize() const { |
| } |
| width += pref.width(); |
| } |
| - width += (child_count() - 1) * kViewPadding; |
| + if (!ui::MaterialDesignController::IsModeMaterial()) |
| + width += (child_count() - 1) * kViewPadding; |
| if (ascent != 0) |
| height = std::max(ascent + descent, height); |
| return gfx::Size(width, height); |
| @@ -82,7 +88,9 @@ void BookmarkBarInstructionsView::Layout() { |
| y = (height() - pref.height()) / 2; |
| int view_width = std::min(remaining_width, pref.width()); |
| view->SetBounds(x, y, view_width, pref.height()); |
| - x += view_width + kViewPadding; |
| + x += view_width; |
| + if (!ui::MaterialDesignController::IsModeMaterial()) |
| + x += kViewPadding; |
| remaining_width = std::max(0, width() - x); |
| } |
| } |
| @@ -128,6 +136,26 @@ void BookmarkBarInstructionsView::UpdateColors() { |
| SkColor text_color = |
| theme_provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); |
| instructions_->SetEnabledColor(text_color); |
| - if (import_link_) |
| - import_link_->SetEnabledColor(text_color); |
| + if (import_link_) { |
|
varkha
2015/10/19 15:01:29
nit: could return early on !import_link to simplif
Evan Stade
2015/10/19 16:49:52
Done.
|
| + if (!ui::MaterialDesignController::IsModeMaterial()) { |
| + import_link_->SetEnabledColor(text_color); |
| + } else { |
| + // For MD, use the default link color if it provides enough contrast. If |
| + // contrast is too low, fall back to the bookmark text color and use an |
| + // underline to make it obvious it's a link. The default color readability |
| + // code (which only adjusts luminance) doesn't work well in this case. |
| + SkColor bg = theme_provider->GetColor( |
| + ThemeProperties::ThemeProperties::COLOR_TOOLBAR); |
| + SkColor link_color = GetNativeTheme()->GetSystemColor( |
| + ui::NativeTheme::kColorId_LinkEnabled); |
| + if (color_utils::GetContrastRatio(link_color, bg) >= |
| + color_utils::kMinimumReadableContrastRatio) { |
| + import_link_->SetUnderline(false); |
| + import_link_->SetEnabledColor(link_color); |
| + } else { |
| + import_link_->SetUnderline(true); |
| + import_link_->SetEnabledColor(text_color); |
| + } |
|
varkha
2015/10/19 15:01:29
nit: maybe shorten this similar to:
bool enough_c
Evan Stade
2015/10/19 16:49:52
Done.
|
| + } |
| + } |
| } |