diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 14:52:17 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 14:52:17 +0000 |
commit | c2f23d014bb8f371cd7b454c09c3e0bf291620e8 (patch) | |
tree | a84c232915f9654969a913ad9a5926479448c846 | |
parent | 559a9bd2ab0d32b79e1c938159d952b1b329b7ee (diff) | |
download | chromium_src-c2f23d014bb8f371cd7b454c09c3e0bf291620e8.zip chromium_src-c2f23d014bb8f371cd7b454c09c3e0bf291620e8.tar.gz chromium_src-c2f23d014bb8f371cd7b454c09c3e0bf291620e8.tar.bz2 |
Make proxy settings one atomic dictionary in the PrefStores such that modifications are atomic.
BUG=67779,70904
TEST=none
Review URL: http://codereview.chromium.org/6240013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74284 0039d316-1c4b-4281-b951-d872f2087c98
27 files changed, 613 insertions, 317 deletions
diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.cc b/chrome/browser/dom_ui/options/advanced_options_handler.cc index 1cdceb3..30a791d 100644 --- a/chrome/browser/dom_ui/options/advanced_options_handler.cc +++ b/chrome/browser/dom_ui/options/advanced_options_handler.cc @@ -598,10 +598,10 @@ void AdvancedOptionsHandler::SetupProxySettingsSection() { // Disable the button if proxy settings are managed by a sysadmin or // overridden by an extension. PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); - const PrefService::Preference* proxy_server = - pref_service->FindPreference(prefs::kProxyServer); - bool is_extension_controlled = (proxy_server && - proxy_server->IsExtensionControlled()); + const PrefService::Preference* proxy_config = + pref_service->FindPreference(prefs::kProxy); + bool is_extension_controlled = (proxy_config && + proxy_config->IsExtensionControlled()); FundamentalValue disabled(proxy_prefs_->IsManaged() || is_extension_controlled); diff --git a/chrome/browser/extensions/extension_proxy_api.cc b/chrome/browser/extensions/extension_proxy_api.cc index 38095bf..a8852cc 100644 --- a/chrome/browser/extensions/extension_proxy_api.cc +++ b/chrome/browser/extensions/extension_proxy_api.cc @@ -7,7 +7,7 @@ #include "base/string_util.h" #include "base/stringprintf.h" #include "base/values.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/common/pref_names.h" @@ -75,18 +75,72 @@ bool UseCustomProxySettingsFunction::RunImpl() { std::string proxy_mode; proxy_config->GetString("mode", &proxy_mode); + ProxyPrefs::ProxyMode mode_enum; + if (!ProxyPrefs::StringToProxyMode(proxy_mode, &mode_enum)) { + LOG(ERROR) << "Invalid mode for proxy settings: " << proxy_mode << ". " + << "Setting custom proxy settings failed."; + return false; + } DictionaryValue* pac_dict = NULL; proxy_config->GetDictionary("pacScript", &pac_dict); + std::string pac_url; + if (pac_dict && !pac_dict->GetString("url", &pac_url)) { + LOG(ERROR) << "'pacScript' requires a 'url' field. " + << "Setting custom proxy settings failed."; + return false; + } DictionaryValue* proxy_rules = NULL; proxy_config->GetDictionary("rules", &proxy_rules); + std::string proxy_rules_string; + if (proxy_rules && !GetProxyRules(proxy_rules, &proxy_rules_string)) { + LOG(ERROR) << "Invalid 'rules' specified. " + << "Setting custom proxy settings failed."; + return false; + } - // TODO(battre,gfeher): Make sure all the preferences get always - // overwritten. - return ApplyMode(proxy_mode, incognito) && - ApplyPacScript(pac_dict, incognito) && - ApplyProxyRules(proxy_rules, incognito); + // not supported, yet. + std::string bypass_list; + + DictionaryValue* result_proxy_config = NULL; + switch (mode_enum) { + case ProxyPrefs::MODE_DIRECT: + result_proxy_config = ProxyConfigDictionary::CreateDirect(); + break; + case ProxyPrefs::MODE_AUTO_DETECT: + result_proxy_config = ProxyConfigDictionary::CreateAutoDetect(); + break; + case ProxyPrefs::MODE_PAC_SCRIPT: { + if (!pac_dict) { + LOG(ERROR) << "Proxy mode 'pac_script' requires a 'pacScript' field. " + << "Setting custom proxy settings failed."; + return false; + } + result_proxy_config = ProxyConfigDictionary::CreatePacScript(pac_url); + break; + } + case ProxyPrefs::MODE_FIXED_SERVERS: { + if (!proxy_rules) { + LOG(ERROR) << "Proxy mode 'fixed_servers' requires a 'rules' field. " + << "Setting custom proxy settings failed."; + return false; + } + result_proxy_config = ProxyConfigDictionary::CreateFixedServers( + proxy_rules_string, bypass_list); + break; + } + case ProxyPrefs::MODE_SYSTEM: + result_proxy_config = ProxyConfigDictionary::CreateSystem(); + break; + case ProxyPrefs::kModeCount: + NOTREACHED(); + } + if (!result_proxy_config) + return false; + + ApplyPreference(prefs::kProxy, result_proxy_config, incognito); + return true; } bool UseCustomProxySettingsFunction::GetProxyServer( @@ -97,45 +151,11 @@ bool UseCustomProxySettingsFunction::GetProxyServer( return true; } -bool UseCustomProxySettingsFunction::ApplyMode(const std::string& mode, - bool incognito) { - // We take control of the mode preference even if none was specified, so that - // all proxy preferences are controlled by the same extension (if not by a - // higher-priority source). - bool result = true; - ProxyPrefs::ProxyMode mode_enum; - if (!ProxyPrefs::StringToProxyMode(mode, &mode_enum)) { - mode_enum = ProxyPrefs::MODE_SYSTEM; - LOG(WARNING) << "Invalid mode for proxy settings: " << mode; - result = false; - } - ApplyPreference( - prefs::kProxyMode, Value::CreateIntegerValue(mode_enum), incognito); - return result; -} - -bool UseCustomProxySettingsFunction::ApplyPacScript(DictionaryValue* pac_dict, - bool incognito) { - std::string pac_url; - if (pac_dict) - pac_dict->GetString("url", &pac_url); - - // We take control of the PAC preference even if none was specified, so that - // all proxy preferences are controlled by the same extension (if not by a - // higher-priority source). - ApplyPreference( - prefs::kProxyPacUrl, Value::CreateStringValue(pac_url), incognito); - return true; -} - -bool UseCustomProxySettingsFunction::ApplyProxyRules( +bool UseCustomProxySettingsFunction::GetProxyRules( DictionaryValue* proxy_rules, - bool incognito) { - if (!proxy_rules) { - ApplyPreference( - prefs::kProxyServer, Value::CreateStringValue(""), incognito); - return true; - } + std::string* out) { + if (!proxy_rules) + return false; // Local data into which the parameters will be parsed. has_proxy describes // whether a setting was found for the scheme; proxy_dict holds the @@ -189,8 +209,7 @@ bool UseCustomProxySettingsFunction::ApplyProxyRules( } } - ApplyPreference( - prefs::kProxyServer, Value::CreateStringValue(proxy_pref), incognito); + *out = proxy_pref; return true; } @@ -198,8 +217,6 @@ bool RemoveCustomProxySettingsFunction::RunImpl() { bool incognito = false; args_->GetBoolean(0, &incognito); - RemovePreference(prefs::kProxyMode, incognito); - RemovePreference(prefs::kProxyPacUrl, incognito); - RemovePreference(prefs::kProxyServer, incognito); + RemovePreference(prefs::kProxy, incognito); return true; } diff --git a/chrome/browser/extensions/extension_proxy_api.h b/chrome/browser/extensions/extension_proxy_api.h index 8ac4796..ee98813 100644 --- a/chrome/browser/extensions/extension_proxy_api.h +++ b/chrome/browser/extensions/extension_proxy_api.h @@ -30,6 +30,7 @@ class UseCustomProxySettingsFunction : public ProxySettingsFunction { DECLARE_EXTENSION_FUNCTION_NAME("experimental.proxy.useCustomProxySettings") private: + // Temporary data container to pass structured elements between functions. struct ProxyServer { enum { INVALID_PORT = -1 @@ -42,11 +43,15 @@ class UseCustomProxySettingsFunction : public ProxySettingsFunction { int port; }; + // Converts a proxy server description |dict| as passed by the API caller + // (e.g. for the http proxy in the rules element) and converts it to a + // ProxyServer. Returns true if successful. bool GetProxyServer(const DictionaryValue* dict, ProxyServer* proxy_server); - bool ApplyMode(const std::string& mode, bool incognito); - bool ApplyPacScript(DictionaryValue* pac_dict, bool incognito); - bool ApplyProxyRules(DictionaryValue* proxy_rules, bool incognito); + // Converts a proxy "rules" element passed by the API caller into a proxy + // configuration string that can be used by the proxy subsystem (see + // proxy_config.h). Returns true if successful. + bool GetProxyRules(DictionaryValue* proxy_rules, std::string* out); }; class RemoveCustomProxySettingsFunction : public ProxySettingsFunction { diff --git a/chrome/browser/extensions/extension_proxy_apitest.cc b/chrome/browser/extensions/extension_proxy_apitest.cc index 4d2325f..024595f 100644 --- a/chrome/browser/extensions/extension_proxy_apitest.cc +++ b/chrome/browser/extensions/extension_proxy_apitest.cc @@ -4,48 +4,56 @@ #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/pref_names.h" -class ProxySettingsApiTest : public ExtensionApiTest { - protected: - void AssertSettings(int expected_mode, - const char* expected_server, - const char* expected_pac_url, - PrefService* pref_service) { - AssertExtensionControlled(prefs::kProxyMode, pref_service); - int mode = pref_service->GetInteger(prefs::kProxyMode); - EXPECT_EQ(expected_mode, mode); +namespace { - AssertExtensionControlled(prefs::kProxyPacUrl, pref_service); - EXPECT_EQ(expected_pac_url, pref_service->GetString(prefs::kProxyPacUrl)); +const char NO_SERVER[] = ""; +const char NO_PAC[] = ""; - AssertExtensionControlled(prefs::kProxyServer, pref_service); - EXPECT_EQ(expected_server, pref_service->GetString(prefs::kProxyServer)); - } +} // namespace - void AssertNoSettings(PrefService* pref_service) { - AssertNotExtensionControlled(prefs::kProxyServer, pref_service); - AssertNotExtensionControlled(prefs::kProxyMode, pref_service); - AssertNotExtensionControlled(prefs::kProxyPacUrl, pref_service); - } - private: - void AssertExtensionControlled(const char* pref_key, - PrefService* pref_service) { +class ProxySettingsApiTest : public ExtensionApiTest { + protected: + void ValidateSettings(int expected_mode, + const std::string& expected_server, + const std::string& expected_pac_url, + PrefService* pref_service) { const PrefService::Preference* pref = - pref_service->FindPreference(pref_key); + pref_service->FindPreference(prefs::kProxy); ASSERT_TRUE(pref != NULL); EXPECT_TRUE(pref->IsExtensionControlled()); + + ProxyConfigDictionary dict(pref_service->GetDictionary(prefs::kProxy)); + + ProxyPrefs::ProxyMode mode; + ASSERT_TRUE(dict.GetMode(&mode)); + EXPECT_EQ(expected_mode, mode); + + std::string value; + if (!expected_pac_url.empty()) { + ASSERT_TRUE(dict.GetPacUrl(&value)); + EXPECT_EQ(expected_pac_url, value); + } else { + EXPECT_FALSE(dict.GetPacUrl(&value)); + } + + if (!expected_server.empty()) { + ASSERT_TRUE(dict.GetProxyServer(&value)); + EXPECT_EQ(expected_server, value); + } else { + EXPECT_FALSE(dict.GetProxyServer(&value)); + } } - void AssertNotExtensionControlled(const char* pref_key, - PrefService* pref_service) { + void ExpectNoSettings(PrefService* pref_service) { const PrefService::Preference* pref = - pref_service->FindPreference(pref_key); + pref_service->FindPreference(prefs::kProxy); ASSERT_TRUE(pref != NULL); EXPECT_FALSE(pref->IsExtensionControlled()); } @@ -68,7 +76,7 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyDirectSettings) { ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_DIRECT, kNoServer, kNoPac, pref_service); + ValidateSettings(ProxyPrefs::MODE_DIRECT, kNoServer, kNoPac, pref_service); } // Tests auto-detect settings. @@ -81,7 +89,8 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyAutoSettings) { ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_AUTO_DETECT, kNoServer, kNoPac, pref_service); + ValidateSettings(ProxyPrefs::MODE_AUTO_DETECT, kNoServer, kNoPac, + pref_service); } // Tests PAC proxy settings. @@ -94,8 +103,8 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyPacScript) { ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_PAC_SCRIPT, kNoServer, - "http://wpad/windows.pac", pref_service); + ValidateSettings(ProxyPrefs::MODE_PAC_SCRIPT, kNoServer, + "http://wpad/windows.pac", pref_service); } // Tests setting a single proxy to cover all schemes. @@ -108,13 +117,13 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyFixedSingle) { ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_FIXED_SERVERS, - "http=http://127.0.0.1:100;" - "https=http://127.0.0.1:100;" - "ftp=http://127.0.0.1:100;" - "socks=http://9.9.9.9", - kNoPac, - pref_service); + ValidateSettings(ProxyPrefs::MODE_FIXED_SERVERS, + "http=http://127.0.0.1:100;" + "https=http://127.0.0.1:100;" + "ftp=http://127.0.0.1:100;" + "socks=http://9.9.9.9", + kNoPac, + pref_service); } // Tests setting to use the system's proxy settings. @@ -127,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxySystem) { ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_SYSTEM, kNoServer, kNoPac, pref_service); + ValidateSettings(ProxyPrefs::MODE_SYSTEM, kNoServer, kNoPac, pref_service); } // Tests setting separate proxies for each scheme. @@ -140,23 +149,23 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyFixedIndividual) { ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_FIXED_SERVERS, - "http=http://1.1.1.1;" - "https=socks://2.2.2.2;" - "ftp=http://3.3.3.3:9000;" - "socks=socks4://4.4.4.4:9090", - kNoPac, - pref_service); + ValidateSettings(ProxyPrefs::MODE_FIXED_SERVERS, + "http=http://1.1.1.1;" + "https=socks://2.2.2.2;" + "ftp=http://3.3.3.3:9000;" + "socks=socks4://4.4.4.4:9090", + kNoPac, + pref_service); // Now check the incognito preferences. pref_service = browser()->profile()->GetOffTheRecordProfile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_FIXED_SERVERS, - "http=http://1.1.1.1;" - "https=socks://2.2.2.2;" - "ftp=http://3.3.3.3:9000;" - "socks=socks4://4.4.4.4:9090", - kNoPac, - pref_service); + ValidateSettings(ProxyPrefs::MODE_FIXED_SERVERS, + "http=http://1.1.1.1;" + "https=socks://2.2.2.2;" + "ftp=http://3.3.3.3:9000;" + "socks=socks4://4.4.4.4:9090", + kNoPac, + pref_service); } // Tests setting values only for incognito mode @@ -170,17 +179,17 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertNoSettings(pref_service); + ExpectNoSettings(pref_service); // Now check the incognito preferences. pref_service = browser()->profile()->GetOffTheRecordProfile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_FIXED_SERVERS, - "http=http://1.1.1.1;" - "https=socks://2.2.2.2;" - "ftp=http://3.3.3.3:9000;" - "socks=socks4://4.4.4.4:9090", - kNoPac, - pref_service); + ValidateSettings(ProxyPrefs::MODE_FIXED_SERVERS, + "http=http://1.1.1.1;" + "https=socks://2.2.2.2;" + "ftp=http://3.3.3.3:9000;" + "socks=socks4://4.4.4.4:9090", + kNoPac, + pref_service); } // Tests setting values also for incognito mode @@ -194,23 +203,23 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_FIXED_SERVERS, - "http=http://1.1.1.1;" - "https=socks://2.2.2.2;" - "ftp=http://3.3.3.3:9000;" - "socks=socks4://4.4.4.4:9090", - kNoPac, - pref_service); + ValidateSettings(ProxyPrefs::MODE_FIXED_SERVERS, + "http=http://1.1.1.1;" + "https=socks://2.2.2.2;" + "ftp=http://3.3.3.3:9000;" + "socks=socks4://4.4.4.4:9090", + kNoPac, + pref_service); // Now check the incognito preferences. pref_service = browser()->profile()->GetOffTheRecordProfile()->GetPrefs(); - AssertSettings(ProxyPrefs::MODE_FIXED_SERVERS, - "http=http://5.5.5.5;" - "https=socks://6.6.6.6;" - "ftp=http://7.7.7.7:9000;" - "socks=socks4://8.8.8.8:9090", - kNoPac, - pref_service); + ValidateSettings(ProxyPrefs::MODE_FIXED_SERVERS, + "http=http://5.5.5.5;" + "https=socks://6.6.6.6;" + "ftp=http://7.7.7.7:9000;" + "socks=socks4://8.8.8.8:9090", + kNoPac, + pref_service); } // Tests setting and unsetting values @@ -223,5 +232,5 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyFixedIndividualRemove) { ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); - AssertNoSettings(pref_service); + ExpectNoSettings(pref_service); } diff --git a/chrome/browser/net/pref_proxy_config_service.cc b/chrome/browser/net/pref_proxy_config_service.cc index 2b10104..a31dc9f 100644 --- a/chrome/browser/net/pref_proxy_config_service.cc +++ b/chrome/browser/net/pref_proxy_config_service.cc @@ -8,7 +8,7 @@ #include "chrome/browser/browser_thread.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_set_observer.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/common/notification_details.h" #include "chrome/common/notification_source.h" #include "chrome/common/notification_type.h" @@ -86,9 +86,10 @@ bool PrefProxyConfigTracker::ReadPrefConfig(net::ProxyConfig* config) { // Clear the configuration. *config = net::ProxyConfig(); + ProxyConfigDictionary proxy_dict(pref_service_->GetDictionary(prefs::kProxy)); + ProxyPrefs::ProxyMode mode; - int proxy_mode = pref_service_->GetInteger(prefs::kProxyMode); - if (!ProxyPrefs::IntToProxyMode(proxy_mode, &mode)) { + if (!proxy_dict.GetMode(&mode)) { // Fall back to system settings if the mode preference is invalid. return false; } @@ -105,12 +106,12 @@ bool PrefProxyConfigTracker::ReadPrefConfig(net::ProxyConfig* config) { config->set_auto_detect(true); return true; case ProxyPrefs::MODE_PAC_SCRIPT: { - if (!pref_service_->HasPrefPath(prefs::kProxyPacUrl)) { + std::string proxy_pac; + if (!proxy_dict.GetPacUrl(&proxy_pac)) { LOG(ERROR) << "Proxy settings request PAC script but do not specify " << "its URL. Falling back to direct connection."; return true; } - std::string proxy_pac = pref_service_->GetString(prefs::kProxyPacUrl); GURL proxy_pac_url(proxy_pac); if (!proxy_pac_url.is_valid()) { LOG(ERROR) << "Invalid proxy PAC url: " << proxy_pac; @@ -120,18 +121,16 @@ bool PrefProxyConfigTracker::ReadPrefConfig(net::ProxyConfig* config) { return true; } case ProxyPrefs::MODE_FIXED_SERVERS: { - if (!pref_service_->HasPrefPath(prefs::kProxyServer)) { + std::string proxy_server; + if (!proxy_dict.GetProxyServer(&proxy_server)) { LOG(ERROR) << "Proxy settings request fixed proxy servers but do not " << "specify their URLs. Falling back to direct connection."; return true; } - std::string proxy_server = - pref_service_->GetString(prefs::kProxyServer); config->proxy_rules().ParseFromString(proxy_server); - if (pref_service_->HasPrefPath(prefs::kProxyBypassList)) { - std::string proxy_bypass = - pref_service_->GetString(prefs::kProxyBypassList); + std::string proxy_bypass; + if (proxy_dict.GetBypassList(&proxy_bypass)) { config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); } return true; @@ -229,8 +228,6 @@ void PrefProxyConfigService::RegisterObservers() { // static void PrefProxyConfigService::RegisterUserPrefs( PrefService* pref_service) { - pref_service->RegisterIntegerPref(prefs::kProxyMode, ProxyPrefs::MODE_SYSTEM); - pref_service->RegisterStringPref(prefs::kProxyServer, ""); - pref_service->RegisterStringPref(prefs::kProxyPacUrl, ""); - pref_service->RegisterStringPref(prefs::kProxyBypassList, ""); + DictionaryValue* default_settings = ProxyConfigDictionary::CreateSystem(); + pref_service->RegisterDictionaryPref(prefs::kProxy, default_settings); } diff --git a/chrome/browser/net/pref_proxy_config_service_unittest.cc b/chrome/browser/net/pref_proxy_config_service_unittest.cc index dad5c53..d25abaa 100644 --- a/chrome/browser/net/pref_proxy_config_service_unittest.cc +++ b/chrome/browser/net/pref_proxy_config_service_unittest.cc @@ -8,7 +8,7 @@ #include "base/file_path.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/prefs/pref_service_mock_builder.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/testing_pref_service.h" @@ -114,10 +114,8 @@ TEST_F(PrefProxyConfigServiceTest, BaseConfiguration) { TEST_F(PrefProxyConfigServiceTest, DynamicPrefOverrides) { pref_service_->SetManagedPref( - prefs::kProxyServer, Value::CreateStringValue("http://example.com:3128")); - pref_service_->SetManagedPref( - prefs::kProxyMode, - Value::CreateIntegerValue(ProxyPrefs::MODE_FIXED_SERVERS)); + prefs::kProxy, + ProxyConfigDictionary::CreateFixedServers("http://example.com:3128", "")); loop_.RunAllPending(); net::ProxyConfig actual_config; @@ -129,9 +127,8 @@ TEST_F(PrefProxyConfigServiceTest, DynamicPrefOverrides) { net::ProxyServer::FromURI("http://example.com:3128", net::ProxyServer::SCHEME_HTTP)); - pref_service_->SetManagedPref( - prefs::kProxyMode, - Value::CreateIntegerValue(ProxyPrefs::MODE_AUTO_DETECT)); + pref_service_->SetManagedPref(prefs::kProxy, + ProxyConfigDictionary::CreateAutoDetect()); loop_.RunAllPending(); proxy_config_service_->GetLatestProxyConfig(&actual_config); @@ -164,17 +161,9 @@ TEST_F(PrefProxyConfigServiceTest, Observers) { EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(pref_config))).Times(1); - - pref_service_->SetManagedPref(prefs::kProxyPacUrl, - Value::CreateStringValue(kFixedPacUrl)); - // The above does not trigger a notification, because PrefProxyConfig still - // sees the mode as the default (ProxyPrefs::SYSTEM), so that it doesn't claim - // to have proxy config. - // TODO(battre): Remove this comment when http://crbug.com/65732 is - // resolved. pref_service_->SetManagedPref( - prefs::kProxyMode, - Value::CreateIntegerValue(ProxyPrefs::MODE_PAC_SCRIPT)); + prefs::kProxy, + ProxyConfigDictionary::CreatePacScript(kFixedPacUrl)); loop_.RunAllPending(); Mock::VerifyAndClearExpectations(&observer); @@ -190,12 +179,7 @@ TEST_F(PrefProxyConfigServiceTest, Observers) { // Clear the override should switch back to the fixed configuration. EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(config3))).Times(1); - pref_service_->RemoveManagedPref(prefs::kProxyMode); - // The above switches the mode to the default (ProxyPrefs::SYSTEM), so the - // next removal won't bother PrefProxyConfigService. - // TODO(battre): Remove this comment when http://crbug.com/65732 is - // completed. - pref_service_->RemoveManagedPref(prefs::kProxyPacUrl); + pref_service_->RemoveManagedPref(prefs::kProxy); loop_.RunAllPending(); Mock::VerifyAndClearExpectations(&observer); diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc index 35330962..2f37588 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.cc +++ b/chrome/browser/policy/configuration_policy_pref_store.cc @@ -23,7 +23,7 @@ #include "chrome/browser/policy/device_management_policy_provider.h" #include "chrome/browser/policy/profile_policy_context.h" #include "chrome/browser/prefs/pref_value_map.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/search_terms_data.h" #include "chrome/browser/search_engines/template_url.h" @@ -257,13 +257,6 @@ const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry prefs::kDefaultSearchProviderEncodings }, }; -const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry - ConfigurationPolicyPrefKeeper::kProxyPolicyMap[] = { - { Value::TYPE_STRING, kPolicyProxyServer, prefs::kProxyServer }, - { Value::TYPE_STRING, kPolicyProxyPacUrl, prefs::kProxyPacUrl }, - { Value::TYPE_STRING, kPolicyProxyBypassList, prefs::kProxyBypassList } -}; - ConfigurationPolicyPrefKeeper::ConfigurationPolicyPrefKeeper( ConfigurationPolicyProvider* provider) : lower_priority_proxy_settings_overridden_(false), @@ -649,26 +642,37 @@ void ConfigurationPolicyPrefKeeper::ApplyProxySettings() { } else { return; } - prefs_.SetValue(prefs::kProxyMode, Value::CreateIntegerValue(mode)); - - if (HasProxyPolicy(kPolicyProxyServer)) { - prefs_.SetValue(prefs::kProxyServer, proxy_policies_[kPolicyProxyServer]); - proxy_policies_[kPolicyProxyServer] = NULL; - } else { - prefs_.SetValue(prefs::kProxyServer, Value::CreateNullValue()); - } - if (HasProxyPolicy(kPolicyProxyPacUrl)) { - prefs_.SetValue(prefs::kProxyPacUrl, proxy_policies_[kPolicyProxyPacUrl]); - proxy_policies_[kPolicyProxyPacUrl] = NULL; - } else { - prefs_.SetValue(prefs::kProxyPacUrl, Value::CreateNullValue()); - } - if (HasProxyPolicy(kPolicyProxyBypassList)) { - prefs_.SetValue(prefs::kProxyBypassList, - proxy_policies_[kPolicyProxyBypassList]); - proxy_policies_[kPolicyProxyBypassList] = NULL; - } else { - prefs_.SetValue(prefs::kProxyBypassList, Value::CreateNullValue()); + switch (mode) { + case ProxyPrefs::MODE_DIRECT: + prefs_.SetValue(prefs::kProxy, ProxyConfigDictionary::CreateDirect()); + break; + case ProxyPrefs::MODE_AUTO_DETECT: + prefs_.SetValue(prefs::kProxy, ProxyConfigDictionary::CreateAutoDetect()); + break; + case ProxyPrefs::MODE_PAC_SCRIPT: { + std::string pac_url; + proxy_policies_[kPolicyProxyPacUrl]->GetAsString(&pac_url); + prefs_.SetValue(prefs::kProxy, + ProxyConfigDictionary::CreatePacScript(pac_url)); + break; + } + case ProxyPrefs::MODE_FIXED_SERVERS: { + std::string proxy_server; + proxy_policies_[kPolicyProxyServer]->GetAsString(&proxy_server); + std::string bypass_list; + if (HasProxyPolicy(kPolicyProxyBypassList)) + proxy_policies_[kPolicyProxyBypassList]->GetAsString(&bypass_list); + prefs_.SetValue(prefs::kProxy, + ProxyConfigDictionary::CreateFixedServers(proxy_server, + bypass_list)); + break; + } + case ProxyPrefs::MODE_SYSTEM: + prefs_.SetValue(prefs::kProxy, + ProxyConfigDictionary::CreateSystem()); + break; + case ProxyPrefs::kModeCount: + NOTREACHED(); } } diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc index 84d2885..be89d98 100644 --- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc +++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc @@ -6,7 +6,7 @@ #include "base/ref_counted.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/mock_configuration_policy_provider.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_store_observer_mock.h" @@ -242,33 +242,32 @@ class ConfigurationPolicyPrefStoreProxyTest : public testing::Test { const std::string& expected_proxy_bypass_list, const ProxyPrefs::ProxyMode& expected_proxy_mode) { Value* value = NULL; - + ASSERT_EQ(PrefStore::READ_OK, + store.GetValue(prefs::kProxy, &value)); + ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType()); + ProxyConfigDictionary dict(static_cast<DictionaryValue*>(value)); + std::string s; if (expected_proxy_server.empty()) { - EXPECT_EQ(PrefStore::READ_USE_DEFAULT, - store.GetValue(prefs::kProxyServer, NULL)); + EXPECT_FALSE(dict.GetProxyServer(&s)); } else { - EXPECT_EQ(PrefStore::READ_OK, - store.GetValue(prefs::kProxyServer, &value)); - EXPECT_TRUE(StringValue(expected_proxy_server).Equals(value)); + ASSERT_TRUE(dict.GetProxyServer(&s)); + EXPECT_EQ(expected_proxy_server, s); } if (expected_proxy_pac_url.empty()) { - EXPECT_EQ(PrefStore::READ_USE_DEFAULT, - store.GetValue(prefs::kProxyPacUrl, NULL)); + EXPECT_FALSE(dict.GetPacUrl(&s)); } else { - EXPECT_EQ(PrefStore::READ_OK, - store.GetValue(prefs::kProxyPacUrl, &value)); - EXPECT_TRUE(StringValue(expected_proxy_pac_url).Equals(value)); + ASSERT_TRUE(dict.GetPacUrl(&s)); + EXPECT_EQ(expected_proxy_pac_url, s); } if (expected_proxy_bypass_list.empty()) { - EXPECT_EQ(PrefStore::READ_USE_DEFAULT, - store.GetValue(prefs::kProxyBypassList, NULL)); + EXPECT_FALSE(dict.GetBypassList(&s)); } else { - EXPECT_EQ(PrefStore::READ_OK, - store.GetValue(prefs::kProxyBypassList, &value)); - EXPECT_TRUE(StringValue(expected_proxy_bypass_list).Equals(value)); + ASSERT_TRUE(dict.GetBypassList(&s)); + EXPECT_EQ(expected_proxy_bypass_list, s); } - EXPECT_EQ(PrefStore::READ_OK, store.GetValue(prefs::kProxyMode, &value)); - EXPECT_TRUE(FundamentalValue(expected_proxy_mode).Equals(value)); + ProxyPrefs::ProxyMode mode; + ASSERT_TRUE(dict.GetMode(&mode)); + EXPECT_EQ(expected_proxy_mode, mode); } }; @@ -413,8 +412,9 @@ TEST_F(ConfigurationPolicyPrefStoreProxyTest, ProxyInvalid) { scoped_refptr<ConfigurationPolicyPrefStore> store( new ConfigurationPolicyPrefStore(&provider)); + Value* value = NULL; EXPECT_EQ(PrefStore::READ_NO_VALUE, - store->GetValue(prefs::kProxyMode, NULL)); + store->GetValue(prefs::kProxy, &value)); } } diff --git a/chrome/browser/policy/managed_prefs_banner_base.cc b/chrome/browser/policy/managed_prefs_banner_base.cc index b4253b4..39fdf73 100644 --- a/chrome/browser/policy/managed_prefs_banner_base.cc +++ b/chrome/browser/policy/managed_prefs_banner_base.cc @@ -87,10 +87,7 @@ void ManagedPrefsBannerBase::Init(PrefService* local_state, #if defined(GOOGLE_CHROME_BUILD) AddLocalStatePref(prefs::kMetricsReportingEnabled); #endif - AddUserPref(prefs::kProxyMode); - AddUserPref(prefs::kProxyServer); - AddUserPref(prefs::kProxyPacUrl); - AddUserPref(prefs::kProxyBypassList); + AddUserPref(prefs::kProxy); AddUserPref(prefs::kCloudPrintProxyEnabled); break; default: diff --git a/chrome/browser/prefs/command_line_pref_store.cc b/chrome/browser/prefs/command_line_pref_store.cc index e457f2f..97e0d39 100644 --- a/chrome/browser/prefs/command_line_pref_store.cc +++ b/chrome/browser/prefs/command_line_pref_store.cc @@ -7,7 +7,7 @@ #include "app/app_switches.h" #include "base/logging.h" #include "base/values.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "ui/base/ui_base_switches.h" @@ -15,9 +15,6 @@ const CommandLinePrefStore::StringSwitchToPreferenceMapEntry CommandLinePrefStore::string_switch_map_[] = { { switches::kLang, prefs::kApplicationLocale }, - { switches::kProxyServer, prefs::kProxyServer }, - { switches::kProxyPacUrl, prefs::kProxyPacUrl }, - { switches::kProxyBypassList, prefs::kProxyBypassList }, { switches::kAuthSchemes, prefs::kAuthSchemes }, { switches::kAuthServerWhitelist, prefs::kAuthServerWhitelist }, { switches::kAuthNegotiateDelegateWhitelist, @@ -79,16 +76,23 @@ bool CommandLinePrefStore::ValidateProxySwitches() { void CommandLinePrefStore::ApplyProxyMode() { if (command_line_->HasSwitch(switches::kNoProxyServer)) { - SetValue(prefs::kProxyMode, - Value::CreateIntegerValue(ProxyPrefs::MODE_DIRECT)); + SetValue(prefs::kProxy, + ProxyConfigDictionary::CreateDirect()); } else if (command_line_->HasSwitch(switches::kProxyPacUrl)) { - SetValue(prefs::kProxyMode, - Value::CreateIntegerValue(ProxyPrefs::MODE_PAC_SCRIPT)); + std::string pac_script_url = + command_line_->GetSwitchValueASCII(switches::kProxyPacUrl); + SetValue(prefs::kProxy, + ProxyConfigDictionary::CreatePacScript(pac_script_url)); } else if (command_line_->HasSwitch(switches::kProxyAutoDetect)) { - SetValue(prefs::kProxyMode, - Value::CreateIntegerValue(ProxyPrefs::MODE_AUTO_DETECT)); + SetValue(prefs::kProxy, + ProxyConfigDictionary::CreateAutoDetect()); } else if (command_line_->HasSwitch(switches::kProxyServer)) { - SetValue(prefs::kProxyMode, - Value::CreateIntegerValue(ProxyPrefs::MODE_FIXED_SERVERS)); + std::string proxy_server = + command_line_->GetSwitchValueASCII(switches::kProxyServer); + std::string bypass_list = + command_line_->GetSwitchValueASCII(switches::kProxyBypassList); + SetValue(prefs::kProxy, + ProxyConfigDictionary::CreateFixedServers(proxy_server, + bypass_list)); } } diff --git a/chrome/browser/prefs/command_line_pref_store_unittest.cc b/chrome/browser/prefs/command_line_pref_store_unittest.cc index 2518ff9..b0e2d79 100644 --- a/chrome/browser/prefs/command_line_pref_store_unittest.cc +++ b/chrome/browser/prefs/command_line_pref_store_unittest.cc @@ -10,7 +10,7 @@ #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/prefs/command_line_pref_store.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "ui/base/ui_base_switches.h" @@ -26,10 +26,14 @@ class TestCommandLinePrefStore : public CommandLinePrefStore { return ValidateProxySwitches(); } - void VerifyIntPref(const std::string& path, int expected_value) { - Value* actual = NULL; - ASSERT_EQ(PrefStore::READ_OK, GetValue(path, &actual)); - EXPECT_TRUE(FundamentalValue(expected_value).Equals(actual)); + void VerifyProxyMode(ProxyPrefs::ProxyMode expected_mode) { + Value* value = NULL; + ASSERT_EQ(PrefStore::READ_OK, GetValue(prefs::kProxy, &value)); + ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType()); + ProxyConfigDictionary dict(static_cast<DictionaryValue*>(value)); + ProxyPrefs::ProxyMode actual_mode; + ASSERT_TRUE(dict.GetMode(&actual_mode)); + EXPECT_EQ(expected_mode, actual_mode); } }; @@ -59,7 +63,7 @@ TEST(CommandLinePrefStoreTest, SimpleBooleanPref) { scoped_refptr<TestCommandLinePrefStore> store = new TestCommandLinePrefStore(&cl); - store->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_DIRECT); + store->VerifyProxyMode(ProxyPrefs::MODE_DIRECT); } // Tests a command line with no recognized prefs. @@ -78,7 +82,6 @@ TEST(CommandLinePrefStoreTest, NoPrefs) { TEST(CommandLinePrefStoreTest, MultipleSwitches) { CommandLine cl(CommandLine::NO_PROGRAM); cl.AppendSwitch(unknown_string); - cl.AppendSwitch(switches::kProxyAutoDetect); cl.AppendSwitchASCII(switches::kProxyServer, "proxy"); cl.AppendSwitchASCII(switches::kProxyBypassList, "list"); cl.AppendSwitchASCII(unknown_bool, "a value"); @@ -87,16 +90,21 @@ TEST(CommandLinePrefStoreTest, MultipleSwitches) { Value* actual = NULL; EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_bool, &actual)); - store->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_AUTO_DETECT); - EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_string, &actual)); + + store->VerifyProxyMode(ProxyPrefs::MODE_FIXED_SERVERS); + + Value* value = NULL; + ASSERT_EQ(PrefStore::READ_OK, store->GetValue(prefs::kProxy, &value)); + ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType()); + ProxyConfigDictionary dict(static_cast<DictionaryValue*>(value)); + std::string string_result = ""; - ASSERT_EQ(PrefStore::READ_OK, store->GetValue(prefs::kProxyServer, &actual)); - EXPECT_TRUE(actual->GetAsString(&string_result)); + + ASSERT_TRUE(dict.GetProxyServer(&string_result)); EXPECT_EQ("proxy", string_result); - ASSERT_EQ(PrefStore::READ_OK, - store->GetValue(prefs::kProxyBypassList, &actual)); - EXPECT_TRUE(actual->GetAsString(&string_result)); + + ASSERT_TRUE(dict.GetBypassList(&string_result)); EXPECT_EQ("list", string_result); } @@ -138,11 +146,11 @@ TEST(CommandLinePrefStoreTest, ManualProxyModeInference) { cl1.AppendSwitchASCII(switches::kProxyServer, "proxy"); scoped_refptr<TestCommandLinePrefStore> store1 = new TestCommandLinePrefStore(&cl1); - store1->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_FIXED_SERVERS); + store1->VerifyProxyMode(ProxyPrefs::MODE_FIXED_SERVERS); CommandLine cl2(CommandLine::NO_PROGRAM); cl2.AppendSwitchASCII(switches::kProxyPacUrl, "proxy"); scoped_refptr<TestCommandLinePrefStore> store2 = new TestCommandLinePrefStore(&cl2); - store2->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_PAC_SCRIPT); + store2->VerifyProxyMode(ProxyPrefs::MODE_PAC_SCRIPT); } diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc index f5a62521..56ee2b1 100644 --- a/chrome/browser/prefs/pref_service.cc +++ b/chrome/browser/prefs/pref_service.cc @@ -251,10 +251,19 @@ void PrefService::RegisterListPref(const char* path) { RegisterPreference(path, new ListValue()); } +void PrefService::RegisterListPref(const char* path, ListValue* default_value) { + RegisterPreference(path, default_value); +} + void PrefService::RegisterDictionaryPref(const char* path) { RegisterPreference(path, new DictionaryValue()); } +void PrefService::RegisterDictionaryPref(const char* path, + DictionaryValue* default_value) { + RegisterPreference(path, default_value); +} + void PrefService::RegisterLocalizedBooleanPref(const char* path, int locale_default_message_id) { RegisterPreference( diff --git a/chrome/browser/prefs/pref_service.h b/chrome/browser/prefs/pref_service.h index 010a558..3ec774c 100644 --- a/chrome/browser/prefs/pref_service.h +++ b/chrome/browser/prefs/pref_service.h @@ -151,6 +151,9 @@ class PrefService : public base::NonThreadSafe { void RegisterFilePathPref(const char* path, const FilePath& default_value); void RegisterListPref(const char* path); void RegisterDictionaryPref(const char* path); + // These take ownership of the default_value: + void RegisterListPref(const char* path, ListValue* default_value); + void RegisterDictionaryPref(const char* path, DictionaryValue* default_value); // These variants use a default value from the locale dll instead. void RegisterLocalizedBooleanPref(const char* path, diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc index 32ab5b7..90a1882 100644 --- a/chrome/browser/prefs/pref_service_unittest.cc +++ b/chrome/browser/prefs/pref_service_unittest.cc @@ -16,7 +16,7 @@ #include "chrome/browser/prefs/pref_observer_mock.h" #include "chrome/browser/prefs/pref_service_mock_builder.h" #include "chrome/browser/prefs/pref_value_store.h" -#include "chrome/browser/prefs/proxy_prefs.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/browser/prefs/testing_pref_store.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -169,6 +169,54 @@ TEST(PrefServiceTest, GetValueChangedType) { EXPECT_EQ(kTestValue, actual_int_value); } +void assertProxyMode(const ProxyConfigDictionary& dict, + ProxyPrefs::ProxyMode expected_mode) { + ProxyPrefs::ProxyMode actual_mode; + ASSERT_TRUE(dict.GetMode(&actual_mode)); + EXPECT_EQ(expected_mode, actual_mode); +} + +void assertProxyServer(const ProxyConfigDictionary& dict, + const std::string& expected) { + std::string actual; + if (!expected.empty()) { + ASSERT_TRUE(dict.GetProxyServer(&actual)); + EXPECT_EQ(expected, actual); + } else { + EXPECT_FALSE(dict.GetProxyServer(&actual)); + } +} + +void assertPacUrl(const ProxyConfigDictionary& dict, + const std::string& expected) { + std::string actual; + if (!expected.empty()) { + ASSERT_TRUE(dict.GetPacUrl(&actual)); + EXPECT_EQ(expected, actual); + } else { + EXPECT_FALSE(dict.GetPacUrl(&actual)); + } +} + +void assertBypassList(const ProxyConfigDictionary& dict, + const std::string& expected) { + std::string actual; + if (!expected.empty()) { + ASSERT_TRUE(dict.GetBypassList(&actual)); + EXPECT_EQ(expected, actual); + } else { + EXPECT_FALSE(dict.GetBypassList(&actual)); + } +} + +void assertProxyModeWithoutParams(const ProxyConfigDictionary& dict, + ProxyPrefs::ProxyMode proxy_mode) { + assertProxyMode(dict, proxy_mode); + assertProxyServer(dict, ""); + assertPacUrl(dict, ""); + assertBypassList(dict, ""); +} + TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineOptions) { CommandLine command_line(CommandLine::NO_PROGRAM); command_line.AppendSwitchASCII(switches::kProxyBypassList, "123"); @@ -189,11 +237,11 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineOptions) { builder.WithCommandLine(&command_line); scoped_ptr<PrefService> prefs(builder.Create()); browser::RegisterUserPrefs(prefs.get()); - EXPECT_EQ(ProxyPrefs::MODE_FIXED_SERVERS, - prefs->GetInteger(prefs::kProxyMode)); - EXPECT_EQ("789", prefs->GetString(prefs::kProxyServer)); - EXPECT_EQ(std::string(), prefs->GetString(prefs::kProxyPacUrl)); - EXPECT_EQ("123", prefs->GetString(prefs::kProxyBypassList)); + ProxyConfigDictionary dict(prefs->GetDictionary(prefs::kProxy)); + assertProxyMode(dict, ProxyPrefs::MODE_FIXED_SERVERS); + assertProxyServer(dict, "789"); + assertPacUrl(dict, ""); + assertBypassList(dict, "123"); // Try a second time time with the managed PrefStore in place, the // manual proxy policy should have removed all traces of the command @@ -202,11 +250,11 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineOptions) { builder.WithManagedPlatformProvider(provider.get()); scoped_ptr<PrefService> prefs2(builder.Create()); browser::RegisterUserPrefs(prefs2.get()); - EXPECT_EQ(ProxyPrefs::MODE_FIXED_SERVERS, - prefs2->GetInteger(prefs::kProxyMode)); - EXPECT_EQ("ghi", prefs2->GetString(prefs::kProxyServer)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyPacUrl)); - EXPECT_EQ("abc", prefs2->GetString(prefs::kProxyBypassList)); + ProxyConfigDictionary dict2(prefs2->GetDictionary(prefs::kProxy)); + assertProxyMode(dict2, ProxyPrefs::MODE_FIXED_SERVERS); + assertProxyServer(dict2, "ghi"); + assertPacUrl(dict2, ""); + assertBypassList(dict2, "abc"); } TEST(PrefServiceTest, ProxyPolicyOverridesUnrelatedCommandLineOptions) { @@ -225,10 +273,11 @@ TEST(PrefServiceTest, ProxyPolicyOverridesUnrelatedCommandLineOptions) { builder.WithCommandLine(&command_line); scoped_ptr<PrefService> prefs(builder.Create()); browser::RegisterUserPrefs(prefs.get()); - EXPECT_EQ(ProxyPrefs::MODE_FIXED_SERVERS, - prefs->GetInteger(prefs::kProxyMode)); - EXPECT_EQ("789", prefs->GetString(prefs::kProxyServer)); - EXPECT_EQ("123", prefs->GetString(prefs::kProxyBypassList)); + ProxyConfigDictionary dict(prefs->GetDictionary(prefs::kProxy)); + assertProxyMode(dict, ProxyPrefs::MODE_FIXED_SERVERS); + assertProxyServer(dict, "789"); + assertPacUrl(dict, ""); + assertBypassList(dict, "123"); // Try a second time time with the managed PrefStore in place, the // no proxy policy should have removed all traces of the command @@ -238,11 +287,8 @@ TEST(PrefServiceTest, ProxyPolicyOverridesUnrelatedCommandLineOptions) { builder.WithManagedPlatformProvider(provider.get()); scoped_ptr<PrefService> prefs2(builder.Create()); browser::RegisterUserPrefs(prefs2.get()); - EXPECT_EQ(ProxyPrefs::MODE_AUTO_DETECT, - prefs2->GetInteger(prefs::kProxyMode)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyServer)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyPacUrl)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyBypassList)); + ProxyConfigDictionary dict2(prefs2->GetDictionary(prefs::kProxy)); + assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_AUTO_DETECT); } TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineNoProxy) { @@ -260,10 +306,8 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineNoProxy) { builder.WithCommandLine(&command_line); scoped_ptr<PrefService> prefs(builder.Create()); browser::RegisterUserPrefs(prefs.get()); - EXPECT_EQ(ProxyPrefs::MODE_DIRECT, prefs->GetInteger(prefs::kProxyMode)); - EXPECT_EQ(std::string(), prefs->GetString(prefs::kProxyServer)); - EXPECT_EQ(std::string(), prefs->GetString(prefs::kProxyPacUrl)); - EXPECT_EQ(std::string(), prefs->GetString(prefs::kProxyBypassList)); + ProxyConfigDictionary dict(prefs->GetDictionary(prefs::kProxy)); + assertProxyModeWithoutParams(dict, ProxyPrefs::MODE_DIRECT); // Try a second time time with the managed PrefStore in place, the // auto-detect should be overridden. The default pref store must be @@ -272,11 +316,8 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineNoProxy) { builder.WithManagedPlatformProvider(provider.get()); scoped_ptr<PrefService> prefs2(builder.Create()); browser::RegisterUserPrefs(prefs2.get()); - EXPECT_EQ(ProxyPrefs::MODE_AUTO_DETECT, - prefs2->GetInteger(prefs::kProxyMode)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyServer)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyPacUrl)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyBypassList)); + ProxyConfigDictionary dict2(prefs2->GetDictionary(prefs::kProxy)); + assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_AUTO_DETECT); } TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineAutoDetect) { @@ -294,10 +335,8 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineAutoDetect) { builder.WithCommandLine(&command_line); scoped_ptr<PrefService> prefs(builder.Create()); browser::RegisterUserPrefs(prefs.get()); - EXPECT_EQ(ProxyPrefs::MODE_AUTO_DETECT, prefs->GetInteger(prefs::kProxyMode)); - EXPECT_EQ(std::string(), prefs->GetString(prefs::kProxyServer)); - EXPECT_EQ(std::string(), prefs->GetString(prefs::kProxyPacUrl)); - EXPECT_EQ(std::string(), prefs->GetString(prefs::kProxyBypassList)); + ProxyConfigDictionary dict(prefs->GetDictionary(prefs::kProxy)); + assertProxyModeWithoutParams(dict, ProxyPrefs::MODE_AUTO_DETECT); // Try a second time time with the managed PrefStore in place, the // auto-detect should be overridden. The default pref store must be @@ -306,10 +345,8 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineAutoDetect) { builder.WithManagedPlatformProvider(provider.get()); scoped_ptr<PrefService> prefs2(builder.Create()); browser::RegisterUserPrefs(prefs2.get()); - EXPECT_EQ(ProxyPrefs::MODE_DIRECT, prefs2->GetInteger(prefs::kProxyMode)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyServer)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyPacUrl)); - EXPECT_EQ(std::string(), prefs2->GetString(prefs::kProxyBypassList)); + ProxyConfigDictionary dict2(prefs2->GetDictionary(prefs::kProxy)); + assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); } class PrefServiceSetValueTest : public testing::Test { diff --git a/chrome/browser/prefs/pref_set_observer.cc b/chrome/browser/prefs/pref_set_observer.cc index 499aa52..117937e 100644 --- a/chrome/browser/prefs/pref_set_observer.cc +++ b/chrome/browser/prefs/pref_set_observer.cc @@ -47,10 +47,7 @@ PrefSetObserver* PrefSetObserver::CreateProxyPrefSetObserver( PrefService* pref_service, NotificationObserver* observer) { PrefSetObserver* pref_set = new PrefSetObserver(pref_service, observer); - pref_set->AddPref(prefs::kProxyMode); - pref_set->AddPref(prefs::kProxyServer); - pref_set->AddPref(prefs::kProxyPacUrl); - pref_set->AddPref(prefs::kProxyBypassList); + pref_set->AddPref(prefs::kProxy); return pref_set; } diff --git a/chrome/browser/prefs/proxy_config_dictionary.cc b/chrome/browser/prefs/proxy_config_dictionary.cc new file mode 100644 index 0000000..f19877c --- /dev/null +++ b/chrome/browser/prefs/proxy_config_dictionary.cc @@ -0,0 +1,94 @@ +// 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. + +#include "chrome/browser/prefs/proxy_config_dictionary.h" + +#include "base/basictypes.h" +#include "base/logging.h" +#include "base/values.h" + +namespace { + +// Integer to specify the type of proxy settings. +// See ProxyPrefs for possible values and interactions with the other proxy +// preferences. +const char kProxyMode[] = "mode"; +// String specifying the proxy server. For a specification of the expected +// syntax see net::ProxyConfig::ProxyRules::ParseFromString(). +const char kProxyServer[] = "server"; +// URL to the proxy .pac file. +const char kProxyPacUrl[] = "pac_url"; +// String containing proxy bypass rules. For a specification of the +// expected syntax see net::ProxyBypassRules::ParseFromString(). +const char kProxyBypassList[] = "bypass_list"; + +} // namespace + +ProxyConfigDictionary::ProxyConfigDictionary(const DictionaryValue* dict) + : dict_(dict->DeepCopy()) { +} + +bool ProxyConfigDictionary::GetMode(ProxyPrefs::ProxyMode* out) const { + std::string mode_str; + return dict_->GetString(kProxyMode, &mode_str) + && StringToProxyMode(mode_str, out); +} + +bool ProxyConfigDictionary::GetPacUrl(std::string* out) const { + return dict_->GetString(kProxyPacUrl, out); +} + +bool ProxyConfigDictionary::GetProxyServer(std::string* out) const { + return dict_->GetString(kProxyServer, out); +} + +bool ProxyConfigDictionary::GetBypassList(std::string* out) const { + return dict_->GetString(kProxyBypassList, out); +} + +// static +DictionaryValue* ProxyConfigDictionary::CreateDirect() { + return CreateDictionary(ProxyPrefs::MODE_DIRECT, "", "", ""); +} + +// static +DictionaryValue* ProxyConfigDictionary::CreateAutoDetect() { + return CreateDictionary(ProxyPrefs::MODE_AUTO_DETECT, "", "", ""); +} + +// static +DictionaryValue* ProxyConfigDictionary::CreatePacScript( + const std::string& pac_url) { + return CreateDictionary(ProxyPrefs::MODE_PAC_SCRIPT, pac_url, "", ""); +} + +// static +DictionaryValue* ProxyConfigDictionary::CreateFixedServers( + const std::string& proxy_server, + const std::string& bypass_list) { + return CreateDictionary( + ProxyPrefs::MODE_FIXED_SERVERS, "", proxy_server, bypass_list); +} + +// static +DictionaryValue* ProxyConfigDictionary::CreateSystem() { + return CreateDictionary(ProxyPrefs::MODE_SYSTEM, "", "", ""); +} + +// static +DictionaryValue* ProxyConfigDictionary::CreateDictionary( + ProxyPrefs::ProxyMode mode, + const std::string& pac_url, + const std::string& proxy_server, + const std::string& bypass_list) { + DictionaryValue* dict = new DictionaryValue(); + dict->SetString(kProxyMode, GetProxyModeName(mode)); + if (!pac_url.empty()) + dict->SetString(kProxyPacUrl, pac_url); + if (!proxy_server.empty()) + dict->SetString(kProxyServer, proxy_server); + if (!bypass_list.empty()) + dict->SetString(kProxyBypassList, bypass_list); + return dict; +} diff --git a/chrome/browser/prefs/proxy_config_dictionary.h b/chrome/browser/prefs/proxy_config_dictionary.h new file mode 100644 index 0000000..ae5c80e --- /dev/null +++ b/chrome/browser/prefs/proxy_config_dictionary.h @@ -0,0 +1,54 @@ +// 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. + +#ifndef CHROME_BROWSER_PREFS_PROXY_CONFIG_DICTIONARY_H_ +#define CHROME_BROWSER_PREFS_PROXY_CONFIG_DICTIONARY_H_ +#pragma once + +#include <string> + +#include "base/basictypes.h" +#include "base/scoped_ptr.h" +#include "chrome/browser/prefs/proxy_prefs.h" + +class DictionaryValue; + +// Factory and wrapper for proxy config dictionaries that are stored +// in the user preferences. The dictionary has the following structure: +// { +// mode: string, +// server: string, +// pac_url: string, +// bypass_list: string +// } +// See proxy_config_dictionary.cc for the structure of the respective strings. +class ProxyConfigDictionary { + public: + // Creates a deep copy of |dict| and leaves ownership to caller. + explicit ProxyConfigDictionary(const DictionaryValue* dict); + + bool GetMode(ProxyPrefs::ProxyMode* out) const; + bool GetPacUrl(std::string* out) const; + bool GetProxyServer(std::string* out) const; + bool GetBypassList(std::string* out) const; + + static DictionaryValue* CreateDirect(); + static DictionaryValue* CreateAutoDetect(); + static DictionaryValue* CreatePacScript(const std::string& pac_url); + static DictionaryValue* CreateFixedServers( + const std::string& proxy_server, + const std::string& bypass_list); + static DictionaryValue* CreateSystem(); + private: + static DictionaryValue* CreateDictionary(ProxyPrefs::ProxyMode mode, + const std::string& pac_url, + const std::string& proxy_server, + const std::string& bypass_list); + + scoped_ptr<DictionaryValue> dict_; + + DISALLOW_COPY_AND_ASSIGN(ProxyConfigDictionary); +}; + +#endif // CHROME_BROWSER_PREFS_PROXY_CONFIG_DICTIONARY_H_ diff --git a/chrome/browser/prefs/proxy_config_dictionary_unittest.cc b/chrome/browser/prefs/proxy_config_dictionary_unittest.cc new file mode 100644 index 0000000..07c6743 --- /dev/null +++ b/chrome/browser/prefs/proxy_config_dictionary_unittest.cc @@ -0,0 +1,84 @@ +// 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. + +#include <string> + +#include "base/scoped_ptr.h" +#include "base/values.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" +#include "testing/gtest/include/gtest/gtest.h" + +struct ProxyConfigHolder { + ProxyPrefs::ProxyMode mode; + std::string pac_url; + std::string proxy_server; + std::string bypass_list; +}; + +TEST(ProxyConfigDictionaryTest, CreateDirect) { + scoped_ptr<DictionaryValue> dict_value(ProxyConfigDictionary::CreateDirect()); + ProxyConfigDictionary dict(dict_value.get()); + ProxyConfigHolder h; + + ASSERT_TRUE(dict.GetMode(&h.mode)); + EXPECT_EQ(ProxyPrefs::MODE_DIRECT, h.mode); + ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list)); + ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server)); + ASSERT_FALSE(dict.GetBypassList(&h.bypass_list)); +} + +TEST(ProxyConfigDictionaryTest, CreateAutoDetect) { + scoped_ptr<DictionaryValue> dict_value( + ProxyConfigDictionary::CreateAutoDetect()); + ProxyConfigDictionary dict(dict_value.get()); + ProxyConfigHolder h; + + ASSERT_TRUE(dict.GetMode(&h.mode)); + EXPECT_EQ(ProxyPrefs::MODE_AUTO_DETECT, h.mode); + ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list)); + ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server)); + ASSERT_FALSE(dict.GetBypassList(&h.bypass_list)); +} + +TEST(ProxyConfigDictionaryTest, CreatePacScript) { + scoped_ptr<DictionaryValue> dict_value( + ProxyConfigDictionary::CreatePacScript("pac")); + ProxyConfigDictionary dict(dict_value.get()); + ProxyConfigHolder h; + + ASSERT_TRUE(dict.GetMode(&h.mode)); + EXPECT_EQ(ProxyPrefs::MODE_PAC_SCRIPT, h.mode); + ASSERT_TRUE(dict.GetPacUrl(&h.bypass_list)); + EXPECT_EQ("pac", h.bypass_list); + ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server)); + ASSERT_FALSE(dict.GetBypassList(&h.bypass_list)); +} + +TEST(ProxyConfigDictionaryTest, CreateFixedServers) { + scoped_ptr<DictionaryValue> dict_value( + ProxyConfigDictionary::CreateFixedServers("http://1.2.3.4", + "http://foo")); + ProxyConfigDictionary dict(dict_value.get()); + ProxyConfigHolder h; + + ASSERT_TRUE(dict.GetMode(&h.mode)); + EXPECT_EQ(ProxyPrefs::MODE_FIXED_SERVERS, h.mode); + ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list)); + ASSERT_TRUE(dict.GetProxyServer(&h.proxy_server)); + EXPECT_EQ("http://1.2.3.4", h.proxy_server); + ASSERT_TRUE(dict.GetBypassList(&h.bypass_list)); + EXPECT_EQ("http://foo", h.bypass_list); +} + +TEST(ProxyConfigDictionaryTest, CreateSystem) { + scoped_ptr<DictionaryValue> dict_value(ProxyConfigDictionary::CreateSystem()); + ProxyConfigDictionary dict(dict_value.get()); + ProxyConfigHolder h; + + ASSERT_TRUE(dict.GetMode(&h.mode)); + EXPECT_EQ(ProxyPrefs::MODE_SYSTEM, h.mode); + ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list)); + ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server)); + ASSERT_FALSE(dict.GetBypassList(&h.bypass_list)); +} diff --git a/chrome/browser/prefs/proxy_prefs.cc b/chrome/browser/prefs/proxy_prefs.cc index fadd562..bceb76b 100644 --- a/chrome/browser/prefs/proxy_prefs.cc +++ b/chrome/browser/prefs/proxy_prefs.cc @@ -52,4 +52,8 @@ bool StringToProxyMode(const std::string& in_value, ProxyMode* out_value) { return false; } +const char* GetProxyModeName(ProxyMode mode) { + return kProxyModeNames[mode]; +} + } // namespace diff --git a/chrome/browser/prefs/proxy_prefs.h b/chrome/browser/prefs/proxy_prefs.h index da911d4..c70cee8 100644 --- a/chrome/browser/prefs/proxy_prefs.h +++ b/chrome/browser/prefs/proxy_prefs.h @@ -47,6 +47,7 @@ extern const char kSystemProxyModeName[]; bool IntToProxyMode(int in_value, ProxyMode* out_value); bool StringToProxyMode(const std::string& in_value, ProxyMode* out_value); +const char* GetProxyModeName(ProxyMode mode); } // namespace ProxyPrefs diff --git a/chrome/browser/prefs/proxy_prefs_unittest.cc b/chrome/browser/prefs/proxy_prefs_unittest.cc index 72aa0f1..63b8ea3 100644 --- a/chrome/browser/prefs/proxy_prefs_unittest.cc +++ b/chrome/browser/prefs/proxy_prefs_unittest.cc @@ -1,12 +1,10 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. #include <string> -#include "base/logging.h" #include "base/values.h" -#include "base/version.h" #include "chrome/browser/prefs/proxy_prefs.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 55a212b..fac8d4f 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1836,6 +1836,8 @@ 'browser/prefs/pref_value_map.h', 'browser/prefs/pref_value_store.cc', 'browser/prefs/pref_value_store.h', + 'browser/prefs/proxy_config_dictionary.cc', + 'browser/prefs/proxy_config_dictionary.h', 'browser/prefs/proxy_prefs.cc', 'browser/prefs/proxy_prefs.h', 'browser/prefs/scoped_pref_update.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 436b65b..69b4034 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1357,6 +1357,7 @@ 'browser/prefs/pref_set_observer_unittest.cc', 'browser/prefs/pref_value_map_unittest.cc', 'browser/prefs/pref_value_store_unittest.cc', + 'browser/prefs/proxy_config_dictionary_unittest.cc', 'browser/prefs/proxy_prefs_unittest.cc', 'browser/prefs/session_startup_pref_unittest.cc', 'browser/prerender/prerender_manager_unittest.cc', diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 9f6deff..4fc7492 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -3743,7 +3743,7 @@ { "id": "ProxyRules", "type": "object", - "description": "An object encapsulating the set of proxy rules for all protocols.", + "description": "An object encapsulating the set of proxy rules for all protocols. Use either 'singleProxy' or (a subset of) 'proxyForHttp', 'proxyForHttps', 'proxyForFtp' and 'socksProxy'.", "properties": { "singleProxy": {"$ref": "ProxyServer", "optional": true, "description": "The proxy server to be used for all per-URL requests (i.e., http, https, and ftp)."}, "proxyForHttp": {"$ref": "ProxyServer", "optional": true, "description": "The proxy server to be used for HTTP requests."}, @@ -3765,8 +3765,8 @@ "type": "object", "description": "An object encapsulating a complete proxy configuration.", "properties": { - "rules": {"$ref": "ProxyRules", "optional": true, "description": "The proxy rules describing this configuration."}, - "pacScript": {"$ref": "PacScript", "optional": true, "description": "The proxy auto-config (PAC) script for this configuration."}, + "rules": {"$ref": "ProxyRules", "optional": true, "description": "The proxy rules describing this configuration. Use this for 'fixed_servers' mode."}, + "pacScript": {"$ref": "PacScript", "optional": true, "description": "The proxy auto-config (PAC) script for this configuration. Use this for 'pac_script' mode."}, "mode": { "type": "string", "enum": ["direct", "auto_detect", "pac_script", "fixed_servers", "system"], diff --git a/chrome/common/extensions/docs/experimental.proxy.html b/chrome/common/extensions/docs/experimental.proxy.html index eb32de7..c6c8882 100644 --- a/chrome/common/extensions/docs/experimental.proxy.html +++ b/chrome/common/extensions/docs/experimental.proxy.html @@ -1033,7 +1033,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>An object encapsulating the set of proxy rules for all protocols.</dd> + <dd>An object encapsulating the set of proxy rules for all protocols. Use either 'singleProxy' or (a subset of) 'proxyForHttp', 'proxyForHttps', 'proxyForFtp' and 'socksProxy'.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -1624,7 +1624,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>The proxy rules describing this configuration.</dd> + <dd>The proxy rules describing this configuration. Use this for 'fixed_servers' mode.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -1692,7 +1692,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>The proxy auto-config (PAC) script for this configuration.</dd> + <dd>The proxy auto-config (PAC) script for this configuration. Use this for 'pac_script' mode.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index cbf20c5..d14c9f8 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1216,18 +1216,8 @@ const char kCloudPrintPrintSystemSettings[] = // Used by the service process to determine if the remoting host is enabled. const char kRemotingHostEnabled[] = "remoting.host_enabled"; -// Integer to specify the type of proxy settings. -// See ProxyPrefs for possible values and interactions with the other proxy -// preferences. -const char kProxyMode[] = "proxy.mode"; -// String specifying the proxy server. For a specification of the expected -// syntax see net::ProxyConfig::ProxyRules::ParseFromString(). -const char kProxyServer[] = "proxy.server"; -// URL to the proxy .pac file. -const char kProxyPacUrl[] = "proxy.pac_url"; -// String containing proxy bypass rules. For a specification of the -// expected syntax see net::ProxyBypassRules::ParseFromString(). -const char kProxyBypassList[] = "proxy.bypass_list"; +// Preference to story proxy settings. +const char kProxy[] = "proxy"; // Preferences that are exclusivly used to store managed values for default // content settings. diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 83f8d4d..9e37786 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -425,10 +425,7 @@ extern const char kCloudPrintPrintSystemSettings[]; extern const char kRemotingHasSetupCompleted[]; extern const char kRemotingHostEnabled[]; -extern const char kProxyMode[]; -extern const char kProxyServer[]; -extern const char kProxyPacUrl[]; -extern const char kProxyBypassList[]; +extern const char kProxy[]; extern const char kManagedDefaultCookiesSetting[]; extern const char kManagedDefaultImagesSetting[]; |