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

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

Issue 11348273: [autofill] Fill in values on a successful run of interactive autocomplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: var rename Created 8 years 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 "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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 UTF16ToUTF8(form_name_) + 515 UTF16ToUTF8(form_name_) +
516 form_signature_field_names_; 516 form_signature_field_names_;
517 517
518 return Hash64Bit(form_string); 518 return Hash64Bit(form_string);
519 } 519 }
520 520
521 bool FormStructure::IsAutofillable(bool require_method_post) const { 521 bool FormStructure::IsAutofillable(bool require_method_post) const {
522 // TODO(ramankk): Remove this check once we have better way of identifying the 522 // TODO(ramankk): Remove this check once we have better way of identifying the
523 // cases to trigger experimental form filling. 523 // cases to trigger experimental form filling.
524 if (CommandLine::ForCurrentProcess()->HasSwitch( 524 if (CommandLine::ForCurrentProcess()->HasSwitch(
525 switches::kEnableExperimentalFormFilling)) 525 switches::kEnableExperimentalFormFilling))
526 return true; 526 return true;
527 527
528 if (autofill_count() < kRequiredFillableFields) 528 if (autofill_count() < kRequiredFillableFields)
529 return false; 529 return false;
530 530
531 return ShouldBeParsed(require_method_post); 531 return ShouldBeParsed(require_method_post);
532 } 532 }
533 533
534 void FormStructure::UpdateAutofillCount() { 534 void FormStructure::UpdateAutofillCount() {
535 autofill_count_ = 0; 535 autofill_count_ = 0;
536 for (std::vector<AutofillField*>::const_iterator iter = begin(); 536 for (std::vector<AutofillField*>::const_iterator iter = begin();
537 iter != end(); ++iter) { 537 iter != end(); ++iter) {
538 AutofillField* field = *iter; 538 AutofillField* field = *iter;
539 if (field && field->IsFieldFillable()) 539 if (field && field->IsFieldFillable())
540 ++autofill_count_; 540 ++autofill_count_;
541 } 541 }
542 } 542 }
543 543
544 bool FormStructure::ShouldBeParsed(bool require_method_post) const { 544 bool FormStructure::ShouldBeParsed(bool require_method_post) const {
545 // TODO(ramankk): Remove this check once we have better way of identifying the 545 // TODO(ramankk): Remove this check once we have better way of identifying the
546 // cases to trigger experimental form filling. 546 // cases to trigger experimental form filling.
547 if (CommandLine::ForCurrentProcess()->HasSwitch( 547 if (CommandLine::ForCurrentProcess()->HasSwitch(
548 switches::kEnableExperimentalFormFilling)) 548 switches::kEnableExperimentalFormFilling))
549 return true; 549 return true;
550 550
551 if (field_count() < kRequiredFillableFields) 551 if (field_count() < kRequiredFillableFields)
552 return false; 552 return false;
553 553
554 // Rule out http(s)://*/search?... 554 // Rule out http(s)://*/search?...
555 // e.g. http://www.google.com/search?q=... 555 // e.g. http://www.google.com/search?q=...
556 // http://search.yahoo.com/search?p=... 556 // http://search.yahoo.com/search?p=...
557 if (target_url_.path() == "/search") 557 if (target_url_.path() == "/search")
558 return false; 558 return false;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 } 807 }
808 808
809 size_t FormStructure::field_count() const { 809 size_t FormStructure::field_count() const {
810 return fields_.size(); 810 return fields_.size();
811 } 811 }
812 812
813 std::string FormStructure::server_experiment_id() const { 813 std::string FormStructure::server_experiment_id() const {
814 return server_experiment_id_; 814 return server_experiment_id_;
815 } 815 }
816 816
817 FormData FormStructure::ToFormData() const {
818 // |data.user_submitted| will always be false.
819 FormData data;
820 data.name = form_name_;
821 data.origin = source_url_;
822 data.action = target_url_;
823 data.method = ASCIIToUTF16(method_ == POST ? "POST" : "GET");
824
825 for (size_t i = 0; i < fields_.size(); ++i) {
826 data.fields.push_back(FormFieldData(*fields_[i]));
827 }
828
829 return data;
830 }
831
817 bool FormStructure::operator==(const FormData& form) const { 832 bool FormStructure::operator==(const FormData& form) const {
818 // TODO(jhawkins): Is this enough to differentiate a form? 833 // TODO(jhawkins): Is this enough to differentiate a form?
819 if (form_name_ == form.name && 834 if (form_name_ == form.name &&
820 source_url_ == form.origin && 835 source_url_ == form.origin &&
821 target_url_ == form.action) { 836 target_url_ == form.action) {
822 return true; 837 return true;
823 } 838 }
824 839
825 // TODO(jhawkins): Compare field names, IDs and labels once we have labels 840 // TODO(jhawkins): Compare field names, IDs and labels once we have labels
826 // set up. 841 // set up.
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 for (std::vector<AutofillField*>::iterator field = fields_.begin(); 1068 for (std::vector<AutofillField*>::iterator field = fields_.begin();
1054 field != fields_.end(); ++field) { 1069 field != fields_.end(); ++field) {
1055 AutofillType::FieldTypeGroup field_type_group = 1070 AutofillType::FieldTypeGroup field_type_group =
1056 AutofillType((*field)->type()).group(); 1071 AutofillType((*field)->type()).group();
1057 if (field_type_group == AutofillType::CREDIT_CARD) 1072 if (field_type_group == AutofillType::CREDIT_CARD)
1058 (*field)->set_section((*field)->section() + "-cc"); 1073 (*field)->set_section((*field)->section() + "-cc");
1059 else 1074 else
1060 (*field)->set_section((*field)->section() + "-default"); 1075 (*field)->set_section((*field)->section() + "-default");
1061 } 1076 }
1062 } 1077 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698