| OLD | NEW |
| 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 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h" |
| 11 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h" | 11 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h" |
| 12 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | 12 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
| 13 #include "chrome/grit/theme_resources.h" | 13 #include "chrome/grit/theme_resources.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/color_palette.h" | 15 #include "ui/gfx/color_palette.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
| 17 #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" | 18 #include "ui/gfx/paint_vector_icon.h" |
| 19 #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" | 20 #include "ui/vector_icons/vector_icons.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 constexpr CGFloat kFocusRingInset = 3; | 23 constexpr CGFloat kFocusRingInset = 3; |
| 24 constexpr CGFloat kHorizontalPaddingBetweenAvatarAndLabel = 10; | 24 constexpr CGFloat kHorizontalPaddingBetweenAvatarAndLabel = 10; |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 // 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 |
| 28 // spacing between the avatar and label. | 28 // spacing between the avatar and label. |
| 29 @interface CredentialItemButtonCell : NSButtonCell { | 29 @interface CredentialItemButtonCell : NSButtonCell { |
| 30 @private | 30 @private |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 [self setImagePosition:base::i18n::IsRTL() ? NSImageRight : NSImageLeft]; | 129 [self setImagePosition:base::i18n::IsRTL() ? NSImageRight : NSImageLeft]; |
| 130 [self setAlignment:NSNaturalTextAlignment]; | 130 [self setAlignment:NSNaturalTextAlignment]; |
| 131 } | 131 } |
| 132 return self; | 132 return self; |
| 133 } | 133 } |
| 134 | 134 |
| 135 - (NSView*)addInfoIcon:(NSString*)tooltip { | 135 - (NSView*)addInfoIcon:(NSString*)tooltip { |
| 136 DCHECK(!iconController_); | 136 DCHECK(!iconController_); |
| 137 iconController_.reset([[AutofillTooltipController alloc] | 137 iconController_.reset([[AutofillTooltipController alloc] |
| 138 initWithArrowLocation:info_bubble::kTopTrailing]); | 138 initWithArrowLocation:info_bubble::kTopTrailing]); |
| 139 NSImage* image = gfx::NSImageFromImageSkia(gfx::CreateVectorIcon( | 139 NSImage* image = gfx::NSImageFromImageSkia( |
| 140 gfx::VectorIconId::INFO_OUTLINE, gfx::kChromeIconGrey)); | 140 gfx::CreateVectorIcon(ui::kInfoOutlineIcon, gfx::kChromeIconGrey)); |
| 141 [iconController_ setImage:image]; | 141 [iconController_ setImage:image]; |
| 142 [iconController_ setMessage:tooltip]; | 142 [iconController_ setMessage:tooltip]; |
| 143 [self addSubview:[iconController_ view]]; | 143 [self addSubview:[iconController_ view]]; |
| 144 return [iconController_ view]; | 144 return [iconController_ view]; |
| 145 } | 145 } |
| 146 | 146 |
| 147 + (NSImage*)defaultAvatar { | 147 + (NSImage*)defaultAvatar { |
| 148 return gfx::NSImageFromImageSkia(ScaleImageForAccountAvatar( | 148 return gfx::NSImageFromImageSkia(ScaleImageForAccountAvatar( |
| 149 *ResourceBundle::GetSharedInstance() | 149 *ResourceBundle::GetSharedInstance() |
| 150 .GetImageNamed(IDR_PROFILE_AVATAR_PLACEHOLDER_LARGE) | 150 .GetImageNamed(IDR_PROFILE_AVATAR_PLACEHOLDER_LARGE) |
| 151 .ToImageSkia())); | 151 .ToImageSkia())); |
| 152 } | 152 } |
| 153 | 153 |
| 154 - (void)setHoverState:(HoverState)state { | 154 - (void)setHoverState:(HoverState)state { |
| 155 [super setHoverState:state]; | 155 [super setHoverState:state]; |
| 156 bool isHighlighted = ([self hoverState] != kHoverStateNone); | 156 bool isHighlighted = ([self hoverState] != kHoverStateNone); |
| 157 | 157 |
| 158 NSColor* backgroundColor = isHighlighted ? hoverColor_ : backgroundColor_; | 158 NSColor* backgroundColor = isHighlighted ? hoverColor_ : backgroundColor_; |
| 159 [[self cell] setBackgroundColor:backgroundColor]; | 159 [[self cell] setBackgroundColor:backgroundColor]; |
| 160 } | 160 } |
| 161 | 161 |
| 162 - (BOOL)canBecomeKeyView { | 162 - (BOOL)canBecomeKeyView { |
| 163 return YES; | 163 return YES; |
| 164 } | 164 } |
| 165 | 165 |
| 166 @end | 166 @end |
| OLD | NEW |