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

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 5 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 80 // Called when navigation occurs or the tab is closed. Takes the necessary
75 // override a previous call to BlacklistPassword(). 81 // action with the form's login based on the desired |password_action_|.
76 void SavePassword(); 82 void ApplyChange();
77 83
78 // Sets current password to be blacklisted when ApplyEdits() is called. Will 84 void set_password_action(PasswordAction password_action) {
79 // override a previous call to SavePassword(). 85 password_action_ = password_action;
80 void BlacklistPassword(); 86 }
81
82 // Persist changes from the latest call to either SavePassword() or
83 // BlacklistPassword().
84 void ApplyChange();
85 87
86 // Determines if the user opted to 'never remember' passwords for this form. 88 // Determines if the user opted to 'never remember' passwords for this form.
87 bool IsBlacklisted(); 89 bool IsBlacklisted();
88 90
89 // Used by PasswordManager to determine whether or not to display 91 // Used by PasswordManager to determine whether or not to display
90 // a SavePasswordBar when given the green light to save the PasswordForm 92 // a SavePasswordBar when given the green light to save the PasswordForm
91 // managed by this. 93 // managed by this.
92 bool IsNewLogin(); 94 bool IsNewLogin();
93 95
94 // Returns true if the current pending credentials were found using 96 // Returns true if the current pending credentials were found using
(...skipping 15 matching lines...) Expand all
110 112
111 // PasswordStoreConsumer implementation. 113 // PasswordStoreConsumer implementation.
112 virtual void OnPasswordStoreRequestDone( 114 virtual void OnPasswordStoreRequestDone(
113 CancelableRequestProvider::Handle handle, 115 CancelableRequestProvider::Handle handle,
114 const std::vector<autofill::PasswordForm*>& result) OVERRIDE; 116 const std::vector<autofill::PasswordForm*>& result) OVERRIDE;
115 virtual void OnGetPasswordStoreResults( 117 virtual void OnGetPasswordStoreResults(
116 const std::vector<autofill::PasswordForm*>& results) OVERRIDE; 118 const std::vector<autofill::PasswordForm*>& results) OVERRIDE;
117 119
118 // A user opted to 'never remember' passwords for this form. 120 // 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. 121 // 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. 122 // TODO: Make this private once we switch to the new UI.
122 void PermanentlyBlacklist(); 123 void PermanentlyBlacklist();
123 124
124 // If the user has submitted observed_form_, provisionally hold on to 125 // If the user has submitted observed_form_, provisionally hold on to
125 // the submitted credentials until we are told by PasswordManager whether 126 // the submitted credentials until we are told by PasswordManager whether
126 // or not the login was successful. |action| describes how we deal with 127 // or not the login was successful. |action| describes how we deal with
127 // possible usernames. If |action| is ALLOW_OTHER_POSSIBLE_USERNAMES we will 128 // possible usernames. If |action| is ALLOW_OTHER_POSSIBLE_USERNAMES we will
128 // treat a possible usernames match as a sign that our original heuristics 129 // 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 130 // were wrong and that the user selected the correct username from the
130 // Autofill UI. 131 // Autofill UI.
131 void ProvisionallySave(const autofill::PasswordForm& credentials, 132 void ProvisionallySave(const autofill::PasswordForm& credentials,
132 OtherPossibleUsernamesAction action); 133 OtherPossibleUsernamesAction action);
133 134
134 // Handles save-as-new or update of the form managed by this manager. 135 // 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 136 // Note the basic data of updated_credentials must match that of
136 // observed_form_ (e.g DoesManage(pending_credentials_) == true). 137 // observed_form_ (e.g DoesManage(pending_credentials_) == true).
137
138 // TODO: Make this private once we switch to the new UI. 138 // TODO: Make this private once we switch to the new UI.
139 void Save(); 139 void Save();
140 140
141 // Call these if/when we know the form submission worked or failed. 141 // Call these if/when we know the form submission worked or failed.
142 // These routines are used to update internal statistics ("ActionsTaken"). 142 // These routines are used to update internal statistics ("ActionsTaken").
143 void SubmitPassed(); 143 void SubmitPassed();
144 void SubmitFailed(); 144 void SubmitFailed();
145 145
146 // Return the username associated with the credentials. 146 // Return the username associated with the credentials.
147 const string16& associated_username() const { 147 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 300 // Web contents from which we get the RenderViewHost for sending messages to
301 // the corresponding renderer. 301 // the corresponding renderer.
302 content::WebContents* web_contents_; 302 content::WebContents* web_contents_;
303 303
304 // These three fields record the "ActionsTaken" by the browser and 304 // These three fields record the "ActionsTaken" by the browser and
305 // the user with this form, and the result. They are combined and 305 // the user with this form, and the result. They are combined and
306 // recorded in UMA when the manager is destroyed. 306 // recorded in UMA when the manager is destroyed.
307 ManagerAction manager_action_; 307 ManagerAction manager_action_;
308 UserAction user_action_; 308 UserAction user_action_;
309 SubmitResult submit_result_; 309 SubmitResult submit_result_;
310 bool should_save_password_; 310
311 bool should_blacklist_password_; 311 // Whether we should save, blacklist, or do nothing with this form's login
312 // on the next navigation or when the tab is closed.
313 PasswordAction password_action_;
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