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

Side by Side Diff: chrome/browser/password_manager/password_form_manager.h

Issue 23537029: Save password functionality added to the save password bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review 1 Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PASSWORD_MANAGER_PASSWORD_FORM_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_MANAGER_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_MANAGER_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 enum ActionMatch { 42 enum ActionMatch {
43 ACTION_MATCH_REQUIRED, 43 ACTION_MATCH_REQUIRED,
44 ACTION_MATCH_NOT_REQUIRED 44 ACTION_MATCH_NOT_REQUIRED
45 }; 45 };
46 46
47 enum OtherPossibleUsernamesAction { 47 enum OtherPossibleUsernamesAction {
48 ALLOW_OTHER_POSSIBLE_USERNAMES, 48 ALLOW_OTHER_POSSIBLE_USERNAMES,
49 IGNORE_OTHER_POSSIBLE_USERNAMES 49 IGNORE_OTHER_POSSIBLE_USERNAMES
50 }; 50 };
51 51
52 enum PasswordAction {
53 DO_NOTHING,
54 SAVE,
55 BLACKLIST
56 };
57
52 // Compare basic data of observed_form_ with argument. Only check the action 58 // Compare basic data of observed_form_ with argument. Only check the action
53 // URL when action match is required. 59 // URL when action match is required.
54 bool DoesManage(const autofill::PasswordForm& form, 60 bool DoesManage(const autofill::PasswordForm& form,
55 ActionMatch action_match) const; 61 ActionMatch action_match) const;
56 62
57 // Retrieves potential matching logins from the database. 63 // Retrieves potential matching logins from the database.
58 void FetchMatchingLoginsFromPasswordStore(); 64 void FetchMatchingLoginsFromPasswordStore();
59 65
60 // Simple state-check to verify whether this object as received a callback 66 // Simple state-check to verify whether this object as received a callback
61 // from the PasswordStore and completed its matching phase. Note that the 67 // from the PasswordStore and completed its matching phase. Note that the
62 // callback in question occurs on the same (and only) main thread from which 68 // callback in question occurs on the same (and only) main thread from which
63 // instances of this class are ever used, but it is required since it is 69 // instances of this class are ever used, but it is required since it is
64 // conceivable that a user (or ui test) could attempt to submit a login 70 // conceivable that a user (or ui test) could attempt to submit a login
65 // prompt before the callback has occured, which would InvokeLater a call to 71 // prompt before the callback has occured, which would InvokeLater a call to
66 // PasswordManager::ProvisionallySave, which would interact with this object 72 // PasswordManager::ProvisionallySave, which would interact with this object
67 // before the db has had time to answer with matching password entries. 73 // before the db has had time to answer with matching password entries.
68 // This is intended to be a one-time check; if the return value is false the 74 // This is intended to be a one-time check; if the return value is false the
69 // expectation is caller will give up. This clearly won't work if you put it 75 // expectation is caller will give up. This clearly won't work if you put it
70 // in a loop and wait for matching to complete; you're (supposed to be) on 76 // in a loop and wait for matching to complete; you're (supposed to be) on
71 // the same thread! 77 // the same thread!
72 bool HasCompletedMatching(); 78 bool HasCompletedMatching();
73 79
74 // Sets current password to be saved when ApplyEdits() is called. Will
75 // override a previous call to BlacklistPassword().
76 void SavePassword();
77
78 // Sets current password to be blacklisted when ApplyEdits() is called. Will
79 // override a previous call to SavePassword().
80 void BlacklistPassword();
81
82 // Persist changes from the latest call to either SavePassword() or 80 // Persist changes from the latest call to either SavePassword() or
83 // BlacklistPassword(). 81 // BlacklistPassword().
84 void ApplyChange(); 82 void ApplyChange();
85 83
84 // Sets the state that remembers whether login credentials should be saved
85 // or blacklisted when the next navigation occurs or the tab is closed. In
86 // either scenario ApplyChange() is called.
Peter Kasting 2013/09/10 23:04:41 This comment is very confusing (poor wording). Co
npentrel 2013/09/11 09:10:42 Done.
87 void SetPasswordAction(PasswordAction password_action) {
88 password_action_ = password_action;
Peter Kasting 2013/09/10 23:04:41 Simple inlined setters should be named set_passwor
npentrel 2013/09/11 09:10:42 Done.
89 }
90
86 // Determines if the user opted to 'never remember' passwords for this form. 91 // Determines if the user opted to 'never remember' passwords for this form.
87 bool IsBlacklisted(); 92 bool IsBlacklisted();
88 93
89 // Used by PasswordManager to determine whether or not to display 94 // Used by PasswordManager to determine whether or not to display
90 // a SavePasswordBar when given the green light to save the PasswordForm 95 // a SavePasswordBar when given the green light to save the PasswordForm
91 // managed by this. 96 // managed by this.
92 bool IsNewLogin(); 97 bool IsNewLogin();
93 98
94 // Returns true if the current pending credentials were found using 99 // Returns true if the current pending credentials were found using
95 // origin matching of the public suffix, instead of the signon realm of the 100 // origin matching of the public suffix, instead of the signon realm of the
(...skipping 14 matching lines...) Expand all
110 115
111 // PasswordStoreConsumer implementation. 116 // PasswordStoreConsumer implementation.
112 virtual void OnPasswordStoreRequestDone( 117 virtual void OnPasswordStoreRequestDone(
113 CancelableRequestProvider::Handle handle, 118 CancelableRequestProvider::Handle handle,
114 const std::vector<autofill::PasswordForm*>& result) OVERRIDE; 119 const std::vector<autofill::PasswordForm*>& result) OVERRIDE;
115 virtual void OnGetPasswordStoreResults( 120 virtual void OnGetPasswordStoreResults(
116 const std::vector<autofill::PasswordForm*>& results) OVERRIDE; 121 const std::vector<autofill::PasswordForm*>& results) OVERRIDE;
117 122
118 // A user opted to 'never remember' passwords for this form. 123 // A user opted to 'never remember' passwords for this form.
119 // Blacklist it so that from now on when it is seen we ignore it. 124 // Blacklist it so that from now on when it is seen we ignore it.
120
121 // TODO: Make this private once we switch to the new UI. 125 // TODO: Make this private once we switch to the new UI.
122 void PermanentlyBlacklist(); 126 void PermanentlyBlacklist();
123 127
124 // If the user has submitted observed_form_, provisionally hold on to 128 // If the user has submitted observed_form_, provisionally hold on to
125 // the submitted credentials until we are told by PasswordManager whether 129 // the submitted credentials until we are told by PasswordManager whether
126 // or not the login was successful. |action| describes how we deal with 130 // or not the login was successful. |action| describes how we deal with
127 // possible usernames. If |action| is ALLOW_OTHER_POSSIBLE_USERNAMES we will 131 // possible usernames. If |action| is ALLOW_OTHER_POSSIBLE_USERNAMES we will
128 // treat a possible usernames match as a sign that our original heuristics 132 // treat a possible usernames match as a sign that our original heuristics
129 // were wrong and that the user selected the correct username from the 133 // were wrong and that the user selected the correct username from the
130 // Autofill UI. 134 // Autofill UI.
131 void ProvisionallySave(const autofill::PasswordForm& credentials, 135 void ProvisionallySave(const autofill::PasswordForm& credentials,
132 OtherPossibleUsernamesAction action); 136 OtherPossibleUsernamesAction action);
133 137
134 // Handles save-as-new or update of the form managed by this manager. 138 // Handles save-as-new or update of the form managed by this manager.
135 // Note the basic data of updated_credentials must match that of 139 // Note the basic data of updated_credentials must match that of
136 // observed_form_ (e.g DoesManage(pending_credentials_) == true). 140 // observed_form_ (e.g DoesManage(pending_credentials_) == true).
137
138 // TODO: Make this private once we switch to the new UI. 141 // TODO: Make this private once we switch to the new UI.
139 void Save(); 142 void Save();
140 143
141 // Call these if/when we know the form submission worked or failed. 144 // Call these if/when we know the form submission worked or failed.
142 // These routines are used to update internal statistics ("ActionsTaken"). 145 // These routines are used to update internal statistics ("ActionsTaken").
143 void SubmitPassed(); 146 void SubmitPassed();
144 void SubmitFailed(); 147 void SubmitFailed();
145 148
146 // Return the username associated with the credentials. 149 // Return the username associated with the credentials.
147 const string16& associated_username() const { 150 const string16& associated_username() const {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Web contents from which we get the RenderViewHost for sending messages to 303 // Web contents from which we get the RenderViewHost for sending messages to
301 // the corresponding renderer. 304 // the corresponding renderer.
302 content::WebContents* web_contents_; 305 content::WebContents* web_contents_;
303 306
304 // These three fields record the "ActionsTaken" by the browser and 307 // These three fields record the "ActionsTaken" by the browser and
305 // the user with this form, and the result. They are combined and 308 // the user with this form, and the result. They are combined and
306 // recorded in UMA when the manager is destroyed. 309 // recorded in UMA when the manager is destroyed.
307 ManagerAction manager_action_; 310 ManagerAction manager_action_;
308 UserAction user_action_; 311 UserAction user_action_;
309 SubmitResult submit_result_; 312 SubmitResult submit_result_;
310 bool should_save_password_; 313 PasswordAction password_action_;
311 bool should_blacklist_password_;
312 314
313 DISALLOW_COPY_AND_ASSIGN(PasswordFormManager); 315 DISALLOW_COPY_AND_ASSIGN(PasswordFormManager);
314 }; 316 };
315 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_MANAGER_H_ 317 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698