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