Commit a2771862 authored by Aya ElAttar's avatar Aya ElAttar Committed by Commit Bot

Changed SystemFeaturesDisableList to enum list

This pref is going to be checked in multiple places; extensions
management, settings button, web apps, so I found it better to change
it to a list of enums instead of a list of strings.

Bug: 1061859
Change-Id: Ib0bde940c0248f2508271ac0cbfc915ee5e3ca49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124752
Commit-Queue: Aya Elsayed <ayaelattar@google.com>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754511}
parent 9b3e340b
...@@ -27,8 +27,23 @@ void SystemFeaturesDisableListPolicyHandler::ApplyList( ...@@ -27,8 +27,23 @@ void SystemFeaturesDisableListPolicyHandler::ApplyList(
base::Value filtered_list, base::Value filtered_list,
PrefValueMap* prefs) { PrefValueMap* prefs) {
DCHECK(filtered_list.is_list()); DCHECK(filtered_list.is_list());
base::Value enums_list(base::Value::Type::LIST);
for (const auto& element : filtered_list.GetList()) {
enums_list.Append(ConvertToEnum(element.GetString()));
}
prefs->SetValue(policy_prefs::kSystemFeaturesDisableList, prefs->SetValue(policy_prefs::kSystemFeaturesDisableList,
std::move(filtered_list)); std::move(enums_list));
}
SystemFeature SystemFeaturesDisableListPolicyHandler::ConvertToEnum(
const std::string& system_feature) {
if (system_feature == "camera")
return SystemFeature::CAMERA;
if (system_feature == "settings")
return SystemFeature::SETTINGS;
NOTREACHED() << "Unsupported system feature: " << system_feature;
return LAST_SYSTEM_FEATURE;
} }
} // namespace policy } // namespace policy
...@@ -15,6 +15,15 @@ class PrefRegistrySimple; ...@@ -15,6 +15,15 @@ class PrefRegistrySimple;
namespace policy { namespace policy {
// A system feature that can be disabled by SystemFeaturesDisableList policy.
enum SystemFeature {
CAMERA = 0, // The camera chrome app on Chrome OS.
SETTINGS, // The settings feature on Chrome OS. It includes also Chrome
// settings.
LAST_SYSTEM_FEATURE
};
class SystemFeaturesDisableListPolicyHandler class SystemFeaturesDisableListPolicyHandler
: public policy::ListPolicyHandler { : public policy::ListPolicyHandler {
public: public:
...@@ -26,6 +35,9 @@ class SystemFeaturesDisableListPolicyHandler ...@@ -26,6 +35,9 @@ class SystemFeaturesDisableListPolicyHandler
protected: protected:
// ListPolicyHandler: // ListPolicyHandler:
void ApplyList(base::Value filtered_list, PrefValueMap* prefs) override; void ApplyList(base::Value filtered_list, PrefValueMap* prefs) override;
private:
SystemFeature ConvertToEnum(const std::string& system_feature);
}; };
} // namespace policy } // namespace policy
......
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