OLD | NEW |
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 COMPONENTS_AUTOFILL_BROWSER_FORM_GROUP_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_FORM_GROUP_H_ |
6 #define COMPONENTS_AUTOFILL_BROWSER_FORM_GROUP_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_FORM_GROUP_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | |
10 | 9 |
11 #include "base/string16.h" | 10 #include "base/string16.h" |
12 #include "base/string_util.h" | |
13 #include "components/autofill/browser/field_types.h" | 11 #include "components/autofill/browser/field_types.h" |
14 | 12 |
15 namespace autofill { | 13 namespace autofill { |
16 | 14 |
17 class AutofillField; | |
18 struct FormFieldData; | |
19 | |
20 // This class is an interface for collections of form fields, grouped by type. | 15 // This class is an interface for collections of form fields, grouped by type. |
21 // The information in objects of this class is managed by the | |
22 // PersonalDataManager. | |
23 class FormGroup { | 16 class FormGroup { |
24 public: | 17 public: |
25 virtual ~FormGroup() {} | 18 virtual ~FormGroup() {} |
26 | 19 |
27 // Returns a globally unique ID for this object. It is an error to call the | |
28 // default implementation. | |
29 virtual std::string GetGUID() const; | |
30 | |
31 // Used to determine the type of a field based on the text that a user enters | 20 // Used to determine the type of a field based on the text that a user enters |
32 // into the field, interpreted in the given |app_locale| if appropriate. The | 21 // into the field, interpreted in the given |app_locale| if appropriate. The |
33 // field types can then be reported back to the server. This method is | 22 // field types can then be reported back to the server. This method is |
34 // additive on |matching_types|. | 23 // additive on |matching_types|. |
35 virtual void GetMatchingTypes(const base::string16& text, | 24 virtual void GetMatchingTypes(const base::string16& text, |
36 const std::string& app_locale, | 25 const std::string& app_locale, |
37 FieldTypeSet* matching_types) const; | 26 FieldTypeSet* matching_types) const; |
38 | 27 |
39 // Returns a set of AutofillFieldTypes for which this FormGroup has non-empty | 28 // Returns a set of AutofillFieldTypes for which this FormGroup has non-empty |
40 // data. This method is additive on |non_empty_types|. | 29 // data. This method is additive on |non_empty_types|. |
(...skipping 14 matching lines...) Expand all Loading... |
55 // type of that field, localized to the given |app_locale| if appropriate. | 44 // type of that field, localized to the given |app_locale| if appropriate. |
56 virtual base::string16 GetInfo(AutofillFieldType type, | 45 virtual base::string16 GetInfo(AutofillFieldType type, |
57 const std::string& app_locale) const; | 46 const std::string& app_locale) const; |
58 | 47 |
59 // Used to populate this FormGroup object with data. Canonicalizes the data | 48 // Used to populate this FormGroup object with data. Canonicalizes the data |
60 // according to the specified |app_locale| prior to storing, if appropriate. | 49 // according to the specified |app_locale| prior to storing, if appropriate. |
61 virtual bool SetInfo(AutofillFieldType type, | 50 virtual bool SetInfo(AutofillFieldType type, |
62 const base::string16& value, | 51 const base::string16& value, |
63 const std::string& app_locale); | 52 const std::string& app_locale); |
64 | 53 |
65 // Set |field_data|'s value based on |field| and contents of |this| (using | |
66 // data variant |variant|). It is an error to call the default implementation. | |
67 virtual void FillFormField(const AutofillField& field, | |
68 size_t variant, | |
69 const std::string& app_locale, | |
70 FormFieldData* field_data) const; | |
71 | |
72 // Fills in select control with data matching |type| from |this|. | |
73 // Public for testing purposes. | |
74 void FillSelectControl(AutofillFieldType type, | |
75 const std::string& app_locale, | |
76 FormFieldData* field_data) const; | |
77 | |
78 protected: | 54 protected: |
79 // AutofillProfile needs to call into GetSupportedTypes() for objects of | 55 // AutofillProfile needs to call into GetSupportedTypes() for objects of |
80 // non-AutofillProfile type, for which mere inheritance is insufficient. | 56 // non-AutofillProfile type, for which mere inheritance is insufficient. |
81 friend class AutofillProfile; | 57 friend class AutofillProfile; |
82 | 58 |
83 // Returns a set of AutofillFieldTypes for which this FormGroup can store | 59 // Returns a set of AutofillFieldTypes for which this FormGroup can store |
84 // data. This method is additive on |supported_types|. | 60 // data. This method is additive on |supported_types|. |
85 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const = 0; | 61 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const = 0; |
86 | |
87 // Fills in a select control for a country from data in |this|. Returns true | |
88 // for success. | |
89 virtual bool FillCountrySelectControl(const std::string& app_locale, | |
90 FormFieldData* field_data) const; | |
91 }; | 62 }; |
92 | 63 |
93 } // namespace autofill | 64 } // namespace autofill |
94 | 65 |
95 #endif // COMPONENTS_AUTOFILL_BROWSER_FORM_GROUP_H_ | 66 #endif // COMPONENTS_AUTOFILL_BROWSER_FORM_GROUP_H_ |
OLD | NEW |