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

Side by Side Diff: components/password_manager/core/browser/password_manager.h

Issue 2900693002: [Password Manager] Convert |pending_login_managers_| to an array of scoped_refptr (Closed)
Patch Set: Rebase Created 3 years, 6 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_ 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void DropFormManagers(); 177 void DropFormManagers();
178 178
179 // Returns true if password element is detected on the current page. 179 // Returns true if password element is detected on the current page.
180 bool IsPasswordFieldDetectedOnPage(); 180 bool IsPasswordFieldDetectedOnPage();
181 181
182 PasswordManagerClient* client() { return client_; } 182 PasswordManagerClient* client() { return client_; }
183 183
184 #if defined(UNIT_TEST) 184 #if defined(UNIT_TEST)
185 // TODO(crbug.com/639786): Replace using this by quering the factory for 185 // TODO(crbug.com/639786): Replace using this by quering the factory for
186 // mocked PasswordFormManagers. 186 // mocked PasswordFormManagers.
187 const std::vector<std::unique_ptr<PasswordFormManager>>& 187 const std::vector<scoped_refptr<PasswordFormManager>>&
188 pending_login_managers() { 188 pending_login_managers() {
189 return pending_login_managers_; 189 return pending_login_managers_;
190 } 190 }
191 #endif 191 #endif
192 192
193 private: 193 private:
194 FRIEND_TEST_ALL_PREFIXES( 194 FRIEND_TEST_ALL_PREFIXES(
195 PasswordManagerTest, 195 PasswordManagerTest,
196 ShouldBlockPasswordForSameOriginButDifferentSchemeTest); 196 ShouldBlockPasswordForSameOriginButDifferentSchemeTest);
197 197
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // | new 259 // | new
260 // | ___ Infobar 260 // | ___ Infobar
261 // pending_login -- form submit --> provisional_save ___/ 261 // pending_login -- form submit --> provisional_save ___/
262 // ^ | \___ (update DB) 262 // ^ | \___ (update DB)
263 // | fail 263 // | fail
264 // |-----------<------<---------| !new 264 // |-----------<------<---------| !new
265 // 265 //
266 // When a form is "seen" on a page, a PasswordFormManager is created 266 // When a form is "seen" on a page, a PasswordFormManager is created
267 // and stored in this collection until user navigates away from page. 267 // and stored in this collection until user navigates away from page.
268 268
269 std::vector<std::unique_ptr<PasswordFormManager>> pending_login_managers_; 269 std::vector<scoped_refptr<PasswordFormManager>> pending_login_managers_;
270 270
271 // When the user submits a password/credential, this contains the 271 // When the user submits a password/credential, this contains the
272 // PasswordFormManager for the form in question until we deem the login 272 // PasswordFormManager for the form in question until we deem the login
273 // attempt to have succeeded (as in valid credentials). If it fails, we 273 // attempt to have succeeded (as in valid credentials). If it fails, we
274 // send the PasswordFormManager back to the pending_login_managers_ set. 274 // send the PasswordFormManager back to the pending_login_managers_ set.
275 // Scoped in case PasswordManager gets deleted (e.g tab closes) between the 275 // Scoped in case PasswordManager gets deleted (e.g tab closes) between the
276 // time a user submits a login form and gets to the next page. 276 // time a user submits a login form and gets to the next page.
277 std::unique_ptr<PasswordFormManager> provisional_save_manager_; 277 scoped_refptr<PasswordFormManager> provisional_save_manager_;
278 278
279 // The embedder-level client. Must outlive this class. 279 // The embedder-level client. Must outlive this class.
280 PasswordManagerClient* const client_; 280 PasswordManagerClient* const client_;
281 281
282 // Observers to be notified of LoginModel events. This is mutable to allow 282 // Observers to be notified of LoginModel events. This is mutable to allow
283 // notification in const member functions. 283 // notification in const member functions.
284 mutable base::ObserverList<LoginModelObserver> observers_; 284 mutable base::ObserverList<LoginModelObserver> observers_;
285 285
286 // Callbacks to be notified when a password form has been submitted. 286 // Callbacks to be notified when a password form has been submitted.
287 std::vector<PasswordSubmittedCallback> submission_callbacks_; 287 std::vector<PasswordSubmittedCallback> submission_callbacks_;
288 288
289 // Records all visible forms seen during a page load, in all frames of the 289 // Records all visible forms seen during a page load, in all frames of the
290 // page. When the page stops loading, the password manager checks if one of 290 // page. When the page stops loading, the password manager checks if one of
291 // the recorded forms matches the login form from the previous page 291 // the recorded forms matches the login form from the previous page
292 // (to see if the login was a failure), and clears the vector. 292 // (to see if the login was a failure), and clears the vector.
293 std::vector<autofill::PasswordForm> all_visible_forms_; 293 std::vector<autofill::PasswordForm> all_visible_forms_;
294 294
295 // The user-visible URL from the last time a password was provisionally saved. 295 // The user-visible URL from the last time a password was provisionally saved.
296 GURL main_frame_url_; 296 GURL main_frame_url_;
297 297
298 DISALLOW_COPY_AND_ASSIGN(PasswordManager); 298 DISALLOW_COPY_AND_ASSIGN(PasswordManager);
299 }; 299 };
300 300
301 } // namespace password_manager 301 } // namespace password_manager
302 302
303 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_ 303 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698