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

Unified Diff: chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm

Issue 2604273004: Style the Form-Not-Secure warning on Mac (Closed)
Patch Set: add comment Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm
index f45e014f0bd4641023ccd98f43feef2ca7dd6992..30745dedbf726cc8228797ab3a6ac3681f51156b 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm
@@ -5,7 +5,9 @@
#import "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h"
#include "base/logging.h"
+#include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
#include "chrome/browser/ui/autofill/popup_constants.h"
@@ -16,10 +18,14 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/cocoa/window_size_constants.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/color_palette.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia_util_mac.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icons_public.h"
using autofill::AutofillPopupView;
using autofill::AutofillPopupLayoutModel;
@@ -153,6 +159,10 @@ using autofill::AutofillPopupLayoutModel;
bounds:(NSRect)bounds
selected:(BOOL)isSelected
textYOffset:(CGFloat)textYOffset {
+ BOOL isHTTPWarning =
+ (controller_->GetSuggestionAt(index).frontend_id ==
+ autofill::POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE);
+
// If this row is selected, highlight it with this mac system color.
// Otherwise the controller may have a specific background color for this
// entry.
@@ -173,6 +183,9 @@ using autofill::AutofillPopupLayoutModel;
// Draw left side if isRTL == NO, right side if isRTL == YES.
CGFloat x = isRTL ? rightX : leftX;
+ if (isHTTPWarning) {
+ x = [self drawIconAtIndex:index atX:x rightAlign:isRTL bounds:bounds];
+ }
[self drawName:name
atX:x
index:index
@@ -182,7 +195,9 @@ using autofill::AutofillPopupLayoutModel;
// Draw right side if isRTL == NO, left side if isRTL == YES.
x = isRTL ? leftX : rightX;
- x = [self drawIconAtIndex:index atX:x rightAlign:!isRTL bounds:bounds];
+ if (!isHTTPWarning) {
+ x = [self drawIconAtIndex:index atX:x rightAlign:!isRTL bounds:bounds];
+ }
[self drawSubtext:subtext
atX:x
index:index
@@ -263,10 +278,27 @@ using autofill::AutofillPopupLayoutModel;
}
- (NSImage*)iconAtIndex:(size_t)index {
+ const int kHttpWarningIconWidth = 16;
const base::string16& icon = controller_->GetSuggestionAt(index).icon;
if (icon.empty())
return nil;
+ // For the Form-Not-Secure warning about password/credit card fields on HTTP
+ // pages, reuse the omnibox vector icons.
+ if (icon == base::ASCIIToUTF16("httpWarning")) {
Mathieu 2017/01/05 20:37:18 could you try removing https://cs.chromium.org/chr
estark 2017/01/05 21:24:45 I think we use rely on those lines on Android, no?
Robert Sesek 2017/01/06 22:28:10 Is there not a constant for this available?
estark 2017/01/07 03:34:40 Hmm, doesn't appear to be; these icons are selecte
+ return NSImageFromImageSkiaWithColorSpace(
+ gfx::CreateVectorIcon(gfx::VectorIconId::LOCATION_BAR_HTTP,
+ kHttpWarningIconWidth, gfx::kChromeIconGrey),
+ base::mac::GetSRGBColorSpace());
+ }
+
+ if (icon == base::ASCIIToUTF16("httpsInvalid")) {
+ return NSImageFromImageSkiaWithColorSpace(
+ gfx::CreateVectorIcon(gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID,
+ kHttpWarningIconWidth, gfx::kGoogleRed700),
+ base::mac::GetSRGBColorSpace());
+ }
+
int iconId = delegate_->GetIconResourceID(icon);
DCHECK_NE(-1, iconId);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698