diff options
author | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 12:07:08 +0000 |
---|---|---|
committer | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 12:07:08 +0000 |
commit | 150f43b345029c037176b4d23c2c32aacd8b6dfc (patch) | |
tree | 35ea50a24ae1ffc7997a84af592434b80b48dbef /chrome | |
parent | 5b8bcd40e3f3b7426ddee939054913505f43156f (diff) | |
download | chromium_src-150f43b345029c037176b4d23c2c32aacd8b6dfc.zip chromium_src-150f43b345029c037176b4d23c2c32aacd8b6dfc.tar.gz chromium_src-150f43b345029c037176b4d23c2c32aacd8b6dfc.tar.bz2 |
Policy: generate boilerplate policy type and constant code.
This is the first step to being able to re-constitute policy from a non-generic protobuf in a policy request in a fully automated way (i.e. the code for the process can be generated). The non-generic protobuf is required for automatic merging of policy on the server-side.
BUG=68309
TEST=existing policy/provider tests
Review URL: http://codereview.chromium.org/6002015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
26 files changed, 334 insertions, 307 deletions
diff --git a/chrome/app/DEPS b/chrome/app/DEPS index d83f0a1..95afdc9 100644 --- a/chrome/app/DEPS +++ b/chrome/app/DEPS @@ -3,6 +3,7 @@ include_rules = [ "+chrome/browser", "+chrome/installer", "+grit", # For generated headers + "+policy", # For generated headers and source "+sandbox", "+tools/memory_watcher", ] diff --git a/chrome/app/breakpad_mac.mm b/chrome/app/breakpad_mac.mm index caa46cc..e7c40df 100644 --- a/chrome/app/breakpad_mac.mm +++ b/chrome/app/breakpad_mac.mm @@ -23,8 +23,8 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" -#include "chrome/common/policy_constants.h" #include "chrome/installer/util/google_update_settings.h" +#include "policy/policy_constants.h" namespace { diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc index 9fe1032..fc85b26 100644 --- a/chrome/app/breakpad_win.cc +++ b/chrome/app/breakpad_win.cc @@ -28,10 +28,10 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" #include "chrome/common/result_codes.h" -#include "chrome/common/policy_constants.h" #include "chrome/installer/util/google_chrome_sxs_distribution.h" #include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/install_util.h" +#include "policy/policy_constants.h" namespace { diff --git a/chrome/app/policy/policy_templates.gypi b/chrome/app/policy/policy_templates.gypi index 4f41c3a..b96e138 100644 --- a/chrome/app/policy/policy_templates.gypi +++ b/chrome/app/policy/policy_templates.gypi @@ -3,7 +3,95 @@ # found in the LICENSE file. { + 'variables': { + 'policy_out_dir': '<(SHARED_INTERMEDIATE_DIR)/policy', + 'generate_policy_source_script': + ['python', 'tools/build/generate_policy_source.py'], + }, + 'target_defaults': { + 'variables': { + 'policy_target': 0, + }, + 'target_conditions': [ + [ 'policy_target==1', { + 'include_dirs': [ + '<(policy_out_dir)', + ], + 'actions': [ + { + 'variables': + { + 'policy_constant_header': + '<(policy_out_dir)/policy/policy_constants.h', + 'policy_constant_source': + '<(policy_out_dir)/policy/policy_constants.cc', + 'configuration_policy_type_header': + '<(policy_out_dir)/policy/configuration_policy_type.h', + }, + 'inputs': [ + 'policy_templates.json', + '../../tools/build/generate_policy_source.py' + ], + 'outputs': [ + '<(policy_constant_header)', + '<(policy_constant_source)', + '<(configuration_policy_type_header)', + ], + 'action_name': 'generate_policy_source', + 'action': [ + '<@(generate_policy_source_script)', + '--policy-constants-header=<(policy_constant_header)', + '--policy-constants-source=<(policy_constant_source)', + '--policy-type-header=<(configuration_policy_type_header)', + '<(OS)', + '<@(_inputs)', + ], + 'message': 'Generating policy source', + 'process_outputs_as_sources': 1, + }, + ], + }, ], + ], + }, + 'targets': [ + { + 'target_name': 'policy', + 'type': '<(library)', + 'include_dirs': [ + '<(policy_out_dir)', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(SHARED_INTERMEDIATE_DIR)/policy' + ], + }, + 'variables': { + 'policy_target': 1, + }, + }, + ], 'conditions': [ + ['OS=="win"', { + 'targets': [ + { + 'target_name': 'policy_win64', + 'type': '<(library)', + 'variables': { + 'policy_target': 1, + }, + 'direct_dependent_settings': { + 'include_dirs': [ + '<(SHARED_INTERMEDIATE_DIR)/policy' + ], + }, + 'configurations': { + 'Common_Base': { + 'msvs_target_platform': 'x64', + }, + }, + }, + ], + }], ['OS=="win" or OS=="mac" or OS=="linux"', { 'targets': [ { diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_templates.json index 291fb8d..8cc0e7c 100644 --- a/chrome/app/policy/policy_templates.json +++ b/chrome/app/policy/policy_templates.json @@ -715,6 +715,19 @@ </ph>.''', }, { + 'name': 'BlockThirdPartyCookies', + 'type': 'main', + 'supported_on': ['chrome.*:10-'], + 'features': {'dynamic_refresh': 1}, + 'example_value': False, + 'caption': '''Block third party cookies''', + 'desc': '''Blocks third party cookies. + + Enabling this setting prevents cookies from being set by web page elements that are not from the domain that is in the browser's address bar. + + Disabling this setting allows cookies to be set by web page elements that are not from the domain that is in the browser's address bar and prevents users from changing this setting.''', + }, + { 'name': 'DefaultSearchProviderName', 'type': 'string', 'supported_on': ['chrome.*:8-'], diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 1cf13fc..757e0b4 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -8,6 +8,7 @@ include_rules = [ "+chrome/tools/profiles", # For history unit tests. "+chrome/views", "+grit", # For generated headers + "+policy", # For generated headers and source "+ppapi/c", # For various types. "+ppapi/proxy", "+rlz", diff --git a/chrome/browser/policy/asynchronous_policy_provider_unittest.cc b/chrome/browser/policy/asynchronous_policy_provider_unittest.cc index c6aee70..9d186b8 100644 --- a/chrome/browser/policy/asynchronous_policy_provider_unittest.cc +++ b/chrome/browser/policy/asynchronous_policy_provider_unittest.cc @@ -7,7 +7,7 @@ #include "chrome/browser/policy/asynchronous_policy_test_base.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/mock_configuration_policy_store.h" -#include "chrome/common/policy_constants.h" +#include "policy/policy_constants.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/policy/config_dir_policy_provider_unittest.cc b/chrome/browser/policy/config_dir_policy_provider_unittest.cc index 67ac917..4bfd49f 100644 --- a/chrome/browser/policy/config_dir_policy_provider_unittest.cc +++ b/chrome/browser/policy/config_dir_policy_provider_unittest.cc @@ -13,7 +13,7 @@ #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/mock_configuration_policy_store.h" #include "chrome/common/json_value_serializer.h" -#include "chrome/common/policy_constants.h" +#include "policy/policy_constants.h" #include "testing/gtest/include/gtest/gtest.h" namespace policy { @@ -226,7 +226,7 @@ INSTANTIATE_TEST_CASE_P( ConfigDirPolicyProviderValueTest, testing::Values( ValueTestParams::ForStringPolicy( - kPolicyHomePage, + kPolicyHomepageLocation, key::kHomepageLocation), ValueTestParams::ForBooleanPolicy( kPolicyHomepageIsNewTabPage, @@ -235,8 +235,8 @@ INSTANTIATE_TEST_CASE_P( kPolicyRestoreOnStartup, key::kRestoreOnStartup), ValueTestParams::ForListPolicy( - kPolicyURLsToRestoreOnStartup, - key::kURLsToRestoreOnStartup), + kPolicyRestoreOnStartupURLs, + key::kRestoreOnStartupURLs), ValueTestParams::ForBooleanPolicy( kPolicyDefaultSearchProviderEnabled, key::kDefaultSearchProviderEnabled), @@ -304,17 +304,17 @@ INSTANTIATE_TEST_CASE_P( kPolicyAutoFillEnabled, key::kAutoFillEnabled), ValueTestParams::ForStringPolicy( - kPolicyApplicationLocale, + kPolicyApplicationLocaleValue, key::kApplicationLocaleValue), ValueTestParams::ForBooleanPolicy( kPolicySyncDisabled, key::kSyncDisabled), ValueTestParams::ForListPolicy( - kPolicyExtensionInstallAllowList, - key::kExtensionInstallAllowList), + kPolicyExtensionInstallWhitelist, + key::kExtensionInstallWhitelist), ValueTestParams::ForListPolicy( - kPolicyExtensionInstallDenyList, - key::kExtensionInstallDenyList), + kPolicyExtensionInstallBlacklist, + key::kExtensionInstallBlacklist), ValueTestParams::ForBooleanPolicy( kPolicyShowHomeButton, key::kShowHomeButton), diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc index 2d4ab5f..9f00c51 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.cc +++ b/chrome/browser/policy/configuration_policy_pref_store.cc @@ -28,8 +28,8 @@ #include "chrome/browser/search_engines/search_terms_data.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/common/notification_service.h" -#include "chrome/common/policy_constants.h" #include "chrome/common/pref_names.h" +#include "policy/policy_constants.h" namespace policy { @@ -150,12 +150,12 @@ class ConfigurationPolicyPrefKeeper const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry ConfigurationPolicyPrefKeeper::kSimplePolicyMap[] = { - { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage }, + { Value::TYPE_STRING, kPolicyHomepageLocation, prefs::kHomePage }, { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage, prefs::kHomePageIsNewTabPage }, { Value::TYPE_INTEGER, kPolicyRestoreOnStartup, prefs::kRestoreOnStartup}, - { Value::TYPE_LIST, kPolicyURLsToRestoreOnStartup, + { Value::TYPE_LIST, kPolicyRestoreOnStartupURLs, prefs::kURLsToRestoreOnStartup }, { Value::TYPE_BOOLEAN, kPolicyAlternateErrorPagesEnabled, prefs::kAlternateErrorPagesEnabled }, @@ -175,13 +175,13 @@ const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry prefs::kPrintingEnabled }, { Value::TYPE_BOOLEAN, kPolicyMetricsReportingEnabled, prefs::kMetricsReportingEnabled }, - { Value::TYPE_STRING, kPolicyApplicationLocale, + { Value::TYPE_STRING, kPolicyApplicationLocaleValue, prefs::kApplicationLocale}, - { Value::TYPE_LIST, kPolicyExtensionInstallAllowList, + { Value::TYPE_LIST, kPolicyExtensionInstallWhitelist, prefs::kExtensionInstallAllowList}, - { Value::TYPE_LIST, kPolicyExtensionInstallDenyList, + { Value::TYPE_LIST, kPolicyExtensionInstallBlacklist, prefs::kExtensionInstallDenyList}, - { Value::TYPE_LIST, kPolicyExtensionInstallForceList, + { Value::TYPE_LIST, kPolicyExtensionInstallForcelist, prefs::kExtensionInstallForceList}, { Value::TYPE_LIST, kPolicyDisabledPlugins, prefs::kPluginsPluginsBlacklist}, @@ -747,12 +747,12 @@ ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore() { const ConfigurationPolicyProvider::PolicyDefinitionList* ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = { - { kPolicyHomePage, Value::TYPE_STRING, key::kHomepageLocation }, + { kPolicyHomepageLocation, Value::TYPE_STRING, key::kHomepageLocation }, { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN, key::kHomepageIsNewTabPage }, { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup }, - { kPolicyURLsToRestoreOnStartup, Value::TYPE_LIST, - key::kURLsToRestoreOnStartup }, + { kPolicyRestoreOnStartupURLs, Value::TYPE_LIST, + key::kRestoreOnStartupURLs }, { kPolicyDefaultSearchProviderEnabled, Value::TYPE_BOOLEAN, key::kDefaultSearchProviderEnabled }, { kPolicyDefaultSearchProviderName, Value::TYPE_STRING, @@ -791,15 +791,15 @@ ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { key::kPasswordManagerAllowShowPasswords }, { kPolicyAutoFillEnabled, Value::TYPE_BOOLEAN, key::kAutoFillEnabled }, { kPolicyDisabledPlugins, Value::TYPE_LIST, key::kDisabledPlugins }, - { kPolicyApplicationLocale, Value::TYPE_STRING, + { kPolicyApplicationLocaleValue, Value::TYPE_STRING, key::kApplicationLocaleValue }, { kPolicySyncDisabled, Value::TYPE_BOOLEAN, key::kSyncDisabled }, - { kPolicyExtensionInstallAllowList, Value::TYPE_LIST, - key::kExtensionInstallAllowList }, - { kPolicyExtensionInstallDenyList, Value::TYPE_LIST, - key::kExtensionInstallDenyList }, - { kPolicyExtensionInstallForceList, Value::TYPE_LIST, - key::kExtensionInstallForceList }, + { kPolicyExtensionInstallWhitelist, Value::TYPE_LIST, + key::kExtensionInstallWhitelist }, + { kPolicyExtensionInstallBlacklist, Value::TYPE_LIST, + key::kExtensionInstallBlacklist }, + { kPolicyExtensionInstallForcelist, Value::TYPE_LIST, + key::kExtensionInstallForcelist }, { kPolicyShowHomeButton, Value::TYPE_BOOLEAN, key::kShowHomeButton }, { kPolicyPrintingEnabled, Value::TYPE_BOOLEAN, key::kPrintingEnabled }, { kPolicyJavascriptEnabled, Value::TYPE_BOOLEAN, key::kJavascriptEnabled }, diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc index 0ad9eb6d..759591a 100644 --- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc +++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc @@ -71,11 +71,11 @@ INSTANTIATE_TEST_CASE_P( ConfigurationPolicyPrefStoreListTestInstance, ConfigurationPolicyPrefStoreListTest, testing::Values( - TypeAndName(kPolicyURLsToRestoreOnStartup, + TypeAndName(kPolicyRestoreOnStartupURLs, prefs::kURLsToRestoreOnStartup), - TypeAndName(kPolicyExtensionInstallAllowList, + TypeAndName(kPolicyExtensionInstallWhitelist, prefs::kExtensionInstallAllowList), - TypeAndName(kPolicyExtensionInstallDenyList, + TypeAndName(kPolicyExtensionInstallBlacklist, prefs::kExtensionInstallDenyList), TypeAndName(kPolicyDisabledPlugins, prefs::kPluginsPluginsBlacklist))); @@ -105,11 +105,11 @@ INSTANTIATE_TEST_CASE_P( ConfigurationPolicyPrefStoreStringTestInstance, ConfigurationPolicyPrefStoreStringTest, testing::Values( - TypeAndName(kPolicyHomePage, + TypeAndName(kPolicyHomepageLocation, prefs::kHomePage), - TypeAndName(kPolicyApplicationLocale, + TypeAndName(kPolicyApplicationLocaleValue, prefs::kApplicationLocale), - TypeAndName(kPolicyApplicationLocale, + TypeAndName(kPolicyApplicationLocaleValue, prefs::kApplicationLocale), TypeAndName(kPolicyAuthSchemes, prefs::kAuthSchemes), @@ -670,7 +670,7 @@ TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) { store_->GetValue(prefs::kHomePage, NULL)); EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); - provider_.AddPolicy(kPolicyHomePage, + provider_.AddPolicy(kPolicyHomepageLocation, Value::CreateStringValue("http://www.chromium.org")); store_->OnUpdatePolicy(); Mock::VerifyAndClearExpectations(&observer_); @@ -683,7 +683,7 @@ TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) { Mock::VerifyAndClearExpectations(&observer_); EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); - provider_.RemovePolicy(kPolicyHomePage); + provider_.RemovePolicy(kPolicyHomepageLocation); store_->OnUpdatePolicy(); Mock::VerifyAndClearExpectations(&observer_); EXPECT_EQ(PrefStore::READ_NO_VALUE, diff --git a/chrome/browser/policy/configuration_policy_provider_delegate_win.cc b/chrome/browser/policy/configuration_policy_provider_delegate_win.cc index 1f2f467..7e93486 100644 --- a/chrome/browser/policy/configuration_policy_provider_delegate_win.cc +++ b/chrome/browser/policy/configuration_policy_provider_delegate_win.cc @@ -7,7 +7,7 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/win/registry.h" -#include "chrome/common/policy_constants.h" +#include "policy/policy_constants.h" using base::win::RegKey; diff --git a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc index d221f9a..c0f1e30 100644 --- a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc @@ -11,7 +11,7 @@ #include "chrome/browser/policy/configuration_policy_provider_mac.h" #include "chrome/browser/policy/mock_configuration_policy_store.h" #include "chrome/browser/preferences_mock_mac.h" -#include "chrome/common/policy_constants.h" +#include "policy/policy_constants.h" #include "testing/gtest/include/gtest/gtest.h" namespace policy { @@ -200,7 +200,7 @@ INSTANTIATE_TEST_CASE_P( ConfigurationPolicyProviderMacTest, testing::Values( PolicyTestParams::ForStringPolicy( - kPolicyHomePage, + kPolicyHomepageLocation, key::kHomepageLocation), PolicyTestParams::ForBooleanPolicy( kPolicyHomepageIsNewTabPage, @@ -209,8 +209,8 @@ INSTANTIATE_TEST_CASE_P( kPolicyRestoreOnStartup, key::kRestoreOnStartup), PolicyTestParams::ForListPolicy( - kPolicyURLsToRestoreOnStartup, - key::kURLsToRestoreOnStartup), + kPolicyRestoreOnStartupURLs, + key::kRestoreOnStartupURLs), PolicyTestParams::ForBooleanPolicy( kPolicyDefaultSearchProviderEnabled, key::kDefaultSearchProviderEnabled), @@ -278,17 +278,17 @@ INSTANTIATE_TEST_CASE_P( kPolicyAutoFillEnabled, key::kAutoFillEnabled), PolicyTestParams::ForStringPolicy( - kPolicyApplicationLocale, + kPolicyApplicationLocaleValue, key::kApplicationLocaleValue), PolicyTestParams::ForBooleanPolicy( kPolicySyncDisabled, key::kSyncDisabled), PolicyTestParams::ForListPolicy( - kPolicyExtensionInstallAllowList, - key::kExtensionInstallAllowList), + kPolicyExtensionInstallWhitelist, + key::kExtensionInstallWhitelist), PolicyTestParams::ForListPolicy( - kPolicyExtensionInstallDenyList, - key::kExtensionInstallDenyList), + kPolicyExtensionInstallBlacklist, + key::kExtensionInstallBlacklist), PolicyTestParams::ForBooleanPolicy( kPolicyShowHomeButton, key::kShowHomeButton), diff --git a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc index 1d2a9ee..eed2c06 100644 --- a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc @@ -17,8 +17,8 @@ #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/configuration_policy_provider_win.h" #include "chrome/browser/policy/mock_configuration_policy_store.h" -#include "chrome/common/policy_constants.h" #include "chrome/common/pref_names.h" +#include "policy/policy_constants.h" #include "testing/gtest/include/gtest/gtest.h" using base::win::RegKey; @@ -358,7 +358,7 @@ INSTANTIATE_TEST_CASE_P( ConfigurationPolicyProviderWinTest, testing::Values( PolicyTestParams::ForStringPolicy( - kPolicyHomePage, + kPolicyHomepageLocation, key::kHomepageLocation), PolicyTestParams::ForBooleanPolicy( kPolicyHomepageIsNewTabPage, @@ -367,8 +367,8 @@ INSTANTIATE_TEST_CASE_P( kPolicyRestoreOnStartup, key::kRestoreOnStartup), PolicyTestParams::ForListPolicy( - kPolicyURLsToRestoreOnStartup, - key::kURLsToRestoreOnStartup), + kPolicyRestoreOnStartupURLs, + key::kRestoreOnStartupURLs), PolicyTestParams::ForBooleanPolicy( kPolicyDefaultSearchProviderEnabled, key::kDefaultSearchProviderEnabled), @@ -436,14 +436,14 @@ INSTANTIATE_TEST_CASE_P( kPolicySyncDisabled, key::kSyncDisabled), PolicyTestParams::ForStringPolicy( - kPolicyApplicationLocale, + kPolicyApplicationLocaleValue, key::kApplicationLocaleValue), PolicyTestParams::ForListPolicy( - kPolicyExtensionInstallAllowList, - key::kExtensionInstallAllowList), + kPolicyExtensionInstallWhitelist, + key::kExtensionInstallWhitelist), PolicyTestParams::ForListPolicy( - kPolicyExtensionInstallDenyList, - key::kExtensionInstallDenyList), + kPolicyExtensionInstallBlacklist, + key::kExtensionInstallBlacklist), PolicyTestParams::ForBooleanPolicy( kPolicyShowHomeButton, key::kShowHomeButton), diff --git a/chrome/browser/policy/configuration_policy_store_interface.h b/chrome/browser/policy/configuration_policy_store_interface.h index e697ed1..c88f07f 100644 --- a/chrome/browser/policy/configuration_policy_store_interface.h +++ b/chrome/browser/policy/configuration_policy_store_interface.h @@ -7,72 +7,14 @@ #pragma once #include "base/basictypes.h" +// configuration_policy_type.h is generated. See policy_template.json for +// policy definitions. +#include "policy/configuration_policy_type.h" class Value; namespace policy { -enum ConfigurationPolicyType { - kPolicyHomePage, - kPolicyHomepageIsNewTabPage, - kPolicyRestoreOnStartup, - kPolicyURLsToRestoreOnStartup, - kPolicyDefaultSearchProviderEnabled, - kPolicyDefaultSearchProviderName, - kPolicyDefaultSearchProviderKeyword, - kPolicyDefaultSearchProviderSearchURL, - kPolicyDefaultSearchProviderSuggestURL, - kPolicyDefaultSearchProviderIconURL, - kPolicyDefaultSearchProviderInstantURL, - kPolicyDefaultSearchProviderEncodings, - kPolicyDisableSpdy, - kPolicyProxyMode, - kPolicyProxyServerMode, - kPolicyProxyServer, - kPolicyProxyPacUrl, - kPolicyProxyBypassList, - kPolicyAlternateErrorPagesEnabled, - kPolicySearchSuggestEnabled, - kPolicyDnsPrefetchingEnabled, - kPolicySafeBrowsingEnabled, - kPolicyMetricsReportingEnabled, - kPolicyPasswordManagerEnabled, - kPolicyPasswordManagerAllowShowPasswords, - kPolicyAutoFillEnabled, - kPolicySyncDisabled, - kPolicyApplicationLocale, - kPolicyExtensionInstallAllowList, - kPolicyExtensionInstallDenyList, - kPolicyShowHomeButton, - kPolicyDisabledPlugins, - kPolicyPrintingEnabled, - kPolicyChromeFrameRendererSettings, - kPolicyRenderInChromeFrameList, - kPolicyRenderInHostList, - kPolicyJavascriptEnabled, - kPolicySavingBrowserHistoryDisabled, - kPolicyDeveloperToolsDisabled, - kPolicyBlockThirdPartyCookies, - kPolicyDefaultCookiesSetting, - kPolicyDefaultImagesSetting, - kPolicyDefaultJavaScriptSetting, - kPolicyDefaultPluginsSetting, - kPolicyDefaultPopupsSetting, - kPolicyDefaultNotificationSetting, - kPolicyDefaultGeolocationSetting, - kPolicyExtensionInstallForceList, - kPolicyChromeOsLockOnIdleSuspend, - kPolicyAuthSchemes, - kPolicyDisableAuthNegotiateCnameLookup, - kPolicyEnableAuthNegotiatePort, - kPolicyAuthServerWhitelist, - kPolicyAuthNegotiateDelegateWhitelist, - kPolicyGSSAPILibraryName, - kPolicyDisable3DAPIs, - kPolicyPolicyRefreshRate, -}; - - // Constants for the "Proxy Server Mode" defined in the policies. // Note that these diverge from internal presentation defined in // ProxyPrefs::ProxyMode for legacy reasons. The following four diff --git a/chrome/browser/policy/device_management_policy_provider_unittest.cc b/chrome/browser/policy/device_management_policy_provider_unittest.cc index 55ba883..d0a0eaa 100644 --- a/chrome/browser/policy/device_management_policy_provider_unittest.cc +++ b/chrome/browser/policy/device_management_policy_provider_unittest.cc @@ -16,9 +16,9 @@ #include "chrome/common/net/gaia/gaia_constants.h" #include "chrome/common/notification_observer_mock.h" #include "chrome/common/notification_service.h" -#include "chrome/common/policy_constants.h" #include "chrome/test/testing_device_token_fetcher.h" #include "chrome/test/testing_profile.h" +#include "policy/policy_constants.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/policy/file_based_policy_provider_unittest.cc b/chrome/browser/policy/file_based_policy_provider_unittest.cc index 1bb2185..2948f5f 100644 --- a/chrome/browser/policy/file_based_policy_provider_unittest.cc +++ b/chrome/browser/policy/file_based_policy_provider_unittest.cc @@ -7,7 +7,7 @@ #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/configuration_policy_store_interface.h" #include "chrome/browser/policy/file_based_policy_provider.h" -#include "chrome/common/policy_constants.h" +#include "policy/policy_constants.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 1f421cb..4455b2f 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -38,6 +38,7 @@ 'common_nacl_win64', 'common_constants_win64', 'installer_util_nacl_win64', + 'policy_win64', ], 'allocator_target': '../base/allocator/allocator.gyp:allocator', 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome', @@ -849,6 +850,7 @@ 'browser/sync/protocol/sync_proto.gyp:sync_proto_cpp', 'common_constants', 'common_net', + 'policy', 'sync', 'sync_notifier', ], @@ -1794,6 +1796,7 @@ 'dependencies': [ 'common_constants', 'installer_util', + 'policy', '../base/base.gyp:base', '../breakpad/breakpad.gyp:breakpad_handler', '../breakpad/breakpad.gyp:breakpad_sender', diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index b2d44d1..6d5cf63 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -20,6 +20,7 @@ 'profile_import', 'browser/sync/protocol/sync_proto.gyp:sync_proto_cpp', 'browser/policy/proto/device_management_proto.gyp:device_management_proto_cpp', + 'policy', 'safe_browsing_csd_proto', 'safe_browsing_report_proto', 'syncapi', diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 2cb8e92..727f61b 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -203,6 +203,7 @@ 'common_constants', 'common_net', 'default_plugin/default_plugin.gyp:default_plugin', + 'policy', 'theme_resources', '../app/app.gyp:app_base', '../app/app.gyp:app_resources', @@ -581,6 +582,7 @@ 'chrome_resources', 'chrome_strings', 'common_constants_win64', + 'policy_win64', '../app/app.gyp:app_base_nacl_win64', '../app/app.gyp:app_resources', '../base/base.gyp:base_nacl_win64', diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index 1d9768c..319a078 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -443,6 +443,7 @@ 'dependencies': [ 'installer_util', 'installer_util_strings', + 'policy', '../breakpad/breakpad.gyp:breakpad_handler', '../breakpad/breakpad.gyp:breakpad_sender', '../sandbox/sandbox.gyp:sandbox', @@ -489,9 +490,10 @@ # On Windows make sure we've built Win64 version of chrome_dll, # which contains all of the library code with Chromium # functionality. - 'chrome_dll_nacl_win64', 'installer_util_nacl_win64', 'common_constants_win64', + 'chrome_dll_nacl_win64', + 'policy_win64', '../breakpad/breakpad.gyp:breakpad_handler_win64', '../breakpad/breakpad.gyp:breakpad_sender_win64', '../base/base.gyp:base_nacl_win64', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index ee495e0..2fbdfd6 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -31,6 +31,7 @@ 'chrome_strings', 'browser/sync/protocol/sync_proto.gyp:sync_proto_cpp', 'browser/policy/proto/device_management_proto.gyp:device_management_proto_cpp', + 'policy', 'theme_resources', '../base/base.gyp:test_support_base', '../ipc/ipc.gyp:test_support_ipc', @@ -171,6 +172,7 @@ 'test_support_common', 'chrome_resources', 'chrome_strings', + 'policy', 'theme_resources', '../skia/skia.gyp:skia', '../testing/gtest.gyp:gtest', @@ -220,6 +222,7 @@ 'test_support_common', 'chrome_resources', 'chrome_strings', + 'policy', '../skia/skia.gyp:skia', '../testing/gtest.gyp:gtest', ], @@ -247,6 +250,7 @@ 'msvs_guid': 'D2250C20-3A94-4FB9-AF73-11BC5B73884B', 'dependencies': [ 'browser', + 'policy', 'renderer', 'test_support_common', 'test_support_ui', @@ -305,6 +309,7 @@ 'chrome_resources', 'chrome_strings', 'debugger', + 'policy', 'syncapi', 'test_support_common', 'test_support_ui', @@ -911,6 +916,7 @@ 'common', 'chrome_resources', 'chrome_strings', + 'policy', 'test_support_ui', '../base/base.gyp:base', '../build/temp_gyp/googleurl.gyp:googleurl', @@ -978,6 +984,7 @@ 'chrome_resources', 'chrome_strings', 'common', + 'policy', 'profile_import', 'renderer', 'service', @@ -1967,6 +1974,7 @@ 'chrome', 'chrome_resources', 'chrome_strings', + 'policy', 'profile_import', 'renderer', 'test_support_common', @@ -2347,6 +2355,7 @@ 'msvs_guid': 'BBF2BC2F-7CD8-463E-BE88-CB81AAD92BFE', 'dependencies': [ 'chrome', + 'policy', 'test_support_common', '../app/app.gyp:app_resources', '../base/base.gyp:base', @@ -2601,6 +2610,7 @@ 'dependencies': [ 'chrome', 'debugger', + 'policy', 'test_support_common', 'test_support_ui', 'theme_resources', @@ -2635,6 +2645,7 @@ 'dependencies': [ 'chrome', 'debugger', + 'policy', 'test_support_common', 'test_support_ui', 'theme_resources', @@ -2664,6 +2675,7 @@ 'dependencies': [ 'chrome', 'debugger', + 'policy', 'test_support_common', 'test_support_ui', 'theme_resources', @@ -2841,6 +2853,7 @@ 'chrome', 'chrome_resources', 'common', + 'policy', 'profile_import', 'renderer', 'chrome_strings', @@ -3003,6 +3016,7 @@ 'chrome', 'chrome_resources', 'chrome_strings', + 'policy', 'renderer', 'test_support_common', '../app/app.gyp:app_base', @@ -3098,6 +3112,7 @@ 'chrome', 'chrome_resources', 'chrome_strings', + 'policy', 'test_support_common', 'test_support_ui', '../skia/skia.gyp:skia', @@ -3206,6 +3221,7 @@ 'dependencies': [ 'test_support_common', 'browser', + 'policy', 'renderer', 'syncapi', '../base/base.gyp:base', @@ -3283,6 +3299,7 @@ 'dependencies': [ 'chrome_resources', 'chrome_strings', + 'policy', 'test_support_common', 'test_support_ui', '../skia/skia.gyp:skia', @@ -3336,6 +3353,7 @@ 'product_prefix': '_', 'dependencies': [ 'chrome', + 'policy', 'debugger', 'syncapi', 'test_support_common', diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index 957c83f..584bd9e 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -294,7 +294,7 @@ bool PathProvider(int key, FilePath* result) { if (!file_util::PathExists(cur)) // we don't want to create this return false; break; -#if !defined(OS_MACOSX) && defined(OS_POSIX) +#if defined(OS_POSIX) && !defined(OS_MACOSX) case chrome::DIR_POLICY_FILES: { #if defined(GOOGLE_CHROME_BUILD) cur = FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); diff --git a/chrome/common/policy_constants.cc b/chrome/common/policy_constants.cc deleted file mode 100644 index f02264c..0000000 --- a/chrome/common/policy_constants.cc +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/policy_constants.h" - -namespace policy { - -#if defined(OS_WIN) -#if defined(GOOGLE_CHROME_BUILD) -const wchar_t kRegistrySubKey[] = L"SOFTWARE\\Policies\\Google\\Chrome"; -#else -const wchar_t kRegistrySubKey[] = L"SOFTWARE\\Policies\\Chromium"; -#endif -#endif - -namespace key { - -const char kHomepageLocation[] = "HomepageLocation"; -const char kHomepageIsNewTabPage[] = "HomepageIsNewTabPage"; -const char kRestoreOnStartup[] = "RestoreOnStartup"; -const char kURLsToRestoreOnStartup[] = "RestoreOnStartupURLs"; -const char kDefaultSearchProviderEnabled[] = "DefaultSearchProviderEnabled"; -const char kDefaultSearchProviderName[] = "DefaultSearchProviderName"; -const char kDefaultSearchProviderKeyword[] = "DefaultSearchProviderKeyword"; -const char kDefaultSearchProviderSearchURL[] = - "DefaultSearchProviderSearchURL"; -const char kDefaultSearchProviderSuggestURL[] = - "DefaultSearchProviderSuggestURL"; -const char kDefaultSearchProviderInstantURL[] = - "DefaultSearchProviderInstantURL"; -const char kDefaultSearchProviderIconURL[] = - "DefaultSearchProviderIconURL"; -const char kDefaultSearchProviderEncodings[] = - "DefaultSearchProviderEncodings"; -const char kDisableSpdy[] = "DisableSpdy"; -const char kProxyMode[] = "ProxyMode"; -// Deprecated name of policy to set proxy server mode -const char kProxyServerMode[] = "ProxyServerMode"; -const char kProxyServer[] = "ProxyServer"; -const char kProxyPacUrl[] = "ProxyPacUrl"; -const char kProxyBypassList[] = "ProxyBypassList"; -const char kAlternateErrorPagesEnabled[] = "AlternateErrorPagesEnabled"; -const char kSearchSuggestEnabled[] = "SearchSuggestEnabled"; -const char kDnsPrefetchingEnabled[] = "DnsPrefetchingEnabled"; -const char kSafeBrowsingEnabled[] = "SafeBrowsingEnabled"; -const char kMetricsReportingEnabled[] = "MetricsReportingEnabled"; -const char kPasswordManagerEnabled[] = "PasswordManagerEnabled"; -const char kPasswordManagerAllowShowPasswords[] = - "PasswordManagerAllowShowPasswords"; -const char kDisabledPlugins[] = "DisabledPlugins"; -const char kAutoFillEnabled[] = "AutoFillEnabled"; -const char kApplicationLocaleValue[] = "ApplicationLocaleValue"; -const char kSyncDisabled[] = "SyncDisabled"; -const char kExtensionInstallAllowList[] = "ExtensionInstallWhitelist"; -const char kExtensionInstallDenyList[] = "ExtensionInstallBlacklist"; -const char kExtensionInstallForceList[] = "ExtensionInstallForcelist"; -const char kShowHomeButton[] = "ShowHomeButton"; -const char kPrintingEnabled[] = "PrintingEnabled"; -const char kJavascriptEnabled[] = "JavascriptEnabled"; -const char kSavingBrowserHistoryDisabled[] = "SavingBrowserHistoryDisabled"; -const char kDeveloperToolsDisabled[] = "DeveloperToolsDisabled"; -const char kBlockThirdPartyCookies[] = "BlockThirdPartyCookies"; -const char kDefaultCookiesSetting[] = "DefaultCookiesSetting"; -const char kDefaultImagesSetting[] = "DefaultImagesSetting"; -const char kDefaultJavaScriptSetting[] = "DefaultJavaScriptSetting"; -const char kDefaultPluginsSetting[] = "DefaultPluginsSetting"; -const char kDefaultPopupsSetting[] = "DefaultPopupsSetting"; -const char kDefaultNotificationSetting[] = "DefaultNotificationSetting"; -const char kDefaultGeolocationSetting[] = "DefaultGeolocationSetting"; -const char kAuthSchemes[] = "AuthSchemes"; -const char kDisableAuthNegotiateCnameLookup[] = - "DisableAuthNegotiateCnameLookup"; -const char kEnableAuthNegotiatePort[] = "EnableAuthNegotiatePort"; -const char kAuthServerWhitelist[] = "AuthServerWhitelist"; -const char kAuthNegotiateDelegateWhitelist[] = "AuthNegotiateDelegateWhitelist"; -const char kGSSAPILibraryName[] = "GSSAPILibraryName"; -const char kDisable3DAPIs[] = "Disable3DAPIs"; -const char kPolicyRefreshRate[] = "PolicyRefreshRate"; - -// Chrome Frame specific policy constants -const char kChromeFrameRendererSettings[] = "ChromeFrameRendererSettings"; -const char kRenderInChromeFrameList[] = "RenderInChromeFrameList"; -const char kRenderInHostList[] = "RenderInHostList"; -const char kChromeFrameContentTypes[] = "ChromeFrameContentTypes"; - -#if defined(OS_CHROMEOS) -// ChromeOS policy constants -const char kChromeOsLockOnIdleSuspend[] = "ChromeOsLockOnIdleSuspend"; -#endif - -} // namespace key - -} // namespace policy diff --git a/chrome/common/policy_constants.h b/chrome/common/policy_constants.h deleted file mode 100644 index 22a41ba..0000000 --- a/chrome/common/policy_constants.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_POLICY_CONSTANTS_H_ -#define CHROME_COMMON_POLICY_CONSTANTS_H_ -#pragma once - -#include "build/build_config.h" - -namespace policy { - -#if defined(OS_WIN) -// The windows registry path we read the policy configuration from. -extern const wchar_t kRegistrySubKey[]; -#endif - -// Key names for the policy settings. -namespace key { - -extern const char kHomepageLocation[]; -extern const char kHomepageIsNewTabPage[]; -extern const char kRestoreOnStartup[]; -extern const char kURLsToRestoreOnStartup[]; -extern const char kDefaultSearchProviderEnabled[]; -extern const char kDefaultSearchProviderName[]; -extern const char kDefaultSearchProviderKeyword[]; -extern const char kDefaultSearchProviderSearchURL[]; -extern const char kDefaultSearchProviderSuggestURL[]; -extern const char kDefaultSearchProviderInstantURL[]; -extern const char kDefaultSearchProviderIconURL[]; -extern const char kDefaultSearchProviderEncodings[]; -extern const char kDisableSpdy[]; -extern const char kProxyMode[]; -extern const char kProxyServerMode[]; -extern const char kProxyServer[]; -extern const char kProxyPacUrl[]; -extern const char kProxyBypassList[]; -extern const char kAlternateErrorPagesEnabled[]; -extern const char kSearchSuggestEnabled[]; -extern const char kDnsPrefetchingEnabled[]; -extern const char kSafeBrowsingEnabled[]; -extern const char kMetricsReportingEnabled[]; -extern const char kPasswordManagerEnabled[]; -extern const char kPasswordManagerAllowShowPasswords[]; -extern const char kDisabledPlugins[]; -extern const char kAutoFillEnabled[]; -extern const char kApplicationLocaleValue[]; -extern const char kSyncDisabled[]; -extern const char kExtensionInstallAllowList[]; -extern const char kExtensionInstallDenyList[]; -extern const char kExtensionInstallForceList[]; -extern const char kShowHomeButton[]; -extern const char kPrintingEnabled[]; -extern const char kJavascriptEnabled[]; -extern const char kSavingBrowserHistoryDisabled[]; -extern const char kDeveloperToolsDisabled[]; -extern const char kBlockThirdPartyCookies[]; -extern const char kDefaultCookiesSetting[]; -extern const char kDefaultImagesSetting[]; -extern const char kDefaultJavaScriptSetting[]; -extern const char kDefaultPluginsSetting[]; -extern const char kDefaultPopupsSetting[]; -extern const char kDefaultNotificationSetting[]; -extern const char kDefaultGeolocationSetting[]; -extern const char kAuthSchemes[]; -extern const char kDisableAuthNegotiateCnameLookup[]; -extern const char kEnableAuthNegotiatePort[]; -extern const char kAuthServerWhitelist[]; -extern const char kAuthNegotiateDelegateWhitelist[]; -extern const char kGSSAPILibraryName[]; -extern const char kDisable3DAPIs[]; -extern const char kPolicyRefreshRate[]; - -// Chrome Frame specific policy constants -extern const char kChromeFrameRendererSettings[]; -extern const char kRenderInChromeFrameList[]; -extern const char kRenderInHostList[]; -extern const char kChromeFrameContentTypes[]; - -#if defined(OS_CHROMEOS) -// ChromeOS policy constants -extern const char kChromeOsLockOnIdleSuspend[]; -#endif - -} // namespace key - -} // namespace policy - -#endif // CHROME_COMMON_POLICY_CONSTANTS_H_ diff --git a/chrome/common_constants.gypi b/chrome/common_constants.gypi index 07eee8c..47b4d58 100644 --- a/chrome/common_constants.gypi +++ b/chrome/common_constants.gypi @@ -26,8 +26,6 @@ 'common/json_value_serializer.h', 'common/net/gaia/gaia_constants.cc', 'common/net/gaia/gaia_constants.h', - 'common/policy_constants.cc', - 'common/policy_constants.h', 'common/pref_names.cc', 'common/pref_names.h', ], diff --git a/chrome/tools/build/generate_policy_source.py b/chrome/tools/build/generate_policy_source.py new file mode 100644 index 0000000..1051092 --- /dev/null +++ b/chrome/tools/build/generate_policy_source.py @@ -0,0 +1,142 @@ +#!/usr/bin/python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +'''python %prog [options] platform template + +platform specifies which platform source is being generated for + and can be one of (win, mac, linux). +template is the path to a .json policy template file.''' + +from __future__ import with_statement +from optparse import OptionParser +import sys; + + +CHROME_SUBKEY = 'SOFTWARE\\\\Policies\\\\Google\\\\Chrome'; +CHROMIUM_SUBKEY = 'SOFTWARE\\\\Policies\\\\Chromium'; + + +def main(): + parser = OptionParser(usage=__doc__); + parser.add_option("--pch", "--policy-constants-header", dest="header_path", + help="generate header file of policy constants", + metavar="FILE"); + parser.add_option("--pcc", "--policy-constants-source", dest="source_path", + help="generate source file of policy constants", + metavar="FILE"); + parser.add_option("--pth", "--policy-type-header", dest="type_path", + help="generate header file for policy type enumeration", + metavar="FILE"); + + (opts, args) = parser.parse_args(); + + if len(args) < 2 or len(args) > 2: + print "exactly one platform and input file must be specified." + parser.print_help() + sys.exit(2) + template_file_contents = _LoadJSONFile(args[1]); + if opts.header_path is not None: + _WritePolicyConstantHeader(template_file_contents, + args, + opts); + if opts.source_path is not None: + _WritePolicyConstantSource(template_file_contents, + args, + opts); + if opts.type_path is not None: + _WritePolicyTypeEnumerationHeader(template_file_contents, + args, + opts); + + +def _OutputGeneratedWarningForC(f, template_file_path): + f.write('//\n' + '// DO NOT MODIFY THIS FILE DIRECTLY!\n' + '// IT IS GENERATED BY generate_policy_source.py\n' + '// FROM ' + template_file_path + ' \n' + '//\n\n') + + +def _WritePolicyConstantHeader(template_file_contents, args, opts): + platform = args[0]; + with open(opts.header_path, "w") as f: + _OutputGeneratedWarningForC(f, args[1]) + f.write('#ifndef CHROME_COMMON_POLICY_CONSTANTS_H_\n' + '#define CHROME_COMMON_POLICY_CONSTANTS_H_\n' + '#pragma once\n' + '\n' + 'namespace policy {\n\n') + if platform == "win": + f.write('// The windows registry path where policy configuration ' + 'resides.\nextern const wchar_t kRegistrySubKey[];\n\n') + f.write('// Key names for the policy settings.\n' + 'namespace key {\n\n') + for policy_name in _GetPolicyNameList(template_file_contents): + f.write('extern const char k' + policy_name + '[];\n') + f.write('\n} // namespace key\n\n' + '} // namespace policy\n\n' + '#endif // CHROME_COMMON_POLICY_CONSTANTS_H_\n') + + +def _WritePolicyConstantSource(template_file_contents, args, opts): + platform = args[0]; + with open(opts.source_path, "w") as f: + _OutputGeneratedWarningForC(f, args[1]) + f.write('#include "policy/policy_constants.h"\n' + '\n' + 'namespace policy {\n' + '\n') + if platform == "win": + f.write('#if defined(GOOGLE_CHROME_BUILD)\n' + 'const wchar_t kRegistrySubKey[] = ' + 'L"' + CHROME_SUBKEY + '";\n' + '#else\n' + 'const wchar_t kRegistrySubKey[] = ' + 'L"' + CHROMIUM_SUBKEY + '";\n' + '#endif\n\n') + f.write('namespace key {\n\n') + for policy_name in _GetPolicyNameList(template_file_contents): + f.write('const char k%s[] = "%s";\n' % (policy_name, policy_name)) + f.write('\n} // namespace key\n\n' + '} // namespace policy\n') + + +def _WritePolicyTypeEnumerationHeader(template_file_contents, args, opts): + with open(opts.type_path, "w") as f: + _OutputGeneratedWarningForC(f, args[1]) + f.write('#ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_TYPE_H_\n' + '#define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_TYPE_H_\n' + '#pragma once\n' + '\n' + 'namespace policy {\n' + '\n' + 'enum ConfigurationPolicyType {\n') + for policy_name in _GetPolicyNameList(template_file_contents): + f.write(' kPolicy' + policy_name + ",\n"); + f.write('};\n\n' + '} // namespace policy\n\n' + '#endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_TYPE_H_\n') + + +def _GetPolicyNameList(template_file_contents): + policy_names = []; + for policy in template_file_contents['policy_definitions']: + if policy['type'] == 'group': + for sub_policy in policy['policies']: + policy_names.append(sub_policy['name']) + else: + policy_names.append(policy['name']) + policy_names.sort() + return policy_names + + +def _LoadJSONFile(json_file): + with open(json_file, "r") as f: + text = f.read() + return eval(text) + + +if __name__ == '__main__': + main(); |