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

Side by Side Diff: chrome/browser/ui/cocoa/passwords/credential_item_button.mm

Issue 2703253007: Use (i) icon and the same tooltip for the credit cards dialog and account chooser on Mac. (Closed)
Patch Set: rebase Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "chrome/browser/ui/cocoa/passwords/credential_item_button.h" 5 #import "chrome/browser/ui/cocoa/passwords/credential_item_button.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #import "base/mac/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h"
10 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h" 11 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" 12 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
12 #include "chrome/grit/theme_resources.h" 13 #include "chrome/grit/theme_resources.h"
13 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/color_palette.h"
14 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
15 #include "ui/gfx/image/image_skia_util_mac.h" 17 #include "ui/gfx/image/image_skia_util_mac.h"
18 #include "ui/gfx/paint_vector_icon.h"
16 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 19 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
20 #include "ui/gfx/vector_icons_public.h"
17 21
18 namespace { 22 namespace {
19 constexpr CGFloat kFocusRingInset = 3; 23 constexpr CGFloat kFocusRingInset = 3;
20 constexpr CGFloat kHorizontalPaddingBetweenAvatarAndLabel = 10; 24 constexpr CGFloat kHorizontalPaddingBetweenAvatarAndLabel = 10;
21 } // namespace 25 } // namespace
22 26
23 // Custom button cell that adds a left padding before the avatar, and a custom 27 // Custom button cell that adds a left padding before the avatar, and a custom
24 // spacing between the avatar and label. 28 // spacing between the avatar and label.
25 @interface CredentialItemButtonCell : NSButtonCell { 29 @interface CredentialItemButtonCell : NSButtonCell {
26 @private 30 @private
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 [[NSBezierPath bezierPathWithRoundedRect:focusRingRect 90 [[NSBezierPath bezierPathWithRoundedRect:focusRingRect
87 xRadius:2 91 xRadius:2
88 yRadius:2] fill]; 92 yRadius:2] fill];
89 } 93 }
90 94
91 @end 95 @end
92 96
93 @interface CredentialItemButton () { 97 @interface CredentialItemButton () {
94 base::scoped_nsobject<NSColor> backgroundColor_; 98 base::scoped_nsobject<NSColor> backgroundColor_;
95 base::scoped_nsobject<NSColor> hoverColor_; 99 base::scoped_nsobject<NSColor> hoverColor_;
100 base::scoped_nsobject<AutofillTooltipController> iconController_;
96 } 101 }
97 @end 102 @end
98 103
99 @implementation CredentialItemButton 104 @implementation CredentialItemButton
100 @synthesize passwordForm = passwordForm_; 105 @synthesize passwordForm = passwordForm_;
101 @synthesize credentialType = credentialType_; 106 @synthesize credentialType = credentialType_;
102 107
103 - (id)initWithFrame:(NSRect)frameRect 108 - (id)initWithFrame:(NSRect)frameRect
104 backgroundColor:(NSColor*)backgroundColor 109 backgroundColor:(NSColor*)backgroundColor
105 hoverColor:(NSColor*)hoverColor { 110 hoverColor:(NSColor*)hoverColor {
(...skipping 14 matching lines...) Expand all
120 .GetFontList(ResourceBundle::SmallFont) 125 .GetFontList(ResourceBundle::SmallFont)
121 .GetPrimaryFont() 126 .GetPrimaryFont()
122 .GetNativeFont()]; 127 .GetNativeFont()];
123 [self setButtonType:NSMomentaryLightButton]; 128 [self setButtonType:NSMomentaryLightButton];
124 [self setImagePosition:base::i18n::IsRTL() ? NSImageRight : NSImageLeft]; 129 [self setImagePosition:base::i18n::IsRTL() ? NSImageRight : NSImageLeft];
125 [self setAlignment:NSNaturalTextAlignment]; 130 [self setAlignment:NSNaturalTextAlignment];
126 } 131 }
127 return self; 132 return self;
128 } 133 }
129 134
135 - (NSView*)addInfoIcon:(NSString*)tooltip {
136 DCHECK(!iconController_);
137 iconController_.reset([[AutofillTooltipController alloc]
138 initWithArrowLocation:info_bubble::kTopTrailing]);
139 NSImage* image = gfx::NSImageFromImageSkia(gfx::CreateVectorIcon(
140 gfx::VectorIconId::INFO_OUTLINE, gfx::kChromeIconGrey));
141 [iconController_ setImage:image];
142 [iconController_ setMessage:tooltip];
143 [self addSubview:[iconController_ view]];
144 return [iconController_ view];
145 }
146
130 + (NSImage*)defaultAvatar { 147 + (NSImage*)defaultAvatar {
131 return gfx::NSImageFromImageSkia(ScaleImageForAccountAvatar( 148 return gfx::NSImageFromImageSkia(ScaleImageForAccountAvatar(
132 *ResourceBundle::GetSharedInstance() 149 *ResourceBundle::GetSharedInstance()
133 .GetImageNamed(IDR_PROFILE_AVATAR_PLACEHOLDER_LARGE) 150 .GetImageNamed(IDR_PROFILE_AVATAR_PLACEHOLDER_LARGE)
134 .ToImageSkia())); 151 .ToImageSkia()));
135 } 152 }
136 153
137 - (void)setHoverState:(HoverState)state { 154 - (void)setHoverState:(HoverState)state {
138 [super setHoverState:state]; 155 [super setHoverState:state];
139 bool isHighlighted = ([self hoverState] != kHoverStateNone); 156 bool isHighlighted = ([self hoverState] != kHoverStateNone);
140 157
141 NSColor* backgroundColor = isHighlighted ? hoverColor_ : backgroundColor_; 158 NSColor* backgroundColor = isHighlighted ? hoverColor_ : backgroundColor_;
142 [[self cell] setBackgroundColor:backgroundColor]; 159 [[self cell] setBackgroundColor:backgroundColor];
143 } 160 }
144 161
145 - (BOOL)canBecomeKeyView { 162 - (BOOL)canBecomeKeyView {
146 return YES; 163 return YES;
147 } 164 }
148 165
149 @end 166 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/passwords/credential_item_button.h ('k') | components/resources/autofill_scaled_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698