Chromium Code Reviews| 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 ui::NativeTheme::kColorId_LinkEnabled); |
| 61 : GetNativeTheme()->GetSystemColor( | |
| 62 ui::NativeTheme::kColorId_LinkEnabled); | |
| 63 } | 61 } |
| 64 | 62 |
| 65 SkColor SelectedKeywordView::GetBorderColor() const { | 63 SkColor SelectedKeywordView::GetBorderColor() const { |
| 66 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | 64 DCHECK(ui::MaterialDesignController::IsModeMaterial()); |
| 67 return GetTextColor(); | 65 return GetTextColor(); |
| 68 } | 66 } |
| 69 | 67 |
| 70 gfx::Size SelectedKeywordView::GetPreferredSize() const { | 68 gfx::Size SelectedKeywordView::GetPreferredSize() const { |
| 71 // Height will be ignored by the LocationBarView. | 69 // Height will be ignored by the LocationBarView. |
| 72 return GetSizeForLabelWidth(full_label_.GetPreferredSize().width()); | 70 return GetSizeForLabelWidth(full_label_.GetPreferredSize().width()); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 89 return; | 87 return; |
| 90 DCHECK(profile_); | 88 DCHECK(profile_); |
| 91 TemplateURLService* model = | 89 TemplateURLService* model = |
| 92 TemplateURLServiceFactory::GetForProfile(profile_); | 90 TemplateURLServiceFactory::GetForProfile(profile_); |
| 93 if (!model) | 91 if (!model) |
| 94 return; | 92 return; |
| 95 | 93 |
| 96 bool is_extension_keyword; | 94 bool is_extension_keyword; |
| 97 const base::string16 short_name = | 95 const base::string16 short_name = |
| 98 model->GetKeywordShortName(keyword, &is_extension_keyword); | 96 model->GetKeywordShortName(keyword, &is_extension_keyword); |
| 99 const base::string16 full_name = is_extension_keyword ? | 97 int keyword_text_ids = ui::MaterialDesignController::IsModeMaterial() |
|
Peter Kasting
2016/05/20 20:54:11
Nit: "ids" here looks to me more like "IDs" than "
Evan Stade
2016/05/20 22:33:53
Done.
| |
| 100 short_name : | 98 ? IDS_OMNIBOX_KEYWORD_TEXT_MD |
| 101 l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT, short_name); | 99 : IDS_OMNIBOX_KEYWORD_TEXT; |
| 100 const base::string16 full_name = | |
| 101 is_extension_keyword ? short_name : l10n_util::GetStringFUTF16( | |
| 102 keyword_text_ids, short_name); | |
| 102 full_label_.SetText(full_name); | 103 full_label_.SetText(full_name); |
| 103 | 104 |
| 104 const base::string16 min_string( | 105 const base::string16 min_string( |
| 105 location_bar_util::CalculateMinString(short_name)); | 106 location_bar_util::CalculateMinString(short_name)); |
| 106 const base::string16 partial_name = is_extension_keyword ? | 107 const base::string16 partial_name = |
| 107 min_string : | 108 is_extension_keyword ? min_string : l10n_util::GetStringFUTF16( |
| 108 l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT, min_string); | 109 keyword_text_ids, min_string); |
| 109 partial_label_.SetText(min_string.empty() ? | 110 partial_label_.SetText(min_string.empty() ? |
| 110 full_label_.text() : partial_name); | 111 full_label_.text() : partial_name); |
| 111 } | 112 } |
| 112 | 113 |
| 113 const char* SelectedKeywordView::GetClassName() const { | 114 const char* SelectedKeywordView::GetClassName() const { |
| 114 return "SelectedKeywordView"; | 115 return "SelectedKeywordView"; |
| 115 } | 116 } |
| OLD | NEW |