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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 GetTextColor())); | 49 GetTextColor())); |
50 } else { | 50 } else { |
51 SetImage(*GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)); | 51 SetImage(*GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 SkColor SelectedKeywordView::GetTextColor() const { | 55 SkColor SelectedKeywordView::GetTextColor() const { |
56 if (!ui::MaterialDesignController::IsModeMaterial()) | 56 if (!ui::MaterialDesignController::IsModeMaterial()) |
57 return text_color_; | 57 return text_color_; |
58 | 58 |
59 return color_utils::IsDark(GetParentBackgroundColor()) | 59 return GetNativeTheme()->GetSystemColor( |
60 ? gfx::kGoogleBlue700 | 60 color_utils::IsDark(GetParentBackgroundColor()) |
61 : GetNativeTheme()->GetSystemColor( | 61 ? ui::NativeTheme::kColorId_TextfieldDefaultColor |
62 ui::NativeTheme::kColorId_LinkEnabled); | 62 : ui::NativeTheme::kColorId_LinkEnabled); |
63 } | 63 } |
64 | 64 |
65 SkColor SelectedKeywordView::GetBorderColor() const { | 65 SkColor SelectedKeywordView::GetBorderColor() const { |
66 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | 66 DCHECK(ui::MaterialDesignController::IsModeMaterial()); |
67 return GetTextColor(); | 67 return GetTextColor(); |
68 } | 68 } |
69 | 69 |
70 gfx::Size SelectedKeywordView::GetPreferredSize() const { | 70 gfx::Size SelectedKeywordView::GetPreferredSize() const { |
71 // Height will be ignored by the LocationBarView. | 71 // Height will be ignored by the LocationBarView. |
72 return GetSizeForLabelWidth(full_label_.GetPreferredSize().width()); | 72 return GetSizeForLabelWidth(full_label_.GetPreferredSize().width()); |
(...skipping 16 matching lines...) Expand all Loading... |
89 return; | 89 return; |
90 DCHECK(profile_); | 90 DCHECK(profile_); |
91 TemplateURLService* model = | 91 TemplateURLService* model = |
92 TemplateURLServiceFactory::GetForProfile(profile_); | 92 TemplateURLServiceFactory::GetForProfile(profile_); |
93 if (!model) | 93 if (!model) |
94 return; | 94 return; |
95 | 95 |
96 bool is_extension_keyword; | 96 bool is_extension_keyword; |
97 const base::string16 short_name = | 97 const base::string16 short_name = |
98 model->GetKeywordShortName(keyword, &is_extension_keyword); | 98 model->GetKeywordShortName(keyword, &is_extension_keyword); |
99 const base::string16 full_name = is_extension_keyword ? | 99 int keyword_text_id = ui::MaterialDesignController::IsModeMaterial() |
100 short_name : | 100 ? IDS_OMNIBOX_KEYWORD_TEXT_MD |
101 l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT, short_name); | 101 : IDS_OMNIBOX_KEYWORD_TEXT; |
| 102 const base::string16 full_name = |
| 103 is_extension_keyword ? short_name : l10n_util::GetStringFUTF16( |
| 104 keyword_text_id, short_name); |
102 full_label_.SetText(full_name); | 105 full_label_.SetText(full_name); |
103 | 106 |
104 const base::string16 min_string( | 107 const base::string16 min_string( |
105 location_bar_util::CalculateMinString(short_name)); | 108 location_bar_util::CalculateMinString(short_name)); |
106 const base::string16 partial_name = is_extension_keyword ? | 109 const base::string16 partial_name = |
107 min_string : | 110 is_extension_keyword ? min_string : l10n_util::GetStringFUTF16( |
108 l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT, min_string); | 111 keyword_text_id, min_string); |
109 partial_label_.SetText(min_string.empty() ? | 112 partial_label_.SetText(min_string.empty() ? |
110 full_label_.text() : partial_name); | 113 full_label_.text() : partial_name); |
111 } | 114 } |
112 | 115 |
113 const char* SelectedKeywordView::GetClassName() const { | 116 const char* SelectedKeywordView::GetClassName() const { |
114 return "SelectedKeywordView"; | 117 return "SelectedKeywordView"; |
115 } | 118 } |
OLD | NEW |