summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prefs
diff options
context:
space:
mode:
authordanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-13 12:23:06 +0000
committerdanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-13 12:23:06 +0000
commitf0e63b4b3b44cb5a0f3099a7f3102d4fe7acf3a7 (patch)
treeb0bc10591db36c04c36023a28dd88d10d7f7d50e /chrome/browser/prefs
parent16c5c87e1296e597b259ad94d8eb7245bd7956a1 (diff)
downloadchromium_src-f0e63b4b3b44cb5a0f3099a7f3102d4fe7acf3a7.zip
chromium_src-f0e63b4b3b44cb5a0f3099a7f3102d4fe7acf3a7.tar.gz
chromium_src-f0e63b4b3b44cb5a0f3099a7f3102d4fe7acf3a7.tar.bz2
Policy: Add ProxyMode and deprecate ProxyServerMode.
- Add support for 'deprecated' attribute in template generator - Add support for both int- and string- based enums in the template generator - Add logic to handle ProxyMode and fall back to ProxyServerMode BUG=68134 TEST=ConfigurationPolicyPrefStore*, new policy template generator tests Review URL: http://codereview.chromium.org/5958014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs')
-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
3 files changed, 35 insertions, 17 deletions
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);