[AF] Turn Off Autofill When Autocomplete=off and No Server Data

Overwrite the overall predicted field type to UNKNOWN_TYPE when there
is no server data for this field, and the autocomplete attribute is
set to off.

Testing:
Added unit tests with flag ON and OFF.
Tested manually to see that the issue seen in crbug.com/867995 is
fixed.

Bug: 949783
Change-Id: I0f3071edf30019aba5c374a866c3f9506090d715
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1554048
Commit-Queue: Fabio Tirelo <[email protected]>
Reviewed-by: Fabio Tirelo <[email protected]>
Auto-Submit: Sebastien Lalancette <[email protected]>
Cr-Commit-Position: refs/heads/master@{#648666}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 7aa9dae..8a776d58 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -4030,6 +4030,11 @@
      FEATURE_VALUE_TYPE(features::kInSessionPasswordChange)},
 #endif  // OS_CHROMEOS
 
+    {"autofill-off-no-server-data",
+     flag_descriptions::kAutofillOffNoServerDataName,
+     flag_descriptions::kAutofillOffNoServerDataDescription, kOsAll,
+     FEATURE_VALUE_TYPE(autofill::features::kAutofillOffNoServerData)},
+
     {"enable-portals", flag_descriptions::kEnablePortalsName,
      flag_descriptions::kEnablePortalsDescription, kOsAll,
      FEATURE_VALUE_TYPE(blink::features::kPortals)},
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index c04bfc8..4f212af1 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -918,6 +918,11 @@
     "expiry_milestone": 77
   },
   {
+    "name": "autofill-off-no-server-data",
+    "owners": [ "seblalancette" ],
+    "expiry_milestone": 79
+  },
+  {
     "name": "enable-autoplay-ignore-web-audio",
     "owners": [ "beccahughes", "mlamouri", "media-dev" ],
     "expiry_milestone": 73
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 41771ef4..073657a 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -139,6 +139,11 @@
     "When enabled, no local copy of server card will be saved when credit card "
     "upload succeeds.";
 
+const char kAutofillOffNoServerDataName[] = "Autofill Off No Server Data";
+const char kAutofillOffNoServerDataDescription[] =
+    "Disables Autofill for fields with autocomplete off that have no "
+    "crowd-sourced evidence that Autofill would be helpful.";
+
 const char kAutofillProfileClientValidationName[] =
     "Autofill Validates Profiles By Client";
 const char kAutofillProfileClientValidationDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 10dde3a..b7c07d4 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -113,6 +113,9 @@
 extern const char kAutofillNoLocalSaveOnUploadSuccessName[];
 extern const char kAutofillNoLocalSaveOnUploadSuccessDescription[];
 
+extern const char kAutofillOffNoServerDataName[];
+extern const char kAutofillOffNoServerDataDescription[];
+
 extern const char kAutofillProfileClientValidationName[];
 extern const char kAutofillProfileClientValidationDescription[];