summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-27 07:03:56 +0000
committerahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-27 07:03:56 +0000
commit8a5b386945d0ed8a702c3b882e23224dca919ebe (patch)
tree4820afbbc2b18e76b45f702ac10ac88b0e2e370f /components
parentb30cdf8653f22274709b4472cb3316af7bc254f1 (diff)
downloadchromium_src-8a5b386945d0ed8a702c3b882e23224dca919ebe.zip
chromium_src-8a5b386945d0ed8a702c3b882e23224dca919ebe.tar.gz
chromium_src-8a5b386945d0ed8a702c3b882e23224dca919ebe.tar.bz2
Fixing TODO in autofill_agent.cc.
Currently, too many IPCs are being set from FocusedNodeChanged in AutofillAgent. This limits sending the IPCs to when the current page is on the Autocheckout whitelist. BUG= Review URL: https://chromiumcodereview.appspot.com/13094014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/autofill/browser/autofill_manager.cc12
-rw-r--r--components/autofill/common/autofill_messages.h3
-rw-r--r--components/autofill/renderer/autofill_agent.cc13
-rw-r--r--components/autofill/renderer/autofill_agent.h6
4 files changed, 26 insertions, 8 deletions
diff --git a/components/autofill/browser/autofill_manager.cc b/components/autofill/browser/autofill_manager.cc
index 209294a..e7de168 100644
--- a/components/autofill/browser/autofill_manager.cc
+++ b/components/autofill/browser/autofill_manager.cc
@@ -453,10 +453,14 @@ void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms,
if (!host)
return;
- // If whitelisted URL, fetch all the forms.
- if (has_more_forms && !GetAutocheckoutURLPrefix().empty()) {
- host->Send(new AutofillMsg_GetAllForms(host->GetRoutingID()));
- return;
+ if (!GetAutocheckoutURLPrefix().empty()) {
+ host->Send(
+ new AutofillMsg_WhitelistedForAutocheckout(host->GetRoutingID()));
+ // If whitelisted URL, fetch all the forms.
+ if (has_more_forms) {
+ host->Send(new AutofillMsg_GetAllForms(host->GetRoutingID()));
+ return;
+ }
}
autocheckout_manager_.OnFormsSeen();
diff --git a/components/autofill/common/autofill_messages.h b/components/autofill/common/autofill_messages.h
index 3c1dc4c..7a35b17 100644
--- a/components/autofill/common/autofill_messages.h
+++ b/components/autofill/common/autofill_messages.h
@@ -165,6 +165,9 @@ IPC_MESSAGE_ROUTED2(AutofillMsg_FillFormsAndClick,
std::vector<FormData> /* form_data */,
autofill::WebElementDescriptor /* element_descriptor */)
+// Sent when the current page is whitelisted for Autocheckout.
+IPC_MESSAGE_ROUTED0(AutofillMsg_WhitelistedForAutocheckout)
+
// Autofill messages sent from the renderer to the browser.
// TODO(creis): check in the browser that the renderer actually has permission
diff --git a/components/autofill/renderer/autofill_agent.cc b/components/autofill/renderer/autofill_agent.cc
index 355b4bf..2c71783 100644
--- a/components/autofill/renderer/autofill_agent.cc
+++ b/components/autofill/renderer/autofill_agent.cc
@@ -152,6 +152,7 @@ AutofillAgent::AutofillAgent(
has_shown_autofill_popup_for_current_edit_(false),
did_set_node_text_(false),
autocheckout_click_in_progress_(false),
+ is_whitelisted_for_autocheckout_(false),
ignore_text_changes_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
render_view->GetWebView()->setAutofillClient(this);
@@ -185,6 +186,8 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
OnRequestAutocompleteResult)
IPC_MESSAGE_HANDLER(AutofillMsg_FillFormsAndClick,
OnFillFormsAndClick)
+ IPC_MESSAGE_HANDLER(AutofillMsg_WhitelistedForAutocheckout,
+ OnWhitelistedForAutocheckout)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -204,6 +207,7 @@ void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
form_elements_.clear();
has_more_forms = form_cache_.ExtractFormsAndFormElements(
*frame, kRequiredAutofillFields, &forms, &form_elements_);
+ is_whitelisted_for_autocheckout_ = false;
} else {
form_cache_.ExtractForms(*frame, &forms);
}
@@ -278,10 +282,7 @@ void AutofillAgent::ZoomLevelChanged() {
}
void AutofillAgent::FocusedNodeChanged(const WebKit::WebNode& node) {
- // TODO(ahutter): Remove this hack once Autocheckout whitelisting info is
- // pushed to the renderer.
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableExperimentalFormFilling))
+ if (!is_whitelisted_for_autocheckout_)
return;
if (node.isNull() || !node.isElementNode())
@@ -772,6 +773,10 @@ void AutofillAgent::OnFillFormsAndClick(
}
}
+void AutofillAgent::OnWhitelistedForAutocheckout() {
+ is_whitelisted_for_autocheckout_ = true;
+}
+
void AutofillAgent::ClickFailed() {
Send(new AutofillHostMsg_ClickFailed(routing_id(),
CANNOT_PROCEED));
diff --git a/components/autofill/renderer/autofill_agent.h b/components/autofill/renderer/autofill_agent.h
index 9ae4ef8..12dd1b56 100644
--- a/components/autofill/renderer/autofill_agent.h
+++ b/components/autofill/renderer/autofill_agent.h
@@ -139,6 +139,9 @@ class AutofillAgent : public content::RenderViewObserver,
void OnFillFormsAndClick(const std::vector<FormData>& form_data,
const WebElementDescriptor& element_descriptor);
+ // Called when |topmost_frame_| is whitelisted for Autocheckout.
+ void OnWhitelistedForAutocheckout();
+
// Called when clicking an Autocheckout proceed element fails to do anything.
void ClickFailed();
@@ -250,6 +253,9 @@ class AutofillAgent : public content::RenderViewObserver,
// Autocheckout flow.
bool autocheckout_click_in_progress_;
+ // Whether or not |topmost_frame_| is whitelisted for Autocheckout.
+ bool is_whitelisted_for_autocheckout_;
+
// Whether or not to ignore text changes. Useful for when we're committing
// a composition when we are defocusing the WebView and we don't want to
// trigger an autofill popup to show.