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

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

Issue 11000016: Move forms/ out of webkit/. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Response to review Created 8 years, 2 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/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/sha1.h" 12 #include "base/sha1.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/autofill/autofill_metrics.h" 18 #include "chrome/browser/autofill/autofill_metrics.h"
19 #include "chrome/browser/autofill/autofill_type.h" 19 #include "chrome/browser/autofill/autofill_type.h"
20 #include "chrome/browser/autofill/autofill_xml_parser.h" 20 #include "chrome/browser/autofill/autofill_xml_parser.h"
21 #include "chrome/browser/autofill/field_types.h" 21 #include "chrome/browser/autofill/field_types.h"
22 #include "chrome/browser/autofill/form_field.h" 22 #include "chrome/browser/autofill/form_field.h"
23 #include "chrome/common/form_data.h"
24 #include "chrome/common/form_data_predictions.h"
25 #include "chrome/common/form_field_data.h"
26 #include "chrome/common/form_field_data_predictions.h"
23 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 27 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
24 #include "webkit/forms/form_data.h"
25 #include "webkit/forms/form_data_predictions.h"
26 #include "webkit/forms/form_field.h"
27 #include "webkit/forms/form_field_predictions.h"
28
29 using webkit::forms::FormData;
30 using webkit::forms::FormDataPredictions;
31 using webkit::forms::FormFieldPredictions;
32 28
33 namespace { 29 namespace {
34 30
35 const char kFormMethodPost[] = "post"; 31 const char kFormMethodPost[] = "post";
36 32
37 // XML elements and attributes. 33 // XML elements and attributes.
38 const char kAttributeAcceptedFeatures[] = "accepts"; 34 const char kAttributeAcceptedFeatures[] = "accepts";
39 const char kAttributeAutofillUsed[] = "autofillused"; 35 const char kAttributeAutofillUsed[] = "autofillused";
40 const char kAttributeAutofillType[] = "autofilltype"; 36 const char kAttributeAutofillType[] = "autofilltype";
41 const char kAttributeClientVersion[] = "clientversion"; 37 const char kAttributeClientVersion[] = "clientversion";
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 FormStructure::FormStructure(const FormData& form) 233 FormStructure::FormStructure(const FormData& form)
238 : form_name_(form.name), 234 : form_name_(form.name),
239 source_url_(form.origin), 235 source_url_(form.origin),
240 target_url_(form.action), 236 target_url_(form.action),
241 autofill_count_(0), 237 autofill_count_(0),
242 upload_required_(USE_UPLOAD_RATES), 238 upload_required_(USE_UPLOAD_RATES),
243 server_experiment_id_("no server response"), 239 server_experiment_id_("no server response"),
244 has_author_specified_types_(false) { 240 has_author_specified_types_(false) {
245 // Copy the form fields. 241 // Copy the form fields.
246 std::map<string16, size_t> unique_names; 242 std::map<string16, size_t> unique_names;
247 for (std::vector<webkit::forms::FormField>::const_iterator field = 243 for (std::vector<FormFieldData>::const_iterator field =
248 form.fields.begin(); 244 form.fields.begin();
249 field != form.fields.end(); field++) { 245 field != form.fields.end(); field++) {
250 // Add all supported form fields (including with empty names) to the 246 // Add all supported form fields (including with empty names) to the
251 // signature. This is a requirement for Autofill servers. 247 // signature. This is a requirement for Autofill servers.
252 form_signature_field_names_.append("&"); 248 form_signature_field_names_.append("&");
253 form_signature_field_names_.append(UTF16ToUTF8(field->name)); 249 form_signature_field_names_.append(UTF16ToUTF8(field->name));
254 250
255 // Generate a unique name for this field by appending a counter to the name. 251 // Generate a unique name for this field by appending a counter to the name.
256 // Make sure to prepend the counter with a non-numeric digit so that we are 252 // Make sure to prepend the counter with a non-numeric digit so that we are
257 // guaranteed to avoid collisions. 253 // guaranteed to avoid collisions.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 form.data.method = 476 form.data.method =
481 ASCIIToUTF16((form_structure->method_ == POST) ? "POST" : "GET"); 477 ASCIIToUTF16((form_structure->method_ == POST) ? "POST" : "GET");
482 form.data.origin = form_structure->source_url_; 478 form.data.origin = form_structure->source_url_;
483 form.data.action = form_structure->target_url_; 479 form.data.action = form_structure->target_url_;
484 form.signature = form_structure->FormSignature(); 480 form.signature = form_structure->FormSignature();
485 form.experiment_id = form_structure->server_experiment_id_; 481 form.experiment_id = form_structure->server_experiment_id_;
486 482
487 for (std::vector<AutofillField*>::const_iterator field = 483 for (std::vector<AutofillField*>::const_iterator field =
488 form_structure->fields_.begin(); 484 form_structure->fields_.begin();
489 field != form_structure->fields_.end(); ++field) { 485 field != form_structure->fields_.end(); ++field) {
490 form.data.fields.push_back(webkit::forms::FormField(**field)); 486 form.data.fields.push_back(FormFieldData(**field));
491 487
492 FormFieldPredictions annotated_field; 488 FormFieldDataPredictions annotated_field;
493 annotated_field.signature = (*field)->FieldSignature(); 489 annotated_field.signature = (*field)->FieldSignature();
494 annotated_field.heuristic_type = 490 annotated_field.heuristic_type =
495 AutofillType::FieldTypeToString((*field)->heuristic_type()); 491 AutofillType::FieldTypeToString((*field)->heuristic_type());
496 annotated_field.server_type = 492 annotated_field.server_type =
497 AutofillType::FieldTypeToString((*field)->server_type()); 493 AutofillType::FieldTypeToString((*field)->server_type());
498 annotated_field.overall_type = 494 annotated_field.overall_type =
499 AutofillType::FieldTypeToString((*field)->type()); 495 AutofillType::FieldTypeToString((*field)->type());
500 form.fields.push_back(annotated_field); 496 form.fields.push_back(annotated_field);
501 } 497 }
502 498
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 for (std::vector<AutofillField*>::iterator field = fields_.begin(); 962 for (std::vector<AutofillField*>::iterator field = fields_.begin();
967 field != fields_.end(); ++field) { 963 field != fields_.end(); ++field) {
968 AutofillType::FieldTypeGroup field_type_group = 964 AutofillType::FieldTypeGroup field_type_group =
969 AutofillType((*field)->type()).group(); 965 AutofillType((*field)->type()).group();
970 if (field_type_group == AutofillType::CREDIT_CARD) 966 if (field_type_group == AutofillType::CREDIT_CARD)
971 (*field)->set_section((*field)->section() + ASCIIToUTF16("-cc")); 967 (*field)->set_section((*field)->section() + ASCIIToUTF16("-cc"));
972 else 968 else
973 (*field)->set_section((*field)->section() + ASCIIToUTF16("-default")); 969 (*field)->set_section((*field)->section() + ASCIIToUTF16("-default"));
974 } 970 }
975 } 971 }
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