OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_AUTOFILL_AUTOFILL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 #include <string> | 10 #include <string> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 AutoFillManager(TabContents* tab_contents, | 92 AutoFillManager(TabContents* tab_contents, |
93 PersonalDataManager* personal_data); | 93 PersonalDataManager* personal_data); |
94 void set_personal_data_manager(PersonalDataManager* personal_data) { | 94 void set_personal_data_manager(PersonalDataManager* personal_data) { |
95 personal_data_ = personal_data; | 95 personal_data_ = personal_data; |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 // Returns a list of values from the stored profiles that match |type| and the | 99 // Returns a list of values from the stored profiles that match |type| and the |
100 // value of |field| and returns the labels of the matching profiles. |labels| | 100 // value of |field| and returns the labels of the matching profiles. |labels| |
101 // is filled with the Profile label and possibly the last four digits of a | 101 // is filled with the Profile label and possibly the last four digits of a |
102 // corresponding credit card: 'Home; 1258' - Home is the Profile label and | 102 // corresponding credit card: 'Home; *1258' - Home is the Profile label and |
103 // 1258 is the last four digits of the credit card. If |include_cc_labels| is | 103 // 1258 is the last four digits of the credit card. If |include_cc_labels| is |
104 // true, check for billing fields and append CC digits to the labels; | 104 // true, check for billing fields and append CC digits to the labels; |
105 // otherwise, regular profiles are returned for billing address fields. | 105 // otherwise, regular profiles are returned for billing address fields. |
106 void GetProfileSuggestions(FormStructure* form, | 106 void GetProfileSuggestions(FormStructure* form, |
107 const webkit_glue::FormField& field, | 107 const webkit_glue::FormField& field, |
108 AutoFillType type, | 108 AutoFillType type, |
109 bool include_cc_labels, | 109 bool include_cc_labels, |
110 std::vector<string16>* values, | 110 std::vector<string16>* values, |
111 std::vector<string16>* labels, | 111 std::vector<string16>* labels, |
112 std::vector<int>* unique_ids); | 112 std::vector<int>* unique_ids); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 webkit_glue::FormField* field); | 156 webkit_glue::FormField* field); |
157 | 157 |
158 // Set |field| argument's value for phone number based on contents of the | 158 // Set |field| argument's value for phone number based on contents of the |
159 // |profile|. | 159 // |profile|. |
160 void FillPhoneNumberField(const AutoFillProfile* profile, | 160 void FillPhoneNumberField(const AutoFillProfile* profile, |
161 webkit_glue::FormField* field); | 161 webkit_glue::FormField* field); |
162 | 162 |
163 // Parses the forms using heuristic matching and querying the AutoFill server. | 163 // Parses the forms using heuristic matching and querying the AutoFill server. |
164 void ParseForms(const std::vector<webkit_glue::FormData>& forms); | 164 void ParseForms(const std::vector<webkit_glue::FormData>& forms); |
165 | 165 |
| 166 // Methods for packing and unpacking credit card and profile IDs for sending |
| 167 // and receiving to and from the renderer process. |
| 168 static int PackIDs(int cc_id, int profile_id); |
| 169 static void UnpackIDs(int id, int* cc_id, int* profile_id); |
| 170 |
166 // The TabContents hosting this AutoFillManager. | 171 // The TabContents hosting this AutoFillManager. |
167 // Weak reference. | 172 // Weak reference. |
168 // May not be NULL. | 173 // May not be NULL. |
169 TabContents* tab_contents_; | 174 TabContents* tab_contents_; |
170 | 175 |
171 // The personal data manager, used to save and load personal data to/from the | 176 // The personal data manager, used to save and load personal data to/from the |
172 // web database. This is overridden by the AutoFillManagerTest. | 177 // web database. This is overridden by the AutoFillManagerTest. |
173 // Weak reference. | 178 // Weak reference. |
174 // May be NULL. NULL indicates OTR. | 179 // May be NULL. NULL indicates OTR. |
175 PersonalDataManager* personal_data_; | 180 PersonalDataManager* personal_data_; |
176 | 181 |
177 // Handles queries and uploads to AutoFill servers. | 182 // Handles queries and uploads to AutoFill servers. |
178 AutoFillDownloadManager download_manager_; | 183 AutoFillDownloadManager download_manager_; |
179 | 184 |
180 // Our copy of the form data. | 185 // Our copy of the form data. |
181 ScopedVector<FormStructure> form_structures_; | 186 ScopedVector<FormStructure> form_structures_; |
182 | 187 |
183 // The form data the user has submitted. | 188 // The form data the user has submitted. |
184 scoped_ptr<FormStructure> upload_form_structure_; | 189 scoped_ptr<FormStructure> upload_form_structure_; |
185 | 190 |
186 // The InfoBar that asks for permission to store credit card information. | 191 // The InfoBar that asks for permission to store credit card information. |
187 scoped_ptr<AutoFillCCInfoBarDelegate> cc_infobar_; | 192 scoped_ptr<AutoFillCCInfoBarDelegate> cc_infobar_; |
188 | 193 |
| 194 friend class AutoFillManagerTest; |
| 195 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm); |
| 196 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillNonBillingFormSemicolon); |
| 197 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillBillFormSemicolon); |
| 198 |
189 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); | 199 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); |
190 }; | 200 }; |
191 | 201 |
192 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 202 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
OLD | NEW |