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

Unified Diff: webkit/glue/form_field_values.cc

Issue 341042: Store the form name, source URL and target URL in FormFieldValues. These are... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/form_field_values.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/form_field_values.cc
===================================================================
--- webkit/glue/form_field_values.cc (revision 30521)
+++ webkit/glue/form_field_values.cc (working copy)
@@ -4,6 +4,7 @@
#include "config.h"
+#include "Document.h"
#include "Frame.h"
#include "HTMLFormElement.h"
#include "HTMLInputElement.h"
@@ -28,7 +29,8 @@
RefPtr<WebCore::HTMLFormElement> form = WebFormToHTMLFormElement(webform);
DCHECK(form);
- WebCore::Frame* frame = form->document()->frame();
+ WebCore::Document* document = form->document();
+ WebCore::Frame* frame = document->frame();
if (!frame)
return NULL;
@@ -36,14 +38,24 @@
if (!loader)
return NULL;
+ // Construct a new FormFieldValues.
+ FormFieldValues* result = new FormFieldValues();
+
+ result->form_name = StringToString16(form->name());
+ result->source_url = KURLToGURL(document->url());
+ result->target_url = KURLToGURL(document->completeURL(form->action()));
+ result->ExtractFormFieldValues(webform);
+
+ return result;
+}
+
+void FormFieldValues::ExtractFormFieldValues(const WebKit::WebForm& webform) {
+ RefPtr<WebCore::HTMLFormElement> form = WebFormToHTMLFormElement(webform);
+
const WTF::Vector<WebCore::HTMLFormControlElement*>& form_elements =
form->formElements;
- // Construct a new FormFieldValues.
- FormFieldValues* result = new FormFieldValues();
-
size_t form_element_count = form_elements.size();
-
for (size_t i = 0; i < form_element_count; i++) {
WebCore::HTMLFormControlElement* form_element = form_elements[i];
@@ -69,10 +81,8 @@
if (name.length() == 0)
continue; // If we have no name, there is nothing to store.
- result->elements.push_back(FormField(name, value));
+ elements.push_back(FormField(name, value));
}
-
- return result;
}
} // namespace webkit_glue
« no previous file with comments | « webkit/glue/form_field_values.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698