Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / passwords / manage_password_item_view.h
1 // Copyright 2013 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_VIEWS_PASSWORDS_MANAGE_PASSWORD_ITEM_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORD_ITEM_VIEW_H_
7
8 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
9 #include "components/autofill/core/common/password_form.h"
10 #include "components/password_manager/core/common/password_manager_ui.h"
11
12 class ManagePasswordsBubbleModel;
13
14 namespace views {
15 class GridLayout;
16 class ImageButton;
17 }
18
19 // A custom view for credentials which allows the management of the specific
20 // credentials. The view has three distinct states:
21 //
22 // * Present credentials to the user which she may choose to save.
23 // * Present already-saved credentials to the user for management.
24 // * Offer the user the ability to undo a deletion action.
25 //
26 // The ManagePasswordItemView serves as a container for a single view
27 // representing one of these states.
28 class ManagePasswordItemView : public views::View {
29  public:
30   // Render credentials in two columns: username and password.
31   class PendingView : public views::View {
32    public:
33     explicit PendingView(ManagePasswordItemView* parent);
34
35    private:
36     virtual ~PendingView();
37   };
38
39   // Render credentials in three columns: username, password, and delete.
40   class ManageView : public views::View, public views::ButtonListener {
41    public:
42     explicit ManageView(ManagePasswordItemView* parent);
43
44    private:
45     virtual ~ManageView();
46
47     // views::ButtonListener:
48     virtual void ButtonPressed(views::Button* sender,
49                                const ui::Event& event) OVERRIDE;
50
51     views::ImageButton* delete_button_;
52     ManagePasswordItemView* parent_;
53   };
54
55   // Render a notification to the user that a password has been removed, and
56   // offer an undo link.
57   class UndoView : public views::View, public views::LinkListener {
58    public:
59     explicit UndoView(ManagePasswordItemView* parent);
60
61    private:
62     virtual ~UndoView();
63
64     // views::LinkListener:
65     virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
66
67     views::Link* undo_link_;
68     ManagePasswordItemView* parent_;
69   };
70
71   ManagePasswordItemView(
72       ManagePasswordsBubbleModel* manage_passwords_bubble_model,
73       autofill::PasswordForm password_form,
74       password_manager::ui::PasswordItemPosition position);
75
76  private:
77   virtual ~ManagePasswordItemView();
78
79   void NotifyClickedDelete();
80   void NotifyClickedUndo();
81
82   // Changes the views according to the state of |delete_password_|.
83   void Refresh();
84
85   ManagePasswordsBubbleModel* model_;
86   autofill::PasswordForm password_form_;
87   bool delete_password_;
88
89   DISALLOW_COPY_AND_ASSIGN(ManagePasswordItemView);
90 };
91
92 #endif  // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORD_ITEM_VIEW_H_