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 { |
markusheintz_
2014/04/22 11:00:54
For future CLs: This class should not be called mo
Mike West
2014/04/22 11:57:39
Duly noted. :)
| |
20 public: | 22 public: |
21 explicit ManagePasswordsBubbleModel(content::WebContents* web_contents); | |
22 virtual ~ManagePasswordsBubbleModel(); | |
23 | |
24 enum ManagePasswordsBubbleState { | 23 enum ManagePasswordsBubbleState { |
25 PASSWORD_TO_BE_SAVED, | 24 PASSWORD_TO_BE_SAVED, |
26 MANAGE_PASSWORDS, | 25 MANAGE_PASSWORDS, |
27 NEVER_SAVE_PASSWORDS, | 26 NEVER_SAVE_PASSWORDS, |
28 }; | 27 }; |
29 | 28 |
30 enum PasswordAction { REMOVE_PASSWORD, ADD_PASSWORD }; | 29 enum PasswordAction { REMOVE_PASSWORD, ADD_PASSWORD }; |
31 | 30 |
31 // Creates a ManagePasswordsBubbleModel, which holds a raw pointer to the | |
32 // WebContents in which it lives. Defaults to a display disposition of | |
33 // AUTOMATIC_WITH_PASSWORD_PENDING, and a dismissal reason of NOT_DISPLAYED. | |
34 // The bubble's state is updated from the ManagePasswordsBubbleUIController | |
35 // associated with |web_contents| upon creation. | |
36 explicit ManagePasswordsBubbleModel(content::WebContents* web_contents); | |
37 virtual ~ManagePasswordsBubbleModel(); | |
38 | |
39 // Called by the view code when the bubble is shown. | |
40 void OnBubbleShown(ManagePasswordsBubble::DisplayReason reason); | |
41 | |
42 // Called by the view code when the bubble is hidden. | |
43 void OnBubbleHidden(); | |
44 | |
32 // Called by the view code when the "Nope" button in clicked by the user. | 45 // Called by the view code when the "Nope" button in clicked by the user. |
33 void OnNopeClicked(); | 46 void OnNopeClicked(); |
34 | 47 |
35 // Called by the view code when the "Never for this site." button in clicked | 48 // Called by the view code when the "Never for this site." button in clicked |
36 // by the user. | 49 // by the user. |
37 void OnNeverForThisSiteClicked(); | 50 void OnNeverForThisSiteClicked(); |
38 | 51 |
39 // Called by the view code when the save button in clicked by the user. | 52 // Called by the view code when the save button in clicked by the user. |
40 void OnSaveClicked(); | 53 void OnSaveClicked(); |
41 | 54 |
55 // Called by the view code when the "Done" button is clicked by the user. | |
56 void OnDoneClicked(); | |
57 | |
42 // Called by the view code when the manage link is clicked by the user. | 58 // Called by the view code when the manage link is clicked by the user. |
43 void OnManageLinkClicked(); | 59 void OnManageLinkClicked(); |
44 | 60 |
45 // Called by the view code to delete or add a password form to the | 61 // Called by the view code to delete or add a password form to the |
46 // PasswordStore. | 62 // PasswordStore. |
47 void OnPasswordAction(const autofill::PasswordForm& password_form, | 63 void OnPasswordAction(const autofill::PasswordForm& password_form, |
48 PasswordAction action); | 64 PasswordAction action); |
49 | 65 |
66 // Called by the view code when the bubble is closed without ever displaying | |
67 // content to the user. We shouldn't log to UMA in this case. | |
68 void OnCloseWithoutLogging(); | |
69 | |
50 ManagePasswordsBubbleState manage_passwords_bubble_state() { | 70 ManagePasswordsBubbleState manage_passwords_bubble_state() { |
51 return manage_passwords_bubble_state_; | 71 return manage_passwords_bubble_state_; |
52 } | 72 } |
53 | 73 |
54 bool WaitingToSavePassword() { | 74 bool WaitingToSavePassword() { |
55 return manage_passwords_bubble_state() == PASSWORD_TO_BE_SAVED; | 75 return manage_passwords_bubble_state() == PASSWORD_TO_BE_SAVED; |
56 } | 76 } |
57 | 77 |
58 const base::string16& title() { return title_; } | 78 const base::string16& title() { return title_; } |
59 const autofill::PasswordForm& pending_credentials() { | 79 const autofill::PasswordForm& pending_credentials() { |
60 return pending_credentials_; | 80 return pending_credentials_; |
61 } | 81 } |
62 const autofill::PasswordFormMap& best_matches() { return best_matches_; } | 82 const autofill::PasswordFormMap& best_matches() { return best_matches_; } |
63 const base::string16& manage_link() { return manage_link_; } | 83 const base::string16& manage_link() { return manage_link_; } |
64 | 84 |
85 // Gets and sets the reason the bubble was displayed; exposed for testing. | |
86 password_manager::metrics_util::UIDisplayDisposition display_disposition() | |
87 const { | |
88 return display_disposition_; | |
89 } | |
90 | |
91 // Gets the reason the bubble was dismissed; exposed for testing. | |
92 password_manager::metrics_util::UIDismissalReason dismissal_reason() const { | |
93 return dismissal_reason_; | |
94 } | |
95 | |
96 // State setter; exposed for testing. | |
97 void set_manage_passwords_bubble_state(ManagePasswordsBubbleState state) { | |
98 manage_passwords_bubble_state_ = state; | |
99 } | |
100 | |
65 private: | 101 private: |
66 // content::WebContentsObserver | 102 // content::WebContentsObserver |
67 virtual void WebContentsDestroyed( | 103 virtual void WebContentsDestroyed( |
68 content::WebContents* web_contents) OVERRIDE; | 104 content::WebContents* web_contents) OVERRIDE; |
69 | 105 |
70 content::WebContents* web_contents_; | 106 content::WebContents* web_contents_; |
71 ManagePasswordsBubbleState manage_passwords_bubble_state_; | 107 ManagePasswordsBubbleState manage_passwords_bubble_state_; |
72 base::string16 title_; | 108 base::string16 title_; |
73 autofill::PasswordForm pending_credentials_; | 109 autofill::PasswordForm pending_credentials_; |
74 autofill::PasswordFormMap best_matches_; | 110 autofill::PasswordFormMap best_matches_; |
75 base::string16 manage_link_; | 111 base::string16 manage_link_; |
76 | 112 |
113 password_manager::metrics_util::UIDisplayDisposition display_disposition_; | |
114 password_manager::metrics_util::UIDismissalReason dismissal_reason_; | |
115 | |
77 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); | 116 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); |
78 }; | 117 }; |
79 | 118 |
80 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ | 119 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ |
OLD | NEW |