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

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

Issue 6646051: Fix DCHECK, memory leak, and refactor PasswordStore to use CancelableRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use non-zero tests until http://crbug.com/77650 is addressed. Created 9 years, 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 13
14 #include "base/stl_util-inl.h" 14 #include "base/stl_util-inl.h"
15 #include "chrome/browser/password_manager/password_store.h" 15 #include "chrome/browser/password_manager/password_store_consumer.h"
16 #include "webkit/glue/password_form.h" 16 #include "webkit/glue/password_form.h"
17 17
18 class PasswordManager; 18 class PasswordManager;
19 class PasswordStore;
19 class Profile; 20 class Profile;
20 21
21 // Per-password-form-{on-page, dialog} class responsible for interactions 22 // Per-password-form-{on-page, dialog} class responsible for interactions
22 // between a given form, the per-tab PasswordManager, and the PasswordStore. 23 // between a given form, the per-tab PasswordManager, and the PasswordStore.
23 class PasswordFormManager : public PasswordStoreConsumer { 24 class PasswordFormManager : public PasswordStoreConsumer {
24 public: 25 public:
25 // profile contains the link to the PasswordStore and whether we're off 26 // profile contains the link to the PasswordStore and whether we're off
26 // the record 27 // the record
27 // password_manager owns this object 28 // password_manager owns this object
28 // form_on_page is the form that may be submitted and could need login data. 29 // form_on_page is the form that may be submitted and could need login data.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Checks if the form is a valid password form. Forms which lack either 66 // Checks if the form is a valid password form. Forms which lack either
66 // login or password field are not considered valid. 67 // login or password field are not considered valid.
67 bool HasValidPasswordForm(); 68 bool HasValidPasswordForm();
68 69
69 // Determines if we need to autofill given the results of the query. 70 // Determines if we need to autofill given the results of the query.
70 void OnRequestDone( 71 void OnRequestDone(
71 int handle, const std::vector<webkit_glue::PasswordForm*>& result); 72 int handle, const std::vector<webkit_glue::PasswordForm*>& result);
72 73
73 // PasswordStoreConsumer implementation. 74 // PasswordStoreConsumer implementation.
74 virtual void OnPasswordStoreRequestDone( 75 virtual void OnPasswordStoreRequestDone(
75 int handle, const std::vector<webkit_glue::PasswordForm*>& result); 76 CancelableRequestProvider::Handle handle,
77 const std::vector<webkit_glue::PasswordForm*>& result);
76 78
77 // A user opted to 'never remember' passwords for this form. 79 // A user opted to 'never remember' passwords for this form.
78 // Blacklist it so that from now on when it is seen we ignore it. 80 // Blacklist it so that from now on when it is seen we ignore it.
79 void PermanentlyBlacklist(); 81 void PermanentlyBlacklist();
80 82
81 // If the user has submitted observed_form_, provisionally hold on to 83 // If the user has submitted observed_form_, provisionally hold on to
82 // the submitted credentials until we are told by PasswordManager whether 84 // the submitted credentials until we are told by PasswordManager whether
83 // or not the login was successful. 85 // or not the login was successful.
84 void ProvisionallySave(const webkit_glue::PasswordForm& credentials); 86 void ProvisionallySave(const webkit_glue::PasswordForm& credentials);
85 87
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 kSubmitResultFailed, 131 kSubmitResultFailed,
130 kSubmitResultPassed, 132 kSubmitResultPassed,
131 kSubmitResultMax 133 kSubmitResultMax
132 }; 134 };
133 135
134 // The maximum number of combinations of the three preceding enums. 136 // The maximum number of combinations of the three preceding enums.
135 // This is used when recording the actions taken by the form in UMA. 137 // This is used when recording the actions taken by the form in UMA.
136 static const int kMaxNumActionsTaken = kManagerActionMax * kUserActionMax * 138 static const int kMaxNumActionsTaken = kManagerActionMax * kUserActionMax *
137 kSubmitResultMax; 139 kSubmitResultMax;
138 140
139 // Called by destructor to ensure if this object is deleted, no potential
140 // outstanding callbacks can call OnPasswordStoreRequestDone.
141 void CancelLoginsQuery();
142
143 // Helper for OnPasswordStoreRequestDone to determine whether or not 141 // Helper for OnPasswordStoreRequestDone to determine whether or not
144 // the given result form is worth scoring. 142 // the given result form is worth scoring.
145 bool IgnoreResult(const webkit_glue::PasswordForm& form) const; 143 bool IgnoreResult(const webkit_glue::PasswordForm& form) const;
146 144
147 // Helper for Save in the case that best_matches.size() == 0, meaning 145 // Helper for Save in the case that best_matches.size() == 0, meaning
148 // we have no prior record of this form/username/password and the user 146 // we have no prior record of this form/username/password and the user
149 // has opted to 'Save Password'. If |reset_preferred_login| is set, 147 // has opted to 'Save Password'. If |reset_preferred_login| is set,
150 // the previously preferred login from |best_matches_| will be reset. 148 // the previously preferred login from |best_matches_| will be reset.
151 void SaveAsNewLogin(bool reset_preferred_login); 149 void SaveAsNewLogin(bool reset_preferred_login);
152 150
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 webkit_glue::PasswordForm pending_credentials_; 188 webkit_glue::PasswordForm pending_credentials_;
191 189
192 // Whether pending_credentials_ stores a new login or is an update 190 // Whether pending_credentials_ stores a new login or is an update
193 // to an existing one. 191 // to an existing one.
194 bool is_new_login_; 192 bool is_new_login_;
195 193
196 // PasswordManager owning this. 194 // PasswordManager owning this.
197 const PasswordManager* const password_manager_; 195 const PasswordManager* const password_manager_;
198 196
199 // Handle to any pending PasswordStore::GetLogins query. 197 // Handle to any pending PasswordStore::GetLogins query.
200 int pending_login_query_; 198 CancelableRequestProvider::Handle pending_login_query_;
201 199
202 // Convenience pointer to entry in best_matches_ that is marked 200 // Convenience pointer to entry in best_matches_ that is marked
203 // as preferred. This is only allowed to be null if there are no best matches 201 // as preferred. This is only allowed to be null if there are no best matches
204 // at all, since there will always be one preferred login when there are 202 // at all, since there will always be one preferred login when there are
205 // multiple matches (when first saved, a login is marked preferred). 203 // multiple matches (when first saved, a login is marked preferred).
206 const webkit_glue::PasswordForm* preferred_match_; 204 const webkit_glue::PasswordForm* preferred_match_;
207 205
208 typedef enum { 206 typedef enum {
209 PRE_MATCHING_PHASE, // Have not yet invoked a GetLogins query to find 207 PRE_MATCHING_PHASE, // Have not yet invoked a GetLogins query to find
210 // matching login information from password store. 208 // matching login information from password store.
(...skipping 14 matching lines...) Expand all
225 // These three fields record the "ActionsTaken" by the browser and 223 // These three fields record the "ActionsTaken" by the browser and
226 // the user with this form, and the result. They are combined and 224 // the user with this form, and the result. They are combined and
227 // recorded in UMA when the manager is destroyed. 225 // recorded in UMA when the manager is destroyed.
228 ManagerAction manager_action_; 226 ManagerAction manager_action_;
229 UserAction user_action_; 227 UserAction user_action_;
230 SubmitResult submit_result_; 228 SubmitResult submit_result_;
231 229
232 DISALLOW_COPY_AND_ASSIGN(PasswordFormManager); 230 DISALLOW_COPY_AND_ASSIGN(PasswordFormManager);
233 }; 231 };
234 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_MANAGER_H_ 232 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/password_manager/password_form_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698