Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / passwords / credential_item_view.h
blob5d17099909b33f11f6594e09d0acb6ca574b9edd
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.
5 #ifndef CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_
6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_
8 #import <Cocoa/Cocoa.h>
10 #import "base/mac/scoped_nsobject.h"
11 #include "components/autofill/core/common/password_form.h"
12 #include "components/password_manager/core/common/credential_manager_types.h"
14 @class CredentialItemView;
15 class GURL;
17 namespace password_manager_mac {
18 // The style of the credential item.
19 enum CredentialItemStyle {
20 // Shows the credential details next to the avatar.
21 ACCOUNT_CHOOSER,
22 // Shows an auto-signin message next to the avatar.
23 AUTO_SIGNIN,
25 } // namespace password_manager
27 // Handles user interaction with and image fetching for a CredentialItemView.
28 @protocol CredentialItemDelegate<NSObject>
30 // Retrieves the image located at |avatarURL| and updates |view| by calling
31 // [CredentialItemView updateAvatar:] if successful.
32 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemView*)view;
34 @end
36 // A view to show a single account credential.
37 @interface CredentialItemView : NSView {
38 autofill::PasswordForm passwordForm_;
39 password_manager::CredentialType credentialType_;
40 NSTextField* upperLabel_;
41 NSTextField* lowerLabel_;
42 NSImageView* avatarView_;
43 id<CredentialItemDelegate> delegate_; // Weak.
46 @property(nonatomic, readonly) autofill::PasswordForm passwordForm;
47 @property(nonatomic, readonly) password_manager::CredentialType credentialType;
49 // Initializes an item view populated with the data in |passwordForm|. Uses
50 // |delegate| to asynchronously fetch the avatar image.
51 - (id)initWithPasswordForm:(const autofill::PasswordForm&)passwordForm
52 credentialType:(password_manager::CredentialType)credentialType
53 style:(password_manager_mac::CredentialItemStyle)style
54 delegate:(id<CredentialItemDelegate>)delegate;
56 // Sets a custom avatar for this item. The image should be scaled and cropped
57 // to a circle of size |kAvatarImageSize|, otherwise it will look ridiculous.
58 - (void)updateAvatar:(NSImage*)avatar;
60 // The default avatar image, used when a custom one is not set.
61 + (NSImage*)defaultAvatar;
63 @end
65 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_