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.
5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_
8 #include "components/autofill/core/common/password_form.h"
9 #include "content/public/browser/web_contents_observer.h"
11 class ManagePasswordsIconController
;
17 // This model provides data for the ManagePasswordsBubble and controls the
18 // password management actions.
19 class ManagePasswordsBubbleModel
: public content::WebContentsObserver
{
21 explicit ManagePasswordsBubbleModel(content::WebContents
* web_contents
);
22 virtual ~ManagePasswordsBubbleModel();
24 enum ManagePasswordsBubbleState
{
26 MANAGE_PASSWORDS_AFTER_SAVING
,
30 // Called by the view code when the cancel button in clicked by the user.
31 void OnCancelClicked();
33 // Called by the view code when the save button in clicked by the user.
36 // Called by the view code when the manage link is clicked by the user.
37 void OnManageLinkClicked();
39 // Called by the view code to delete or add a password form to the
41 void OnPasswordAction(autofill::PasswordForm password_form
, bool remove
);
43 // Called by the view code when the ManagePasswordItemView is destroyed and
44 // the user chose to delete the password.
45 // TODO(npentrel): Remove this once best_matches_ are newly made on bubble
47 void DeleteFromBestMatches(autofill::PasswordForm password_form
);
49 ManagePasswordsBubbleState
manage_passwords_bubble_state() {
50 return manage_passwords_bubble_state_
;
53 bool password_submitted() { return password_submitted_
; }
54 const base::string16
& title() { return title_
; }
55 const autofill::PasswordForm
& pending_credentials() {
56 return pending_credentials_
;
58 const autofill::PasswordFormMap
& best_matches() { return best_matches_
; }
59 const base::string16
& manage_link() { return manage_link_
; }
62 // content::WebContentsObserver
63 virtual void WebContentsDestroyed(
64 content::WebContents
* web_contents
) OVERRIDE
;
66 content::WebContents
* web_contents_
;
67 ManagePasswordsBubbleState manage_passwords_bubble_state_
;
68 bool password_submitted_
;
69 base::string16 title_
;
70 autofill::PasswordForm pending_credentials_
;
71 autofill::PasswordFormMap best_matches_
;
72 base::string16 manage_link_
;
74 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel
);
77 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_