[omnibox] Scope the on-clobber ZeroSuggest flag to Contextual Web only

Originally, we added an on-clobber entrypoint to ZeroSuggest guarded by
a feature flag which applied to all page classifications.

On further thought, it seems best to make this feature flag apply to
the Contextual Web (OTHER) page classification only, as different page
classifications may have different UI entrypoints to ZeroSuggest.

Bug: 1106096
Change-Id: I376e0b22d1b23d202e729d7a133920d94d9708e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2357209
Reviewed-by: Justin Donnelly <[email protected]>
Commit-Queue: Tommy Li <[email protected]>
Cr-Commit-Position: refs/heads/master@{#798330}
diff --git a/components/omnibox/browser/zero_suggest_provider.cc b/components/omnibox/browser/zero_suggest_provider.cc
index 1f0ac85..b586f75 100644
--- a/components/omnibox/browser/zero_suggest_provider.cc
+++ b/components/omnibox/browser/zero_suggest_provider.cc
@@ -624,16 +624,26 @@
     return false;
   }
 
-  // When the omnibox is empty, only allow zero suggest for the ChromeOS
-  // Launcher and NTP, unless the clobber flag is on.
-  //
-  // TODO(tommycli): Add more nuance here, likely with an omnibox_focus_type.
-  if (input_type == metrics::OmniboxInputType::EMPTY &&
-      !(page_class == metrics::OmniboxEventProto::CHROMEOS_APP_LIST ||
-        IsNTPPage(page_class) ||
-        base::FeatureList::IsEnabled(
-            omnibox::kClobberIsZeroSuggestEntrypoint))) {
-    return false;
+  if (input_type == metrics::OmniboxInputType::EMPTY) {
+    // Function that returns whether EMPTY input zero-suggest is allowed.
+    auto IsEmptyZeroSuggestAllowed = [&]() {
+      if (page_class == metrics::OmniboxEventProto::CHROMEOS_APP_LIST ||
+          IsNTPPage(page_class)) {
+        return true;
+      }
+
+      if (page_class == metrics::OmniboxEventProto::OTHER) {
+        return input.focus_type() == OmniboxFocusType::DELETED_PERMANENT_TEXT &&
+               base::FeatureList::IsEnabled(
+                   omnibox::kClobberTriggersContextualWebZeroSuggest);
+      }
+
+      return false;
+    };
+
+    // Return false if disallowed. Otherwise, proceed down to further checks.
+    if (!IsEmptyZeroSuggestAllowed())
+      return false;
   }
 
   // When omnibox contains pre-populated content, only show zero suggest for