Re-enable PolicyPrefsTestCoverageTest.AllPoliciesHaveATestCase
Also ensure that prefs::kExtensibleEnterpriseSSOEnabled is registered
and that kExtensibleEnterpriseSSOEnabled.json typo and pref location
are fixed.
Bug: 340868357, 341097718
Change-Id: I6acd50a74d3e854a3d98ec5736d5c7e6102dcb96
Fixed: 341097718
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5552898
Reviewed-by: Alexander Hendrich <[email protected]>
Code-Coverage: [email protected] <[email protected]>
Reviewed-by: Greg Thompson <[email protected]>
Reviewed-by: Igor Ruvinov <[email protected]>
Commit-Queue: Yann Dago <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1305133}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 63c0cb5a..cbac415 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -6068,6 +6068,14 @@
"webauthn/local_credential_management_mac.h",
]
}
+ if (is_mac || is_win) {
+ sources += [
+ "enterprise/platform_auth/platform_auth_policy_observer.cc",
+ "enterprise/platform_auth/platform_auth_policy_observer.h",
+ "enterprise/platform_auth/platform_auth_provider_manager.cc",
+ "enterprise/platform_auth/platform_auth_provider_manager.h",
+ ]
+ }
if (is_win) {
libs += [
"secur32.lib",
@@ -6099,11 +6107,7 @@
"enterprise/platform_auth/cloud_ap_utils_win.h",
"enterprise/platform_auth/platform_auth_navigation_throttle.cc",
"enterprise/platform_auth/platform_auth_navigation_throttle.h",
- "enterprise/platform_auth/platform_auth_policy_observer.cc",
- "enterprise/platform_auth/platform_auth_policy_observer.h",
"enterprise/platform_auth/platform_auth_provider.h",
- "enterprise/platform_auth/platform_auth_provider_manager.cc",
- "enterprise/platform_auth/platform_auth_provider_manager.h",
"enterprise/signals/device_info_fetcher_win.cc",
"enterprise/signals/device_info_fetcher_win.h",
"first_run/first_run_internal_win.cc",
diff --git a/chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.cc b/chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.cc
index 9f6e2be..3b66a33 100644
--- a/chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.cc
+++ b/chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.cc
@@ -18,7 +18,7 @@
PrefService* local_state) {
pref_change_registrar_.Init(local_state);
pref_change_registrar_.Add(
- prefs::kCloudApAuthEnabled,
+ GetPrefName(),
base::BindRepeating(&PlatformAuthPolicyObserver::OnPrefChanged,
base::Unretained(this)));
// Initialize `PlatformAuthProviderManager` using the current policy value.
@@ -28,14 +28,31 @@
// static
void PlatformAuthPolicyObserver::RegisterPrefs(
PrefRegistrySimple* pref_registry) {
- pref_registry->RegisterIntegerPref(prefs::kCloudApAuthEnabled, 0);
+#if BUILDFLAG(IS_WIN)
+ pref_registry->RegisterIntegerPref(GetPrefName(), 0);
+#elif BUILDFLAG(IS_MAC)
+ pref_registry->RegisterIntegerPref(GetPrefName(), 1);
+#else
+#error Unsupported platform
+#endif
+}
+
+// static
+const char* PlatformAuthPolicyObserver::GetPrefName() {
+#if BUILDFLAG(IS_WIN)
+ return prefs::kCloudApAuthEnabled;
+#elif BUILDFLAG(IS_MAC)
+ return prefs::kExtensibleEnterpriseSSOEnabled;
+#else
+#error Unsupported platform
+#endif
}
void PlatformAuthPolicyObserver::OnPrefChanged() {
// 0 == Disabled
// 1 == Enabled
- const bool enabled = pref_change_registrar_.prefs()->GetInteger(
- prefs::kCloudApAuthEnabled) != 0;
+ const bool enabled =
+ pref_change_registrar_.prefs()->GetInteger(GetPrefName()) != 0;
enterprise_auth::PlatformAuthProviderManager::GetInstance().SetEnabled(
enabled, base::OnceClosure());
}
diff --git a/chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.h b/chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.h
index 8c1fc552..d02960f8 100644
--- a/chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.h
+++ b/chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.h
@@ -19,6 +19,7 @@
PlatformAuthPolicyObserver& operator=(const PlatformAuthPolicyObserver&) =
delete;
+ static const char* GetPrefName();
static void RegisterPrefs(PrefRegistrySimple* pref_registry);
private:
diff --git a/chrome/browser/policy/policy_prefs_browsertest.cc b/chrome/browser/policy/policy_prefs_browsertest.cc
index 20a7f80..a2bd8ab 100644
--- a/chrome/browser/policy/policy_prefs_browsertest.cc
+++ b/chrome/browser/policy/policy_prefs_browsertest.cc
@@ -79,14 +79,7 @@
typedef PlatformBrowserTest PolicyPrefsTestCoverageTest;
-// TODO(crbug.com/341097718): Flaky on Mac.
-#if BUILDFLAG(IS_MAC)
-#define MAYBE_AllPoliciesHaveATestCase DISABLED_AllPoliciesHaveATestCase
-#else
-#define MAYBE_AllPoliciesHaveATestCase AllPoliciesHaveATestCase
-#endif
-IN_PROC_BROWSER_TEST_F(PolicyPrefsTestCoverageTest,
- MAYBE_AllPoliciesHaveATestCase) {
+IN_PROC_BROWSER_TEST_F(PolicyPrefsTestCoverageTest, AllPoliciesHaveATestCase) {
VerifyAllPoliciesHaveATestCase(GetTestCaseDir());
}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index e0a8968..c5f9cff 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -471,7 +471,6 @@
#endif
#if BUILDFLAG(IS_WIN)
-#include "chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.h"
#include "chrome/browser/font_prewarmer_tab_helper.h"
#include "chrome/browser/media/cdm_pref_service_helper.h"
#include "chrome/browser/media/media_foundation_service_monitor.h"
@@ -485,6 +484,7 @@
#endif // BUILDFLAG(IS_WIN)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
+#include "chrome/browser/enterprise/platform_auth/platform_auth_policy_observer.h"
#include "components/os_crypt/sync/os_crypt.h"
#endif
@@ -1865,9 +1865,9 @@
screen_ai::RegisterLocalStatePrefs(registry);
#endif // BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
-#if BUILDFLAG(IS_WIN)
+#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
PlatformAuthPolicyObserver::RegisterPrefs(registry);
-#endif // BUILDFLAG(IS_WIN)
+#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
// Platform-specific and compile-time conditional individual preferences.
// If you have multiple preferences that should clearly be grouped together,