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

Side by Side Diff: components/autofill/core/browser/password_autofill_manager.h

Issue 184103016: Autofill: Refactoring to support fetching password after a username is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor PasswordAutofillManager in password_manager component. Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_
7 7
8 // This file was contains some repeated code from 8 // This file was contains some repeated code from
9 // chrome/renderer/autofill/password_autofill_manager because as we move to the 9 // chrome/renderer/autofill/password_autofill_manager because as we move to the
10 // new Autofill UI we needs these functions in both the browser and renderer. 10 // new Autofill UI we needs these functions in both the browser and renderer.
11 // Once the move is completed the repeated code in the renderer half should be 11 // Once the move is completed the repeated code in the renderer half should be
12 // removed. 12 // removed.
13 // http://crbug.com/51644 13 // http://crbug.com/51644
14 14
15 #include <map> 15 #include <map>
16 16
17 #include "components/autofill/core/common/password_form_fill_data.h" 17 #include "components/autofill/core/common/password_form_fill_data.h"
18 18
19 class PasswordManagerClient;
20
19 namespace autofill { 21 namespace autofill {
20
21 class AutofillDriver; 22 class AutofillDriver;
23 }
22 24
23 // This class is responsible for filling password forms. 25 // This class is responsible for filling password forms.
24 class PasswordAutofillManager { 26 class PasswordAutofillManager {
25 public: 27 public:
26 explicit PasswordAutofillManager(AutofillDriver* autofill_driver); 28 PasswordAutofillManager(
29 PasswordManagerClient* password_manager_client,
30 AutofillDriver* autofill_driver);
27 virtual ~PasswordAutofillManager(); 31 virtual ~PasswordAutofillManager();
28 32
29 // Fills the password associated with user name |username|. Returns true if 33 // Fills the password associated with user name |username|.
30 // the username and password fields were filled, false otherwise. 34 void DidAcceptAutofillSuggestion(const FormFieldData& field,
31 bool DidAcceptAutofillSuggestion(const FormFieldData& field,
32 const base::string16& username); 35 const base::string16& username);
33 36
34 // Invoked when a password mapping is added. 37 // Invoked when a password mapping is added.
35 void AddPasswordFormMapping( 38 void AddPasswordFormMapping(
36 const FormFieldData& username_element, 39 const FormFieldData& username_element,
37 const PasswordFormFillData& password); 40 const PasswordFormFillData& password);
38 41
39 // Invoked to clear any page specific cached values. 42 // Invoked to clear any page specific cached values.
40 void Reset(); 43 void Reset();
41 44
42 private: 45 private:
43 // TODO(csharp): Modify the AutofillExternalDeletegate code so that it can 46 // TODO(csharp): Modify the AutofillExternalDeletegate code so that it can
44 // figure out if a entry is a password one without using this mapping. 47 // figure out if a entry is a password one without using this mapping.
45 // crbug.com/118601 48 // crbug.com/118601
46 typedef std::map<FormFieldData, 49 typedef std::map<FormFieldData, PasswordFormFillData> LoginToPasswordInfoMap;
47 PasswordFormFillData>
48 LoginToPasswordInfoMap;
49 50
50 // Returns true if |current_username| matches a username for one of the 51 // If |current_username| matches a username for one of the login mappings in
51 // login mappings in |password|. 52 // |fill_data|, returns true and assigns the password to |out_password|.
52 bool WillFillUserNameAndPassword( 53 // Otherwise, returns false and leaves |out_password| untouched.
54 bool GetPasswordForUsername(
53 const base::string16& current_username, 55 const base::string16& current_username,
54 const PasswordFormFillData& password); 56 const PasswordFormFillData& fill_data,
57 base::string16* out_password);
55 58
56 // Finds login information for a |node| that was previously filled. 59 // Finds login information for a |node| that was previously filled.
57 bool FindLoginInfo(const FormFieldData& field, 60 bool FindLoginInfo(const FormFieldData& field,
58 PasswordFormFillData* found_password); 61 PasswordFormFillData* found_password);
59 62
60 // The logins we have filled so far with their associated info. 63 // The logins we have filled so far with their associated info.
61 LoginToPasswordInfoMap login_to_password_info_; 64 LoginToPasswordInfoMap login_to_password_info_;
62 65
66 // Provides embedder-level operations on passwords. Must outlive |this|.
67 PasswordManagerClient* const password_manager_client_; // weak
68
63 // Provides driver-level context to the shared code of the component. Must 69 // Provides driver-level context to the shared code of the component. Must
64 // outlive |this|. 70 // outlive |this|.
65 AutofillDriver* const autofill_driver_; // weak 71 AutofillDriver* const autofill_driver_; // weak
66 72
67 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); 73 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager);
68 }; 74 };
69 75
70 } // namespace autofill
71
72 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ 76 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698