Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: components/autofill/browser/autofill_manager.cc

Issue 15942004: Stop offering Autocheckout bubble on the forms of no interest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/browser/autofill_manager.cc
diff --git a/components/autofill/browser/autofill_manager.cc b/components/autofill/browser/autofill_manager.cc
index 35b703c59e24d9735bef6341499e06ab1d54e0a4..a8ebecd48a0bb578c2b2232aaf930fa28a91a2ee 100644
--- a/components/autofill/browser/autofill_manager.cc
+++ b/components/autofill/browser/autofill_manager.cc
@@ -170,6 +170,16 @@ void DeterminePossibleFieldTypesForUpload(
}
}
+// Returns true if server returned known field types to one or more fields in
+// this form.
+bool HasServerSpecifiedFieldTypes(const FormStructure& form_structure) {
+ for (size_t i = 0; i < form_structure.field_count(); ++i) {
+ if (form_structure.field(i)->server_type() != NO_SERVER_DATA)
+ return true;
+ }
+ return false;
+}
+
} // namespace
// static
@@ -847,19 +857,6 @@ void AutofillManager::OnClickFailed(autofill::AutocheckoutStatus status) {
autocheckout_manager_.OnClickFailed(status);
}
-void AutofillManager::OnMaybeShowAutocheckoutBubble(
- const GURL& source_url,
- const content::SSLStatus& ssl_status,
- const gfx::RectF& bounding_box) {
- if (!IsAutofillEnabled())
- return;
-
- autocheckout_manager_.MaybeShowAutocheckoutBubble(
- source_url,
- ssl_status,
- bounding_box);
-}
-
std::string AutofillManager::GetAutocheckoutURLPrefix() const {
if (!web_contents())
return std::string();
@@ -925,6 +922,29 @@ void AutofillManager::UploadFormDataAsyncCallback(
UploadFormData(*submitted_form);
}
+void AutofillManager::OnMaybeShowAutocheckoutBubble(
+ const FormData& form,
+ const gfx::RectF& bounding_box) {
+ if (!IsAutofillEnabled())
+ return;
+
+ // Don't show bubble if corresponding FormStructure doesn't have anything to
+ // autofill.
+ FormStructure* cached_form;
+ if (!FindCachedForm(form, &cached_form))
+ return;
+
+ // Don't offer Autocheckout bubble if Autofill server is not aware of this
+ // form in the context of Autocheckout experiment.
+ if (!HasServerSpecifiedFieldTypes(*cached_form))
+ return;
+
+ autocheckout_manager_.MaybeShowAutocheckoutBubble(
+ form.origin,
+ form.ssl_status,
+ bounding_box);
+}
+
void AutofillManager::UploadFormData(const FormStructure& submitted_form) {
if (!download_manager_)
return;
« no previous file with comments | « components/autofill/browser/autofill_manager.h ('k') | components/autofill/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698