1 // Copyright 2014 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_MANAGE_PASSWORD_ITEM_VIEW_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORD_ITEM_VIEW_CONTROLLER_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/password_manager_ui.h"
13 #import "ui/base/cocoa/tracking_area.h"
17 } // namespace autofill
19 @class HoverImageButton;
20 class ManagePasswordsBubbleModel;
22 // The state of the password item.
23 enum ManagePasswordItemState {
24 MANAGE_PASSWORD_ITEM_STATE_PENDING,
25 MANAGE_PASSWORD_ITEM_STATE_MANAGE,
26 MANAGE_PASSWORD_ITEM_STATE_DELETED
29 // Abstract superclass for items that are clickable. Highlights on hover.
30 @interface ManagePasswordItemClickableView : NSView {
33 ui::ScopedCrTrackingArea trackingArea_;
37 // Shows the option to undelete a password.
38 @interface ManagePasswordItemUndoView : ManagePasswordItemClickableView {
40 base::scoped_nsobject<NSButton> undoButton_;
42 - (id)initWithTarget:(id)target action:(SEL)action;
45 @interface ManagePasswordItemUndoView (Testing)
46 @property(readonly) NSButton* undoButton;
49 // Shows a username, obscured password, and delete button in a single row.
50 @interface ManagePasswordItemManageView : ManagePasswordItemClickableView {
52 base::scoped_nsobject<NSTextField> usernameField_;
53 base::scoped_nsobject<NSSecureTextField> passwordField_;
54 base::scoped_nsobject<HoverImageButton> deleteButton_;
56 - (id)initWithForm:(const autofill::PasswordForm&)form
61 @interface ManagePasswordItemManageView (Testing)
62 @property(readonly) NSTextField* usernameField;
63 @property(readonly) NSSecureTextField* passwordField;
64 @property(readonly) NSButton* deleteButton;
67 // Shows a username and obscured password in a single row.
68 @interface ManagePasswordItemPendingView : NSView {
70 base::scoped_nsobject<NSTextField> usernameField_;
71 base::scoped_nsobject<NSSecureTextField> passwordField_;
73 - (id)initWithForm:(const autofill::PasswordForm&)form;
76 @interface ManagePasswordItemPendingView (Testing)
77 @property(readonly) NSTextField* usernameField;
78 @property(readonly) NSSecureTextField* passwordField;
81 // Shows a single item in a password management list. Transitions between
82 // PENDING, MANAGE, and DELETED states according to user interaction.
83 @interface ManagePasswordItemViewController : NSViewController {
85 ManagePasswordsBubbleModel* model_; // weak
86 autofill::PasswordForm passwordForm_;
87 ManagePasswordItemState state_;
88 password_manager::ui::PasswordItemPosition position_;
89 base::scoped_nsobject<NSView> contentView_;
91 - (id)initWithModel:(ManagePasswordsBubbleModel*)model
92 passwordForm:(const autofill::PasswordForm&)passwordForm
93 position:(password_manager::ui::PasswordItemPosition)position;
96 @interface ManagePasswordItemViewController (Testing)
97 @property(readonly) ManagePasswordItemState state;
98 @property(readonly) NSView* contentView;
99 @property(readonly) autofill::PasswordForm passwordForm;
102 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORD_ITEM_VIEW_CONTROLLER_H_