Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / autofill / core / browser / contact_info.cc
index 7571e5f..b320a81 100644 (file)
@@ -159,10 +159,13 @@ NameInfo& NameInfo::operator=(const NameInfo& info) {
   return *this;
 }
 
-bool NameInfo::EqualsIgnoreCase(const NameInfo& info) {
-  return (StringToLowerASCII(given_) == StringToLowerASCII(info.given_) &&
-          StringToLowerASCII(middle_) == StringToLowerASCII(info.middle_) &&
-          StringToLowerASCII(family_) == StringToLowerASCII(info.family_));
+bool NameInfo::ParsedNamesAreEqual(const NameInfo& info) {
+  return (base::StringToLowerASCII(given_) ==
+              base::StringToLowerASCII(info.given_) &&
+          base::StringToLowerASCII(middle_) ==
+              base::StringToLowerASCII(info.middle_) &&
+          base::StringToLowerASCII(family_) ==
+              base::StringToLowerASCII(info.family_));
 }
 
 void NameInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
@@ -189,7 +192,7 @@ base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
       return MiddleInitial();
 
     case NAME_FULL:
-      return FullName();
+      return full_;
 
     default:
       return base::string16();
@@ -199,10 +202,6 @@ base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
 void NameInfo::SetRawInfo(ServerFieldType type, const base::string16& value) {
   DCHECK_EQ(NAME, AutofillType(type).group());
 
-  // Always clear out the full name if we're making a change.
-  if (value != GetRawInfo(type))
-    full_.clear();
-
   switch (type) {
     case NAME_FIRST:
       given_ = value;
@@ -218,9 +217,7 @@ void NameInfo::SetRawInfo(ServerFieldType type, const base::string16& value) {
       break;
 
     case NAME_FULL:
-      // TODO(estade): this should just set |full_|; only SetInfo should attempt
-      // to be smart. http://crbug.com/384640
-      SetFullName(value);
+      full_ = value;
       break;
 
     default:
@@ -228,6 +225,29 @@ void NameInfo::SetRawInfo(ServerFieldType type, const base::string16& value) {
   }
 }
 
+base::string16 NameInfo::GetInfo(const AutofillType& type,
+                                 const std::string& app_locale) const {
+  if (type.GetStorableType() == NAME_FULL)
+    return FullName();
+
+  return GetRawInfo(type.GetStorableType());
+}
+
+bool NameInfo::SetInfo(const AutofillType& type,
+                       const base::string16& value,
+                       const std::string& app_locale) {
+  // Always clear out the full name if we're making a change.
+  if (value != GetInfo(type, app_locale))
+    full_.clear();
+
+  if (type.GetStorableType() == NAME_FULL) {
+    SetFullName(value);
+    return true;
+  }
+
+  return FormGroup::SetInfo(type, value, app_locale);
+}
+
 base::string16 NameInfo::FullName() const {
   if (!full_.empty())
     return full_;
@@ -256,14 +276,6 @@ base::string16 NameInfo::MiddleInitial() const {
 }
 
 void NameInfo::SetFullName(const base::string16& full) {
-  // Hack: don't do anything if this wouldn't change the full, concatenated
-  // name. Otherwise when unpickling data from the database, "First|Middle|"
-  // will get parsed as "First||Middle".
-  // TODO(estade): we should be able to remove this when fixing the TODO in
-  // SetRawInfo. http://crbug.com/384640
-  if (FullName() == full)
-    return;
-
   full_ = full;
 
   // If |full| is empty, leave the other name parts alone. This might occur