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/location_bar/selected_keyword_view.h" | 5 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 10 #include "chrome/browser/search_engines/template_url_service_factory.h" |
11 #include "chrome/browser/ui/location_bar/location_bar_util.h" | 11 #include "chrome/browser/ui/location_bar/location_bar_util.h" |
12 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 12 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
14 #include "components/search_engines/template_url_service.h" | 14 #include "components/search_engines/template_url_service.h" |
15 #include "grit/components_scaled_resources.h" | 15 #include "grit/components_scaled_resources.h" |
16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/resource/material_design/material_design_controller.h" | 18 #include "ui/base/resource/material_design/material_design_controller.h" |
19 #include "ui/base/theme_provider.h" | 19 #include "ui/base/theme_provider.h" |
| 20 #include "ui/gfx/color_palette.h" |
20 #include "ui/gfx/paint_vector_icon.h" | 21 #include "ui/gfx/paint_vector_icon.h" |
21 #include "ui/gfx/vector_icons_public.h" | 22 #include "ui/gfx/vector_icons_public.h" |
22 #include "ui/native_theme/native_theme.h" | 23 #include "ui/native_theme/native_theme.h" |
23 #include "ui/views/painter.h" | 24 #include "ui/views/painter.h" |
24 | 25 |
25 SelectedKeywordView::SelectedKeywordView(const gfx::FontList& font_list, | 26 SelectedKeywordView::SelectedKeywordView(const gfx::FontList& font_list, |
26 SkColor text_color, | 27 SkColor text_color, |
27 SkColor parent_background_color, | 28 SkColor parent_background_color, |
28 Profile* profile) | 29 Profile* profile) |
29 : IconLabelBubbleView(0, | 30 : IconLabelBubbleView(0, |
(...skipping 19 matching lines...) Expand all Loading... |
49 void SelectedKeywordView::ResetImage() { | 50 void SelectedKeywordView::ResetImage() { |
50 if (ui::MaterialDesignController::IsModeMaterial()) { | 51 if (ui::MaterialDesignController::IsModeMaterial()) { |
51 SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::KEYWORD_SEARCH, 16, | 52 SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::KEYWORD_SEARCH, 16, |
52 GetTextColor())); | 53 GetTextColor())); |
53 } else { | 54 } else { |
54 SetImage(*GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)); | 55 SetImage(*GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)); |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
58 SkColor SelectedKeywordView::GetTextColor() const { | 59 SkColor SelectedKeywordView::GetTextColor() const { |
59 return GetNativeTheme()->GetSystemColor( | 60 return IsInvertedColorScheme() ? gfx::kGoogleBlue700 |
60 ui::NativeTheme::kColorId_LinkEnabled); | 61 : GetNativeTheme()->GetSystemColor( |
| 62 ui::NativeTheme::kColorId_LinkEnabled); |
61 } | 63 } |
62 | 64 |
63 SkColor SelectedKeywordView::GetBorderColor() const { | 65 SkColor SelectedKeywordView::GetBorderColor() const { |
64 return GetTextColor(); | 66 return GetTextColor(); |
65 } | 67 } |
66 | 68 |
67 gfx::Size SelectedKeywordView::GetPreferredSize() const { | 69 gfx::Size SelectedKeywordView::GetPreferredSize() const { |
68 // Height will be ignored by the LocationBarView. | 70 // Height will be ignored by the LocationBarView. |
69 return GetSizeForLabelWidth(full_label_.GetPreferredSize().width()); | 71 return GetSizeForLabelWidth(full_label_.GetPreferredSize().width()); |
70 } | 72 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 int SelectedKeywordView::GetImageAndPaddingWidth() const { | 116 int SelectedKeywordView::GetImageAndPaddingWidth() const { |
115 int width = IconLabelBubbleView::GetImageAndPaddingWidth(); | 117 int width = IconLabelBubbleView::GetImageAndPaddingWidth(); |
116 // Squeeze the icon and label closer to account for intrinsic padding in the | 118 // Squeeze the icon and label closer to account for intrinsic padding in the |
117 // icon. | 119 // icon. |
118 if (ui::MaterialDesignController::IsModeMaterial()) | 120 if (ui::MaterialDesignController::IsModeMaterial()) |
119 width -= 3; | 121 width -= 3; |
120 | 122 |
121 DCHECK_GE(width, 0); | 123 DCHECK_GE(width, 0); |
122 return width; | 124 return width; |
123 } | 125 } |
OLD | NEW |