summaryrefslogtreecommitdiffstats
path: root/WebKit/android/WebCoreSupport
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-01-07 16:04:47 +0000
committerBen Murdoch <benm@google.com>2011-01-11 15:04:36 +0000
commitd647e7c2e5ceee4dbcef5eee5c723cbdbed719d0 (patch)
tree49f75cb1fafd62f4be4ae593b03d89d5f2d200ee /WebKit/android/WebCoreSupport
parent6eef37161f9d4fde23b1b87a5bb26dfcf1a55c8c (diff)
downloadexternal_webkit-d647e7c2e5ceee4dbcef5eee5c723cbdbed719d0.zip
external_webkit-d647e7c2e5ceee4dbcef5eee5c723cbdbed719d0.tar.gz
external_webkit-d647e7c2e5ceee4dbcef5eee5c723cbdbed719d0.tar.bz2
Merge Chromium at 9.0.597.55: Merge 67599. (2/2)
This needed a bit of work so I've split into two commits. This is part 2, where we now need to pass both the field that was focussed and the form it belongs to. To achieve this I have a new class that encapsulates the pointers. Change-Id: Iea1a5a55696c63255bcc57b070116409a2195f4c
Diffstat (limited to 'WebKit/android/WebCoreSupport')
-rw-r--r--WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp29
-rw-r--r--WebKit/android/WebCoreSupport/autofill/WebAutoFill.h20
2 files changed, 38 insertions, 11 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
index a844f55..b8afbe9 100644
--- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
+++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
@@ -48,7 +48,6 @@
namespace android
{
-
WebAutoFill::WebAutoFill()
: mQueryId(1)
, mWebViewCore(0)
@@ -74,10 +73,17 @@ 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())
@@ -85,7 +91,7 @@ void WebAutoFill::searchDocument(WebCore::Frame* frame)
init();
- mQueryMap.clear();
+ cleanUpQueryMap();
mUniqueIdMap.clear();
mForms.clear();
mQueryId = 1;
@@ -133,15 +139,15 @@ 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(false, formField);
+ bool suggestions = mAutoFillManager->GetAutoFillSuggestions(*form, *formField);
mQueryId++;
if (!suggestions) {
ASSERT(mWebViewCore);
@@ -169,8 +175,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 +187,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..ee1ac17 100644
--- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h
+++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h
@@ -49,6 +49,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 +90,8 @@ private:
void init();
void searchDocument(WebCore::Frame*);
void setEmptyProfile();
+ void formsSeenImpl();
+ void cleanUpQueryMap();
OwnPtr<FormManager> mFormManager;
OwnPtr<AutoFillManager> mAutoFillManager;
@@ -84,7 +102,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;