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

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

Issue 11264053: Added switch to guard all autofill new elements work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/sha1.h" 13 #include "base/sha1.h"
13 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
14 #include "base/string_util.h" 15 #include "base/string_util.h"
15 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
16 #include "base/time.h" 17 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "chrome/common/chrome_switches.h"
18 #include "chrome/browser/autofill/autofill_metrics.h" 20 #include "chrome/browser/autofill/autofill_metrics.h"
19 #include "chrome/browser/autofill/autofill_type.h" 21 #include "chrome/browser/autofill/autofill_type.h"
20 #include "chrome/browser/autofill/autofill_xml_parser.h" 22 #include "chrome/browser/autofill/autofill_xml_parser.h"
21 #include "chrome/browser/autofill/field_types.h" 23 #include "chrome/browser/autofill/field_types.h"
22 #include "chrome/browser/autofill/form_field.h" 24 #include "chrome/browser/autofill/form_field.h"
23 #include "chrome/common/form_data.h" 25 #include "chrome/common/form_data.h"
24 #include "chrome/common/form_data_predictions.h" 26 #include "chrome/common/form_data_predictions.h"
25 #include "chrome/common/form_field_data.h" 27 #include "chrome/common/form_field_data.h"
26 #include "chrome/common/form_field_data_predictions.h" 28 #include "chrome/common/form_field_data_predictions.h"
27 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 29 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 502 }
501 503
502 std::string form_string = scheme + "://" + host + "&" + 504 std::string form_string = scheme + "://" + host + "&" +
503 UTF16ToUTF8(form_name_) + 505 UTF16ToUTF8(form_name_) +
504 form_signature_field_names_; 506 form_signature_field_names_;
505 507
506 return Hash64Bit(form_string); 508 return Hash64Bit(form_string);
507 } 509 }
508 510
509 bool FormStructure::IsAutofillable(bool require_method_post) const { 511 bool FormStructure::IsAutofillable(bool require_method_post) const {
512 // TODO(ramankk): Remove this check once we have better way of identifying the
513 // cases to trigger experimental form filling.
514 if (CommandLine::ForCurrentProcess()->HasSwitch(
515 switches::kEnableExperimentalFormFilling))
516 return true;
517
510 if (autofill_count() < kRequiredFillableFields) 518 if (autofill_count() < kRequiredFillableFields)
511 return false; 519 return false;
512 520
513 return ShouldBeParsed(require_method_post); 521 return ShouldBeParsed(require_method_post);
514 } 522 }
515 523
516 void FormStructure::UpdateAutofillCount() { 524 void FormStructure::UpdateAutofillCount() {
517 autofill_count_ = 0; 525 autofill_count_ = 0;
518 for (std::vector<AutofillField*>::const_iterator iter = begin(); 526 for (std::vector<AutofillField*>::const_iterator iter = begin();
519 iter != end(); ++iter) { 527 iter != end(); ++iter) {
520 AutofillField* field = *iter; 528 AutofillField* field = *iter;
521 if (field && field->IsFieldFillable()) 529 if (field && field->IsFieldFillable())
522 ++autofill_count_; 530 ++autofill_count_;
523 } 531 }
524 } 532 }
525 533
526 bool FormStructure::ShouldBeParsed(bool require_method_post) const { 534 bool FormStructure::ShouldBeParsed(bool require_method_post) const {
535 // TODO(ramankk): Remove this check once we have better way of identifying the
536 // cases to trigger experimental form filling.
537 if (CommandLine::ForCurrentProcess()->HasSwitch(
538 switches::kEnableExperimentalFormFilling))
539 return true;
540
527 if (field_count() < kRequiredFillableFields) 541 if (field_count() < kRequiredFillableFields)
528 return false; 542 return false;
529 543
530 // Rule out http(s)://*/search?... 544 // Rule out http(s)://*/search?...
531 // e.g. http://www.google.com/search?q=... 545 // e.g. http://www.google.com/search?q=...
532 // http://search.yahoo.com/search?p=... 546 // http://search.yahoo.com/search?p=...
533 if (target_url_.path() == "/search") 547 if (target_url_.path() == "/search")
534 return false; 548 return false;
535 549
536 // Make sure there as at least one text field. 550 // Make sure there as at least one text field.
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 for (std::vector<AutofillField*>::iterator field = fields_.begin(); 1043 for (std::vector<AutofillField*>::iterator field = fields_.begin();
1030 field != fields_.end(); ++field) { 1044 field != fields_.end(); ++field) {
1031 AutofillType::FieldTypeGroup field_type_group = 1045 AutofillType::FieldTypeGroup field_type_group =
1032 AutofillType((*field)->type()).group(); 1046 AutofillType((*field)->type()).group();
1033 if (field_type_group == AutofillType::CREDIT_CARD) 1047 if (field_type_group == AutofillType::CREDIT_CARD)
1034 (*field)->set_section((*field)->section() + "-cc"); 1048 (*field)->set_section((*field)->section() + "-cc");
1035 else 1049 else
1036 (*field)->set_section((*field)->section() + "-default"); 1050 (*field)->set_section((*field)->section() + "-default");
1037 } 1051 }
1038 } 1052 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698