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

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

Issue 12852003: Autofill:Autocheckout: Enable looking at all elements for Autocheckout flow (ignoring 3 element lim… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments and more tests. Created 7 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 (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 "components/autofill/browser/form_structure.h" 5 #include "components/autofill/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"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 if (field && field->IsFieldFillable()) 606 if (field && field->IsFieldFillable())
607 ++autofill_count_; 607 ++autofill_count_;
608 } 608 }
609 } 609 }
610 610
611 bool FormStructure::ShouldBeParsed(bool require_method_post) const { 611 bool FormStructure::ShouldBeParsed(bool require_method_post) const {
612 // Ignore counting checkable elements towards minimum number of elements 612 // Ignore counting checkable elements towards minimum number of elements
613 // required to parse. This avoids trying to crowdsource forms with few text 613 // required to parse. This avoids trying to crowdsource forms with few text
614 // or select elements. 614 // or select elements.
615 if ((field_count() - checkable_field_count()) < RequiredFillableFields()) 615 if ((field_count() - checkable_field_count()) < RequiredFillableFields())
616 return false; 616 return false;
Ilya Sherman 2013/03/18 22:25:40 Did you intentionally move this code back?
Raman Kakilate 2013/03/18 22:36:01 Yes. RequiredFillableFields() does IsAutocheckoutE
617 617
618 // Rule out http(s)://*/search?... 618 // Rule out http(s)://*/search?...
619 // e.g. http://www.google.com/search?q=... 619 // e.g. http://www.google.com/search?q=...
620 // http://search.yahoo.com/search?p=... 620 // http://search.yahoo.com/search?p=...
621 if (target_url_.path() == "/search") 621 if (target_url_.path() == "/search")
622 return false; 622 return false;
623 623
624 if (!IsAutocheckoutEnabled()) { 624 if (!IsAutocheckoutEnabled()) {
625 // Make sure there is at least one text field when Autocheckout is 625 // Make sure there is at least one text field when Autocheckout is
626 // not enabled. 626 // not enabled.
627 bool has_text_field = false; 627 bool has_text_field = false;
628 for (std::vector<AutofillField*>::const_iterator it = begin(); 628 for (std::vector<AutofillField*>::const_iterator it = begin();
629 it != end() && !has_text_field; ++it) { 629 it != end() && !has_text_field; ++it) {
630 has_text_field |= (*it)->form_control_type != "select-one"; 630 has_text_field |= (*it)->form_control_type != "select-one";
631 } 631 }
632 if (!has_text_field) 632 if (!has_text_field)
633 return false; 633 return false;
634 } 634 }
635 635
636 return !require_method_post || (method_ == POST); 636 return !require_method_post || (method_ == POST);
637 } 637 }
638 638
639 bool FormStructure::ShouldBeCrowdsourced() const { 639 bool FormStructure::ShouldBeCrowdsourced() const {
640 return !has_author_specified_types_ && ShouldBeParsed(true); 640 // Allow all forms in Autocheckout flow to be crowdsourced.
641 return (!has_author_specified_types_ && ShouldBeParsed(true)) ||
642 IsAutocheckoutEnabled();
641 } 643 }
642 644
643 void FormStructure::UpdateFromCache(const FormStructure& cached_form) { 645 void FormStructure::UpdateFromCache(const FormStructure& cached_form) {
644 // Map from field signatures to cached fields. 646 // Map from field signatures to cached fields.
645 std::map<std::string, const AutofillField*> cached_fields; 647 std::map<std::string, const AutofillField*> cached_fields;
646 for (size_t i = 0; i < cached_form.field_count(); ++i) { 648 for (size_t i = 0; i < cached_form.field_count(); ++i) {
647 const AutofillField* field = cached_form.field(i); 649 const AutofillField* field = cached_form.field(i);
648 cached_fields[field->FieldSignature()] = field; 650 cached_fields[field->FieldSignature()] = field;
649 } 651 }
650 652
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 for (std::vector<AutofillField*>::iterator field = fields_.begin(); 1150 for (std::vector<AutofillField*>::iterator field = fields_.begin();
1149 field != fields_.end(); ++field) { 1151 field != fields_.end(); ++field) {
1150 AutofillType::FieldTypeGroup field_type_group = 1152 AutofillType::FieldTypeGroup field_type_group =
1151 AutofillType((*field)->type()).group(); 1153 AutofillType((*field)->type()).group();
1152 if (field_type_group == AutofillType::CREDIT_CARD) 1154 if (field_type_group == AutofillType::CREDIT_CARD)
1153 (*field)->set_section((*field)->section() + "-cc"); 1155 (*field)->set_section((*field)->section() + "-cc");
1154 else 1156 else
1155 (*field)->set_section((*field)->section() + "-default"); 1157 (*field)->set_section((*field)->section() + "-default");
1156 } 1158 }
1157 } 1159 }
OLDNEW
« no previous file with comments | « components/autofill/browser/autofill_manager_unittest.cc ('k') | components/autofill/browser/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698