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

Side by Side Diff: chrome/browser/autofill/form_structure.cc

Issue 11539003: Pop up requestAutocomplete UI when autofill server hints chrome client that it is in a multipage au… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resolve with AutofillDialogController refactoring. Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/autofill/form_structure.h" 5 #include "chrome/browser/autofill/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"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 } // namespace 223 } // namespace
224 224
225 FormStructure::FormStructure(const FormData& form) 225 FormStructure::FormStructure(const FormData& form)
226 : form_name_(form.name), 226 : form_name_(form.name),
227 source_url_(form.origin), 227 source_url_(form.origin),
228 target_url_(form.action), 228 target_url_(form.action),
229 autofill_count_(0), 229 autofill_count_(0),
230 upload_required_(USE_UPLOAD_RATES), 230 upload_required_(USE_UPLOAD_RATES),
231 server_experiment_id_("no server response"), 231 server_experiment_id_("no server response"),
232 current_page_number_(-1),
233 total_pages_(-1),
232 has_author_specified_types_(false) { 234 has_author_specified_types_(false) {
233 // Copy the form fields. 235 // Copy the form fields.
234 std::map<string16, size_t> unique_names; 236 std::map<string16, size_t> unique_names;
235 for (std::vector<FormFieldData>::const_iterator field = 237 for (std::vector<FormFieldData>::const_iterator field =
236 form.fields.begin(); 238 form.fields.begin();
237 field != form.fields.end(); field++) { 239 field != form.fields.end(); field++) {
238 // Add all supported form fields (including with empty names) to the 240 // Add all supported form fields (including with empty names) to the
239 // signature. This is a requirement for Autofill servers. 241 // signature. This is a requirement for Autofill servers.
240 form_signature_field_names_.append("&"); 242 form_signature_field_names_.append("&");
241 form_signature_field_names_.append(UTF16ToUTF8(field->name)); 243 form_signature_field_names_.append(UTF16ToUTF8(field->name));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 bool heuristics_detected_fillable_field = false; 424 bool heuristics_detected_fillable_field = false;
423 bool query_response_overrode_heuristics = false; 425 bool query_response_overrode_heuristics = false;
424 426
425 // Copy the field types into the actual form. 427 // Copy the field types into the actual form.
426 std::vector<AutofillFieldType>::iterator current_type = field_types.begin(); 428 std::vector<AutofillFieldType>::iterator current_type = field_types.begin();
427 for (std::vector<FormStructure*>::const_iterator iter = forms.begin(); 429 for (std::vector<FormStructure*>::const_iterator iter = forms.begin();
428 iter != forms.end(); ++iter) { 430 iter != forms.end(); ++iter) {
429 FormStructure* form = *iter; 431 FormStructure* form = *iter;
430 form->upload_required_ = upload_required; 432 form->upload_required_ = upload_required;
431 form->server_experiment_id_ = experiment_id; 433 form->server_experiment_id_ = experiment_id;
434 form->current_page_number_ = parse_handler.current_page_number();
435 form->total_pages_ = parse_handler.total_pages();
432 436
433 for (std::vector<AutofillField*>::iterator field = form->fields_.begin(); 437 for (std::vector<AutofillField*>::iterator field = form->fields_.begin();
434 field != form->fields_.end(); ++field, ++current_type) { 438 field != form->fields_.end(); ++field, ++current_type) {
435 // In some cases *successful* response does not return all the fields. 439 // In some cases *successful* response does not return all the fields.
436 // Quit the update of the types then. 440 // Quit the update of the types then.
437 if (current_type == field_types.end()) 441 if (current_type == field_types.end())
438 break; 442 break;
439 443
440 // UNKNOWN_TYPE is reserved for use by the client. 444 // UNKNOWN_TYPE is reserved for use by the client.
441 DCHECK_NE(*current_type, UNKNOWN_TYPE); 445 DCHECK_NE(*current_type, UNKNOWN_TYPE);
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 // No errors encountered while parsing! 1013 // No errors encountered while parsing!
1010 // Update the |field|'s type based on what was parsed from the attribute. 1014 // Update the |field|'s type based on what was parsed from the attribute.
1011 field->set_heuristic_type(field_type); 1015 field->set_heuristic_type(field_type);
1012 if (field_type_token == "tel-local-prefix") 1016 if (field_type_token == "tel-local-prefix")
1013 field->set_phone_part(AutofillField::PHONE_PREFIX); 1017 field->set_phone_part(AutofillField::PHONE_PREFIX);
1014 else if (field_type_token == "tel-local-suffix") 1018 else if (field_type_token == "tel-local-suffix")
1015 field->set_phone_part(AutofillField::PHONE_SUFFIX); 1019 field->set_phone_part(AutofillField::PHONE_SUFFIX);
1016 } 1020 }
1017 } 1021 }
1018 1022
1023 bool FormStructure::IsStartOfAutofillableFlow() const {
1024 return current_page_number_ == 0 && total_pages_ > 0;
1025 }
1026
1027 bool FormStructure::IsInAutofillableFlow() const {
1028 return current_page_number_ >= 0 && current_page_number_ < total_pages_;
1029 }
1030
1019 void FormStructure::IdentifySections(bool has_author_specified_sections) { 1031 void FormStructure::IdentifySections(bool has_author_specified_sections) {
1020 if (fields_.empty()) 1032 if (fields_.empty())
1021 return; 1033 return;
1022 1034
1023 if (!has_author_specified_sections) { 1035 if (!has_author_specified_sections) {
1024 // Name sections after the first field in the section. 1036 // Name sections after the first field in the section.
1025 string16 current_section = fields_.front()->unique_name(); 1037 string16 current_section = fields_.front()->unique_name();
1026 1038
1027 // Keep track of the types we've seen in this section. 1039 // Keep track of the types we've seen in this section.
1028 std::set<AutofillFieldType> seen_types; 1040 std::set<AutofillFieldType> seen_types;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 for (std::vector<AutofillField*>::iterator field = fields_.begin(); 1083 for (std::vector<AutofillField*>::iterator field = fields_.begin();
1072 field != fields_.end(); ++field) { 1084 field != fields_.end(); ++field) {
1073 AutofillType::FieldTypeGroup field_type_group = 1085 AutofillType::FieldTypeGroup field_type_group =
1074 AutofillType((*field)->type()).group(); 1086 AutofillType((*field)->type()).group();
1075 if (field_type_group == AutofillType::CREDIT_CARD) 1087 if (field_type_group == AutofillType::CREDIT_CARD)
1076 (*field)->set_section((*field)->section() + "-cc"); 1088 (*field)->set_section((*field)->section() + "-cc");
1077 else 1089 else
1078 (*field)->set_section((*field)->section() + "-default"); 1090 (*field)->set_section((*field)->section() + "-default");
1079 } 1091 }
1080 } 1092 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/form_structure.h ('k') | chrome/browser/autofill/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698