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

Unified Diff: chrome/browser/policy/configuration_policy_handler_list_factory.cc

Issue 341723002: Refactored StringToIntEnumListPolicyHandler to be more general purpose (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback. Created 6 years, 6 months 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
« no previous file with comments | « no previous file | components/policy/core/browser/configuration_policy_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/configuration_policy_handler_list_factory.cc
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
index 4795d6e5d5e5f37c4162af9827047aa7dd740e01..6971e4a738114e732b1279348d406df3a2472e66 100644
--- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc
+++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -484,15 +484,29 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = {
};
#if !defined(OS_IOS)
-// Mapping from extension type names to Manifest::Type.
-StringToIntEnumListPolicyHandler::MappingEntry kExtensionAllowedTypesMap[] = {
- { "extension", extensions::Manifest::TYPE_EXTENSION },
- { "theme", extensions::Manifest::TYPE_THEME },
- { "user_script", extensions::Manifest::TYPE_USER_SCRIPT },
- { "hosted_app", extensions::Manifest::TYPE_HOSTED_APP },
- { "legacy_packaged_app", extensions::Manifest::TYPE_LEGACY_PACKAGED_APP },
- { "platform_app", extensions::Manifest::TYPE_PLATFORM_APP },
-};
+void GetExtensionAllowedTypesMap(
+ ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
+ // Mapping from extension type names to Manifest::Type.
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "extension", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ extensions::Manifest::TYPE_EXTENSION))));
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "theme", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ extensions::Manifest::TYPE_THEME))));
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "user_script", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ extensions::Manifest::TYPE_USER_SCRIPT))));
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "hosted_app", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ extensions::Manifest::TYPE_HOSTED_APP))));
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "legacy_packaged_app", scoped_ptr<base::Value>(
+ base::Value::CreateIntegerValue(
+ extensions::Manifest::TYPE_LEGACY_PACKAGED_APP))));
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "platform_app", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ extensions::Manifest::TYPE_PLATFORM_APP))));
+}
#endif // !defined(OS_IOS)
} // namespace
@@ -560,11 +574,10 @@ scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
key::kExtensionInstallSources,
extensions::pref_names::kAllowedInstallSites)));
handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
- new StringToIntEnumListPolicyHandler(
+ new StringMappingListPolicyHandler(
key::kExtensionAllowedTypes,
extensions::pref_names::kAllowedTypes,
- kExtensionAllowedTypesMap,
- kExtensionAllowedTypesMap + arraysize(kExtensionAllowedTypesMap))));
+ base::Bind(GetExtensionAllowedTypesMap))));
#endif // !defined(OS_IOS)
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
« no previous file with comments | « no previous file | components/policy/core/browser/configuration_policy_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698