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

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

Issue 2926833002: Revert of [Password Manager] Convert |pending_login_managers_| to an array of scoped_refptr (Closed)
Patch Set: 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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/observer_list.h" 16 #include "base/observer_list.h"
18 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
19 #include "build/build_config.h" 18 #include "build/build_config.h"
20 #include "components/autofill/core/common/password_form.h" 19 #include "components/autofill/core/common/password_form.h"
21 #include "components/autofill/core/common/password_form_fill_data.h" 20 #include "components/autofill/core/common/password_form_fill_data.h"
22 #include "components/password_manager/core/browser/login_model.h" 21 #include "components/password_manager/core/browser/login_model.h"
23 #include "components/password_manager/core/browser/password_form_manager.h" 22 #include "components/password_manager/core/browser/password_form_manager.h"
24 23
25 class PrefRegistrySimple; 24 class PrefRegistrySimple;
26 25
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void DropFormManagers(); 177 void DropFormManagers();
179 178
180 // Returns true if password element is detected on the current page. 179 // Returns true if password element is detected on the current page.
181 bool IsPasswordFieldDetectedOnPage(); 180 bool IsPasswordFieldDetectedOnPage();
182 181
183 PasswordManagerClient* client() { return client_; } 182 PasswordManagerClient* client() { return client_; }
184 183
185 #if defined(UNIT_TEST) 184 #if defined(UNIT_TEST)
186 // 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
187 // mocked PasswordFormManagers. 186 // mocked PasswordFormManagers.
188 const std::vector<scoped_refptr<PasswordFormManager>>& 187 const std::vector<std::unique_ptr<PasswordFormManager>>&
189 pending_login_managers() { 188 pending_login_managers() {
190 return pending_login_managers_; 189 return pending_login_managers_;
191 } 190 }
192 #endif 191 #endif
193 192
194 private: 193 private:
195 FRIEND_TEST_ALL_PREFIXES( 194 FRIEND_TEST_ALL_PREFIXES(
196 PasswordManagerTest, 195 PasswordManagerTest,
197 ShouldBlockPasswordForSameOriginButDifferentSchemeTest); 196 ShouldBlockPasswordForSameOriginButDifferentSchemeTest);
198 197
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // | new 259 // | new
261 // | ___ Infobar 260 // | ___ Infobar
262 // pending_login -- form submit --> provisional_save ___/ 261 // pending_login -- form submit --> provisional_save ___/
263 // ^ | \___ (update DB) 262 // ^ | \___ (update DB)
264 // | fail 263 // | fail
265 // |-----------<------<---------| !new 264 // |-----------<------<---------| !new
266 // 265 //
267 // 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
268 // and stored in this collection until user navigates away from page. 267 // and stored in this collection until user navigates away from page.
269 268
270 std::vector<scoped_refptr<PasswordFormManager>> pending_login_managers_; 269 std::vector<std::unique_ptr<PasswordFormManager>> pending_login_managers_;
271 270
272 // When the user submits a password/credential, this contains the 271 // When the user submits a password/credential, this contains the
273 // PasswordFormManager for the form in question until we deem the login 272 // PasswordFormManager for the form in question until we deem the login
274 // 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
275 // send the PasswordFormManager back to the pending_login_managers_ set. 274 // send the PasswordFormManager back to the pending_login_managers_ set.
276 // 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
277 // 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.
278 scoped_refptr<PasswordFormManager> provisional_save_manager_; 277 std::unique_ptr<PasswordFormManager> provisional_save_manager_;
279 278
280 // The embedder-level client. Must outlive this class. 279 // The embedder-level client. Must outlive this class.
281 PasswordManagerClient* const client_; 280 PasswordManagerClient* const client_;
282 281
283 // 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
284 // notification in const member functions. 283 // notification in const member functions.
285 mutable base::ObserverList<LoginModelObserver> observers_; 284 mutable base::ObserverList<LoginModelObserver> observers_;
286 285
287 // Callbacks to be notified when a password form has been submitted. 286 // Callbacks to be notified when a password form has been submitted.
288 std::vector<PasswordSubmittedCallback> submission_callbacks_; 287 std::vector<PasswordSubmittedCallback> submission_callbacks_;
289 288
290 // 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
291 // 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
292 // the recorded forms matches the login form from the previous page 291 // the recorded forms matches the login form from the previous page
293 // (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.
294 std::vector<autofill::PasswordForm> all_visible_forms_; 293 std::vector<autofill::PasswordForm> all_visible_forms_;
295 294
296 // 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.
297 GURL main_frame_url_; 296 GURL main_frame_url_;
298 297
299 DISALLOW_COPY_AND_ASSIGN(PasswordManager); 298 DISALLOW_COPY_AND_ASSIGN(PasswordManager);
300 }; 299 };
301 300
302 } // namespace password_manager 301 } // namespace password_manager
303 302
304 #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