[DIPS] Add Chrome feature flag for Delete Incidental Party State (DIPS)

This CL adds a chrome feature flag for user access via
chrome://flags/#bounce-tracking-mitigations

This addition will allow users to force enable/disable the DIPS
feature with the default parameter values as stated in
dips_features.cc, or with params set to delete state according to our
intended launch configuration.

See: https://screenshot.googleplex.com/4gA4nrbnuYCUCys.png

Bug: 1424141

Change-Id: I2367d27491bd6610f03f88592c99cf6722f26611
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4401450
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Commit-Queue: Jonathan Njeunje <njeunje@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1128074}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 0e464d49..9f75978 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -33,6 +33,7 @@
 #include "chrome/browser/browser_features.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/companion/core/features.h"
+#include "chrome/browser/dips/dips_features.h"
 #include "chrome/browser/fast_checkout/fast_checkout_features.h"
 #include "chrome/browser/feature_guide/notifications/feature_notification_guide_service.h"
 #include "chrome/browser/flag_descriptions.h"
@@ -3429,6 +3430,15 @@
 };
 #endif  // BUILDFLAG(ENABLE_EXTENSIONS)
 
+const FeatureEntry::FeatureParam kDIPSWithDeletion[] = {
+    {"persist_database", "true"},
+    {"delete", "true"},
+    {"triggering_action", "stateful_bounce"}};
+
+const FeatureEntry::FeatureVariation kDIPSVariations[] = {
+    {"With Deletion", kDIPSWithDeletion, std::size(kDIPSWithDeletion),
+     nullptr}};
+
 #if BUILDFLAG(IS_CHROMEOS_ASH)
 const FeatureEntry::FeatureParam kVcSegmentationModelHighResolution[] = {
     {"segmentation_model", "high_resolution"},
@@ -8587,6 +8597,10 @@
      flag_descriptions::kThirdPartyStoragePartitioningDescription, kOsAll,
      FEATURE_VALUE_TYPE(net::features::kThirdPartyStoragePartitioning)},
 
+    {"bounce-tracking-mitigations", flag_descriptions::kDIPSName,
+     flag_descriptions::kDIPSDescription, kOsAll,
+     FEATURE_WITH_PARAMS_VALUE_TYPE(dips::kFeature, kDIPSVariations, "DIPS")},
+
 #if BUILDFLAG(IS_CHROMEOS_ASH)
     {kBorealisBigGlInternalName, flag_descriptions::kBorealisBigGlName,
      flag_descriptions::kBorealisBigGlDescription, kOsCrOS,
diff --git a/chrome/browser/dips/dips_features.cc b/chrome/browser/dips/dips_features.cc
index 2cfc104..07b1d891 100644
--- a/chrome/browser/dips/dips_features.cc
+++ b/chrome/browser/dips/dips_features.cc
@@ -40,15 +40,19 @@
 const base::FeatureParam<base::TimeDelta> kInteractionTtl{
     &kFeature, "interaction_ttl", base::Days(45)};
 
-// Sets the actions which will trigger DIPS clearing for a site. The default is
-// to set to kBounce, but can be overridden by Finch experiment groups or by
-// command-line flags.
 constexpr base::FeatureParam<DIPSTriggeringAction>::Option
     kTriggeringActionOptions[] = {
         {DIPSTriggeringAction::kNone, "none"},
         {DIPSTriggeringAction::kStorage, "storage"},
         {DIPSTriggeringAction::kBounce, "bounce"},
         {DIPSTriggeringAction::kStatefulBounce, "stateful_bounce"}};
+
+// Sets the actions which will trigger DIPS clearing for a site. The default is
+// to set to kBounce, but can be overridden by Finch experiment groups,
+// command-line flags, or chrome flags.
+//
+// Note: Maintain a matching nomenclature of the options with the feature flag
+// entries at about_flags.cc.
 const base::FeatureParam<DIPSTriggeringAction> kTriggeringAction{
     &kFeature, "triggering_action", DIPSTriggeringAction::kNone,
     &kTriggeringActionOptions};
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index 5c167f9..7478bddd 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -875,6 +875,14 @@
     "expiry_milestone": 122
   },
   {
+    "name": "bounce-tracking-mitigations",
+    "owners": [
+      "wanderview@chromium.org",
+      "njeunje@chromium.org",
+      "//chrome/browser/dips/OWNERS"],
+      "expiry_milestone": 119
+  },
+  {
     "name": "bring-your-own-tabs-ios",
     "owners": [ "ginnyhuang@chromium.org", "hiramahmood@google.com", "bling-get-set-up@google.com" ],
     "expiry_milestone": 120
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 42a10cb..e60d71e 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -180,6 +180,13 @@
     "is able to work around the history intervention which is not the expected "
     "behavior";
 
+const char kDIPSName[] = "Bounce Tracking Mitigations";
+const char kDIPSDescription[] =
+    "This flag controls bounce tracking mitigations. Setting the flag to "
+    "\"Enabled With Deletion\" will cause the browser to delete state for "
+    "sites that appear to be performing cross-site tracking using the bounce "
+    "tracking technique.";
+
 const char kDocumentPictureInPictureApiName[] =
     "Document Picture-in-Picture API";
 const char kDocumentPictureInPictureApiDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index a46d951..80b641c8 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -119,6 +119,9 @@
 extern const char kDebugHistoryInterventionNoUserActivationName[];
 extern const char kDebugHistoryInterventionNoUserActivationDescription[];
 
+extern const char kDIPSName[];
+extern const char kDIPSDescription[];
+
 extern const char kDocumentPictureInPictureApiName[];
 extern const char kDocumentPictureInPictureApiDescription[];
 
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 6681bd8a..e55c798 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -61292,6 +61292,7 @@
   <int value="-354783358" label="NTPSaveToOffline:disabled"/>
   <int value="-353182790" label="ConsistentOmniboxGeolocation:disabled"/>
   <int value="-353180213" label="DevicePosture:disabled"/>
+  <int value="-352731236" label="DIPS:enabled"/>
   <int value="-351830087" label="AssistantConsentSimplifiedText:enabled"/>
   <int value="-351744276"
       label="ExperimentalAccessibilityDictationContextChecking:enabled"/>
@@ -62977,6 +62978,7 @@
   <int value="564522013" label="Av1Decoder:disabled"/>
   <int value="565254510" label="LensRegionSearchStaticPage:disabled"/>
   <int value="565406673" label="EnableVirtualKeyboardMdUi:enabled"/>
+  <int value="566031886" label="DIPS:disabled"/>
   <int value="567368307" label="enable-experimental-canvas-features"/>
   <int value="570469494" label="LoginDetection:disabled"/>
   <int value="570882482" label="CrOSDspBasedAecAllowed:enabled"/>