Navi: Only show NTP background module when Google is the default.

Bug: 951873
Change-Id: Iae42b37dd9c44705c9bfaa66a58dcce6441a0fdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1576015
Reviewed-by: Dan Beam <dbeam@chromium.org>
Commit-Queue: Hector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653678}
diff --git a/chrome/browser/ui/webui/welcome/nux_helper.cc b/chrome/browser/ui/webui/welcome/nux_helper.cc
index 1601a02..33a9c63 100644
--- a/chrome/browser/ui/webui/welcome/nux_helper.cc
+++ b/chrome/browser/ui/webui/welcome/nux_helper.cc
@@ -53,9 +53,11 @@
   return true;
 }
 
-bool CanShowNTPBackgroundModule(const policy::PolicyMap& policies) {
-  // We shouldn't show this module if any policy is set that overrides the NTP.
-  return !policies.GetValue(policy::key::kNewTabPageLocation);
+bool CanShowNTPBackgroundModule(const policy::PolicyMap& policies,
+                                Profile* profile) {
+  // We can't set the background if the NTP is something other than Google.
+  return !policies.GetValue(policy::key::kNewTabPageLocation) &&
+         search::DefaultSearchProviderIsGoogle(profile);
 }
 
 bool CanShowSetDefaultModule(const policy::PolicyMap& policies) {
@@ -173,13 +175,13 @@
       policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
 }
 
-std::vector<std::string> GetAvailableModules(
-    const policy::PolicyMap& policies) {
+std::vector<std::string> GetAvailableModules(Profile* profile) {
+  const policy::PolicyMap& policies = GetPoliciesFromProfile(profile);
   std::vector<std::string> available_modules;
 
   if (CanShowGoogleAppModule(policies))
     available_modules.push_back("nux-google-apps");
-  if (CanShowNTPBackgroundModule(policies))
+  if (CanShowNTPBackgroundModule(policies, profile))
     available_modules.push_back("nux-ntp-background");
   if (CanShowSetDefaultModule(policies))
     available_modules.push_back("nux-set-as-default");
@@ -190,7 +192,7 @@
 }
 
 bool DoesOnboardingHaveModulesToShow(Profile* profile) {
-  return !GetAvailableModules(GetPoliciesFromProfile(profile)).empty();
+  return !GetAvailableModules(profile).empty();
 }
 
 std::string FilterModules(const std::string& requested_modules,
@@ -225,8 +227,7 @@
     returning_user_modules = kNuxOnboardingReturningUserModules.Get();
   }
 
-  const policy::PolicyMap& policies = GetPoliciesFromProfile(profile);
-  std::vector<std::string> available_modules = GetAvailableModules(policies);
+  std::vector<std::string> available_modules = GetAvailableModules(profile);
 
   base::DictionaryValue modules;
   modules.SetString("new-user",