summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-01-11 07:50:44 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-11 07:50:44 -0800
commit354a67ba58009fa494d34c28980688a3ee292205 (patch)
tree59e77b244ffef5add385c59f75326ca14f09f7b7
parent8aab444a555fec87ca3cc19fdd3a06fa54f46f2c (diff)
parentcd51200f40bf65e9e34a749187707ae619c6d1e5 (diff)
downloadexternal_webkit-354a67ba58009fa494d34c28980688a3ee292205.zip
external_webkit-354a67ba58009fa494d34c28980688a3ee292205.tar.gz
external_webkit-354a67ba58009fa494d34c28980688a3ee292205.tar.bz2
Merge changes Iad96314e,Ic978944b,Iea1a5a55,Id22f7f0c,Ia1a391a9,Ic4642c38,I561d89dc,Ia102dea1 into honeycomb
* changes: Merge Chromium at 9.0.597.55: Move formsSeen call to IO thread. Merge Chromium at 9.0.597.55: Remove URLRequest forward declaration. Merge Chromium at 9.0.597.55: Merge 67599. (2/2) Merge Chromium at 9.0.597.55: Merge r67599 (1/2) Merge Chromium at 9.0.597.55: Merge r67192 Merge Chromium at 9.0.597.55: Add DnsCertChecker to constructor Merge Chromium at 9.0.597.55: Autofill: Merge r66860 Merge Chromium at 9.0.597.55: Autofill: Merge r66850
-rw-r--r--WebKit/android/WebCoreSupport/WebCache.cpp1
-rw-r--r--WebKit/android/WebCoreSupport/WebResponse.h2
-rw-r--r--WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp20
-rw-r--r--WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h12
-rw-r--r--WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp12
-rw-r--r--WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.h7
-rw-r--r--WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp51
-rw-r--r--WebKit/android/WebCoreSupport/autofill/WebAutoFill.h27
8 files changed, 98 insertions, 34 deletions
diff --git a/WebKit/android/WebCoreSupport/WebCache.cpp b/WebKit/android/WebCoreSupport/WebCache.cpp
index c5705dd..07031c8 100644
--- a/WebKit/android/WebCoreSupport/WebCache.cpp
+++ b/WebKit/android/WebCoreSupport/WebCache.cpp
@@ -111,6 +111,7 @@ WebCache::WebCache(bool isPrivateBrowsing)
m_cache = new net::HttpCache(m_hostResolver.get(),
0, // dnsrr_resolver
+ 0, // dns_cert_checker
net::ProxyService::CreateWithoutProxyResolver(m_proxyConfigService, 0 /* net_log */),
net::SSLConfigService::CreateSystemSSLConfigService(),
net::HttpAuthHandlerFactory::CreateDefault(m_hostResolver.get()),
diff --git a/WebKit/android/WebCoreSupport/WebResponse.h b/WebKit/android/WebCoreSupport/WebResponse.h
index 8bbfef5..9f7d448 100644
--- a/WebKit/android/WebCoreSupport/WebResponse.h
+++ b/WebKit/android/WebCoreSupport/WebResponse.h
@@ -38,8 +38,6 @@ class ResourceResponse;
class ResourceError;
}
-class URLRequest;
-
namespace android {
class WebResponse {
diff --git a/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp b/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp
index 07f8338..6af0875 100644
--- a/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp
@@ -52,13 +52,15 @@ using namespace WebCore::HTMLNames;
namespace webkit_glue {
FormField::FormField()
- : size_(0) {
+ : max_length_(0),
+ is_autofilled_(false) {
}
// TODO: This constructor should probably be deprecated and the
// functionality moved to FormManager.
FormField::FormField(const HTMLFormControlElement& element)
- : size_(0) {
+ : max_length_(0),
+ is_autofilled_(false) {
name_ = nameForAutoFill(element);
// TODO: Extract the field label. For now we just use the field
@@ -69,7 +71,8 @@ FormField::FormField(const HTMLFormControlElement& element)
if (form_control_type_ == kText) {
const HTMLInputElement& input_element = static_cast<const HTMLInputElement&>(element);
value_ = WTFStringToString16(input_element.value());
- size_ = input_element.size();
+ max_length_ = input_element.size();
+ is_autofilled_ = input_element.isAutofilled();
} else if (form_control_type_ == kSelectOne) {
const HTMLSelectElement& const_select_element = static_cast<const HTMLSelectElement&>(element);
HTMLSelectElement& select_element = const_cast<HTMLSelectElement&>(const_select_element);
@@ -87,12 +90,13 @@ FormField::FormField(const HTMLFormControlElement& element)
TrimWhitespace(value_, TRIM_LEADING, &value_);
}
-FormField::FormField(const string16& label, const string16& name, const string16& value, const string16& form_control_type, int size)
+FormField::FormField(const string16& label, const string16& name, const string16& value, const string16& form_control_type, int max_length, bool is_autofilled)
: label_(label),
name_(name),
value_(value),
form_control_type_(form_control_type),
- size_(size) {
+ max_length_(max_length),
+ is_autofilled_(is_autofilled) {
}
FormField::~FormField() {
@@ -104,7 +108,7 @@ bool FormField::operator==(const FormField& field) const {
return (label_ == field.label_ &&
name_ == field.name_ &&
form_control_type_ == field.form_control_type_ &&
- size_ == field.size_);
+ max_length_ == field.max_length_);
}
bool FormField::operator!=(const FormField& field) const {
@@ -116,7 +120,7 @@ bool FormField::StrictlyEqualsHack(const FormField& field) const {
name_ == field.name_ &&
value_ == field.value_ &&
form_control_type_ == field.form_control_type_ &&
- size_ == field.size_);
+ max_length_ == field.max_length_);
}
std::ostream& operator<<(std::ostream& os, const FormField& field) {
@@ -129,7 +133,7 @@ std::ostream& operator<<(std::ostream& os, const FormField& field) {
<< " "
<< UTF16ToUTF8(field.form_control_type())
<< " "
- << field.size();
+ << field.max_length();
}
} // namespace webkit_glue
diff --git a/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h b/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h
index 8fb13a1..c5e3ecc 100644
--- a/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h
+++ b/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h
@@ -45,14 +45,16 @@ class FormField {
public:
FormField();
explicit FormField(const WebCore::HTMLFormControlElement& element);
- FormField(const string16& label, const string16& name, const string16& value, const string16& form_control_type, int size);
+ FormField(const string16& label, const string16& name, const string16& value, const string16& form_control_type, int max_length, bool is_autofilled);
virtual ~FormField();
const string16& label() const { return label_; }
const string16& name() const { return name_; }
const string16& value() const { return value_; }
const string16& form_control_type() const { return form_control_type_; }
- int size() const { return size_; }
+ int max_length() const { return max_length_; }
+ bool is_autofilled() const { return is_autofilled_; }
+
// Returns option string for elements for which they make sense (select-one,
// for example) for the rest of elements return an empty array.
const std::vector<string16>& option_strings() const { return option_strings_; }
@@ -61,7 +63,8 @@ public:
void set_name(const string16& name) { name_ = name; }
void set_value(const string16& value) { value_ = value; }
void set_form_control_type(const string16& form_control_type) { form_control_type_ = form_control_type; }
- void set_size(int size) { size_ = size; }
+ void set_max_length(int max_length) { max_length_ = max_length; }
+ void set_autofilled(bool is_autofilled) { is_autofilled_ = is_autofilled; }
void set_option_strings(const std::vector<string16>& strings) { option_strings_ = strings; }
// Equality tests for identity which does not include |value_| or |size_|.
@@ -80,7 +83,8 @@ private:
string16 name_;
string16 value_;
string16 form_control_type_;
- int size_;
+ int max_length_;
+ bool is_autofilled_;
std::vector<string16> option_strings_;
};
diff --git a/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp b/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp
index 5a5ff9a..d30918f 100644
--- a/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp
@@ -318,7 +318,8 @@ void FormManager::HTMLFormControlElementToFormField(HTMLFormControlElement* elem
if (formControlType(*element) == kText) {
HTMLInputElement* input_element = static_cast<HTMLInputElement*>(element);
- field->set_size(input_element->size());
+ field->set_max_length(input_element->maxLength());
+ field->set_autofilled(input_element->isAutofilled());
}
if (!(extract_mask & EXTRACT_VALUE))
@@ -556,8 +557,7 @@ bool FormManager::FindFormWithFormControlElement(HTMLFormControlElement* element
for (std::vector<HTMLFormControlElement*>::const_iterator iter = form_element->control_elements.begin(); iter != form_element->control_elements.end(); ++iter) {
if (nameForAutoFill(**iter) == nameForAutoFill(*element)) {
ExtractMask extract_mask = static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS);
- HTMLFormElementToFormData(form_element->form_element, requirements, extract_mask, form);
- return true;
+ return HTMLFormElementToFormData(form_element->form_element, requirements, extract_mask, form);
}
}
}
@@ -617,7 +617,7 @@ bool FormManager::ClearFormWithNode(Node* node) {
return true;
}
-bool FormManager::ClearPreviewedFormWithNode(Node* node) {
+bool FormManager::ClearPreviewedFormWithNode(Node* node, bool was_autofilled) {
FormElement* form_element = NULL;
if (!FindCachedFormElementWithNode(node, &form_element))
return false;
@@ -650,8 +650,10 @@ bool FormManager::ClearPreviewedFormWithNode(Node* node) {
// Call |setValue()| to force the renderer to update the field's displayed
// value.
input_element->setValue(input_element->value());
+ input_element->setAutofilled(was_autofilled);
+ } else {
+ input_element->setAutofilled(false);
}
- input_element->setAutofilled(false);
// Clearing the suggested value in the focused node (above) can cause
// selection to be lost. We force selection range to restore the text
diff --git a/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.h b/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.h
index eed3963..e844981 100644
--- a/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.h
+++ b/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.h
@@ -122,9 +122,10 @@ public:
bool ClearFormWithNode(Node* node);
// Clears the placeholder values and the auto-filled background for any fields
- // in the form containing |node| that have been previewed. Returns false if
- // the form is not found.
- bool ClearPreviewedFormWithNode(Node* node);
+ // in the form containing |node| that have been previewed. Resets the
+ // autofilled state of |node| to |was_autofilled|. Returns false if the form
+ // is not found.
+ bool ClearPreviewedFormWithNode(Node* node, bool was_autofilled);
// Resets the stored set of forms.
void Reset();
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
index a844f55..a80636c 100644
--- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
+++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
@@ -48,11 +48,11 @@
namespace android
{
-
WebAutoFill::WebAutoFill()
: mQueryId(1)
, mWebViewCore(0)
, mLastSearchDomVersion(0)
+ , mParsingForms(false)
{
mTabContents = new TabContents();
setEmptyProfile();
@@ -74,18 +74,27 @@ void WebAutoFill::init()
WebAutoFill::~WebAutoFill()
{
- mQueryMap.clear();
+ cleanUpQueryMap();
mUniqueIdMap.clear();
}
+void WebAutoFill::cleanUpQueryMap()
+{
+ for (AutoFillQueryFormDataMap::iterator it = mQueryMap.begin(); it != mQueryMap.end(); it++)
+ delete it->second;
+ mQueryMap.clear();
+}
+
void WebAutoFill::searchDocument(WebCore::Frame* frame)
{
if (!enabled())
return;
+ MutexLocker lock(mFormsSeenMutex);
+
init();
- mQueryMap.clear();
+ cleanUpQueryMap();
mUniqueIdMap.clear();
mForms.clear();
mQueryId = 1;
@@ -98,8 +107,24 @@ void WebAutoFill::searchDocument(WebCore::Frame* frame)
mFormManager->ExtractForms(frame);
mFormManager->GetFormsInFrame(frame, FormManager::REQUIRE_AUTOCOMPLETE, &mForms);
- mAutoFillManager->FormsSeen(mForms);
+ // Needs to be done on a Chrome thread as it will make a URL request to the AutoFill server.
+ // TODO: Use our own Autofill thread instead of the IO thread.
+ // TODO: For now, block here. Would like to make this properly async.
+ base::Thread* thread = WebUrlLoaderClient::ioThread();
+ mParsingForms = true;
+ thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, &WebAutoFill::formsSeenImpl));
+ while (mParsingForms)
+ mFormsSeenCondition.wait(mFormsSeenMutex);
+}
+
+// Called on the Chromium IO thread.
+void WebAutoFill::formsSeenImpl()
+{
+ MutexLocker lock(mFormsSeenMutex);
+ mAutoFillManager->FormsSeen(mForms);
+ mParsingForms = false;
+ mFormsSeenCondition.signal();
}
void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldElement)
@@ -133,15 +158,16 @@ void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldEle
}
// Get the FormField from the Node.
- webkit_glue::FormField formField;
- FormManager::HTMLFormControlElementToFormField(formFieldElement, FormManager::EXTRACT_NONE, &formField);
- formField.set_label(FormManager::LabelForElement(*formFieldElement));
+ webkit_glue::FormField* formField = new webkit_glue::FormField;
+ FormManager::HTMLFormControlElementToFormField(formFieldElement, FormManager::EXTRACT_NONE, formField);
+ formField->set_label(FormManager::LabelForElement(*formFieldElement));
webkit_glue::FormData* form = new webkit_glue::FormData;
mFormManager->FindFormWithFormControlElement(formFieldElement, FormManager::REQUIRE_AUTOCOMPLETE, form);
- mQueryMap[mQueryId] = form;
+ mQueryMap[mQueryId] = new FormDataAndField(form, formField);
+
+ bool suggestions = mAutoFillManager->GetAutoFillSuggestions(*form, *formField);
- bool suggestions = mAutoFillManager->GetAutoFillSuggestions(false, formField);
mQueryId++;
if (!suggestions) {
ASSERT(mWebViewCore);
@@ -169,8 +195,11 @@ void WebAutoFill::fillFormFields(int queryId)
if (!enabled())
return;
- webkit_glue::FormData* form = mQueryMap[queryId];
+ webkit_glue::FormData* form = mQueryMap[queryId]->form();
+ webkit_glue::FormField* field = mQueryMap[queryId]->field();
ASSERT(form);
+ ASSERT(field);
+
AutoFillQueryToUniqueIdMap::iterator iter = mUniqueIdMap.find(queryId);
if (iter == mUniqueIdMap.end()) {
// The user has most likely tried to AutoFill the form again without
@@ -178,7 +207,7 @@ void WebAutoFill::fillFormFields(int queryId)
// but stop here to be certain.
return;
}
- mAutoFillManager->FillAutoFillFormData(queryId, *form, iter->second);
+ mAutoFillManager->FillAutoFillFormData(queryId, *form, *field, iter->second);
mUniqueIdMap.erase(iter);
}
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h
index 3713aa4..9389281 100644
--- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h
+++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h
@@ -34,6 +34,7 @@
#include <vector>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
+#include <wtf/ThreadingPrimitives.h>
class AutoFillManager;
class AutoFillProfile;
@@ -49,6 +50,22 @@ namespace android
class FormManager;
class WebViewCore;
+class FormDataAndField {
+public:
+ FormDataAndField(webkit_glue::FormData* form, webkit_glue::FormField* field)
+ : mForm(form)
+ , mField(field)
+ {
+ }
+
+ webkit_glue::FormData* form() { return mForm.get(); }
+ webkit_glue::FormField* field() { return mField.get(); }
+
+private:
+ OwnPtr<webkit_glue::FormData> mForm;
+ OwnPtr<webkit_glue::FormField> mField;
+};
+
class WebAutoFill : public Noncopyable
{
public:
@@ -74,6 +91,8 @@ private:
void init();
void searchDocument(WebCore::Frame*);
void setEmptyProfile();
+ void formsSeenImpl();
+ void cleanUpQueryMap();
OwnPtr<FormManager> mFormManager;
OwnPtr<AutoFillManager> mAutoFillManager;
@@ -84,7 +103,7 @@ private:
typedef std::vector<webkit_glue::FormData, std::allocator<webkit_glue::FormData> > FormList;
FormList mForms;
- typedef std::map<int, webkit_glue::FormData*> AutoFillQueryFormDataMap;
+ typedef std::map<int, FormDataAndField*> AutoFillQueryFormDataMap;
AutoFillQueryFormDataMap mQueryMap;
typedef std::map<int, int> AutoFillQueryToUniqueIdMap;
@@ -94,9 +113,15 @@ private:
WebViewCore* mWebViewCore;
int mLastSearchDomVersion;
+
+ WTF::Mutex mFormsSeenMutex; // Guards mFormsSeenCondition and mParsingForms.
+ WTF::ThreadCondition mFormsSeenCondition;
+ bool volatile mParsingForms;
};
}
+DISABLE_RUNNABLE_METHOD_REFCOUNT(android::WebAutoFill);
+
#endif // ENABLE(WEB_AUTOFILL)
#endif // WebAutoFill_h