Read Connector policies from profile prefs instead of local_state prefs
This refactor is only the first step to getting Connectors policies to
work on a profile basis, as the CBCM DM token is still read even when
the policy is set at the user level.
This refactor breaks a few assumptions of the previous implementation:
- SetUpForTesting, TearDownForTesting and ClearCacheForTesting are no
longer needed by ConnectorsManager since it is no longer a global
singleton.
- Extra null checks are added for ConnectorsService and
SafeBrowsingPrivateEventRouter since they can be null in tests. This
wasn't a problem before since ConnectorsManager::GetInstance never
returned null and SafeBrowsingPrivateEventRouter::context_ wasn't
read by test not using those classes, but that is no longer the case.
- kEnterpriseConnectorsEnabled is moving to ConnectorsService since
it will be used by future code outside of ConnectorsManager.
- policy_test_cases.json is updated since the policies are now read from
profile prefs, but the policies are not truly per-profile since they
depend on the CBCM DM token so they are not marked as such in
policy_templates.json.
Bug: 1147464
Change-Id: Ifacd55555ef6a5edab796dacbd336d971b9ae1ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2529613
Reviewed-by: David Trainor <[email protected]>
Reviewed-by: Daniel Rubery <[email protected]>
Reviewed-by: Roger Tawa <[email protected]>
Reviewed-by: Owen Min <[email protected]>
Commit-Queue: Dominique Fauteux-Chapleau <[email protected]>
Cr-Commit-Position: refs/heads/master@{#834298}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 58a0fba..ef712056 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -518,6 +518,13 @@
registry->RegisterDictionaryPref(kRegisteredSupervisedUserAllowlists);
registry->RegisterIntegerPref(kSupervisedUsersNextId, 0);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+
+#if !defined(OS_ANDROID)
+ registry->RegisterListPref(enterprise_connectors::kOnFileAttachedPref);
+ registry->RegisterListPref(enterprise_connectors::kOnFileDownloadedPref);
+ registry->RegisterListPref(enterprise_connectors::kOnBulkDataEntryPref);
+ registry->RegisterListPref(enterprise_connectors::kOnSecurityEventPref);
+#endif // !defined(OS_ANDROID)
}
// Register prefs used only for migration (clearing or moving to a new key).
@@ -662,7 +669,6 @@
registry->RegisterIntegerPref(first_run::kTosDialogBehavior, 0);
#else // defined(OS_ANDROID)
- enterprise_connectors::RegisterLocalStatePrefs(registry);
enterprise_reporting::RegisterLocalStatePrefs(registry);
gcm::RegisterPrefs(registry);
IntranetRedirectDetector::RegisterPrefs(registry);
@@ -928,6 +934,7 @@
captions::CaptionController::RegisterProfilePrefs(registry);
ChromeAuthenticatorRequestDelegate::RegisterProfilePrefs(registry);
DevToolsWindow::RegisterProfilePrefs(registry);
+ enterprise_connectors::RegisterProfilePrefs(registry);
enterprise_reporting::RegisterProfilePrefs(registry);
extensions::CommandService::RegisterProfilePrefs(registry);
extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry);
@@ -1108,6 +1115,14 @@
local_state->ClearPref(kRegisteredSupervisedUserAllowlists);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#if !defined(OS_ANDROID)
+ // Added 11/2020
+ local_state->ClearPref(enterprise_connectors::kOnFileAttachedPref);
+ local_state->ClearPref(enterprise_connectors::kOnFileDownloadedPref);
+ local_state->ClearPref(enterprise_connectors::kOnBulkDataEntryPref);
+ local_state->ClearPref(enterprise_connectors::kOnSecurityEventPref);
+#endif // !defined(OS_ANDROID)
+
// Please don't delete the following line. It is used by PRESUBMIT.py.
// END_MIGRATE_OBSOLETE_LOCAL_STATE_PREFS
}