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

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

Powered by Google App Engine
This is Rietveld 408576698