blob: cbfccb302c5a79d7a064f0708184b325037a81d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/string16.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
#include "webkit/glue/form_field_values.h"
using WebKit::WebFormElement;
using WebKit::WebFrame;
using WebKit::WebInputElement;
using WebKit::WebVector;
namespace webkit_glue {
FormFieldValues* FormFieldValues::Create(const WebFormElement& form) {
DCHECK(!form.isNull());
WebFrame* frame = form.frame();
if (!frame)
return NULL;
// Construct a new FormFieldValues.
FormFieldValues* result = new FormFieldValues();
result->form_name = form.name();
result->method = form.method();
result->source_url = frame->url();
result->target_url = frame->completeURL(form.action());
result->ExtractFormFieldValues(form);
return result;
}
void FormFieldValues::ExtractFormFieldValues(const WebFormElement& form) {
WebVector<WebInputElement> input_elements;
form.getInputElements(input_elements);
for (size_t i = 0; i < input_elements.size(); i++) {
const WebInputElement& input_element = input_elements[i];
if (input_element.isEnabledFormControl()) {
// TODO(jhawkins): Remove this check when we have labels.
if (!input_element.nameForAutofill().isEmpty())
elements.push_back(FormField(input_element));
}
}
}
} // namespace webkit_glue
|