summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-15 23:51:24 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-15 23:51:24 +0000
commit45c6e53a2c50e19a3f79fcc6f05914793ed93de6 (patch)
treee4f0c22f63fe5197938dc868f00c7d6a8e2ea8a6 /chrome
parentcffa2055808bf2149ce48118dcacde477b7ead60 (diff)
downloadchromium_src-45c6e53a2c50e19a3f79fcc6f05914793ed93de6.zip
chromium_src-45c6e53a2c50e19a3f79fcc6f05914793ed93de6.tar.gz
chromium_src-45c6e53a2c50e19a3f79fcc6f05914793ed93de6.tar.bz2
FormFieldValues -> FormData consolidation: Use webkit_glue::FormField to store field data in FormData instead of storing the field data separately in the struct.
BUG=33032 TEST=none Review URL: http://codereview.chromium.org/847002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41658 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autofill/autofill_manager.cc12
-rw-r--r--chrome/browser/autofill/autofill_manager.h3
-rw-r--r--chrome/browser/autofill/form_structure.cc5
-rw-r--r--chrome/browser/autofill/form_structure.h7
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_view_host.h4
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h4
-rw-r--r--chrome/common/render_messages.h12
-rw-r--r--chrome/common/render_messages_internal.h6
-rw-r--r--chrome/renderer/form_manager.cc30
-rw-r--r--chrome/renderer/form_manager.h10
-rw-r--r--chrome/renderer/form_manager_unittest.cc284
-rw-r--r--chrome/renderer/render_view.cc8
-rw-r--r--chrome/renderer/render_view.h3
14 files changed, 199 insertions, 193 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index d49dd4c..ee44c75 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -154,7 +154,7 @@ bool AutoFillManager::GetAutoFillSuggestions(
}
bool AutoFillManager::FillAutoFillFormData(int query_id,
- const FormData& form,
+ const webkit_glue::FormData& form,
const string16& name,
const string16& label) {
if (!IsAutoFillEnabled())
@@ -185,7 +185,7 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
if (!profile)
return false;
- FormData result = form;
+ webkit_glue::FormData result = form;
for (std::vector<FormStructure*>::const_iterator iter =
form_structures_.begin();
iter != form_structures_.end(); ++iter) {
@@ -196,10 +196,10 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
for (size_t i = 0; i < form_structure->field_count(); ++i) {
const AutoFillField* field = form_structure->field(i);
- for (size_t j = 0; j < result.values.size(); ++j) {
- if (field->name() == result.elements[j]) {
- result.values[j] =
- profile->GetFieldText(AutoFillType(field->heuristic_type()));
+ for (size_t j = 0; j < result.fields.size(); ++j) {
+ if (field->name() == result.fields[j].name()) {
+ result.fields[j].set_value(
+ profile->GetFieldText(AutoFillType(field->heuristic_type())));
break;
}
}
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index ecc72d9..fa4593e 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -14,6 +14,7 @@
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
namespace webkit_glue {
+struct FormData;
class FormField;
class FormFieldValues;
}
@@ -48,7 +49,7 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
virtual bool GetAutoFillSuggestions(int query_id,
const webkit_glue::FormField& field);
virtual bool FillAutoFillFormData(int query_id,
- const FormData& form,
+ const webkit_glue::FormData& form,
const string16& name,
const string16& label);
diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc
index a93910c..4841da8 100644
--- a/chrome/browser/autofill/form_structure.cc
+++ b/chrome/browser/autofill/form_structure.cc
@@ -16,6 +16,9 @@
#include "webkit/glue/form_field.h"
#include "webkit/glue/form_field_values.h"
+using webkit_glue::FormData;
+using webkit_glue::FormFieldValues;
+
namespace {
const char* kFormMethodPost = "post";
@@ -55,7 +58,7 @@ static std::string Hash64Bit(const std::string& str) {
} // namespace
-FormStructure::FormStructure(const webkit_glue::FormFieldValues& values)
+FormStructure::FormStructure(const FormFieldValues& values)
: form_name_(UTF16ToUTF8(values.form_name)),
source_url_(values.source_url),
target_url_(values.target_url) {
diff --git a/chrome/browser/autofill/form_structure.h b/chrome/browser/autofill/form_structure.h
index d91882b..6c41203 100644
--- a/chrome/browser/autofill/form_structure.h
+++ b/chrome/browser/autofill/form_structure.h
@@ -14,9 +14,8 @@
#include "chrome/browser/autofill/field_types.h"
#include "googleurl/src/gurl.h"
-struct FormData;
-
namespace webkit_glue {
+struct FormData;
class FormFieldValues;
}
@@ -60,8 +59,8 @@ class FormStructure {
return fields_.end();
}
- bool operator==(const FormData& form) const;
- bool operator!=(const FormData& form) const;
+ bool operator==(const webkit_glue::FormData& form) const;
+ bool operator!=(const webkit_glue::FormData& form) const;
private:
// Associates the field with the heuristic type for each of the field views.
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 6cfd4f8..354acaf 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1608,7 +1608,7 @@ void RenderViewHost::OnRemoveAutofillEntry(const string16& field_name,
}
void RenderViewHost::OnFillAutoFillFormData(int query_id,
- const FormData& form,
+ const webkit_glue::FormData& form,
const string16& name,
const string16& label) {
RenderViewHostDelegate::AutoFill* autofill_delegate =
@@ -1637,7 +1637,7 @@ void RenderViewHost::AutocompleteSuggestionsReturned(
}
void RenderViewHost::AutoFillFormDataFilled(int query_id,
- const FormData& form) {
+ const webkit_glue::FormData& form) {
Send(new ViewMsg_AutoFillFormDataFilled(routing_id(), query_id, form));
}
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 4059bec..27fb3ff 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -398,7 +398,7 @@ class RenderViewHost : public RenderWidgetHost {
int default_suggestion_index);
// Called by the AutoFillManager when the FormData has been filled out.
- void AutoFillFormDataFilled(int query_id, const FormData& form);
+ void AutoFillFormDataFilled(int query_id, const webkit_glue::FormData& form);
// Notifies the Renderer that a move or resize of its containing window has
// started (this is used to hide the autocomplete popups if any).
@@ -590,7 +590,7 @@ class RenderViewHost : public RenderWidgetHost {
void OnRemoveAutofillEntry(const string16& field_name,
const string16& value);
void OnFillAutoFillFormData(int query_id,
- const FormData& form,
+ const webkit_glue::FormData& form,
const string16& name,
const string16& label);
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index d908e1f..535bb1f 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -19,7 +19,6 @@
struct BookmarkDragData;
struct ContextMenuParams;
class FilePath;
-struct FormData;
class GURL;
struct NativeWebKeyboardEvent;
class NavigationEntry;
@@ -54,6 +53,7 @@ class Message;
}
namespace webkit_glue {
+struct FormData;
class FormField;
class FormFieldValues;
struct PasswordForm;
@@ -411,7 +411,7 @@ class RenderViewHostDelegate {
// matches the |name|, |label| key. Returns true to indicate that
// RenderViewHost::AutoFillFormDataFilled has been called.
virtual bool FillAutoFillFormData(int query_id,
- const FormData& form,
+ const webkit_glue::FormData& form,
const string16& name,
const string16& label) = 0;
};
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index d032520..eae961a 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1555,24 +1555,20 @@ struct ParamTraits<SyncLoadResult> {
// Traits for FormData structure to pack/unpack.
template <>
-struct ParamTraits<FormData> {
- typedef FormData param_type;
+struct ParamTraits<webkit_glue::FormData> {
+ typedef webkit_glue::FormData param_type;
static void Write(Message* m, const param_type& p) {
WriteParam(m, p.name);
WriteParam(m, p.origin);
WriteParam(m, p.action);
- WriteParam(m, p.labels);
- WriteParam(m, p.elements);
- WriteParam(m, p.values);
+ WriteParam(m, p.fields);
}
static bool Read(const Message* m, void** iter, param_type* p) {
return
ReadParam(m, iter, &p->name) &&
ReadParam(m, iter, &p->origin) &&
ReadParam(m, iter, &p->action) &&
- ReadParam(m, iter, &p->labels) &&
- ReadParam(m, iter, &p->elements) &&
- ReadParam(m, iter, &p->values);
+ ReadParam(m, iter, &p->fields);
}
static void Log(const param_type& p, std::wstring* l) {
l->append(L"<FormData>");
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index fbbd9d5..8fd3b9d 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -395,7 +395,7 @@ IPC_BEGIN_MESSAGES(View)
// Fill a form with data and optionally submit it
IPC_MESSAGE_ROUTED1(ViewMsg_FormFill,
- FormData /* form */)
+ webkit_glue::FormData /* form */)
// Fill a password form and prepare field autocomplete for multiple
// matching logins.
@@ -646,7 +646,7 @@ IPC_BEGIN_MESSAGES(View)
// AutoFill form data.
IPC_MESSAGE_ROUTED2(ViewMsg_AutoFillFormDataFilled,
int /* id of the request message */,
- FormData /* form data */)
+ webkit_glue::FormData /* form data */)
// Sent by the Browser process to alert a window about whether a blocked
// popup notification is visible. The renderer assumes every new window is a
@@ -1807,7 +1807,7 @@ IPC_BEGIN_MESSAGES(ViewHost)
// profile data.
IPC_MESSAGE_ROUTED4(ViewHostMsg_FillAutoFillFormData,
int /* id of this message */,
- FormData /* the form */,
+ webkit_glue::FormData /* the form */,
string16 /* profile name */,
string16 /* profile label */)
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc
index 5067fe3..246c448 100644
--- a/chrome/renderer/form_manager.cc
+++ b/chrome/renderer/form_manager.cc
@@ -26,6 +26,8 @@ using WebKit::WebNode;
using WebKit::WebNodeList;
using WebKit::WebString;
using WebKit::WebVector;
+using webkit_glue::FormData;
+using webkit_glue::FormField;
FormManager::FormManager() {
}
@@ -83,7 +85,8 @@ void FormManager::GetForms(std::vector<FormData>* forms,
}
}
-bool FormManager::FindForm(const WebInputElement& element, FormData* form) {
+bool FormManager::FindForm(const WebInputElement& element,
+ FormData* form) {
// Frame loop.
for (WebFrameFormElementMap::iterator iter = form_elements_map_.begin();
iter != form_elements_map_.end(); ++iter) {
@@ -122,7 +125,7 @@ bool FormManager::FillForm(const FormData& form) {
// evaluate to |true| for some reason TBD, so forcing to string16.
string16 element_name((*form_iter)->form_element.name());
if (element_name == form.name &&
- (*form_iter)->input_elements.size() == form.elements.size()) {
+ (*form_iter)->input_elements.size() == form.fields.size()) {
form_element = *form_iter;
break;
}
@@ -132,18 +135,17 @@ bool FormManager::FillForm(const FormData& form) {
if (!form_element)
return false;
- DCHECK(form_element->input_elements.size() == form.elements.size());
- DCHECK(form.elements.size() == form.values.size());
+ DCHECK(form_element->input_elements.size() == form.fields.size());
size_t i = 0;
for (FormInputElementMap::iterator iter =
form_element->input_elements.begin();
iter != form_element->input_elements.end(); ++iter, ++i) {
- DCHECK_EQ(form.elements[i], iter->second.nameForAutofill());
+ DCHECK_EQ(form.fields[i].name(), iter->second.nameForAutofill());
- if (!form.values[i].empty() &&
+ if (!form.fields[i].value().empty() &&
iter->second.inputType() != WebInputElement::Submit) {
- iter->second.setValue(form.values[i]);
+ iter->second.setValue(form.fields[i].value());
iter->second.setAutofilled(true);
}
}
@@ -194,9 +196,17 @@ void FormManager::FormElementToFormData(WebFrame* frame,
!input_element.isEnabledFormControl())
continue;
- form->labels.push_back(LabelForElement(input_element));
- form->elements.push_back(input_element.nameForAutofill());
- form->values.push_back(input_element.value());
+ string16 label = LabelForElement(input_element);
+ string16 name = input_element.nameForAutofill();
+ string16 value = input_element.value();
+ string16 form_control_type = input_element.formControlType();
+ WebInputElement::InputType input_type = input_element.inputType();
+ FormField field = FormField(label,
+ name,
+ value,
+ form_control_type,
+ input_type);
+ form->fields.push_back(field);
}
}
diff --git a/chrome/renderer/form_manager.h b/chrome/renderer/form_manager.h
index 9e7abf8..a6805b2 100644
--- a/chrome/renderer/form_manager.h
+++ b/chrome/renderer/form_manager.h
@@ -34,18 +34,20 @@ class FormManager {
void ExtractForms(WebKit::WebFrame* frame);
// Returns a vector of forms that match |requirements|.
- void GetForms(std::vector<FormData>* forms, RequirementsMask requirements);
+ void GetForms(std::vector<webkit_glue::FormData>* forms,
+ RequirementsMask requirements);
// Finds the form that contains |input_element| and returns it in |form|.
// Returns false if the form is not found.
- bool FindForm(const WebKit::WebInputElement& input_element, FormData* form);
+ bool FindForm(const WebKit::WebInputElement& input_element,
+ webkit_glue::FormData* form);
// Fills the form represented by |form|. |form| should have the name set to
// the name of the form to fill out, and the number of elements and values
// must match the number of stored elements in the form.
// TODO(jhawkins): Is matching on name alone good enough? It's possible to
// store multiple forms with the same names from different frames.
- bool FillForm(const FormData& form);
+ bool FillForm(const webkit_glue::FormData& form);
// Resets the stored set of forms.
void Reset();
@@ -73,7 +75,7 @@ class FormManager {
void FormElementToFormData(WebKit::WebFrame* frame,
const FormElement* form_element,
RequirementsMask requirements,
- FormData* form);
+ webkit_glue::FormData* form);
// Returns the corresponding label for |element|.
static string16 LabelForElement(const WebKit::WebInputElement& element);
diff --git a/chrome/renderer/form_manager_unittest.cc b/chrome/renderer/form_manager_unittest.cc
index d819096..418afd8 100644
--- a/chrome/renderer/form_manager_unittest.cc
+++ b/chrome/renderer/form_manager_unittest.cc
@@ -9,12 +9,16 @@
#include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+#include "webkit/glue/form_data.h"
using WebKit::WebElement;
using WebKit::WebFrame;
using WebKit::WebInputElement;
using WebKit::WebString;
+using webkit_glue::FormData;
+using webkit_glue::FormField;
+
class FormManagerTest : public RenderViewTest {
public:
FormManagerTest() {}
@@ -42,23 +46,23 @@ TEST_F(FormManagerTest, ExtractForms) {
EXPECT_EQ(GURL(web_frame->url()), form.origin);
EXPECT_EQ(GURL("http://cnn.com"), form.action);
- const std::vector<string16>& labels = form.labels;
- ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
- EXPECT_EQ(string16(), labels[2]);
-
- const std::vector<string16>& elements = form.elements;
- ASSERT_EQ(3U, elements.size());
- EXPECT_EQ(ASCIIToUTF16("firstname"), elements[0]);
- EXPECT_EQ(ASCIIToUTF16("lastname"), elements[1]);
- EXPECT_EQ(ASCIIToUTF16("reply-send"), elements[2]);
-
- const std::vector<string16>& values = form.values;
- ASSERT_EQ(3U, values.size());
- EXPECT_EQ(ASCIIToUTF16("John"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Smith"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Send"), values[2]);
+ const std::vector<FormField>& fields = form.fields;
+ ASSERT_EQ(3U, fields.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("firstname"),
+ ASCIIToUTF16("John"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[0]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("lastname"),
+ ASCIIToUTF16("Smith"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[1]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("reply-send"),
+ ASCIIToUTF16("Send"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields[2]);
}
TEST_F(FormManagerTest, ExtractMultipleForms) {
@@ -87,20 +91,18 @@ TEST_F(FormManagerTest, ExtractMultipleForms) {
EXPECT_EQ(GURL(web_frame->url()), form.origin);
EXPECT_EQ(GURL("http://cnn.com"), form.action);
- const std::vector<string16>& labels = form.labels;
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
-
- const std::vector<string16>& elements = form.elements;
- ASSERT_EQ(2U, elements.size());
- EXPECT_EQ(ASCIIToUTF16("firstname"), elements[0]);
- EXPECT_EQ(ASCIIToUTF16("reply-send"), elements[1]);
-
- const std::vector<string16>& values = form.values;
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("John"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Send"), values[1]);
+ const std::vector<FormField>& fields = form.fields;
+ ASSERT_EQ(2U, fields.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("firstname"),
+ ASCIIToUTF16("John"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[0]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("reply-send"),
+ ASCIIToUTF16("Send"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields[1]);
// Second form.
const FormData& form2 = forms[1];
@@ -108,20 +110,18 @@ TEST_F(FormManagerTest, ExtractMultipleForms) {
EXPECT_EQ(GURL(web_frame->url()), form2.origin);
EXPECT_EQ(GURL("http://zoo.com"), form2.action);
- const std::vector<string16>& labels2 = form2.labels;
- ASSERT_EQ(2U, labels2.size());
- EXPECT_EQ(string16(), labels2[0]);
- EXPECT_EQ(string16(), labels2[1]);
-
- const std::vector<string16>& elements2 = form2.elements;
- ASSERT_EQ(2U, elements2.size());
- EXPECT_EQ(ASCIIToUTF16("lastname"), elements2[0]);
- EXPECT_EQ(ASCIIToUTF16("second"), elements2[1]);
-
- const std::vector<string16>& values2 = form2.values;
- ASSERT_EQ(2U, values2.size());
- EXPECT_EQ(ASCIIToUTF16("Smith"), values2[0]);
- EXPECT_EQ(ASCIIToUTF16("Submit"), values2[1]);
+ const std::vector<FormField>& fields2 = form2.fields;
+ ASSERT_EQ(2U, fields2.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("lastname"),
+ ASCIIToUTF16("Smith"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields2[0]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("second"),
+ ASCIIToUTF16("Submit"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields2[1]);
}
TEST_F(FormManagerTest, GetFormsAutocomplete) {
@@ -171,20 +171,18 @@ TEST_F(FormManagerTest, GetFormsAutocomplete) {
EXPECT_EQ(GURL(web_frame->url()), form.origin);
EXPECT_EQ(GURL("http://abc.com"), form.action);
- const std::vector<string16>& labels = form.labels;
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
-
- const std::vector<string16>& elements = form.elements;
- ASSERT_EQ(2U, elements.size());
- EXPECT_EQ(ASCIIToUTF16("lastname"), elements[0]);
- EXPECT_EQ(ASCIIToUTF16("reply"), elements[1]);
-
- const std::vector<string16>& values = form.values;
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Smith"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Send"), values[1]);
+ const std::vector<FormField>& fields = form.fields;
+ ASSERT_EQ(2U, fields.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("lastname"),
+ ASCIIToUTF16("Smith"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[0]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("reply"),
+ ASCIIToUTF16("Send"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields[1]);
}
TEST_F(FormManagerTest, GetFormsElementsEnabled) {
@@ -210,20 +208,18 @@ TEST_F(FormManagerTest, GetFormsElementsEnabled) {
EXPECT_EQ(GURL(web_frame->url()), form.origin);
EXPECT_EQ(GURL("http://xyz.com"), form.action);
- const std::vector<string16>& labels = form.labels;
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
-
- const std::vector<string16>& elements = form.elements;
- ASSERT_EQ(2U, elements.size());
- EXPECT_EQ(ASCIIToUTF16("lastname"), elements[0]);
- EXPECT_EQ(ASCIIToUTF16("submit"), elements[1]);
-
- const std::vector<string16>& values = form.values;
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Smith"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Send"), values[1]);
+ const std::vector<FormField>& fields = form.fields;
+ ASSERT_EQ(2U, fields.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("lastname"),
+ ASCIIToUTF16("Smith"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[0]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("submit"),
+ ASCIIToUTF16("Send"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields[1]);
}
TEST_F(FormManagerTest, FindForm) {
@@ -256,23 +252,23 @@ TEST_F(FormManagerTest, FindForm) {
EXPECT_EQ(GURL(web_frame->url()), form.origin);
EXPECT_EQ(GURL("http://buh.com"), form.action);
- const std::vector<string16>& labels = form.labels;
- ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
- EXPECT_EQ(string16(), labels[2]);
-
- const std::vector<string16>& elements = form.elements;
- ASSERT_EQ(3U, elements.size());
- EXPECT_EQ(ASCIIToUTF16("firstname"), elements[0]);
- EXPECT_EQ(ASCIIToUTF16("lastname"), elements[1]);
- EXPECT_EQ(ASCIIToUTF16("reply-send"), elements[2]);
-
- const std::vector<string16>& values = form.values;
- ASSERT_EQ(3U, values.size());
- EXPECT_EQ(ASCIIToUTF16("John"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Smith"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Send"), values[2]);
+ const std::vector<FormField>& fields = form.fields;
+ ASSERT_EQ(3U, fields.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("firstname"),
+ ASCIIToUTF16("John"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[0]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("lastname"),
+ ASCIIToUTF16("Smith"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[1]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("reply-send"),
+ ASCIIToUTF16("Send"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields[2]);
}
TEST_F(FormManagerTest, FillForm) {
@@ -305,28 +301,27 @@ TEST_F(FormManagerTest, FillForm) {
EXPECT_EQ(GURL(web_frame->url()), form.origin);
EXPECT_EQ(GURL("http://buh.com"), form.action);
- const std::vector<string16>& labels = form.labels;
- ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
- EXPECT_EQ(string16(), labels[2]);
-
- const std::vector<string16>& elements = form.elements;
- ASSERT_EQ(3U, elements.size());
- EXPECT_EQ(ASCIIToUTF16("firstname"), elements[0]);
- EXPECT_EQ(ASCIIToUTF16("lastname"), elements[1]);
- EXPECT_EQ(ASCIIToUTF16("reply-send"), elements[2]);
-
- // Verify that the text fields have no values.
- const std::vector<string16>& values = form.values;
- ASSERT_EQ(3U, values.size());
- EXPECT_EQ(string16(), values[0]);
- EXPECT_EQ(string16(), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Send"), values[2]);
+ const std::vector<FormField>& fields = form.fields;
+ ASSERT_EQ(3U, fields.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("firstname"),
+ string16(),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[0]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("lastname"),
+ string16(),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[1]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("reply-send"),
+ ASCIIToUTF16("Send"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields[2]);
// Fill the form.
- form.values[0] = ASCIIToUTF16("Wyatt");
- form.values[1] = ASCIIToUTF16("Earp");
+ form.fields[0].set_value(ASCIIToUTF16("Wyatt"));
+ form.fields[1].set_value(ASCIIToUTF16("Earp"));
EXPECT_TRUE(form_manager.FillForm(form));
// Find the newly-filled form that contains the input element.
@@ -336,24 +331,23 @@ TEST_F(FormManagerTest, FillForm) {
EXPECT_EQ(GURL(web_frame->url()), form2.origin);
EXPECT_EQ(GURL("http://buh.com"), form2.action);
- const std::vector<string16>& labels2 = form2.labels;
- ASSERT_EQ(3U, labels2.size());
- EXPECT_EQ(string16(), labels2[0]);
- EXPECT_EQ(string16(), labels2[1]);
- EXPECT_EQ(string16(), labels2[2]);
-
- const std::vector<string16>& elements2 = form2.elements;
- ASSERT_EQ(3U, elements2.size());
- EXPECT_EQ(ASCIIToUTF16("firstname"), elements2[0]);
- EXPECT_EQ(ASCIIToUTF16("lastname"), elements2[1]);
- EXPECT_EQ(ASCIIToUTF16("reply-send"), elements2[2]);
-
- // Verify that the text fields have no values.
- const std::vector<string16>& values2 = form2.values;
- ASSERT_EQ(3U, values2.size());
- EXPECT_EQ(ASCIIToUTF16("Wyatt"), values2[0]);
- EXPECT_EQ(ASCIIToUTF16("Earp"), values2[1]);
- EXPECT_EQ(ASCIIToUTF16("Send"), values2[2]);
+ const std::vector<FormField>& fields2 = form2.fields;
+ ASSERT_EQ(3U, fields2.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("firstname"),
+ ASCIIToUTF16("Wyatt"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields2[0]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("lastname"),
+ ASCIIToUTF16("Earp"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields2[1]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("reply-send"),
+ ASCIIToUTF16("Send"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields2[2]);
}
TEST_F(FormManagerTest, Reset) {
@@ -405,21 +399,21 @@ TEST_F(FormManagerTest, Labels) {
EXPECT_EQ(GURL(web_frame->url()), form.origin);
EXPECT_EQ(GURL("http://cnn.com"), form.action);
- const std::vector<string16>& labels = form.labels;
- ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("First name:"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Last name:"), labels[1]);
- EXPECT_EQ(string16(), labels[2]);
-
- const std::vector<string16>& elements = form.elements;
- ASSERT_EQ(3U, elements.size());
- EXPECT_EQ(ASCIIToUTF16("firstname"), elements[0]);
- EXPECT_EQ(ASCIIToUTF16("lastname"), elements[1]);
- EXPECT_EQ(ASCIIToUTF16("reply-send"), elements[2]);
-
- const std::vector<string16>& values = form.values;
- ASSERT_EQ(3U, values.size());
- EXPECT_EQ(ASCIIToUTF16("John"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Smith"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Send"), values[2]);
+ const std::vector<FormField>& fields = form.fields;
+ ASSERT_EQ(3U, fields.size());
+ EXPECT_EQ(FormField(ASCIIToUTF16("First name:"),
+ ASCIIToUTF16("firstname"),
+ ASCIIToUTF16("John"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[0]);
+ EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"),
+ ASCIIToUTF16("lastname"),
+ ASCIIToUTF16("Smith"),
+ ASCIIToUTF16("text"),
+ WebInputElement::Text), fields[1]);
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("reply-send"),
+ ASCIIToUTF16("Send"),
+ ASCIIToUTF16("submit"),
+ WebInputElement::Submit), fields[2]);
}
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 64fe3d7..4efea99 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1460,7 +1460,8 @@ void RenderView::OnAutocompleteSuggestionsReturned(
autofill_query_node_.reset();
}
-void RenderView::OnAutoFillFormDataFilled(int query_id, const FormData& form) {
+void RenderView::OnAutoFillFormDataFilled(int query_id,
+ const webkit_glue::FormData& form) {
if (query_id != autofill_query_id_)
return;
@@ -1984,7 +1985,7 @@ void RenderView::didAcceptAutoFillSuggestion(
static int query_counter = 0;
autofill_query_id_ = query_counter++;
- FormData form;
+ webkit_glue::FormData form;
const WebInputElement element = node.toConstElement<WebInputElement>();
if (!form_manager_.FindForm(element, &form))
return;
@@ -3949,8 +3950,7 @@ void RenderView::OnResize(const gfx::Size& new_size,
// either width or height, allow scroll bars.
bool allow_scrollbars = (
disable_scrollbars_size_limit_.width() <= new_size.width() ||
- disable_scrollbars_size_limit_.height() <= new_size.height()
- );
+ disable_scrollbars_size_limit_.height() <= new_size.height());
webview()->mainFrame()->setCanHaveScrollbars(allow_scrollbars);
}
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 66ff242..4478354 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -737,7 +737,8 @@ class RenderView : public RenderWidget,
int default_suggestions_index);
// Notification that we have received AutoFill form data.
- void OnAutoFillFormDataFilled(int query_id, const FormData& form);
+ void OnAutoFillFormDataFilled(int query_id,
+ const webkit_glue::FormData& form);
// Message that the popup notification has been shown or hidden.
void OnPopupNotificationVisibilityChanged(bool visible);