[Extensions] Move NTP overriding prefs to settings_api_bubble_helpers

The NTP overridden bubble UI is deprecated (and has been replaced by a
dialog-based approach). However, the preferences related to the UI are
currently encapsulated in the bubble code. We deliberately use the same
preferences so that users who previously acknowledged NTP-overriding
extensions with the bubble UI are not re-notified.

Move the relevant preferences out of the NTP bubble code and into the
more general settings_api_bubble_helpers code. This is the entry point
for both the bubbles and the UI code, and was the only (non-testing)
call site for the preference code.

This CL moves two preference related bits: the first is the preference
to acknowledge a given extension has overridden the NTP. The second is
a preference for whether a global acknowledgement of pre-existing
extensions has been triggered (this is used when expanding the UI to
new platforms). Move each of these to the settings_api_bubble_helpers
code.

Additionally, move the ntp_overridden_bubble_delegate_unittest code to
settings_api_bubble_helpers_unittest. Since the only unittest here was
pertaining to the acknowledgement preferences, we can easily tweak the
test to exercise the same conceptual case for the code in
settings_api_bubble_helpers.

This paves the way to remove NtpOverriddenBubbleDelegate in its
entirety.

Bug: 1186126
Change-Id: Id4c34011c7875b0f8f7414385c19984ecdbab810
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2744647
Commit-Queue: Devlin <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: David Bertoni <[email protected]>
Cr-Commit-Position: refs/heads/master@{#864031}
diff --git a/chrome/browser/ui/extensions/settings_api_bubble_helpers.h b/chrome/browser/ui/extensions/settings_api_bubble_helpers.h
index 0d29533..547df7f 100644
--- a/chrome/browser/ui/extensions/settings_api_bubble_helpers.h
+++ b/chrome/browser/ui/extensions/settings_api_bubble_helpers.h
@@ -5,9 +5,12 @@
 #ifndef CHROME_BROWSER_UI_EXTENSIONS_SETTINGS_API_BUBBLE_HELPERS_H_
 #define CHROME_BROWSER_UI_EXTENSIONS_SETTINGS_API_BUBBLE_HELPERS_H_
 
+#include "base/auto_reset.h"
 #include "components/omnibox/browser/autocomplete_match.h"
 
 class Browser;
+class PrefRegistrySimple;
+class Profile;
 
 namespace content {
 class WebContents;
@@ -15,10 +18,27 @@
 
 namespace extensions {
 
+extern const char kNtpOverridingExtensionAcknowledged[];
+
 // Sets whether the NTP post-install UI is enabled for testing purposes.
 // TODO(devlin): This would be cooler as a base::AutoReset<>.
 void SetNtpPostInstallUiEnabledForTesting(bool enabled);
 
+// Testing-only method to configure if existing NTP extensions are
+// auto-acknowledged.
+base::AutoReset<bool> SetAcknowledgeExistingNtpExtensionsForTesting(
+    bool should_acknowledge);
+
+// Registers prefs related to the settings overridden UI.
+void RegisterSettingsOverriddenUiPrefs(PrefRegistrySimple* registry);
+
+// Iterates over existing NTP-overriding extensions installed in the given
+// `profile` and marks them as acknowledged. Stores a preference indicating
+// the action was completed. Subsequent calls will *not* acknowledge more
+// extensions. This is needed to avoid prompting users with existing
+// extensions when we expand the warning to new platforms.
+void AcknowledgePreExistingNtpExtensions(Profile* profile);
+
 // Shows a bubble notifying the user that the homepage is controlled by an
 // extension. This bubble is shown only on the first use of the Home button
 // after the controlling extension takes effect.