Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model.h

Issue 232753002: Password bubble: Deplatformify ManagePasswordsBubbleView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests!!! Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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);
22 virtual ~ManagePasswordsBubbleModel();
23
24 enum ManagePasswordsBubbleState { 23 enum ManagePasswordsBubbleState {
25 PASSWORD_TO_BE_SAVED, 24 PASSWORD_TO_BE_SAVED,
26 MANAGE_PASSWORDS_AFTER_SAVING, 25 MANAGE_PASSWORDS_AFTER_SAVING,
27 MANAGE_PASSWORDS, 26 MANAGE_PASSWORDS,
28 NEVER_SAVE_PASSWORDS, 27 NEVER_SAVE_PASSWORDS,
29 }; 28 };
30 29
31 enum PasswordAction { REMOVE_PASSWORD, ADD_PASSWORD }; 30 enum PasswordAction { REMOVE_PASSWORD, ADD_PASSWORD };
32 31
32 // Creates a ManagePasswordsBubbleModel, which holds a raw pointer to the
33 // WebContents in which it lives. Defaults to a display disposition of
34 // AUTOMATIC_WITH_PASSWORD_PENDING, and a dismissal reason of NOT_DISPLAYED.
35 // The bubble's state is updated from the ManagePasswordsBubbleUIController
36 // associated with |web_contents| upon creation.
37 explicit ManagePasswordsBubbleModel(content::WebContents* web_contents);
38 virtual ~ManagePasswordsBubbleModel();
39
40 // Called by the view code when the bubble is shown.
41 void OnBubbleShown(ManagePasswordsBubble::DisplayReason reason);
42
43 // Called by the view code when the bubble is hidden.
44 void OnBubbleHidden();
45
33 // Called by the view code when the "Nope" button in clicked by the user. 46 // Called by the view code when the "Nope" button in clicked by the user.
34 void OnNopeClicked(); 47 void OnNopeClicked();
35 48
36 // Called by the view code when the "Never for this site." button in clicked 49 // Called by the view code when the "Never for this site." button in clicked
37 // by the user. 50 // by the user.
38 void OnNeverForThisSiteClicked(); 51 void OnNeverForThisSiteClicked();
39 52
40 // Called by the view code when the save button in clicked by the user. 53 // Called by the view code when the save button in clicked by the user.
41 void OnSaveClicked(); 54 void OnSaveClicked();
42 55
56 // Called by the view code when the "Done" button is clicked by the user.
57 void OnDoneClicked();
58
43 // Called by the view code when the manage link is clicked by the user. 59 // Called by the view code when the manage link is clicked by the user.
44 void OnManageLinkClicked(); 60 void OnManageLinkClicked();
45 61
46 // Called by the view code to delete or add a password form to the 62 // Called by the view code to delete or add a password form to the
47 // PasswordStore. 63 // PasswordStore.
48 void OnPasswordAction(const autofill::PasswordForm& password_form, 64 void OnPasswordAction(const autofill::PasswordForm& password_form,
49 PasswordAction action); 65 PasswordAction action);
50 66
67 // Called by the view code when the bubble is closed without ever displaying
68 // content to the user. We shouldn't log to UMA in this case.
69 void OnCloseWithoutLogging();
70
51 // Called by the view code when the ManagePasswordItemView is destroyed and 71 // Called by the view code when the ManagePasswordItemView is destroyed and
52 // the user chose to delete the password. 72 // the user chose to delete the password.
53 // TODO(npentrel): Remove this once best_matches_ are newly made on bubble 73 // TODO(npentrel): Remove this once best_matches_ are newly made on bubble
54 // opening. 74 // opening.
55 void DeleteFromBestMatches(autofill::PasswordForm password_form); 75 void DeleteFromBestMatches(autofill::PasswordForm password_form);
56 76
57 ManagePasswordsBubbleState manage_passwords_bubble_state() { 77 ManagePasswordsBubbleState manage_passwords_bubble_state() {
58 return manage_passwords_bubble_state_; 78 return manage_passwords_bubble_state_;
59 } 79 }
60 80
61 bool WaitingToSavePassword() { 81 bool WaitingToSavePassword() {
62 return manage_passwords_bubble_state() == PASSWORD_TO_BE_SAVED; 82 return manage_passwords_bubble_state() == PASSWORD_TO_BE_SAVED;
63 } 83 }
64 84
65 bool password_submitted() { return password_submitted_; } 85 bool password_submitted() { return password_submitted_; }
66 const base::string16& title() { return title_; } 86 const base::string16& title() { return title_; }
67 const autofill::PasswordForm& pending_credentials() { 87 const autofill::PasswordForm& pending_credentials() {
68 return pending_credentials_; 88 return pending_credentials_;
69 } 89 }
70 const autofill::PasswordFormMap& best_matches() { return best_matches_; } 90 const autofill::PasswordFormMap& best_matches() { return best_matches_; }
71 const base::string16& manage_link() { return manage_link_; } 91 const base::string16& manage_link() { return manage_link_; }
72 92
93 // Gets and sets the reason the bubble was displayed; exposed for testing.
94 password_manager::metrics_util::UIDisplayDisposition display_disposition()
95 const {
96 return display_disposition_;
97 }
98
99 // Gets the reason the bubble was dismissed; exposed for testing.
100 password_manager::metrics_util::UIDismissalReason dismissal_reason() const {
101 return dismissal_reason_;
102 }
103
104 // State setter; exposed for testing.
105 void set_manage_passwords_bubble_state(ManagePasswordsBubbleState state) {
106 manage_passwords_bubble_state_ = state;
107 }
108
73 private: 109 private:
74 // content::WebContentsObserver 110 // content::WebContentsObserver
75 virtual void WebContentsDestroyed( 111 virtual void WebContentsDestroyed(
76 content::WebContents* web_contents) OVERRIDE; 112 content::WebContents* web_contents) OVERRIDE;
77 113
78 content::WebContents* web_contents_; 114 content::WebContents* web_contents_;
79 ManagePasswordsBubbleState manage_passwords_bubble_state_; 115 ManagePasswordsBubbleState manage_passwords_bubble_state_;
80 bool password_submitted_; 116 bool password_submitted_;
81 base::string16 title_; 117 base::string16 title_;
82 autofill::PasswordForm pending_credentials_; 118 autofill::PasswordForm pending_credentials_;
83 autofill::PasswordFormMap best_matches_; 119 autofill::PasswordFormMap best_matches_;
84 base::string16 manage_link_; 120 base::string16 manage_link_;
85 121
122 password_manager::metrics_util::UIDisplayDisposition display_disposition_;
123 password_manager::metrics_util::UIDismissalReason dismissal_reason_;
124
86 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); 125 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel);
87 }; 126 };
88 127
89 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ 128 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698