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

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

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