OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ |
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ | 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ |
7 | 7 |
8 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" | |
8 #include "components/autofill/core/common/password_form.h" | 9 #include "components/autofill/core/common/password_form.h" |
10 #include "components/password_manager/core/browser/password_manager_metrics_util .h" | |
9 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
10 | 12 |
11 class ManagePasswordsIconController; | 13 class ManagePasswordsIconController; |
12 | 14 |
13 namespace content { | 15 namespace content { |
14 class WebContents; | 16 class WebContents; |
15 } | 17 } |
16 | 18 |
17 // This model provides data for the ManagePasswordsBubble and controls the | 19 // This model provides data for the ManagePasswordsBubble and controls the |
18 // password management actions. | 20 // password management actions. |
19 class ManagePasswordsBubbleModel : public content::WebContentsObserver { | 21 class ManagePasswordsBubbleModel : public content::WebContentsObserver { |
20 public: | 22 public: |
21 explicit ManagePasswordsBubbleModel(content::WebContents* web_contents); | 23 explicit ManagePasswordsBubbleModel(content::WebContents* web_contents); |
vabr (Chromium)
2014/04/10 09:30:24
Would it make sense to comment on the default valu
Mike West
2014/04/10 09:53:46
Done.
| |
22 virtual ~ManagePasswordsBubbleModel(); | 24 virtual ~ManagePasswordsBubbleModel(); |
23 | 25 |
24 enum ManagePasswordsBubbleState { | 26 enum ManagePasswordsBubbleState { |
25 PASSWORD_TO_BE_SAVED, | 27 PASSWORD_TO_BE_SAVED, |
26 MANAGE_PASSWORDS_AFTER_SAVING, | 28 MANAGE_PASSWORDS_AFTER_SAVING, |
27 MANAGE_PASSWORDS, | 29 MANAGE_PASSWORDS, |
28 NEVER_SAVE_PASSWORDS, | 30 NEVER_SAVE_PASSWORDS, |
29 }; | 31 }; |
30 | 32 |
31 enum PasswordAction { REMOVE_PASSWORD, ADD_PASSWORD }; | 33 enum PasswordAction { REMOVE_PASSWORD, ADD_PASSWORD }; |
32 | 34 |
35 // Called by the view code when the bubble is shown. | |
36 void OnBubbleShown(ManagePasswordsBubble::DisplayReason reason); | |
37 | |
38 // Called by the view code when the bubble is hidden. | |
39 void OnBubbleHidden(); | |
40 | |
33 // Called by the view code when the "Nope" button in clicked by the user. | 41 // Called by the view code when the "Nope" button in clicked by the user. |
34 void OnNopeClicked(); | 42 void OnNopeClicked(); |
35 | 43 |
36 // Called by the view code when the "Never for this site." button in clicked | 44 // Called by the view code when the "Never for this site." button in clicked |
37 // by the user. | 45 // by the user. |
38 void OnNeverForThisSiteClicked(); | 46 void OnNeverForThisSiteClicked(); |
39 | 47 |
40 // Called by the view code when the save button in clicked by the user. | 48 // Called by the view code when the save button in clicked by the user. |
41 void OnSaveClicked(); | 49 void OnSaveClicked(); |
42 | 50 |
51 // Called by the view code when the "Done" button is clicked by the user. | |
52 void OnDoneClicked(); | |
53 | |
43 // Called by the view code when the manage link is clicked by the user. | 54 // Called by the view code when the manage link is clicked by the user. |
44 void OnManageLinkClicked(); | 55 void OnManageLinkClicked(); |
45 | 56 |
46 // Called by the view code to delete or add a password form to the | 57 // Called by the view code to delete or add a password form to the |
47 // PasswordStore. | 58 // PasswordStore. |
48 void OnPasswordAction(const autofill::PasswordForm& password_form, | 59 void OnPasswordAction(const autofill::PasswordForm& password_form, |
49 PasswordAction action); | 60 PasswordAction action); |
50 | 61 |
62 // Close the bubble without logging. | |
vabr (Chromium)
2014/04/10 09:30:24
nit: This does not really say more than the functi
| |
63 void OnCloseWithoutLogging(); | |
64 | |
51 // Called by the view code when the ManagePasswordItemView is destroyed and | 65 // Called by the view code when the ManagePasswordItemView is destroyed and |
52 // the user chose to delete the password. | 66 // the user chose to delete the password. |
53 // TODO(npentrel): Remove this once best_matches_ are newly made on bubble | 67 // TODO(npentrel): Remove this once best_matches_ are newly made on bubble |
54 // opening. | 68 // opening. |
55 void DeleteFromBestMatches(autofill::PasswordForm password_form); | 69 void DeleteFromBestMatches(autofill::PasswordForm password_form); |
56 | 70 |
57 ManagePasswordsBubbleState manage_passwords_bubble_state() { | 71 ManagePasswordsBubbleState manage_passwords_bubble_state() { |
58 return manage_passwords_bubble_state_; | 72 return manage_passwords_bubble_state_; |
59 } | 73 } |
60 | 74 |
61 bool WaitingToSavePassword() { | 75 bool WaitingToSavePassword() { |
62 return manage_passwords_bubble_state() == PASSWORD_TO_BE_SAVED; | 76 return manage_passwords_bubble_state() == PASSWORD_TO_BE_SAVED; |
63 } | 77 } |
64 | 78 |
65 bool password_submitted() { return password_submitted_; } | 79 bool password_submitted() { return password_submitted_; } |
66 const base::string16& title() { return title_; } | 80 const base::string16& title() { return title_; } |
67 const autofill::PasswordForm& pending_credentials() { | 81 const autofill::PasswordForm& pending_credentials() { |
68 return pending_credentials_; | 82 return pending_credentials_; |
69 } | 83 } |
70 const autofill::PasswordFormMap& best_matches() { return best_matches_; } | 84 const autofill::PasswordFormMap& best_matches() { return best_matches_; } |
71 const base::string16& manage_link() { return manage_link_; } | 85 const base::string16& manage_link() { return manage_link_; } |
72 | 86 |
87 // Gets and sets the reason the bubble was displayed. | |
88 password_manager::metrics_util::UIDisplayDisposition display_disposition() | |
89 const { | |
90 return display_disposition_; | |
91 } | |
92 void set_display_disposition( | |
vabr (Chromium)
2014/04/10 09:30:24
I might be mistaken, but all these 4 accessors onl
Mike West
2014/04/10 09:53:46
They're also used in the tests I haven't finished
vabr (Chromium)
2014/04/10 10:24:44
But then please mark them as for testing only, and
| |
93 password_manager::metrics_util::UIDisplayDisposition disposition) { | |
94 display_disposition_ = disposition; | |
95 } | |
96 | |
97 // Gets and sets the reason the bubble was dismissed. | |
98 password_manager::metrics_util::UIDismissalReason dismissal_reason() const { | |
99 return dismissal_reason_; | |
100 } | |
101 void set_dismissal_reason( | |
102 password_manager::metrics_util::UIDismissalReason reason) { | |
103 dismissal_reason_ = reason; | |
104 } | |
105 | |
73 private: | 106 private: |
74 // content::WebContentsObserver | 107 // content::WebContentsObserver |
75 virtual void WebContentsDestroyed( | 108 virtual void WebContentsDestroyed( |
76 content::WebContents* web_contents) OVERRIDE; | 109 content::WebContents* web_contents) OVERRIDE; |
77 | 110 |
78 content::WebContents* web_contents_; | 111 content::WebContents* web_contents_; |
79 ManagePasswordsBubbleState manage_passwords_bubble_state_; | 112 ManagePasswordsBubbleState manage_passwords_bubble_state_; |
80 bool password_submitted_; | 113 bool password_submitted_; |
81 base::string16 title_; | 114 base::string16 title_; |
82 autofill::PasswordForm pending_credentials_; | 115 autofill::PasswordForm pending_credentials_; |
83 autofill::PasswordFormMap best_matches_; | 116 autofill::PasswordFormMap best_matches_; |
84 base::string16 manage_link_; | 117 base::string16 manage_link_; |
85 | 118 |
119 password_manager::metrics_util::UIDisplayDisposition display_disposition_; | |
120 password_manager::metrics_util::UIDismissalReason dismissal_reason_; | |
121 | |
86 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); | 122 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); |
87 }; | 123 }; |
88 | 124 |
89 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ | 125 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ |
OLD | NEW |