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

Unified Diff: chrome/browser/ui/autofill/autofill_popup_layout_model.cc

Issue 2498503002: Http Bad: Add icons to the http warning message (Closed)
Patch Set: fix compile error Created 4 years, 1 month 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/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..e10cfc6eee90f1c0c97f873b93ee50fadcd7d67f 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();
row_size += icon_width + kIconPadding;
}
@@ -192,6 +198,34 @@ SkColor AutofillPopupLayoutModel::GetValueFontColorForRow(size_t index) const {
return kValueTextColor;
}
}
+
+gfx::ImageSkia AutofillPopupLayoutModel::GetIconImage(size_t index) const {
+ std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
Evan Stade 2016/11/28 16:12:02 you're copying the entire list of suggestions ---
lshang 2016/11/29 10:07:35 This file is doing this in several places. I'd rec
Evan Stade 2016/11/29 15:23:32 It's unfortunate that the code is set up like this
+ base::string16 icon_str = suggestions[index].icon;
+
+ // 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);
+ } else if (icon_str == base::ASCIIToUTF16("httpsInvalid")) {
Evan Stade 2016/11/28 16:12:02 nit: no else after return. (x3 in this function)
lshang 2016/11/29 10:07:35 Done.
+ return gfx::CreateVectorIcon(
+ gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID, kHttpWarningIconWidth,
+ gfx::kGoogleRed700);
+ } else {
+ NOTREACHED();
Evan Stade 2016/11/28 16:12:02 nit: no need to explicitly handle this case. Just
lshang 2016/11/29 10:07:35 Done. Good Point!
+ return gfx::ImageSkia();
+ }
+ // For other suggestion entries, get icon from PNG files.
+ } else {
+ int icon_id = GetIconResourceID(icon_str);
+ DCHECK_NE(-1, icon_id);
+ return *(
+ ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id));
+ }
+}
#endif
int AutofillPopupLayoutModel::LineFromY(int y) const {

Powered by Google App Engine
This is Rietveld 408576698