Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / passwords / manage_password_item_view_controller.h
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.
4
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_
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/core/common/password_manager_ui.h"
13 #import "ui/base/cocoa/tracking_area.h"
14
15 namespace autofill {
16 struct PasswordForm;
17 }  // namespace autofill
18
19 @class HoverImageButton;
20 class ManagePasswordsBubbleModel;
21
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
27 };
28
29 // Abstract superclass for items that are clickable. Highlights on hover.
30 @interface ManagePasswordItemClickableView : NSView {
31  @private
32   BOOL hovering_;
33   ui::ScopedCrTrackingArea trackingArea_;
34 }
35 @end
36
37 // Shows the option to undelete a password.
38 @interface ManagePasswordItemUndoView : ManagePasswordItemClickableView {
39  @private
40   base::scoped_nsobject<NSButton> undoButton_;
41 }
42 - (id)initWithTarget:(id)target action:(SEL)action;
43 @end
44
45 @interface ManagePasswordItemUndoView (Testing)
46 @property(readonly) NSButton* undoButton;
47 @end
48
49 // Shows a username, obscured password, and delete button in a single row.
50 @interface ManagePasswordItemManageView : ManagePasswordItemClickableView {
51  @private
52   base::scoped_nsobject<NSTextField> usernameField_;
53   base::scoped_nsobject<NSSecureTextField> passwordField_;
54   base::scoped_nsobject<HoverImageButton> deleteButton_;
55 }
56 - (id)initWithForm:(const autofill::PasswordForm&)form
57             target:(id)target
58             action:(SEL)action;
59 @end
60
61 @interface ManagePasswordItemManageView (Testing)
62 @property(readonly) NSTextField* usernameField;
63 @property(readonly) NSSecureTextField* passwordField;
64 @property(readonly) NSButton* deleteButton;
65 @end
66
67 // Shows a username and obscured password in a single row.
68 @interface ManagePasswordItemPendingView : NSView {
69  @private
70   base::scoped_nsobject<NSTextField> usernameField_;
71   base::scoped_nsobject<NSSecureTextField> passwordField_;
72 }
73 - (id)initWithForm:(const autofill::PasswordForm&)form;
74 @end
75
76 @interface ManagePasswordItemPendingView (Testing)
77 @property(readonly) NSTextField* usernameField;
78 @property(readonly) NSSecureTextField* passwordField;
79 @end
80
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 {
84  @private
85   ManagePasswordsBubbleModel* model_;  // weak
86   autofill::PasswordForm passwordForm_;
87   ManagePasswordItemState state_;
88   password_manager::ui::PasswordItemPosition position_;
89   base::scoped_nsobject<NSView> contentView_;
90 }
91 - (id)initWithModel:(ManagePasswordsBubbleModel*)model
92        passwordForm:(const autofill::PasswordForm&)passwordForm
93            position:(password_manager::ui::PasswordItemPosition)position;
94 @end
95
96 @interface ManagePasswordItemViewController (Testing)
97 @property(readonly) ManagePasswordItemState state;
98 @property(readonly) NSView* contentView;
99 @property(readonly) autofill::PasswordForm passwordForm;
100 @end
101
102 #endif  // CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORD_ITEM_VIEW_CONTROLLER_H_