summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-03 00:30:59 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-03 00:30:59 +0000
commitb143821ab651df119648c0a201b6ab4bf616a500 (patch)
treebb9946d52d2d1937bbfc3d2de641a0fabca80c3f /chrome/browser/autofill
parent89098b14454bd3e9ec38c98084e1e0488de67fb3 (diff)
downloadchromium_src-b143821ab651df119648c0a201b6ab4bf616a500.zip
chromium_src-b143821ab651df119648c0a201b6ab4bf616a500.tar.gz
chromium_src-b143821ab651df119648c0a201b6ab4bf616a500.tar.bz2
AutoFill: Use the FormManager cache to send forms to the AutoFillManager.
Remove the FormFieldValues class and replace its usage with FormData. BUG=38325,33032 TEST=none Review URL: http://codereview.chromium.org/1606005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/address_field_unittest.cc2
-rw-r--r--chrome/browser/autofill/autofill_download_unittest.cc89
-rw-r--r--chrome/browser/autofill/autofill_manager.cc28
-rw-r--r--chrome/browser/autofill/autofill_manager.h8
-rw-r--r--chrome/browser/autofill/credit_card_field_unittest.cc2
-rw-r--r--chrome/browser/autofill/form_structure.cc16
-rw-r--r--chrome/browser/autofill/form_structure.h3
-rw-r--r--chrome/browser/autofill/form_structure_unittest.cc345
-rw-r--r--chrome/browser/autofill/phone_field_unittest.cc2
9 files changed, 243 insertions, 252 deletions
diff --git a/chrome/browser/autofill/address_field_unittest.cc b/chrome/browser/autofill/address_field_unittest.cc
index bbcbcf2..322e697 100644
--- a/chrome/browser/autofill/address_field_unittest.cc
+++ b/chrome/browser/autofill/address_field_unittest.cc
@@ -7,7 +7,7 @@
#include "chrome/browser/autofill/address_field.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
-#include "webkit/glue/form_field_values.h"
+#include "webkit/glue/form_field.h"
namespace {
diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc
index e1df3b8..fe09261a 100644
--- a/chrome/browser/autofill/autofill_download_unittest.cc
+++ b/chrome/browser/autofill/autofill_download_unittest.cc
@@ -11,8 +11,9 @@
#include "net/url_request/url_request_status.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
-#include "webkit/glue/form_field_values.h"
+#include "webkit/glue/form_data.h"
+using webkit_glue::FormData;
using WebKit::WebInputElement;
// This tests AutoFillDownloadManager. AutoFillDownloadTestHelper implements
@@ -99,52 +100,52 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
TestURLFetcherFactory factory;
URLFetcher::set_factory(&factory);
- webkit_glue::FormFieldValues values;
- values.method = ASCIIToUTF16("post");
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
- ASCIIToUTF16("username"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("email"),
- ASCIIToUTF16("email"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("email2"),
- ASCIIToUTF16("email2"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
- ASCIIToUTF16("password"),
- string16(),
- ASCIIToUTF16("password")));
- values.elements.push_back(webkit_glue::FormField(string16(),
- ASCIIToUTF16("Submit"),
- string16(),
- ASCIIToUTF16("submit")));
+ FormData form;
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
+ ASCIIToUTF16("username"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"),
+ ASCIIToUTF16("email"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email2"),
+ ASCIIToUTF16("email2"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
+ ASCIIToUTF16("password"),
+ string16(),
+ ASCIIToUTF16("password")));
+ form.fields.push_back(webkit_glue::FormField(string16(),
+ ASCIIToUTF16("Submit"),
+ string16(),
+ ASCIIToUTF16("submit")));
- FormStructure *form = new FormStructure(values);
+ FormStructure *form_structure = new FormStructure(form);
ScopedVector<FormStructure> form_structures;
- form_structures.push_back(form);
+ form_structures.push_back(form_structure);
- values.elements.clear();
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("address"),
- ASCIIToUTF16("address"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("address2"),
- ASCIIToUTF16("address2"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("city"),
- ASCIIToUTF16("address2"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(string16(),
- ASCIIToUTF16("Submit"),
- string16(),
- ASCIIToUTF16("submit")));
- form = new FormStructure(values);
- form_structures.push_back(form);
+ form.fields.clear();
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address"),
+ ASCIIToUTF16("address"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address2"),
+ ASCIIToUTF16("address2"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("city"),
+ ASCIIToUTF16("address2"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(string16(),
+ ASCIIToUTF16("Submit"),
+ string16(),
+ ASCIIToUTF16("submit")));
+ form_structure = new FormStructure(form);
+ form_structures.push_back(form_structure);
// Request with id 0.
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures));
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 5bed021..b651a97 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -19,7 +19,9 @@
#include "chrome/common/pref_names.h"
#include "webkit/glue/form_data.h"
#include "webkit/glue/form_field.h"
-#include "webkit/glue/form_field_values.h"
+
+using webkit_glue::FormData;
+using webkit_glue::FormField;
namespace {
// We only send a fraction of the forms to upload server.
@@ -68,8 +70,7 @@ void AutoFillManager::RegisterUserPrefs(PrefService* prefs) {
kAutoFillNegativeUploadRateDefaultValue);
}
-void AutoFillManager::FormFieldValuesSubmitted(
- const webkit_glue::FormFieldValues& form) {
+void AutoFillManager::FormSubmitted(const FormData& form) {
if (!IsAutoFillEnabled())
return;
@@ -95,29 +96,22 @@ void AutoFillManager::FormFieldValuesSubmitted(
}
}
-void AutoFillManager::FormsSeen(
- const std::vector<webkit_glue::FormFieldValues>& forms) {
+void AutoFillManager::FormsSeen(const std::vector<FormData>& forms) {
if (!IsAutoFillEnabled())
return;
- for (std::vector<webkit_glue::FormFieldValues>::const_iterator iter =
+ for (std::vector<FormData>::const_iterator iter =
forms.begin();
iter != forms.end(); ++iter) {
FormStructure* form_structure = new FormStructure(*iter);
DeterminePossibleFieldTypes(form_structure);
form_structures_.push_back(form_structure);
}
-
- // Only query the server for form data if the user has profile or
- // credit card data set up.
- if (!personal_data_->profiles().empty() ||
- !personal_data_->credit_cards().empty()) {
- download_manager_.StartQueryRequest(form_structures_);
- }
+ download_manager_.StartQueryRequest(form_structures_);
}
-bool AutoFillManager::GetAutoFillSuggestions(
- int query_id, const webkit_glue::FormField& field) {
+bool AutoFillManager::GetAutoFillSuggestions(int query_id,
+ const FormField& field) {
if (!IsAutoFillEnabled())
return false;
@@ -225,7 +219,7 @@ bool AutoFillManager::GetAutoFillSuggestions(
}
bool AutoFillManager::FillAutoFillFormData(int query_id,
- const webkit_glue::FormData& form,
+ const FormData& form,
const string16& name,
const string16& label) {
if (!IsAutoFillEnabled())
@@ -275,7 +269,7 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
if (!profile && !credit_card)
return false;
- webkit_glue::FormData result = form;
+ FormData result = form;
for (std::vector<FormStructure*>::const_iterator iter =
form_structures_.begin();
iter != form_structures_.end(); ++iter) {
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index d89d5da..b9eafbf 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -18,8 +18,7 @@
namespace webkit_glue {
struct FormData;
class FormField;
-class FormFieldValues;
-}
+} // namespace webkit_glue
class AutoFillInfoBarDelegate;
class AutoFillProfile;
@@ -45,10 +44,9 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
static void RegisterUserPrefs(PrefService* prefs);
// RenderViewHostDelegate::AutoFill implementation:
- virtual void FormFieldValuesSubmitted(
- const webkit_glue::FormFieldValues& form);
+ virtual void FormSubmitted(const webkit_glue::FormData& form);
virtual void FormsSeen(
- const std::vector<webkit_glue::FormFieldValues>& forms);
+ const std::vector<webkit_glue::FormData>& forms);
virtual bool GetAutoFillSuggestions(int query_id,
const webkit_glue::FormField& field);
virtual bool FillAutoFillFormData(int query_id,
diff --git a/chrome/browser/autofill/credit_card_field_unittest.cc b/chrome/browser/autofill/credit_card_field_unittest.cc
index efadf7a..dbd9923 100644
--- a/chrome/browser/autofill/credit_card_field_unittest.cc
+++ b/chrome/browser/autofill/credit_card_field_unittest.cc
@@ -6,7 +6,7 @@
#include "base/scoped_vector.h"
#include "chrome/browser/autofill/credit_card_field.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/glue/form_field_values.h"
+#include "webkit/glue/form_field.h"
namespace {
diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc
index d0f2a71..bb91ec9 100644
--- a/chrome/browser/autofill/form_structure.cc
+++ b/chrome/browser/autofill/form_structure.cc
@@ -14,10 +14,8 @@
#include "third_party/libjingle/files/talk/xmllite/xmlelement.h"
#include "webkit/glue/form_data.h"
#include "webkit/glue/form_field.h"
-#include "webkit/glue/form_field_values.h"
using webkit_glue::FormData;
-using webkit_glue::FormFieldValues;
namespace {
@@ -59,14 +57,14 @@ static std::string Hash64Bit(const std::string& str) {
} // namespace
-FormStructure::FormStructure(const FormFieldValues& values)
- : form_name_(UTF16ToUTF8(values.form_name)),
- source_url_(values.source_url),
- target_url_(values.target_url) {
+FormStructure::FormStructure(const FormData& form)
+ : form_name_(UTF16ToUTF8(form.name)),
+ source_url_(form.origin),
+ target_url_(form.action) {
// Copy the form fields.
std::vector<webkit_glue::FormField>::const_iterator field;
- for (field = values.elements.begin();
- field != values.elements.end(); field++) {
+ for (field = form.fields.begin();
+ field != form.fields.end(); field++) {
// We currently only handle text and select fields. This prevents us from
// thinking we can autofill other types of controls, e.g., password, hidden,
// submit.
@@ -87,7 +85,7 @@ FormStructure::FormStructure(const FormFieldValues& values)
// Terminate the vector with a NULL item.
fields_.push_back(NULL);
- std::string method = UTF16ToUTF8(values.method);
+ std::string method = UTF16ToUTF8(form.method);
if (method == kFormMethodPost) {
method_ = POST;
} else {
diff --git a/chrome/browser/autofill/form_structure.h b/chrome/browser/autofill/form_structure.h
index bb20885..4028117 100644
--- a/chrome/browser/autofill/form_structure.h
+++ b/chrome/browser/autofill/form_structure.h
@@ -20,7 +20,6 @@ namespace buzz {
namespace webkit_glue {
struct FormData;
-class FormFieldValues;
} // namespace webkit_glue
enum RequestMethod {
@@ -38,7 +37,7 @@ enum UploadRequired {
// in the fields along with additional information needed by AutoFill.
class FormStructure {
public:
- explicit FormStructure(const webkit_glue::FormFieldValues& values);
+ explicit FormStructure(const webkit_glue::FormData& form);
// Encodes the XML upload request from this FormStructure.
bool EncodeUploadRequest(bool auto_fill_used,
diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc
index f528d24..cfc535a 100644
--- a/chrome/browser/autofill/form_structure_unittest.cc
+++ b/chrome/browser/autofill/form_structure_unittest.cc
@@ -8,28 +8,29 @@
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
-#include "webkit/glue/form_field_values.h"
+#include "webkit/glue/form_data.h"
+using webkit_glue::FormData;
using WebKit::WebInputElement;
namespace {
TEST(FormStructureTest, FieldCount) {
- webkit_glue::FormFieldValues values;
- values.method = ASCIIToUTF16("post");
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
- ASCIIToUTF16("username"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
- ASCIIToUTF16("password"),
- string16(),
- ASCIIToUTF16("password")));
- values.elements.push_back(webkit_glue::FormField(string16(),
- ASCIIToUTF16("Submit"),
- string16(),
- ASCIIToUTF16("submit")));
- FormStructure form_structure(values);
+ FormData form;
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
+ ASCIIToUTF16("username"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
+ ASCIIToUTF16("password"),
+ string16(),
+ ASCIIToUTF16("password")));
+ form.fields.push_back(webkit_glue::FormField(string16(),
+ ASCIIToUTF16("Submit"),
+ string16(),
+ ASCIIToUTF16("submit")));
+ FormStructure form_structure(form);
// Only text fields are counted.
EXPECT_EQ(1U, form_structure.field_count());
@@ -37,96 +38,96 @@ TEST(FormStructureTest, FieldCount) {
TEST(FormStructureTest, IsAutoFillable) {
scoped_ptr<FormStructure> form_structure;
- webkit_glue::FormFieldValues values;
+ FormData form;
// We need at least three text fields to be auto-fillable.
- values.method = ASCIIToUTF16("post");
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
- ASCIIToUTF16("username"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
- ASCIIToUTF16("password"),
- string16(),
- ASCIIToUTF16("password")));
- values.elements.push_back(webkit_glue::FormField(string16(),
- ASCIIToUTF16("Submit"),
- string16(),
- ASCIIToUTF16("submit")));
- form_structure.reset(new FormStructure(values));
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
+ ASCIIToUTF16("username"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
+ ASCIIToUTF16("password"),
+ string16(),
+ ASCIIToUTF16("password")));
+ form.fields.push_back(webkit_glue::FormField(string16(),
+ ASCIIToUTF16("Submit"),
+ string16(),
+ ASCIIToUTF16("submit")));
+ form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable());
// We now have three text fields.
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
- ASCIIToUTF16("firstname"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
- ASCIIToUTF16("lastname"),
- string16(),
- ASCIIToUTF16("text")));
- form_structure.reset(new FormStructure(values));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
+ ASCIIToUTF16("firstname"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
+ ASCIIToUTF16("lastname"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
// The method must be 'post'.
- values.method = ASCIIToUTF16("get");
- form_structure.reset(new FormStructure(values));
+ form.method = ASCIIToUTF16("get");
+ form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable());
// The target cannot include http(s)://*/search...
- values.method = ASCIIToUTF16("post");
- values.target_url = GURL("http://google.com/search?q=hello");
- form_structure.reset(new FormStructure(values));
+ form.method = ASCIIToUTF16("post");
+ form.action = GURL("http://google.com/search?q=hello");
+ form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable());
// But search can be in the URL.
- values.target_url = GURL("http://search.com/?q=hello");
- form_structure.reset(new FormStructure(values));
+ form.action = GURL("http://search.com/?q=hello");
+ form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
}
TEST(FormStructureTest, HeuristicsContactInfo) {
scoped_ptr<FormStructure> form_structure;
- webkit_glue::FormFieldValues values;
-
- values.method = ASCIIToUTF16("post");
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
- ASCIIToUTF16("firstname"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
- ASCIIToUTF16("lastname"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
- ASCIIToUTF16("email"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
- ASCIIToUTF16("phone"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
- ASCIIToUTF16("fax"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
- ASCIIToUTF16("address"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("City"),
- ASCIIToUTF16("city"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
- ASCIIToUTF16("zipcode"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(string16(),
- ASCIIToUTF16("Submit"),
- string16(),
- ASCIIToUTF16("submit")));
- form_structure.reset(new FormStructure(values));
+ FormData form;
+
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
+ ASCIIToUTF16("firstname"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
+ ASCIIToUTF16("lastname"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
+ ASCIIToUTF16("email"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
+ ASCIIToUTF16("phone"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
+ ASCIIToUTF16("fax"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
+ ASCIIToUTF16("address"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("City"),
+ ASCIIToUTF16("city"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
+ ASCIIToUTF16("zipcode"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(string16(),
+ ASCIIToUTF16("Submit"),
+ string16(),
+ ASCIIToUTF16("submit")));
+ form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
// Expect the correct number of fields.
@@ -173,60 +174,60 @@ TEST(FormStructureTest, HeuristicsContactInfo) {
TEST(FormStructureTest, HeuristicsSample8) {
scoped_ptr<FormStructure> form_structure;
- webkit_glue::FormFieldValues values;
+ FormData form;
- values.method = ASCIIToUTF16("post");
- values.elements.push_back(
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Your First Name:"),
ASCIIToUTF16("bill.first"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Your Last Name:"),
ASCIIToUTF16("bill.last"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street Address Line 1:"),
ASCIIToUTF16("bill.street1"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street Address Line 2:"),
ASCIIToUTF16("bill.street2"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City:"),
ASCIIToUTF16("bill.city"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("State (U.S.):"),
ASCIIToUTF16("bill.state"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Zip/Postal Code:"),
ASCIIToUTF16("BillTo.PostalCode"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Country:"),
ASCIIToUTF16("bill.country"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Phone Number:"),
ASCIIToUTF16("BillTo.Phone"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit")));
- form_structure.reset(new FormStructure(values));
+ form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
// Check that heuristics are initialized as UNKNOWN_TYPE.
@@ -272,47 +273,47 @@ TEST(FormStructureTest, HeuristicsSample8) {
TEST(FormStructureTest, HeuristicsSample6) {
scoped_ptr<FormStructure> form_structure;
- webkit_glue::FormFieldValues values;
+ FormData form;
- values.method = ASCIIToUTF16("post");
- values.elements.push_back(
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("E-mail address"),
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Full name"),
ASCIIToUTF16("name"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Company"),
ASCIIToUTF16("company"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text")));
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("text")));
// TODO(jhawkins): Add state select control.
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Zip Code"),
ASCIIToUTF16("Home.PostalCode"),
string16(),
ASCIIToUTF16("text")));
// TODO(jhawkins): Phone number.
- values.elements.push_back(
+ form.fields.push_back(
webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
ASCIIToUTF16("continue"),
ASCIIToUTF16("submit")));
- form_structure.reset(new FormStructure(values));
+ form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
// Check that heuristics are initialized as UNKNOWN_TYPE.
@@ -354,46 +355,46 @@ TEST(FormStructureTest, HeuristicsSample6) {
// that input element ids (or |name| fields) are missing.
TEST(FormStructureTest, HeuristicsLabelsOnly) {
scoped_ptr<FormStructure> form_structure;
- webkit_glue::FormFieldValues values;
-
- values.method = ASCIIToUTF16("post");
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
- string16(),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
- string16(),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
- string16(),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
- string16(),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
- string16(),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
- string16(),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
- string16(),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
- string16(),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(string16(),
- ASCIIToUTF16("Submit"),
- string16(),
- ASCIIToUTF16("submit")));
- form_structure.reset(new FormStructure(values));
+ FormData form;
+
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
+ string16(),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
+ string16(),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
+ string16(),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
+ string16(),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
+ string16(),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
+ string16(),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
+ string16(),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
+ string16(),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(string16(),
+ ASCIIToUTF16("Submit"),
+ string16(),
+ ASCIIToUTF16("submit")));
+ form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
// Expect the correct number of fields.
@@ -440,34 +441,34 @@ TEST(FormStructureTest, HeuristicsLabelsOnly) {
TEST(FormStructureTest, HeuristicsCreditCardInfo) {
scoped_ptr<FormStructure> form_structure;
- webkit_glue::FormFieldValues values;
+ FormData form;
- values.method = ASCIIToUTF16("post");
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
ASCIIToUTF16("name on card"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
- string16(),
- ASCIIToUTF16("text")));
- values.elements.push_back(webkit_glue::FormField(string16(),
- ASCIIToUTF16("Submit"),
- string16(),
- ASCIIToUTF16("submit")));
- form_structure.reset(new FormStructure(values));
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(webkit_glue::FormField(string16(),
+ ASCIIToUTF16("Submit"),
+ string16(),
+ ASCIIToUTF16("submit")));
+ form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
// Expect the correct number of fields.
diff --git a/chrome/browser/autofill/phone_field_unittest.cc b/chrome/browser/autofill/phone_field_unittest.cc
index e12e894..2a4c8c7 100644
--- a/chrome/browser/autofill/phone_field_unittest.cc
+++ b/chrome/browser/autofill/phone_field_unittest.cc
@@ -7,7 +7,7 @@
#include "chrome/browser/autofill/phone_field.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
-#include "webkit/glue/form_field_values.h"
+#include "webkit/glue/form_field.h"
namespace {