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

Side by Side Diff: components/autofill/core/browser/form_structure.cc

Issue 178263004: rAc - Only show countries we're able to fill in. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android build Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 if (!field->option_values[i].empty())
1133 values.insert(base::i18n::ToUpper(field->option_values[i]));
1134 }
1135
1136 for (size_t i = 0; i < field->option_contents.size(); ++i) {
1137 if (!field->option_contents[i].empty())
1138 values.insert(base::i18n::ToUpper(field->option_contents[i]));
1139 }
1140 }
1141
1142 return values;
1143 }
1144
1115 void FormStructure::IdentifySections(bool has_author_specified_sections) { 1145 void FormStructure::IdentifySections(bool has_author_specified_sections) {
1116 if (fields_.empty()) 1146 if (fields_.empty())
1117 return; 1147 return;
1118 1148
1119 if (!has_author_specified_sections) { 1149 if (!has_author_specified_sections) {
1120 // Name sections after the first field in the section. 1150 // Name sections after the first field in the section.
1121 base::string16 current_section = fields_.front()->unique_name(); 1151 base::string16 current_section = fields_.front()->unique_name();
1122 1152
1123 // Keep track of the types we've seen in this section. 1153 // Keep track of the types we've seen in this section.
1124 std::set<ServerFieldType> seen_types; 1154 std::set<ServerFieldType> seen_types;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 field != fields_.end(); ++field) { 1197 field != fields_.end(); ++field) {
1168 FieldTypeGroup field_type_group = (*field)->Type().group(); 1198 FieldTypeGroup field_type_group = (*field)->Type().group();
1169 if (field_type_group == CREDIT_CARD) 1199 if (field_type_group == CREDIT_CARD)
1170 (*field)->set_section((*field)->section() + "-cc"); 1200 (*field)->set_section((*field)->section() + "-cc");
1171 else 1201 else
1172 (*field)->set_section((*field)->section() + "-default"); 1202 (*field)->set_section((*field)->section() + "-default");
1173 } 1203 }
1174 } 1204 }
1175 1205
1176 } // namespace autofill 1206 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_structure.h ('k') | components/autofill/core/browser/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698