Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_popup_layout_model.cc |
| diff --git a/chrome/browser/ui/autofill/autofill_popup_layout_model.cc b/chrome/browser/ui/autofill/autofill_popup_layout_model.cc |
| index 1b24397deb34abe28169891bfd150173fe235080..f53b06bfde5f85e599a42ac2f1ff915a259164d2 100644 |
| --- a/chrome/browser/ui/autofill/autofill_popup_layout_model.cc |
| +++ b/chrome/browser/ui/autofill/autofill_popup_layout_model.cc |
| @@ -16,8 +16,12 @@ |
| #include "components/grit/components_scaled_resources.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/color_palette.h" |
| +#include "ui/gfx/color_utils.h" |
| #include "ui/gfx/font_list.h" |
| #include "ui/gfx/geometry/rect_conversions.h" |
| +#include "ui/gfx/image/image_skia.h" |
| +#include "ui/gfx/paint_vector_icon.h" |
| +#include "ui/gfx/vector_icons_public.h" |
| namespace autofill { |
| @@ -32,6 +36,8 @@ const size_t kSeparatorHeight = 1; |
| #if !defined(OS_ANDROID) |
| // Size difference between the normal font and the smaller font, in pixels. |
| const int kSmallerFontSizeDelta = -1; |
| + |
| +const int kHttpWarningIconWidth = 16; |
| #endif |
| const struct { |
| @@ -46,6 +52,8 @@ const struct { |
| {"masterCardCC", IDR_AUTOFILL_CC_MASTERCARD}, |
| {"visaCC", IDR_AUTOFILL_CC_VISA}, |
| #if defined(OS_ANDROID) |
| + {"httpWarning", IDR_AUTOFILL_HTTP_WARNING}, |
| + {"httpsInvalid", IDR_AUTOFILL_HTTPS_INVALID_WARNING}, |
| {"scanCreditCardIcon", IDR_AUTOFILL_CC_SCAN_NEW}, |
| {"settings", IDR_AUTOFILL_SETTINGS}, |
| #endif |
| @@ -118,9 +126,7 @@ int AutofillPopupLayoutModel::RowWidthWithoutText(int row, |
| // Add the Autofill icon size, if required. |
| const base::string16& icon = suggestions[row].icon; |
| if (!icon.empty()) { |
| - int icon_width = ui::ResourceBundle::GetSharedInstance() |
| - .GetImageNamed(GetIconResourceID(icon)) |
| - .Width(); |
| + int icon_width = GetIconImage(row).width(); |
|
Evan Stade
2016/11/29 15:23:32
nit: inline below
lshang
2016/11/29 23:48:30
Done.
|
| row_size += icon_width + kIconPadding; |
| } |
| @@ -192,6 +198,29 @@ SkColor AutofillPopupLayoutModel::GetValueFontColorForRow(size_t index) const { |
| return kValueTextColor; |
| } |
| } |
| + |
| +gfx::ImageSkia AutofillPopupLayoutModel::GetIconImage(size_t index) const { |
| + std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); |
| + base::string16 icon_str = suggestions[index].icon; |
|
Evan Stade
2016/11/29 15:23:32
const ref
lshang
2016/11/29 23:48:30
Done.
|
| + |
| + // For http warning message, get icon images from VectorIconId, which is the |
| + // same as security indicator icons in location bar. |
| + if (suggestions[index].frontend_id == |
| + POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) { |
| + if (icon_str == base::ASCIIToUTF16("httpWarning")) { |
| + return gfx::CreateVectorIcon(gfx::VectorIconId::LOCATION_BAR_HTTP, |
| + kHttpWarningIconWidth, gfx::kChromeIconGrey); |
| + } |
| + DCHECK(icon_str == base::ASCIIToUTF16("httpsInvalid")); |
|
Evan Stade
2016/11/29 15:23:32
nit: DCHECK_EQ
lshang
2016/11/29 23:48:30
Done.
|
| + return gfx::CreateVectorIcon(gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID, |
| + kHttpWarningIconWidth, gfx::kGoogleRed700); |
| + } |
| + |
| + // For other suggestion entries, get icon from PNG files. |
| + int icon_id = GetIconResourceID(icon_str); |
| + DCHECK_NE(-1, icon_id); |
| + return *(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id)); |
|
Evan Stade
2016/11/29 15:23:32
I believe you have an extra set of parens here
lshang
2016/11/29 23:48:30
Done.
|
| +} |
| #endif |
| int AutofillPopupLayoutModel::LineFromY(int y) const { |