OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_ |
| 7 |
| 8 #import <Cocoa/Cocoa.h> |
| 9 |
| 10 #import "base/mac/scoped_nsobject.h" |
| 11 #include "components/autofill/core/common/password_form.h" |
| 12 #include "components/password_manager/content/common/credential_manager_types.h" |
| 13 |
| 14 @class CredentialItemView; |
| 15 class GURL; |
| 16 |
| 17 // Handles user interaction with and image fetching for a CredentialItemView. |
| 18 @protocol CredentialItemDelegate<NSObject> |
| 19 |
| 20 // Retrieves the image located at |avatarURL| and updates |view| by calling |
| 21 // [CredentialItemView updateAvatar:] if successful. |
| 22 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemView*)view; |
| 23 |
| 24 @end |
| 25 |
| 26 // A view to show a single account credential. |
| 27 @interface CredentialItemView : NSView { |
| 28 autofill::PasswordForm passwordForm_; |
| 29 password_manager::CredentialType credentialType_; |
| 30 NSTextField* nameLabel_; |
| 31 NSTextField* usernameLabel_; |
| 32 NSImageView* avatarView_; |
| 33 id<CredentialItemDelegate> delegate_; // Weak. |
| 34 } |
| 35 |
| 36 @property(nonatomic, readonly) autofill::PasswordForm passwordForm; |
| 37 @property(nonatomic, readonly) password_manager::CredentialType credentialType; |
| 38 |
| 39 // Initializes an item view populated with the data in |passwordForm|. Uses |
| 40 // |delegate| to asynchronously fetch the avatar image. |
| 41 - (id)initWithPasswordForm:(const autofill::PasswordForm&)passwordForm |
| 42 credentialType:(password_manager::CredentialType)credentialType |
| 43 delegate:(id<CredentialItemDelegate>)delegate; |
| 44 |
| 45 // Sets a custom avatar for this item. The image should be scaled and cropped |
| 46 // to a circle of size |kAvatarImageSize|, otherwise it will look ridiculous. |
| 47 - (void)updateAvatar:(NSImage*)avatar; |
| 48 |
| 49 // The default avatar image, used when a custom one is not set. |
| 50 + (NSImage*)defaultAvatar; |
| 51 |
| 52 @end |
| 53 |
| 54 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_ |
OLD | NEW |