diff options
author | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-08 02:13:09 +0000 |
---|---|---|
committer | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-08 02:13:09 +0000 |
commit | d893ab9643e5284db08087bc7514f59e37d6b319 (patch) | |
tree | 862077a3e8acbb010157f8c3bdd45e95d7e40ecb /webkit/glue/webframeloaderclient_impl.cc | |
parent | bab654788c013d4cdf3900fc43927e159362b5ed (diff) | |
download | chromium_src-d893ab9643e5284db08087bc7514f59e37d6b319.zip chromium_src-d893ab9643e5284db08087bc7514f59e37d6b319.tar.gz chromium_src-d893ab9643e5284db08087bc7514f59e37d6b319.tar.bz2 |
Entries in a form get recorded when the user submits the form. Database and pop-up menu talk to each other. Pop-up menu appears containing suggestions.
Review URL: http://codereview.chromium.org/9462
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5058 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webframeloaderclient_impl.cc')
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 6c50037..817993b 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -42,6 +42,7 @@ MSVC_POP_WARNING(); #if defined(OS_WIN) #include "webkit/activex_shim/activex_shared.h" #endif +#include "webkit/glue/autofill_form.h" #include "webkit/glue/alt_404_page_resource_fetcher.h" #include "webkit/glue/autocomplete_input_listener.h" #include "webkit/glue/form_autocomplete_listener.h" @@ -343,7 +344,8 @@ void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { PassRefPtr<WebCore::HTMLCollection> forms = webframe_->frame()->document()->forms(); - std::vector<PasswordForm> actions; + std::vector<PasswordForm> passwordForms; + unsigned int form_count = forms->length(); for (unsigned int i = 0; i < form_count; ++i) { // Strange but true, sometimes item can be NULL. @@ -357,18 +359,21 @@ void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { continue; std::set<std::wstring> password_related_fields; - scoped_ptr<PasswordForm> data( + scoped_ptr<PasswordForm> passwordFormPtr( PasswordFormDomManager::CreatePasswordForm(form)); - if (data.get()) { - actions.push_back(*data); + + if (passwordFormPtr.get()) { + passwordForms.push_back(*passwordFormPtr); + // Let's remember the names of password related fields so we do not // autofill them with the regular form autofill. - if (!data->username_element.empty()) - password_related_fields.insert(data->username_element); - DCHECK(!data->password_element.empty()); - password_related_fields.insert(data->password_element); - if (!data->old_password_element.empty()) - password_related_fields.insert(data->old_password_element); + + if (!passwordFormPtr->username_element.empty()) + password_related_fields.insert(passwordFormPtr->username_element); + DCHECK(!passwordFormPtr->password_element.empty()); + password_related_fields.insert(passwordFormPtr->password_element); + if (!passwordFormPtr->old_password_element.empty()) + password_related_fields.insert(passwordFormPtr->old_password_element); } // Now let's register for any text input. @@ -378,8 +383,8 @@ void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { } } - if (d && (actions.size() > 0)) - d->OnPasswordFormsSeen(webview, actions); + if (d && (passwordForms.size() > 0)) + d->OnPasswordFormsSeen(webview, passwordForms); if (d) d->DidFinishDocumentLoadForFrame(webview, webframe_); } @@ -1003,7 +1008,7 @@ void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&) } void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, - PassRefPtr<FormState> form_ref) { + PassRefPtr<FormState> form_ref) { SearchableFormData* form_data = SearchableFormData::Create(form_ref->form()); WebDocumentLoaderImpl* loader = static_cast<WebDocumentLoaderImpl*>( webframe_->frame()->loader()->provisionalDocumentLoader()); @@ -1015,6 +1020,19 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, // Don't free the PasswordFormData, the loader will do that. loader->set_password_form_data(pass_data); + WebViewImpl* webview = webframe_->webview_impl(); + WebViewDelegate* d = webview->delegate(); + + // Unless autocomplete=off, record what the user put in it for future + // autofilling. + if (form_ref->form()->autoComplete()) { + scoped_ptr<AutofillForm> autofill_form( + AutofillForm::CreateAutofillForm(form_ref->form())); + if (autofill_form.get()) { + d->OnAutofillFormSubmitted(webview, *autofill_form); + } + } + loader->set_form_submit(true); (webframe_->frame()->loader()->*function)(PolicyUse); |