Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1999)

Unified Diff: chrome/browser/ui/views/location_bar/selected_keyword_view.cc

Issue 2348853004: Remove non-md code in location bar (Views). (Closed)
Patch Set: resolve change collision Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/selected_keyword_view.cc
diff --git a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
index 6b2d235ab3927fdeca2b550d07ea3cf0fd259186..47f8eb45f9798e43143e9bc8c62224d56bf0302d 100644
--- a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
+++ b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
@@ -5,35 +5,22 @@
#include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
#include "base/logging.h"
-#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/location_bar/location_bar_util.h"
-#include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
#include "chrome/grit/generated_resources.h"
-#include "chrome/grit/theme_resources.h"
-#include "components/grit/components_scaled_resources.h"
#include "components/search_engines/template_url_service.h"
#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/theme_provider.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/native_theme/native_theme.h"
-#include "ui/views/painter.h"
SelectedKeywordView::SelectedKeywordView(const gfx::FontList& font_list,
- SkColor text_color,
- SkColor parent_background_color,
Profile* profile)
- : IconLabelBubbleView(0, font_list, parent_background_color, false),
- text_color_(text_color),
- profile_(profile) {
- static const int kBackgroundImages[] =
- IMAGE_GRID(IDR_OMNIBOX_SELECTED_KEYWORD_BUBBLE);
- SetBackgroundImageGrid(kBackgroundImages);
+ : IconLabelBubbleView(font_list, false), profile_(profile) {
full_label_.SetFontList(font_list);
full_label_.SetVisible(false);
partial_label_.SetFontList(font_list);
@@ -44,30 +31,17 @@ SelectedKeywordView::~SelectedKeywordView() {
}
void SelectedKeywordView::ResetImage() {
- if (ui::MaterialDesignController::IsModeMaterial()) {
- SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH,
- 16,
- GetTextColor()));
- } else {
- SetImage(*GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH));
- }
+ SetImage(
+ gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH, GetTextColor()));
}
SkColor SelectedKeywordView::GetTextColor() const {
- if (!ui::MaterialDesignController::IsModeMaterial())
- return text_color_;
-
return GetNativeTheme()->GetSystemColor(
color_utils::IsDark(GetParentBackgroundColor())
? ui::NativeTheme::kColorId_TextfieldDefaultColor
: ui::NativeTheme::kColorId_LinkEnabled);
}
-SkColor SelectedKeywordView::GetBorderColor() const {
- DCHECK(ui::MaterialDesignController::IsModeMaterial());
- return GetTextColor();
-}
-
gfx::Size SelectedKeywordView::GetPreferredSize() const {
// Height will be ignored by the LocationBarView.
return GetSizeForLabelWidth(full_label_.GetPreferredSize().width());
@@ -97,21 +71,25 @@ void SelectedKeywordView::SetKeyword(const base::string16& keyword) {
bool is_extension_keyword;
const base::string16 short_name =
model->GetKeywordShortName(keyword, &is_extension_keyword);
- int keyword_text_id = ui::MaterialDesignController::IsModeMaterial()
- ? IDS_OMNIBOX_KEYWORD_TEXT_MD
- : IDS_OMNIBOX_KEYWORD_TEXT;
const base::string16 full_name =
- is_extension_keyword ? short_name : l10n_util::GetStringFUTF16(
- keyword_text_id, short_name);
+ is_extension_keyword
+ ? short_name
+ : l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT_MD, short_name);
full_label_.SetText(full_name);
const base::string16 min_string(
location_bar_util::CalculateMinString(short_name));
const base::string16 partial_name =
- is_extension_keyword ? min_string : l10n_util::GetStringFUTF16(
- keyword_text_id, min_string);
+ is_extension_keyword
+ ? min_string
+ : l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT_MD, min_string);
partial_label_.SetText(min_string.empty() ?
full_label_.text() : partial_name);
+
+ // Update the label now so ShouldShowLabel() works correctly when the parent
+ // class is calculating the preferred size. It will be updated again in
+ // Layout(), taking into account how much space has actually been allotted.
+ SetLabel(full_name);
}
const char* SelectedKeywordView::GetClassName() const {
« no previous file with comments | « chrome/browser/ui/views/location_bar/selected_keyword_view.h ('k') | chrome/browser/ui/views/location_bar/star_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698