Index: chrome/browser/ui/cocoa/passwords/credential_item_view.h |
diff --git a/chrome/browser/ui/cocoa/passwords/credential_item_view.h b/chrome/browser/ui/cocoa/passwords/credential_item_view.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..670843d089b22eda535535318fcb25ee87e45e91 |
--- /dev/null |
+++ b/chrome/browser/ui/cocoa/passwords/credential_item_view.h |
@@ -0,0 +1,75 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_ |
+#define CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_ |
+ |
+#import <Cocoa/Cocoa.h> |
+ |
+#import "base/mac/scoped_nsobject.h" |
+#include "components/autofill/core/common/password_form.h" |
+#include "components/password_manager/content/common/credential_manager_types.h" |
+ |
+class GURL; |
+ |
+@class CredentialItemView; |
+ |
+// 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
|
+@protocol CredentialItemDelegate<NSObject> |
+ |
+// Retrieves the image located at |avatarURL| and updates |view| by calling |
+// [CredentialItemView updateAvatar:] if successful. |
+- (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemView*)view; |
+ |
+// Indicates that the user has selected the credential corresponding to |
+// |passwordForm| and |credentialType|. |
+- (void)selectPasswordForm:(const autofill::PasswordForm&)passwordForm |
+ credentialType:(password_manager::CredentialType)credentialType; |
+ |
+@end |
+ |
+// A user-clickable view to show a single account credential. |
+@interface CredentialItemView : NSButton { |
+ autofill::PasswordForm passwordForm_; |
+ password_manager::CredentialType credentialType_; |
+ base::scoped_nsobject<NSTextField> nameLabel_; |
+ base::scoped_nsobject<NSTextField> usernameLabel_; |
+ base::scoped_nsobject<NSImageView> avatarView_; |
+ id<CredentialItemDelegate> delegate_; |
+} |
+ |
+// Initializes an item view populated with the data in |passwordForm|. Informs |
+// |delegate| of user interactions and uses it to fetch avatar images. |
+- (id)initWithPasswordForm:(const autofill::PasswordForm&)passwordForm |
+ credentialType:(password_manager::CredentialType)credentialType |
+ delegate:(id<CredentialItemDelegate>)delegate; |
+ |
+// Sets a custom avatar for this item. The image should be scaled and cropped |
+// to a circle of size |kAvatarImageSize|, otherwise it will look ridiculous. |
+- (void)updateAvatar:(NSImage*)avatar; |
+ |
+// The default avatar image, used when a custom one is not set. |
++ (NSImage*)defaultAvatar; |
+ |
+@end |
+ |
+@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.
|
+@property(readonly) NSTextField* nameLabel; |
+@property(readonly) NSTextField* usernameLabel; |
+@property(readonly) NSImageView* avatarView; |
+@end |
+ |
+// A container view that shows a list of CredentialItemViews. |
+@interface CredentialItemListView : NSView |
+ |
+// Initializes a list view with the specified array of |CredentialItemView|s. |
+- (id)initWithItems:(NSArray*)items; |
+ |
+@end |
+ |
+@interface CredentialItemListView(Testing) |
+@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.
|
+@end |
+ |
+#endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_CREDENTIAL_ITEM_VIEW_H_ |