Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Unified Diff: components/policy/core/common/policy_loader_win.cc

Issue 2581353002: Use the Windows MDM API to check if the machine is being managed. (Closed)
Patch Set: Fix components tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/policy_loader_win.cc
diff --git a/components/policy/core/common/policy_loader_win.cc b/components/policy/core/common/policy_loader_win.cc
index 1854f97503cea5b5c1546ba23f5bfe73b20d50f7..28910d8b8a2ce929fc2d5c30fb6dacd59ccd74bb 100644
--- a/components/policy/core/common/policy_loader_win.cc
+++ b/components/policy/core/common/policy_loader_win.cc
@@ -92,10 +92,14 @@ enum DomainCheckErrors {
DOMAIN_CHECK_ERROR_SIZE, // Not a DomainCheckError. Must be last.
};
+bool ShouldHonorPolicies() {
+ return base::win::IsEnterpriseUser();
+}
+
// Verifies that untrusted policies contain only safe values. Modifies the
// |policy| in place.
void FilterUntrustedPolicy(PolicyMap* policy) {
- if (base::win::IsEnrolledToDomain())
+ if (ShouldHonorPolicies())
return;
int invalid_policies = 0;
@@ -293,8 +297,7 @@ void CollectEnterpriseUMAs() {
base::win::OSInfo::GetInstance()->version_type(),
base::win::SUITE_LAST);
- bool in_domain = base::win::IsEnrolledToDomain();
- UMA_HISTOGRAM_BOOLEAN("EnterpriseCheck.InDomain", in_domain);
+ UMA_HISTOGRAM_BOOLEAN("EnterpriseCheck.InDomain", ShouldHonorPolicies());
}
} // namespace
@@ -368,9 +371,9 @@ std::unique_ptr<PolicyBundle> PolicyLoaderWin::Load() {
{ POLICY_SCOPE_USER, HKEY_CURRENT_USER },
};
- bool is_enterprise = base::win::IsEnrolledToDomain();
+ bool honor_policies = ShouldHonorPolicies();
VLOG(1) << "Reading policy from the registry is "
- << (is_enterprise ? "enabled." : "disabled.");
+ << (honor_policies ? "enabled." : "disabled.");
// Load policy data for the different scopes/levels and merge them.
std::unique_ptr<PolicyBundle> bundle(new PolicyBundle());
@@ -398,7 +401,7 @@ std::unique_ptr<PolicyBundle> PolicyLoaderWin::Load() {
// timeout on it more aggressively. For now, there's no justification for
// the additional effort this would introduce.
- bool is_registry_forced = is_enterprise || gpo_provider_ == nullptr;
+ bool is_registry_forced = honor_policies || gpo_provider_ == nullptr;
if (is_registry_forced || !ReadPolicyFromGPO(scope, &gpo_dict, &status)) {
VLOG_IF(1, !is_registry_forced) << "Failed to read GPO files for "
<< scope << " falling back to registry.";

Powered by Google App Engine
This is Rietveld 408576698