Commit befef663 authored by Owen Min's avatar Owen Min Committed by Commit Bot

Always includes user scope policies for device local account policies conversions.

Also rename DevicePolicy to DeviceLocalAccountPolicy in PolicyConversion.


Bug: 989249, 983174
Change-Id: I05219823615a429d991d225119ffcc4541a5b790
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726797Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Commit-Queue: Owen Min <zmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684315}
parent b1f4b1d4
......@@ -176,7 +176,7 @@ std::string SystemLogDelegate::GetPolicyAsJSON() {
return policy::DictionaryPolicyConversions()
.WithBrowserContext(ProfileManager::GetActiveUserProfile())
.EnableUserPolicies(include_user_policies)
.EnableDevicePolicies(true)
.EnableDeviceLocalAccountPolicies(true)
.EnableDeviceInfo(true)
.ToJSON();
}
......
......@@ -127,8 +127,9 @@ PolicyConversions& PolicyConversions::EnableConvertValues(bool enabled) {
return *this;
}
PolicyConversions& PolicyConversions::EnableDevicePolicies(bool enabled) {
device_policies_enabled_ = enabled;
PolicyConversions& PolicyConversions::EnableDeviceLocalAccountPolicies(
bool enabled) {
device_local_account_policies_enabled_ = enabled;
return *this;
}
......@@ -230,13 +231,17 @@ Value PolicyConversions::GetDeviceLocalAccountPolicies() {
Value policies(Value::Type::LIST);
// DeviceLocalAccount policies are only available for affiliated users and for
// system logs.
if (!device_policies_enabled_ &&
if (!device_local_account_policies_enabled_ &&
(!user_manager::UserManager::IsInitialized() ||
!user_manager::UserManager::Get()->GetPrimaryUser() ||
!user_manager::UserManager::Get()->GetPrimaryUser()->IsAffiliated())) {
return policies;
}
// Always includes user policies for device local account policies.
bool current_use_policy_setup = user_policies_enabled_;
user_policies_enabled_ = true;
BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
DCHECK(connector); // always not-null
......@@ -294,6 +299,10 @@ Value PolicyConversions::GetDeviceLocalAccountPolicies() {
std::move(current_account_policies));
policies.GetList().push_back(std::move(current_account_policies_data));
}
// Reset |user_policies_enabled_| setup.
user_policies_enabled_ = current_use_policy_setup;
return policies;
}
......@@ -604,7 +613,7 @@ base::Value GetAllPolicyValuesAsArray(content::BrowserContext* context,
.WithBrowserContext(context)
.EnableConvertTypes(convert_types)
.EnableConvertValues(convert_values)
.EnableDevicePolicies(with_device_data)
.EnableDeviceLocalAccountPolicies(with_device_data)
.EnableDeviceInfo(false)
.EnablePrettyPrint(is_pretty_print)
.EnableUserPolicies(with_user_policies)
......@@ -621,7 +630,7 @@ base::Value GetAllPolicyValuesAsDictionary(content::BrowserContext* context,
.WithBrowserContext(context)
.EnableConvertTypes(convert_types)
.EnableConvertValues(convert_values)
.EnableDevicePolicies(with_device_data)
.EnableDeviceLocalAccountPolicies(with_device_data)
.EnableDeviceInfo(with_device_data)
.EnablePrettyPrint(is_pretty_print)
.EnableUserPolicies(with_user_policies)
......@@ -636,7 +645,7 @@ std::string GetAllPolicyValuesAsJSON(content::BrowserContext* context,
.WithBrowserContext(context)
.EnableConvertTypes(true)
.EnableConvertValues(false)
.EnableDevicePolicies(with_device_data)
.EnableDeviceLocalAccountPolicies(with_device_data)
.EnableDeviceInfo(with_device_data)
.EnablePrettyPrint(is_pretty_print)
.EnableUserPolicies(with_user_policies)
......
......@@ -50,9 +50,9 @@ class PolicyConversions {
// Set to get dictionary policy value as JSON string.
// Disabled by default.
PolicyConversions& EnableConvertValues(bool enabled);
// Set to get device policies on ChromeOS.
// Set to get device local account policies on ChromeOS.
// Disabled by default.
PolicyConversions& EnableDevicePolicies(bool enabled);
PolicyConversions& EnableDeviceLocalAccountPolicies(bool enabled);
// Set to get device basic information on ChromeOS.
// Disabled by default.
PolicyConversions& EnableDeviceInfo(bool enabled);
......@@ -122,7 +122,7 @@ class PolicyConversions {
bool convert_types_enabled_ = true;
bool convert_values_enabled_ = false;
bool device_policies_enabled_ = false;
bool device_local_account_policies_enabled_ = false;
bool device_info_enabled_ = false;
bool pretty_print_enabled_ = true;
bool user_policies_enabled_ = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment