| OLD | NEW | 
|---|
| 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 #include "components/autofill/core/browser/form_structure.h" | 5 #include "components/autofill/core/browser/form_structure.h" | 
| 6 | 6 | 
| 7 #include <utility> | 7 #include <utility> | 
| 8 | 8 | 
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" | 
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" | 
|  | 11 #include "base/i18n/case_conversion.h" | 
| 11 #include "base/logging.h" | 12 #include "base/logging.h" | 
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" | 
| 13 #include "base/sha1.h" | 14 #include "base/sha1.h" | 
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" | 
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" | 
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" | 
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" | 
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" | 
| 19 #include "components/autofill/core/browser/autofill_metrics.h" | 20 #include "components/autofill/core/browser/autofill_metrics.h" | 
| 20 #include "components/autofill/core/browser/autofill_type.h" | 21 #include "components/autofill/core/browser/autofill_type.h" | 
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1105                                      app_locale, | 1106                                      app_locale, | 
| 1106                                      field(i)); | 1107                                      field(i)); | 
| 1107         filled_something = true; | 1108         filled_something = true; | 
| 1108         break; | 1109         break; | 
| 1109       } | 1110       } | 
| 1110     } | 1111     } | 
| 1111   } | 1112   } | 
| 1112   return filled_something; | 1113   return filled_something; | 
| 1113 } | 1114 } | 
| 1114 | 1115 | 
|  | 1116 std::set<base::string16> FormStructure::PossibleValues(ServerFieldType type) { | 
|  | 1117   std::set<base::string16> values; | 
|  | 1118   AutofillType target_type(type); | 
|  | 1119   for (std::vector<AutofillField*>::iterator iter = fields_.begin(); | 
|  | 1120        iter != fields_.end(); ++iter) { | 
|  | 1121     AutofillField* field = *iter; | 
|  | 1122     if (field->Type().GetStorableType() != target_type.GetStorableType() || | 
|  | 1123         field->Type().group() != target_type.group()) { | 
|  | 1124       continue; | 
|  | 1125     } | 
|  | 1126 | 
|  | 1127     // No option values; anything goes. | 
|  | 1128     if (field->option_values.empty()) | 
|  | 1129       return std::set<base::string16>(); | 
|  | 1130 | 
|  | 1131     for (size_t i = 0; i < field->option_values.size(); ++i) { | 
|  | 1132       values.insert(base::i18n::ToUpper(field->option_values[i])); | 
|  | 1133     } | 
|  | 1134 | 
|  | 1135     for (size_t i = 0; i < field->option_contents.size(); ++i) { | 
|  | 1136       values.insert(base::i18n::ToUpper(field->option_contents[i])); | 
|  | 1137     } | 
|  | 1138   } | 
|  | 1139 | 
|  | 1140   return values; | 
|  | 1141 } | 
|  | 1142 | 
| 1115 void FormStructure::IdentifySections(bool has_author_specified_sections) { | 1143 void FormStructure::IdentifySections(bool has_author_specified_sections) { | 
| 1116   if (fields_.empty()) | 1144   if (fields_.empty()) | 
| 1117     return; | 1145     return; | 
| 1118 | 1146 | 
| 1119   if (!has_author_specified_sections) { | 1147   if (!has_author_specified_sections) { | 
| 1120     // Name sections after the first field in the section. | 1148     // Name sections after the first field in the section. | 
| 1121     base::string16 current_section = fields_.front()->unique_name(); | 1149     base::string16 current_section = fields_.front()->unique_name(); | 
| 1122 | 1150 | 
| 1123     // Keep track of the types we've seen in this section. | 1151     // Keep track of the types we've seen in this section. | 
| 1124     std::set<ServerFieldType> seen_types; | 1152     std::set<ServerFieldType> seen_types; | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1167        field != fields_.end(); ++field) { | 1195        field != fields_.end(); ++field) { | 
| 1168     FieldTypeGroup field_type_group = (*field)->Type().group(); | 1196     FieldTypeGroup field_type_group = (*field)->Type().group(); | 
| 1169     if (field_type_group == CREDIT_CARD) | 1197     if (field_type_group == CREDIT_CARD) | 
| 1170       (*field)->set_section((*field)->section() + "-cc"); | 1198       (*field)->set_section((*field)->section() + "-cc"); | 
| 1171     else | 1199     else | 
| 1172       (*field)->set_section((*field)->section() + "-default"); | 1200       (*field)->set_section((*field)->section() + "-default"); | 
| 1173   } | 1201   } | 
| 1174 } | 1202 } | 
| 1175 | 1203 | 
| 1176 }  // namespace autofill | 1204 }  // namespace autofill | 
| OLD | NEW | 
|---|