Chromium Code Reviews| 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 GURL; | |
| 15 | |
| 16 @class CredentialItemView; | |
| 17 | |
| 18 // Handles user interaction with and image fetching for a CredentialItemView. | |
|
groby-ooo-7-16
2015/02/19 17:01:33
Question: This functionality is presumably shared
dconnelly
2015/02/20 15:36:06
ManagePasswordsBubbleModel is the cross-platform d
| |
| 19 @protocol CredentialItemDelegate<NSObject> | |
| 20 | |
| 21 // Retrieves the image located at |avatarURL| and updates |view| by calling | |
| 22 // [CredentialItemView updateAvatar:] if successful. | |
| 23 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemView*)view; | |
| 24 | |
| 25 // Indicates that the user has selected the credential corresponding to | |
| 26 // |passwordForm| and |credentialType|. | |
| 27 - (void)selectPasswordForm:(const autofill::PasswordForm&)passwordForm | |
| 28 credentialType:(password_manager::CredentialType)credentialType; | |
| 29 | |
| 30 @end | |
| 31 | |
| 32 // A user-clickable view to show a single account credential. | |
| 33 @interface CredentialItemView : NSButton { | |
| 34 autofill::PasswordForm passwordForm_; | |
| 35 password_manager::CredentialType credentialType_; | |
| 36 base::scoped_nsobject<NSTextField> nameLabel_; | |
| 37 base::scoped_nsobject<NSTextField> usernameLabel_; | |
| 38 base::scoped_nsobject<NSImageView> avatarView_; | |
| 39 id<CredentialItemDelegate> delegate_; | |
| 40 } | |
| 41 | |
| 42 // Initializes an item view populated with the data in |passwordForm|. Informs | |
| 43 // |delegate| of user interactions and uses it to fetch avatar images. | |
| 44 - (id)initWithPasswordForm:(const autofill::PasswordForm&)passwordForm | |
| 45 credentialType:(password_manager::CredentialType)credentialType | |
| 46 delegate:(id<CredentialItemDelegate>)delegate; | |
| 47 | |
| 48 // Sets a custom avatar for this item. The image should be scaled and cropped | |
| 49 // to a circle of size |kAvatarImageSize|, otherwise it will look ridiculous. | |
| 50 - (void)updateAvatar:(NSImage*)avatar; | |
| 51 | |
| 52 // The default avatar image, used when a custom one is not set. | |
| 53 + (NSImage*)defaultAvatar; | |
| 54 | |
| 55 @end | |
| 56 | |
| 57 @interface CredentialItemView(Testing) | |
|
groby-ooo-7-16
2015/02/19 17:01:33
Any reason this can't just live in the test file?
dconnelly
2015/02/20 15:36:06
Done.
| |
| 58 @property(readonly) NSTextField* nameLabel; | |
| 59 @property(readonly) NSTextField* usernameLabel; | |
| 60 @property(readonly) NSImageView* avatarView; | |
| 61 @end | |
| 62 | |
| 63 // A container view that shows a list of CredentialItemViews. | |
| 64 @interface CredentialItemListView : NSView | |
| 65 | |
| 66 // Initializes a list view with the specified array of |CredentialItemView|s. | |
| 67 - (id)initWithItems:(NSArray*)items; | |
| 68 | |
| 69 @end | |
| 70 | |
| 71 @interface CredentialItemListView(Testing) | |
| 72 @property(readonly) NSArray* items; | |
|
groby-ooo-7-16
2015/02/19 17:01:33
Why not just use subviews?
dconnelly
2015/02/20 15:36:06
Done.
| |
| 73 @end | |
| 74 | |
| 75 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_ | |
| OLD | NEW |