summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/policy/policy_templates.grd42
-rw-r--r--chrome/app/policy/policy_templates.json96
-rw-r--r--chrome/browser/policy/config_dir_policy_provider_unittest.cc5
-rw-r--r--chrome/browser/policy/configuration_policy_pref_store.cc206
-rw-r--r--chrome/browser/policy/configuration_policy_pref_store_unittest.cc75
-rw-r--r--chrome/browser/policy/configuration_policy_provider_mac_unittest.cc5
-rw-r--r--chrome/browser/policy/configuration_policy_provider_win_unittest.cc5
-rw-r--r--chrome/browser/policy/configuration_policy_store_interface.h7
-rw-r--r--chrome/browser/prefs/pref_service_unittest.cc24
-rw-r--r--chrome/browser/prefs/proxy_prefs.cc20
-rw-r--r--chrome/browser/prefs/proxy_prefs.h8
-rw-r--r--chrome/common/policy_constants.cc7
-rw-r--r--chrome/common/policy_constants.h1
13 files changed, 346 insertions, 155 deletions
diff --git a/chrome/app/policy/policy_templates.grd b/chrome/app/policy/policy_templates.grd
index b665271..2fa2016 100644
--- a/chrome/app/policy/policy_templates.grd
+++ b/chrome/app/policy/policy_templates.grd
@@ -285,6 +285,24 @@ templates and will be translated for each locale. -->
If you enable this setting, <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> ignores all proxy-related options specified from the command line.
</message>
+ <message name="IDS_POLICY_PROXYMODE_CAPTION" desc="Text describing the dropdown menu for selecting proxy server mode in the 'proxy' policy settings page.">
+ Choose how to specify proxy server settings
+ </message>
+ <message name="IDS_POLICY_ENUM_PROXYDISABLED_CAPTION" desc="Label in the 'proxy server mode' dropdown menu for selecting no proxy server.">
+ Never use a proxy
+ </message>
+ <message name="IDS_POLICY_ENUM_PROXYAUTODETECT_CAPTION" desc="Label in the 'proxy server mode' dropdown menu for selecting to auto-detect proxy settings.">
+ Auto detect proxy settings
+ </message>
+ <message name="IDS_POLICY_ENUM_PROXYPACSCRIPT_CAPTION" desc="Label in the 'proxy server mode' dropdown menu for selecting pac script proxy settings.">
+ Use a .pac proxy script
+ </message>
+ <message name="IDS_POLICY_ENUM_PROXYFIXEDSERVERS_CAPTION" desc="Label in the 'proxy server mode' dropdown menu for selecting fixed server proxy settings.">
+ Use fixed proxy servers
+ </message>
+ <message name="IDS_POLICY_ENUM_PROXYUSESYSTEM_CAPTION" desc="Label in the 'proxy server mode' dropdown menu for selecting to use system proxy settings.">
+ Use system proxy settings
+ </message>
<message name="IDS_POLICY_PROXYSERVERMODE_CAPTION" desc="Text describing the dropdown menu for selecting proxy server mode in the 'proxy' policy settings page.">
Choose how to specify proxy server settings
</message>
@@ -312,7 +330,25 @@ templates and will be translated for each locale. -->
<message name="IDS_POLICY_PROXYPACURL_CAPTION" desc="The label of the 'proxy pac URL' text field in the 'proxy' policy settings page.">
URL to a proxy .pac file
</message>
- <message name="IDS_POLICY_PROXYSERVERMODE_DESC" desc="The description of the 'proxy bypass rules' policy when displayed in OSX Workgroup Manager.">
+ <message name="IDS_POLICY_PROXYMODE_DESC" desc="The description of the 'proxy mode' policy when displayed in OSX Workgroup Manager.">
+ Allows you to specify the proxy server used by <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing proxy settings.
+
+ If you choose to never use a proxy server and always connect directly, all other options are ignored.
+
+ If you choose to use system proxy settings or auto detect the proxy server, all other options are ignored.
+
+ If you choose fixed server proxy mode, you can specify further options in 'Address or URL of proxy server' and 'Comma-separated list of proxy bypass rules'.
+
+ If you choose to use a .pac proxy script, you must specify the URL to the script in 'URL to a proxy .pac file'.
+
+ For detailed examples, visit:
+ <ph name="PROXY_HELP_URL">$2<ex>http://www.chromium.org/developers/design-documents/network-settings#TOC-Command-line-options-for-proxy-sett</ex></ph>
+
+ If you enable this setting, <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> ignores all proxy-related options specified from the command line.
+ </message>
+ <message name="IDS_POLICY_PROXYSERVERMODE_DESC" desc="The description of the 'proxy server mode'">
+ This policy is deprecated, use ProxyMode instead.
+
Allows you to specify the proxy server used by <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing proxy settings.
If you choose to never use a proxy server and always connect directly, all other options are ignored.
@@ -867,6 +903,10 @@ templates and will be translated for each locale. -->
desc="Text of a link in the generated policy documentation, that takes the user to the top of the page">
Back to top
</message>
+ <message name="IDS_POLICY_DOC_DEPRECATED"
+ desc="Text appended in parentheses to the policy name to indicate that it has been deprecated">
+ deprecated
+ </message>
<message name="IDS_POLICY_DOC_SUPPORTED"
desc="Appears next to the name of each supported feature in the 'list of supported policy features' in the generated policy documentation">
Yes
diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_templates.json
index 274e00a..2b7d4b3 100644
--- a/chrome/app/policy/policy_templates.json
+++ b/chrome/app/policy/policy_templates.json
@@ -21,7 +21,10 @@
# 'group': - not a real policy, contains a list of policies
# NOTE: Currently nesting groups inside other groups is not supported.
# 'string' - a string value
-# 'enum' - the user can select its value from a collection of items
+# 'int-enum' - the user can select an integer value from a collection of
+# items
+# 'string-enum' - the user can select a string value from a collection of
+# items
# 'main' - a boolean value
# 'list' - a list of string values
#
@@ -72,8 +75,8 @@
# Currently supported product names:
# 'chrome_frame', 'chrome_os'
# 'chrome.win', 'chrome.linux', 'chrome.mac', 'chrome.*'
-# For example if 'chrome.*:5-10' is specified for a policy, then it should
-# be read as:
+# For example if 'chrome.*:5-10' is specified for a policy, then it should
+# be read as:
# 'chrome.linux:5-10,chrome.mac:5-10,chrome.win:5-10'
# The product name also affects in which templates will the policy be included.
# chrome.*, chrome.win, chrome_frame -> ADM,ADMX,ADML,doc
@@ -250,15 +253,32 @@
'type': 'group',
'policies': [
{
+ 'name': 'ProxyMode',
+ 'type': 'string-enum',
+ 'items': [
+ {'name': 'ProxyDisabled', 'value': 'direct'},
+ {'name': 'ProxyAutoDetect', 'value': 'auto_detect'},
+ {'name': 'ProxyPacScript', 'value': 'pac_script'},
+ {'name': 'ProxyFixedServers', 'value': 'fixed_servers'},
+ {'name': 'ProxyUseSystem', 'value': 'system'},
+ ],
+ 'supported_on': ['chrome.*:10-'],
+ 'annotations': {
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': 'direct'
+ }
+ },
+ {
'name': 'ProxyServerMode',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'ProxyServerDisabled', 'value': '0'},
- {'name': 'ProxyServerAutoDetect', 'value': '1'},
- {'name': 'ProxyServerManual', 'value': '2'},
- {'name': 'ProxyServerUseSystem', 'value': '3'},
+ {'name': 'ProxyServerDisabled', 'value': 0},
+ {'name': 'ProxyServerAutoDetect', 'value': 1},
+ {'name': 'ProxyServerManual', 'value': 2},
+ {'name': 'ProxyServerUseSystem', 'value': 3},
],
'supported_on': ['chrome.*:8-'],
+ 'deprecated' : True,
'annotations': {
'features': {'dynamic_refresh': 1},
'example_value': 2,
@@ -412,11 +432,11 @@
'type': 'group',
'policies': [{
'name': 'RestoreOnStartup',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'RestoreOnStartupIsNone', 'value': '0'},
- {'name': 'RestoreOnStartupIsLastSession', 'value': '1'},
- {'name': 'RestoreOnStartupIsURLs', 'value': '4'},
+ {'name': 'RestoreOnStartupIsNone', 'value': 0},
+ {'name': 'RestoreOnStartupIsLastSession', 'value': 1},
+ {'name': 'RestoreOnStartupIsURLs', 'value': 4},
],
'supported_on': ['chrome.*:8-'],
'annotations': {
@@ -517,10 +537,10 @@
'policies': [
{
'name': 'DefaultCookiesSetting',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'AllowCookies', 'value': '0'},
- {'name': 'BlockCookies', 'value': '1'},
+ {'name': 'AllowCookies', 'value': 0},
+ {'name': 'BlockCookies', 'value': 1},
],
'supported_on': ['chrome.*:10-'],
'annotations': {
@@ -530,10 +550,10 @@
},
{
'name': 'DefaultImagesSetting',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'AllowImages', 'value': '0'},
- {'name': 'BlockImages', 'value': '1'},
+ {'name': 'AllowImages', 'value': 0},
+ {'name': 'BlockImages', 'value': 1},
],
'supported_on': ['chrome.*:10-'],
'annotations': {
@@ -543,10 +563,10 @@
},
{
'name': 'DefaultJavaScriptSetting',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'AllowJavaScript', 'value': '0'},
- {'name': 'BlockJavaScript', 'value': '1'},
+ {'name': 'AllowJavaScript', 'value': 0},
+ {'name': 'BlockJavaScript', 'value': 1},
],
'supported_on': ['chrome.*:10-'],
'annotations': {
@@ -556,10 +576,10 @@
},
{
'name': 'DefaultPluginsSetting',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'AllowPlugins', 'value': '0'},
- {'name': 'BlockPlugins', 'value': '1'},
+ {'name': 'AllowPlugins', 'value': 0},
+ {'name': 'BlockPlugins', 'value': 1},
],
'supported_on': ['chrome.*:10-'],
'annotations': {
@@ -569,10 +589,10 @@
},
{
'name': 'DefaultPopupsSetting',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'AllowPopups', 'value': '0'},
- {'name': 'BlockPopups', 'value': '1'},
+ {'name': 'AllowPopups', 'value': 0},
+ {'name': 'BlockPopups', 'value': 1},
],
'supported_on': ['chrome.*:10-'],
'annotations': {
@@ -582,11 +602,11 @@
},
{
'name': 'DefaultNotificationSetting',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'AllowNotifications', 'value': '0'},
- {'name': 'BlockNotifications', 'value': '1'},
- {'name': 'AskNotifications', 'value': '2'},
+ {'name': 'AllowNotifications', 'value': 0},
+ {'name': 'BlockNotifications', 'value': 1},
+ {'name': 'AskNotifications', 'value': 2},
],
'supported_on': ['chrome.*:10-'],
'annotations': {
@@ -596,11 +616,11 @@
},
{
'name': 'DefaultGeolocationSetting',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'AllowGeolocation', 'value': '0'},
- {'name': 'BlockGeolocation', 'value': '1'},
- {'name': 'AskGeolocation', 'value': '2'},
+ {'name': 'AllowGeolocation', 'value': 0},
+ {'name': 'BlockGeolocation', 'value': 1},
+ {'name': 'AskGeolocation', 'value': 2},
],
'supported_on': ['chrome.*:10-'],
'annotations': {
@@ -625,10 +645,10 @@
'type': 'group',
'policies': [{
'name': 'ChromeFrameRendererSettings',
- 'type': 'enum',
+ 'type': 'int-enum',
'items': [
- {'name': 'RenderInHost', 'value': '0'},
- {'name': 'RenderInChromeFrame', 'value': '1'},
+ {'name': 'RenderInHost', 'value': 0},
+ {'name': 'RenderInChromeFrame', 'value': 1},
],
'supported_on': ['chrome_frame:8-'],
'annotations': {
diff --git a/chrome/browser/policy/config_dir_policy_provider_unittest.cc b/chrome/browser/policy/config_dir_policy_provider_unittest.cc
index 982ac6fe..30c2189 100644
--- a/chrome/browser/policy/config_dir_policy_provider_unittest.cc
+++ b/chrome/browser/policy/config_dir_policy_provider_unittest.cc
@@ -261,9 +261,12 @@ INSTANTIATE_TEST_CASE_P(
ValueTestParams::ForStringPolicy(
kPolicyDefaultSearchProviderEncodings,
key::kDefaultSearchProviderEncodings),
- ValueTestParams::ForIntegerPolicy(
+ ValueTestParams::ForStringPolicy(
kPolicyProxyMode,
key::kProxyMode),
+ ValueTestParams::ForIntegerPolicy(
+ kPolicyProxyServerMode,
+ key::kProxyServerMode),
ValueTestParams::ForStringPolicy(
kPolicyProxyServer,
key::kProxyServer),
diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc
index 1330279..58b5cac 100644
--- a/chrome/browser/policy/configuration_policy_pref_store.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store.cc
@@ -106,8 +106,9 @@ class ConfigurationPolicyPrefKeeper
// respective values in |prefs_|.
void FinalizeProxyPolicySettings();
- // Returns true if the policy values stored in proxy_* represent a valid
- // proxy configuration.
+ // Returns true if the policy values stored in proxy_* represent a valid proxy
+ // configuration, including the case in which there is no configuration at
+ // all.
bool CheckProxySettings();
// Assumes CheckProxySettings returns true and applies the values stored
@@ -363,6 +364,7 @@ bool ConfigurationPolicyPrefKeeper::ApplyProxyPolicy(
// FinalizeProxyPolicySettings() is called to determine whether the presented
// values were correct and apply them in that case.
if (policy == kPolicyProxyMode ||
+ policy == kPolicyProxyServerMode ||
policy == kPolicyProxyServer ||
policy == kPolicyProxyPacUrl ||
policy == kPolicyProxyBypassList) {
@@ -492,96 +494,151 @@ void ConfigurationPolicyPrefKeeper::FinalizeProxyPolicySettings() {
bool ConfigurationPolicyPrefKeeper::CheckProxySettings() {
bool mode = HasProxyPolicy(kPolicyProxyMode);
+ bool server_mode = HasProxyPolicy(kPolicyProxyServerMode); // deprecated
bool server = HasProxyPolicy(kPolicyProxyServer);
bool pac_url = HasProxyPolicy(kPolicyProxyPacUrl);
bool bypass_list = HasProxyPolicy(kPolicyProxyBypassList);
- if ((server || pac_url || bypass_list) && !mode) {
+ if ((server || pac_url || bypass_list) && !(mode || server_mode)) {
LOG(WARNING) << "A centrally-administered policy defines proxy setting"
<< " details without setting a proxy mode.";
return false;
}
- if (!mode)
- return true;
+ // If there's a server mode, convert it into a mode.
+ std::string mode_value;
+ if (mode) {
+ if (server_mode)
+ LOG(WARNING) << "Both ProxyMode and ProxyServerMode policies defined, "
+ << "ignoring ProxyMode.";
+ if (!proxy_policies_[kPolicyProxyMode]->GetAsString(&mode_value)) {
+ LOG(WARNING) << "Invalid ProxyMode value.";
+ return false;
+ }
+ } else if (server_mode) {
+ int server_mode_value;
+ if (!proxy_policies_[kPolicyProxyServerMode]->GetAsInteger(
+ &server_mode_value)) {
+ LOG(WARNING) << "Invalid ProxyServerMode value.";
+ return false;
+ }
- int mode_value;
- if (!proxy_policies_[kPolicyProxyMode]->GetAsInteger(&mode_value)) {
- LOG(WARNING) << "Invalid proxy mode value.";
- return false;
+ switch (server_mode_value) {
+ case kPolicyNoProxyServerMode:
+ mode_value = ProxyPrefs::kDirectProxyModeName;
+ break;
+ case kPolicyAutoDetectProxyServerMode:
+ mode_value = ProxyPrefs::kAutoDetectProxyModeName;
+ break;
+ case kPolicyManuallyConfiguredProxyServerMode:
+ if (server && pac_url) {
+ LOG(WARNING) << "A centrally-administered policy dictates that"
+ << " both fixed proxy servers and a .pac url. should"
+ << " be used for proxy configuration.";
+ return false;
+ }
+ if (!server && !pac_url) {
+ LOG(WARNING) << "A centrally-administered policy dictates that the"
+ << " proxy settings should use either fixed proxy"
+ << " servers or a .pac url, but specifies neither.";
+ return false;
+ }
+ if (pac_url)
+ mode_value = ProxyPrefs::kPacScriptProxyModeName;
+ else
+ mode_value = ProxyPrefs::kFixedServersProxyModeName;
+ break;
+ case kPolicyUseSystemProxyServerMode:
+ mode_value = ProxyPrefs::kSystemProxyModeName;
+ break;
+ default:
+ LOG(WARNING) << "Invalid proxy mode " << server_mode_value;
+ return false;
+ }
}
- switch (mode_value) {
- case kPolicyNoProxyServerMode:
- if (server || pac_url || bypass_list) {
- LOG(WARNING) << "A centrally-administered policy disables the use of"
- << " a proxy but also specifies an explicit proxy"
- << " configuration.";
- return false;
- }
- break;
- case kPolicyAutoDetectProxyMode:
- if (server || bypass_list || pac_url) {
- LOG(WARNING) << "A centrally-administered policy dictates that a proxy"
- << " shall be auto configured but specifies fixed proxy"
- << " servers, a by-pass list or a .pac script URL.";
- return false;
- }
- break;
- case kPolicyManuallyConfiguredProxyMode:
- if (server && pac_url) {
- LOG(WARNING) << "A centrally-administered policy dictates that the"
- << " system proxy settings should use both a fixed"
- << " proxy server and a .pac url.";
- return false;
- }
- if (!server && !pac_url) {
- LOG(WARNING) << "A centrally-administered policy dictates that the"
- << " system proxy settings should use either a fixed"
- << " proxy server or a .pac url, but specifies neither.";
- return false;
- }
- break;
- case kPolicyUseSystemProxyMode:
- if (server || pac_url || bypass_list) {
- LOG(WARNING) << "A centrally-administered policy dictates that the"
- << " system proxy settings should be used but also "
- << " specifies an explicit proxy configuration.";
- return false;
- }
- break;
- default:
- LOG(WARNING) << "Invalid proxy mode " << mode_value;
+ // If neither ProxyMode nor ProxyServerMode are specified, mode_value will be
+ // empty and the proxy shouldn't be configured at all.
+ if (mode_value.empty())
+ return true;
+
+ if (mode_value == ProxyPrefs::kDirectProxyModeName) {
+ if (server || pac_url || bypass_list) {
+ LOG(WARNING) << "A centrally-administered policy disables the use of"
+ << " a proxy but also specifies an explicit proxy"
+ << " configuration.";
+ return false;
+ }
+ } else if (mode_value == ProxyPrefs::kAutoDetectProxyModeName) {
+ if (server || bypass_list || pac_url) {
+ LOG(WARNING) << "A centrally-administered policy dictates that a proxy"
+ << " shall be auto configured but specifies fixed proxy"
+ << " servers, a by-pass list or a .pac script URL.";
return false;
+ }
+ } else if (mode_value == ProxyPrefs::kPacScriptProxyModeName) {
+ if (server || bypass_list) {
+ LOG(WARNING) << "A centrally-administered policy dictates that a .pac"
+ << " script URL should be used for proxy configuration but"
+ << " also specifies policies required only for fixed"
+ << " proxy servers.";
+ return false;
+ }
+ } else if (mode_value == ProxyPrefs::kFixedServersProxyModeName) {
+ if (pac_url) {
+ LOG(WARNING) << "A centrally-administered policy dictates that"
+ << " fixed proxy servers should be used but also"
+ << " specifies a .pac script URL.";
+ return false;
+ }
+ } else if (mode_value == ProxyPrefs::kSystemProxyModeName) {
+ if (server || pac_url || bypass_list) {
+ LOG(WARNING) << "A centrally-administered policy dictates that the"
+ << " system proxy settings should be used but also "
+ << " specifies an explicit proxy configuration.";
+ return false;
+ }
+ } else {
+ LOG(WARNING) << "Invalid proxy mode " << mode_value;
+ return false;
}
return true;
}
void ConfigurationPolicyPrefKeeper::ApplyProxySettings() {
- if (!HasProxyPolicy(kPolicyProxyMode))
- return;
-
- int int_mode;
- CHECK(proxy_policies_[kPolicyProxyMode]->GetAsInteger(&int_mode));
ProxyPrefs::ProxyMode mode;
- switch (int_mode) {
- case kPolicyNoProxyServerMode:
- mode = ProxyPrefs::MODE_DIRECT;
- break;
- case kPolicyAutoDetectProxyMode:
- mode = ProxyPrefs::MODE_AUTO_DETECT;
- break;
- case kPolicyManuallyConfiguredProxyMode:
- mode = ProxyPrefs::MODE_FIXED_SERVERS;
- if (HasProxyPolicy(kPolicyProxyPacUrl))
- mode = ProxyPrefs::MODE_PAC_SCRIPT;
- break;
- case kPolicyUseSystemProxyMode:
- mode = ProxyPrefs::MODE_SYSTEM;
- break;
- default:
- mode = ProxyPrefs::MODE_DIRECT;
- NOTREACHED();
+ if (HasProxyPolicy(kPolicyProxyMode)) {
+ std::string string_mode;
+ CHECK(proxy_policies_[kPolicyProxyMode]->GetAsString(&string_mode));
+ if (!ProxyPrefs::StringToProxyMode(string_mode, &mode)) {
+ LOG(WARNING) << "A centrally-administered policy specifies a value for"
+ << "the ProxyMode policy that isn't recognized.";
+ return;
+ }
+ } else if (HasProxyPolicy(kPolicyProxyServerMode)) {
+ int int_mode = 0;
+ CHECK(proxy_policies_[kPolicyProxyServerMode]->GetAsInteger(&int_mode));
+ switch (int_mode) {
+ case kPolicyNoProxyServerMode:
+ mode = ProxyPrefs::MODE_DIRECT;
+ break;
+ case kPolicyAutoDetectProxyServerMode:
+ mode = ProxyPrefs::MODE_AUTO_DETECT;
+ break;
+ case kPolicyManuallyConfiguredProxyServerMode:
+ mode = ProxyPrefs::MODE_FIXED_SERVERS;
+ if (HasProxyPolicy(kPolicyProxyPacUrl))
+ mode = ProxyPrefs::MODE_PAC_SCRIPT;
+ break;
+ case kPolicyUseSystemProxyServerMode:
+ mode = ProxyPrefs::MODE_SYSTEM;
+ break;
+ default:
+ mode = ProxyPrefs::MODE_DIRECT;
+ NOTREACHED();
+ }
+ } else {
+ return;
}
prefs_.SetValue(prefs::kProxyMode, Value::CreateIntegerValue(mode));
@@ -710,7 +767,8 @@ ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() {
key::kDefaultSearchProviderIconURL },
{ kPolicyDefaultSearchProviderEncodings, Value::TYPE_STRING,
key::kDefaultSearchProviderEncodings },
- { kPolicyProxyMode, Value::TYPE_INTEGER, key::kProxyMode },
+ { kPolicyProxyMode, Value::TYPE_STRING, key::kProxyMode },
+ { kPolicyProxyServerMode, Value::TYPE_INTEGER, key::kProxyServerMode },
{ kPolicyProxyServer, Value::TYPE_STRING, key::kProxyServer },
{ kPolicyProxyPacUrl, Value::TYPE_STRING, key::kProxyPacUrl },
{ kPolicyProxyBypassList, Value::TYPE_STRING, key::kProxyBypassList },
diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
index 9f461c1..d81ff91 100644
--- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
@@ -269,9 +269,9 @@ TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptions) {
Value::CreateStringValue("http://chromium.org/override"));
provider.AddPolicy(kPolicyProxyServer,
Value::CreateStringValue("chromium.org"));
- provider.AddPolicy(kPolicyProxyMode,
+ provider.AddPolicy(kPolicyProxyServerMode,
Value::CreateIntegerValue(
- kPolicyManuallyConfiguredProxyMode));
+ kPolicyManuallyConfiguredProxyServerMode));
ConfigurationPolicyPrefStore store(&provider);
VerifyProxyPrefs(
@@ -281,9 +281,9 @@ TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptions) {
TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsReversedApplyOrder) {
MockConfigurationPolicyProvider provider;
- provider.AddPolicy(kPolicyProxyMode,
+ provider.AddPolicy(kPolicyProxyServerMode,
Value::CreateIntegerValue(
- kPolicyManuallyConfiguredProxyMode));
+ kPolicyManuallyConfiguredProxyServerMode));
provider.AddPolicy(kPolicyProxyBypassList,
Value::CreateStringValue("http://chromium.org/override"));
provider.AddPolicy(kPolicyProxyServer,
@@ -295,50 +295,95 @@ TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsReversedApplyOrder) {
ProxyPrefs::MODE_FIXED_SERVERS);
}
-TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxy) {
+TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyServerMode) {
MockConfigurationPolicyProvider provider;
- provider.AddPolicy(kPolicyProxyMode,
+ provider.AddPolicy(kPolicyProxyServerMode,
Value::CreateIntegerValue(kPolicyNoProxyServerMode));
ConfigurationPolicyPrefStore store(&provider);
VerifyProxyPrefs(store, "", "", "", ProxyPrefs::MODE_DIRECT);
}
-TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetect) {
+TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyModeName) {
MockConfigurationPolicyProvider provider;
- provider.AddPolicy(kPolicyProxyMode,
- Value::CreateIntegerValue(kPolicyAutoDetectProxyMode));
+ provider.AddPolicy(
+ kPolicyProxyMode,
+ Value::CreateStringValue(ProxyPrefs::kDirectProxyModeName));
+
+ ConfigurationPolicyPrefStore store(&provider);
+ VerifyProxyPrefs(store, "", "", "", ProxyPrefs::MODE_DIRECT);
+}
+
+TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyServerMode) {
+ MockConfigurationPolicyProvider provider;
+ provider.AddPolicy(
+ kPolicyProxyServerMode,
+ Value::CreateIntegerValue(kPolicyAutoDetectProxyServerMode));
ConfigurationPolicyPrefStore store(&provider);
VerifyProxyPrefs(store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT);
}
-TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectPac) {
+TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyModeName) {
+ MockConfigurationPolicyProvider provider;
+ provider.AddPolicy(
+ kPolicyProxyMode,
+ Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName));
+
+ ConfigurationPolicyPrefStore store(&provider);
+ VerifyProxyPrefs(store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT);
+}
+
+TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyMode) {
MockConfigurationPolicyProvider provider;
provider.AddPolicy(kPolicyProxyPacUrl,
Value::CreateStringValue("http://short.org/proxy.pac"));
provider.AddPolicy(
kPolicyProxyMode,
- Value::CreateIntegerValue(kPolicyManuallyConfiguredProxyMode));
+ Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName));
ConfigurationPolicyPrefStore store(&provider);
VerifyProxyPrefs(
store, "", "http://short.org/proxy.pac", "", ProxyPrefs::MODE_PAC_SCRIPT);
}
-TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystem) {
+TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyServerMode) {
MockConfigurationPolicyProvider provider;
- provider.AddPolicy(kPolicyProxyMode,
- Value::CreateIntegerValue(kPolicyUseSystemProxyMode));
+ provider.AddPolicy(
+ kPolicyProxyServerMode,
+ Value::CreateIntegerValue(kPolicyUseSystemProxyServerMode));
ConfigurationPolicyPrefStore store(&provider);
VerifyProxyPrefs(store, "", "", "", ProxyPrefs::MODE_SYSTEM);
}
+TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyMode) {
+ MockConfigurationPolicyProvider provider;
+ provider.AddPolicy(
+ kPolicyProxyMode,
+ Value::CreateStringValue(ProxyPrefs::kSystemProxyModeName));
+
+ ConfigurationPolicyPrefStore store(&provider);
+ VerifyProxyPrefs(store, "", "", "", ProxyPrefs::MODE_SYSTEM);
+}
+
+TEST_F(ConfigurationPolicyPrefStoreProxyTest,
+ ProxyModeOverridesProxyServerMode) {
+ MockConfigurationPolicyProvider provider;
+ provider.AddPolicy(kPolicyProxyServerMode,
+ Value::CreateIntegerValue(kPolicyNoProxyServerMode));
+ provider.AddPolicy(
+ kPolicyProxyMode,
+ Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName));
+
+ ConfigurationPolicyPrefStore store(&provider);
+ VerifyProxyPrefs(store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT);
+}
+
TEST_F(ConfigurationPolicyPrefStoreProxyTest, ProxyInvalid) {
for (int i = 0; i < MODE_COUNT; ++i) {
MockConfigurationPolicyProvider provider;
- provider.AddPolicy(kPolicyProxyMode, Value::CreateIntegerValue(i));
+ provider.AddPolicy(kPolicyProxyServerMode, Value::CreateIntegerValue(i));
// No mode expects all three parameters being set.
provider.AddPolicy(kPolicyProxyPacUrl,
Value::CreateStringValue("http://short.org/proxy.pac"));
diff --git a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc
index 4203fb0..11d04a7 100644
--- a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc
+++ b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc
@@ -235,9 +235,12 @@ INSTANTIATE_TEST_CASE_P(
PolicyTestParams::ForStringPolicy(
kPolicyDefaultSearchProviderEncodings,
key::kDefaultSearchProviderEncodings),
- PolicyTestParams::ForIntegerPolicy(
+ PolicyTestParams::ForStringPolicy(
kPolicyProxyMode,
key::kProxyMode),
+ PolicyTestParams::ForIntegerPolicy(
+ kPolicyProxyServerMode,
+ key::kProxyServerMode),
PolicyTestParams::ForStringPolicy(
kPolicyProxyServer,
key::kProxyServer),
diff --git a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc
index 6085192..481e1d8 100644
--- a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc
+++ b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc
@@ -393,9 +393,12 @@ INSTANTIATE_TEST_CASE_P(
PolicyTestParams::ForStringPolicy(
kPolicyDefaultSearchProviderEncodings,
key::kDefaultSearchProviderEncodings),
- PolicyTestParams::ForIntegerPolicy(
+ PolicyTestParams::ForStringPolicy(
kPolicyProxyMode,
key::kProxyMode),
+ PolicyTestParams::ForIntegerPolicy(
+ kPolicyProxyServerMode,
+ key::kProxyServerMode),
PolicyTestParams::ForStringPolicy(
kPolicyProxyServer,
key::kProxyServer),
diff --git a/chrome/browser/policy/configuration_policy_store_interface.h b/chrome/browser/policy/configuration_policy_store_interface.h
index e690242..b7f2f05 100644
--- a/chrome/browser/policy/configuration_policy_store_interface.h
+++ b/chrome/browser/policy/configuration_policy_store_interface.h
@@ -27,6 +27,7 @@ enum ConfigurationPolicyType {
kPolicyDefaultSearchProviderEncodings,
kPolicyDisableSpdy,
kPolicyProxyMode,
+ kPolicyProxyServerMode,
kPolicyProxyServer,
kPolicyProxyPacUrl,
kPolicyProxyBypassList,
@@ -80,11 +81,11 @@ enum PolicyProxyModeType {
// Disable Proxy, connect directly.
kPolicyNoProxyServerMode = 0,
// Auto detect proxy or use specific PAC script if given.
- kPolicyAutoDetectProxyMode = 1,
+ kPolicyAutoDetectProxyServerMode = 1,
// Use manually configured proxy servers (fixed servers).
- kPolicyManuallyConfiguredProxyMode = 2,
+ kPolicyManuallyConfiguredProxyServerMode = 2,
// Use system proxy server.
- kPolicyUseSystemProxyMode = 3,
+ kPolicyUseSystemProxyServerMode = 3,
MODE_COUNT
};
diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc
index 1a79708..3ead502 100644
--- a/chrome/browser/prefs/pref_service_unittest.cc
+++ b/chrome/browser/prefs/pref_service_unittest.cc
@@ -154,9 +154,9 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineOptions) {
command_line.AppendSwitchASCII(switches::kProxyServer, "789");
scoped_ptr<policy::MockConfigurationPolicyProvider> provider(
new policy::MockConfigurationPolicyProvider());
- Value* mode_value = Value::CreateIntegerValue(
- policy::kPolicyManuallyConfiguredProxyMode);
- provider->AddPolicy(policy::kPolicyProxyMode, mode_value);
+ Value* mode_name = Value::CreateStringValue(
+ ProxyPrefs::kFixedServersProxyModeName);
+ provider->AddPolicy(policy::kPolicyProxyMode, mode_name);
provider->AddPolicy(policy::kPolicyProxyBypassList,
Value::CreateStringValue("abc"));
provider->AddPolicy(policy::kPolicyProxyServer,
@@ -194,9 +194,9 @@ TEST(PrefServiceTest, ProxyPolicyOverridesUnrelatedCommandLineOptions) {
command_line.AppendSwitchASCII(switches::kProxyServer, "789");
scoped_ptr<policy::MockConfigurationPolicyProvider> provider(
new policy::MockConfigurationPolicyProvider());
- Value* mode_value = Value::CreateIntegerValue(
- policy::kPolicyAutoDetectProxyMode);
- provider->AddPolicy(policy::kPolicyProxyMode, mode_value);
+ Value* mode_name = Value::CreateStringValue(
+ ProxyPrefs::kAutoDetectProxyModeName);
+ provider->AddPolicy(policy::kPolicyProxyMode, mode_name);
// First verify that command-line options are set correctly when
// there is no policy in effect.
@@ -229,9 +229,9 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineNoProxy) {
command_line.AppendSwitch(switches::kNoProxyServer);
scoped_ptr<policy::MockConfigurationPolicyProvider> provider(
new policy::MockConfigurationPolicyProvider());
- Value* mode_value = Value::CreateIntegerValue(
- policy::kPolicyAutoDetectProxyMode);
- provider->AddPolicy(policy::kPolicyProxyMode, mode_value);
+ Value* mode_name = Value::CreateStringValue(
+ ProxyPrefs::kAutoDetectProxyModeName);
+ provider->AddPolicy(policy::kPolicyProxyMode, mode_name);
// First verify that command-line options are set correctly when
// there is no policy in effect.
@@ -263,9 +263,9 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineAutoDetect) {
command_line.AppendSwitch(switches::kProxyAutoDetect);
scoped_ptr<policy::MockConfigurationPolicyProvider> provider(
new policy::MockConfigurationPolicyProvider());
- Value* mode_value = Value::CreateIntegerValue(
- policy::kPolicyNoProxyServerMode);
- provider->AddPolicy(policy::kPolicyProxyMode, mode_value);
+ Value* mode_name = Value::CreateStringValue(
+ ProxyPrefs::kDirectProxyModeName);
+ provider->AddPolicy(policy::kPolicyProxyMode, mode_name);
// First verify that the auto-detect is set if there is no managed
// PrefStore.
diff --git a/chrome/browser/prefs/proxy_prefs.cc b/chrome/browser/prefs/proxy_prefs.cc
index 7eb504c..fadd562 100644
--- a/chrome/browser/prefs/proxy_prefs.cc
+++ b/chrome/browser/prefs/proxy_prefs.cc
@@ -7,15 +7,25 @@
#include "base/basictypes.h"
#include "base/logging.h"
+namespace ProxyPrefs {
+
+const char kDirectProxyModeName[] = "direct";
+const char kAutoDetectProxyModeName[] = "auto_detect";
+const char kPacScriptProxyModeName[] = "pac_script";
+const char kFixedServersProxyModeName[] = "fixed_servers";
+const char kSystemProxyModeName[] = "system";
+
+}
+
namespace {
// These names are exposed to the proxy extension API. They must be in sync
// with the constants of ProxyPrefs.
-const char* kProxyModeNames[] = { "direct",
- "auto_detect",
- "pac_script",
- "fixed_servers",
- "system" };
+const char* kProxyModeNames[] = { ProxyPrefs::kDirectProxyModeName,
+ ProxyPrefs::kAutoDetectProxyModeName,
+ ProxyPrefs::kPacScriptProxyModeName,
+ ProxyPrefs::kFixedServersProxyModeName,
+ ProxyPrefs::kSystemProxyModeName };
} // namespace
diff --git a/chrome/browser/prefs/proxy_prefs.h b/chrome/browser/prefs/proxy_prefs.h
index bbeb44d..da911d4 100644
--- a/chrome/browser/prefs/proxy_prefs.h
+++ b/chrome/browser/prefs/proxy_prefs.h
@@ -36,6 +36,14 @@ enum ProxyMode {
kModeCount
};
+// Constants for string values used to specify the proxy mode through externally
+// visible APIs, e.g. through policy or the proxy extension API.
+extern const char kDirectProxyModeName[];
+extern const char kAutoDetectProxyModeName[];
+extern const char kPacScriptProxyModeName[];
+extern const char kFixedServersProxyModeName[];
+extern const char kSystemProxyModeName[];
+
bool IntToProxyMode(int in_value, ProxyMode* out_value);
bool StringToProxyMode(const std::string& in_value,
ProxyMode* out_value);
diff --git a/chrome/common/policy_constants.cc b/chrome/common/policy_constants.cc
index 848b28b..032c07a 100644
--- a/chrome/common/policy_constants.cc
+++ b/chrome/common/policy_constants.cc
@@ -34,10 +34,9 @@ const char kDefaultSearchProviderIconURL[] =
const char kDefaultSearchProviderEncodings[] =
"DefaultSearchProviderEncodings";
const char kDisableSpdy[] = "DisableSpdy";
-// We consider the name ProxyMode more apt than ProxyServerMode but could
-// not change it after publishing that name for the win registry and policy
-// config files.
-const char kProxyMode[] = "ProxyServerMode";
+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";
diff --git a/chrome/common/policy_constants.h b/chrome/common/policy_constants.h
index 37464e6..fae7c8b 100644
--- a/chrome/common/policy_constants.h
+++ b/chrome/common/policy_constants.h
@@ -32,6 +32,7 @@ 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[];