summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-09 18:52:50 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-09 18:52:50 +0000
commit38377654a4cf59397e92890e62cd203971531ac4 (patch)
treea69cafbeb540cb0f24d14c13174e8039056cbfcd /chrome
parent592ca909efa35c0000b349285b059700ae543ee4 (diff)
downloadchromium_src-38377654a4cf59397e92890e62cd203971531ac4.zip
chromium_src-38377654a4cf59397e92890e62cd203971531ac4.tar.gz
chromium_src-38377654a4cf59397e92890e62cd203971531ac4.tar.bz2
Send forms seen in the renderer to the AutoFillManager.
BUG=none TEST=none Review URL: http://codereview.chromium.org/584009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autofill/autofill_manager.cc14
-rw-r--r--chrome/browser/autofill/autofill_manager.h7
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc9
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h5
-rw-r--r--chrome/common/render_messages_internal.h7
-rw-r--r--chrome/renderer/render_view.cc25
-rw-r--r--chrome/renderer/render_view.h5
8 files changed, 67 insertions, 7 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index d1bcf22..60d048f 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -60,6 +60,18 @@ void AutoFillManager::FormFieldValuesSubmitted(
}
}
+void AutoFillManager::FormsSeen(
+ const std::vector<webkit_glue::FormFieldValues>& forms) {
+ form_structures_.reset();
+ for (std::vector<webkit_glue::FormFieldValues>::const_iterator iter =
+ forms.begin();
+ iter != forms.end(); ++iter) {
+ FormStructure* form_structure = new FormStructure(*iter);
+ DeterminePossibleFieldTypes(form_structure);
+ form_structures_.push_back(form_structure);
+ }
+}
+
void AutoFillManager::OnAutoFillDialogApply(
std::vector<AutoFillProfile>* profiles,
std::vector<CreditCard>* credit_cards) {
@@ -96,7 +108,7 @@ void AutoFillManager::DeterminePossibleFieldTypes(
void AutoFillManager::HandleSubmit() {
// If there wasn't enough data to import then we don't want to send an upload
// to the server.
- if (!personal_data_->ImportFormData(form_structures_, this))
+ if (!personal_data_->ImportFormData(form_structures_.get(), this))
return;
UploadFormData();
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 85905c8..0c55853 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/scoped_ptr.h"
+#include "base/scoped_vector.h"
#include "chrome/browser/autofill/autofill_dialog.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
@@ -38,6 +39,8 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
// RenderViewHostDelegate::AutoFill implementation:
virtual void FormFieldValuesSubmitted(
const webkit_glue::FormFieldValues& form);
+ virtual void FormsSeen(
+ const std::vector<webkit_glue::FormFieldValues>& forms);
// AutoFillDialogObserver implementation:
virtual void OnAutoFillDialogApply(
@@ -71,11 +74,11 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
TabContents* tab_contents_;
// The personal data manager, used to save and load personal data to/from the
- // web database.
+ // web database. This may be NULL if we're OTR.
PersonalDataManager* personal_data_;
// Our copy of the form data.
- std::vector<FormStructure*> form_structures_;
+ ScopedVector<FormStructure> form_structures_;
scoped_ptr<FormStructure> upload_form_structure_;
// The infobar that asks for permission to store form information.
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 58e379d..89a2093 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -767,6 +767,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnMsgRunBeforeUnloadConfirm)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ShowModalHTMLDialog,
OnMsgShowModalHTMLDialog)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_FormsSeen, OnMsgFormsSeen)
IPC_MESSAGE_HANDLER(ViewHostMsg_PasswordFormsSeen, OnMsgPasswordFormsSeen)
IPC_MESSAGE_HANDLER(ViewHostMsg_FormFieldValuesSubmitted,
OnMsgFormFieldValuesSubmitted)
@@ -1352,6 +1353,14 @@ void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location,
Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action));
}
+void RenderViewHost::OnMsgFormsSeen(
+ const std::vector<webkit_glue::FormFieldValues>& forms) {
+ RenderViewHostDelegate::AutoFill* autofill_delegate =
+ delegate_->GetAutoFillDelegate();
+ if (autofill_delegate)
+ autofill_delegate->FormsSeen(forms);
+}
+
void RenderViewHost::OnMsgPasswordFormsSeen(
const std::vector<webkit_glue::PasswordForm>& forms) {
delegate_->PasswordFormsSeen(forms);
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 2fb8931..74e0e77 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -540,6 +540,8 @@ class RenderViewHost : public RenderWidgetHost {
void OnMsgShowModalHTMLDialog(const GURL& url, int width, int height,
const std::string& json_arguments,
IPC::Message* reply_msg);
+ void OnMsgFormsSeen(
+ const std::vector<webkit_glue::FormFieldValues>& forms);
void OnMsgPasswordFormsSeen(
const std::vector<webkit_glue::PasswordForm>& forms);
void OnMsgFormFieldValuesSubmitted(const webkit_glue::FormFieldValues& forms);
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index 02c5d92..e782f4b 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -392,6 +392,11 @@ class RenderViewHostDelegate {
// Called when the user submits a form.
virtual void FormFieldValuesSubmitted(
const webkit_glue::FormFieldValues& form) = 0;
+
+ // Called when the frame has finished loading and there are forms in the
+ // frame.
+ virtual void FormsSeen(
+ const std::vector<webkit_glue::FormFieldValues>& forms) = 0;
};
// ---------------------------------------------------------------------------
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 3a58772..591dbb1 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1341,8 +1341,13 @@ IPC_BEGIN_MESSAGES(ViewHost)
string16 /* title */,
FilePath /* Default file name */)
+ // Notification that forms have been seen that are candidates for
+ // filling/submitting by the AutoFillManager.
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_FormsSeen,
+ std::vector<webkit_glue::FormFieldValues> /* forms */)
+
// Notification that password forms have been seen that are candidates for
- // filling/submitting by the password manager
+ // filling/submitting by the password manager.
IPC_MESSAGE_ROUTED1(ViewHostMsg_PasswordFormsSeen,
std::vector<webkit_glue::PasswordForm> /* forms */)
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 740c147..6b54fe3 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2511,8 +2511,10 @@ void RenderView::didFinishDocumentLoad(WebFrame* frame) {
Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_));
- // The document has now been fully loaded. Scan for password forms to be
- // sent up to the browser.
+ // The document has now been fully loaded. Scan for forms to be sent up to
+ // the browser.
+ // TODO(jhawkins): Make these use the FormManager.
+ SendForms(frame);
SendPasswordForms(frame);
// Check whether we have new encoding name.
@@ -4235,6 +4237,25 @@ void RenderView::focusAccessibilityObject(
#endif
}
+void RenderView::SendForms(WebFrame* frame) {
+ WebVector<WebFormElement> web_forms;
+ frame->forms(web_forms);
+
+ std::vector<FormFieldValues> forms;
+ for (size_t i = 0; i < web_forms.size(); ++i) {
+ const WebFormElement& web_form = web_forms[i];
+
+ if (web_form.autoComplete()) {
+ scoped_ptr<FormFieldValues> form(FormFieldValues::Create(web_form));
+ if (form.get())
+ forms.push_back(*form);
+ }
+ }
+
+ if (!forms.empty())
+ Send(new ViewHostMsg_FormsSeen(routing_id_, forms));
+}
+
void RenderView::SendPasswordForms(WebFrame* frame) {
WebVector<WebFormElement> forms;
frame->forms(forms);
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 0066bf3..ab59b72 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -803,7 +803,10 @@ class RenderView : public RenderWidget,
void LogNavigationState(const NavigationState* state,
const WebKit::WebDataSource* ds) const;
- // Scan the given frame for password forms and send them up to the browser.
+ // Scans the given frame for forms and sends them up to the browser.
+ void SendForms(WebKit::WebFrame* frame);
+
+ // Scans the given frame for password forms and sends them up to the browser.
void SendPasswordForms(WebKit::WebFrame* frame);
void Print(WebKit::WebFrame* frame, bool script_initiated);