[Nearby] Preserve disabled state if notification disabled by user

This CL changes the enable/disable logic of the "Nearby device is
trying to share" notification in the following ways:
1. If the user explicitly disables the notification, the disabled
state  is persisted until the user explicitly re-enables the feature
(by clicking the toggle).
2. If the notification is enabled and the user turns off the parent
Nearby Share feature the notification feature is turned off.
3. If the Nearby Share parent feature is toggled from off to on
and the notification feature has not explicitly been disabled by the
user (it was disabled automatically by toggling the parent feature)
then the notification feature is turned on.

Changes were manually verified.

Bug: 1223888
Change-Id: I42763c65368c78fe76d9df68eea0d6d3f7d1e032
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3173552
Commit-Queue: Claude van der Merwe <[email protected]>
Reviewed-by: Tommy Li <[email protected]>
Reviewed-by: Jimmy Gong <[email protected]>
Reviewed-by: Michael Hansen <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: Alex Gough <[email protected]>
Reviewed-by: Josh Nohle <[email protected]>
Cr-Commit-Position: refs/heads/main@{#927570}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 1035a67..1c603625 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -667,6 +667,12 @@
 const char kPrivacyBudgetSeed[] = "privacy_budget.randomizer_seed";
 const char kCloudPolicyOverridesPlatformPolicy[] = "policy.cloud_override";
 
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+// Deprecated 09/2021.
+const char kNearbySharingFastInitiationNotificationEnabledPrefName[] =
+    "nearby_sharing.fast_initiation_notification_enabled";
+#endif  // BUILDFLAG(IS_CHROMEOS_ASH)
+
 // Register local state used only for migration (clearing or moving to a new
 // key).
 void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
@@ -865,6 +871,11 @@
 #endif
 
   registry->RegisterIntegerPref(kAutofillAcceptSaveCreditCardPromptState, 0);
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+  registry->RegisterIntegerPref(
+      kNearbySharingFastInitiationNotificationEnabledPrefName, 0);
+#endif  // BUILDFLAG(IS_CHROMEOS_ASH)
 }
 
 }  // namespace
@@ -1706,6 +1717,12 @@
   profile_prefs->ClearPref(kDiceMigrationCompletePref);
 #endif
 
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+  // Added 09/2021
+  profile_prefs->ClearPref(
+      kNearbySharingFastInitiationNotificationEnabledPrefName);
+#endif  // BUILDFLAG(IS_CHROMEOS_ASH)
+
   // Please don't delete the following line. It is used by PRESUBMIT.py.
   // END_MIGRATE_OBSOLETE_PROFILE_PREFS
 }