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

Unified Diff: components/autofill/core/browser/autofill_type.h

Issue 22040002: [Autofill] Add a separate enumeration for HTML field type hints. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add docs Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_type.h
diff --git a/components/autofill/core/browser/autofill_type.h b/components/autofill/core/browser/autofill_type.h
index 7d77538d0dde2f1aba4257af4a05124209649a35..ffc9db502aa1f84f2d3ca5157a015c2ed92a5bf4 100644
--- a/components/autofill/core/browser/autofill_type.h
+++ b/components/autofill/core/browser/autofill_type.h
@@ -16,31 +16,54 @@ namespace autofill {
class AutofillType {
public:
explicit AutofillType(NativeFieldType field_type);
+ AutofillType(HtmlFieldType field_type, HtmlFieldMode mode);
AutofillType(const AutofillType& autofill_type);
AutofillType& operator=(const AutofillType& autofill_type);
- // TODO(isherman): Audit all uses of this method.
- NativeFieldType native_type() const { return native_type_; }
FieldTypeGroup group() const;
- // Maps |field_type| to a field type that can be directly stored in a profile
- // (in the sense that it makes sense to call |AutofillProfile::SetInfo()| with
- // the returned field type as the first parameter).
- static NativeFieldType GetEquivalentFieldType(NativeFieldType field_type);
+ // Returns true if both the |native_type_| and the |html_type_| are set to
+ // their respective enum's unknown value.
+ bool IsUnknown() const;
+
+ // Maps |this| type to a field type that can be directly stored in an Autofill
+ // data model (in the sense that it makes sense to call
+ // |AutofillDataModel::SetRawInfo()| with the returned field type as the first
+ // parameter). Returns UNKNOWN_TYPE if there is no direct mapping of |this|
+ // type to an equivalent storable type.
+ NativeFieldType GetEquivalentNativeType() const;
Evan Stade 2013/08/05 18:47:24 while "equivalent" was probably never the easiest
Ilya Sherman 2013/08/06 05:05:39 Done.
Evan Stade 2013/08/06 18:39:59 I was hoping for an api change which would make it
Ilya Sherman 2013/08/06 23:04:56 The sort of thing that could lead to a bug is e.g.
+
+ // Maps |this| type to a field type that can be directly stored in an Autofill
+ // data model (in the sense that it makes sense to call
+ // |AutofillDataModel::SetRawInfo()| with the returned field type as the first
+ // parameter). Unlike GetEquivalentNativeType(), this method returns the
+ // nearest storable type if there is no direct mapping of |this| type to an
+ // equivalent storable type.
Evan Stade 2013/08/05 18:47:24 it sounds like this guarantees you won't get UNKOW
Ilya Sherman 2013/08/06 05:05:39 Done.
+ NativeFieldType GetApproximateNativeFieldType() const;
+
+ // Serializes |this| type to a string.
+ std::string ToString() const;
// Maps |field_type| to a field type from ADDRESS_BILLING FieldTypeGroup if
// field type is an Address type.
+ // TODO(isherman): This method is only used by the
+ // AutofillDialogControllerImpl class. Consider moving it to a more focused
+ // location.
static NativeFieldType GetEquivalentBillingFieldType(
NativeFieldType field_type);
- // Utilities for serializing and deserializing a |NativeFieldType|.
- // TODO(isherman): This should probably serialize an HTML type as well.
- // Audit all uses of these functions.
- static std::string FieldTypeToString(NativeFieldType field_type);
+ // TODO(isherman): This method is only used be a single test class. Move the
+ // logic into there or something, eh?
static NativeFieldType StringToFieldType(const std::string& str);
private:
+ // The native field type, or UNKNOWN_TYPE if unset.
NativeFieldType native_type_;
+
+ // The HTML autocomplete field type and mode hints, or HTML_TYPE_UNKNOWN and
+ // HTML_MODE_NONE if unset.
+ HtmlFieldType html_type_;
+ HtmlFieldMode html_mode_;
};
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698