| Index: chrome/browser/prefs/proxy_prefs.cc
|
| diff --git a/chrome/browser/prefs/proxy_prefs.cc b/chrome/browser/prefs/proxy_prefs.cc
|
| index fadd562ce4cbc45cdceea57479ec7a9f213918cb..acfb12fbc3b12ebec5b49d69ca4de248070a5cf6 100644
|
| --- a/chrome/browser/prefs/proxy_prefs.cc
|
| +++ b/chrome/browser/prefs/proxy_prefs.cc
|
| @@ -27,6 +27,19 @@ const char* kProxyModeNames[] = { ProxyPrefs::kDirectProxyModeName,
|
| ProxyPrefs::kFixedServersProxyModeName,
|
| ProxyPrefs::kSystemProxyModeName };
|
|
|
| +// 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
|
|
|
| namespace ProxyPrefs {
|
| @@ -53,3 +66,72 @@ bool StringToProxyMode(const std::string& in_value, ProxyMode* out_value) {
|
| }
|
|
|
| } // namespace
|
| +
|
| +ProxyPrefsDictionary::ProxyPrefsDictionary(const DictionaryValue* dict)
|
| + : dict_(dict) {
|
| + CHECK(dict);
|
| +}
|
| +
|
| +bool ProxyPrefsDictionary::GetMode(ProxyPrefs::ProxyMode* out) const {
|
| + std::string mode_str;
|
| + return dict_->GetString(kProxyMode, &mode_str)
|
| + && StringToProxyMode(mode_str, out);
|
| +}
|
| +
|
| +bool ProxyPrefsDictionary::GetPacUrl(std::string* out) const {
|
| + return dict_->GetString(kProxyPacUrl, out);
|
| +}
|
| +
|
| +bool ProxyPrefsDictionary::GetProxyServer(std::string* out) const {
|
| + return dict_->GetString(kProxyServer, out);
|
| +}
|
| +
|
| +bool ProxyPrefsDictionary::GetBypassList(std::string* out) const {
|
| + return dict_->GetString(kProxyBypassList, out);
|
| +}
|
| +
|
| +// static
|
| +DictionaryValue* ProxyPrefsDictionary::CreateDirect() {
|
| + return CreateDictionary(ProxyPrefs::MODE_DIRECT, "", "", "");
|
| +}
|
| +
|
| +// static
|
| +DictionaryValue* ProxyPrefsDictionary::CreateAutoDetect() {
|
| + return CreateDictionary(ProxyPrefs::MODE_AUTO_DETECT, "", "", "");
|
| +}
|
| +
|
| +// static
|
| +DictionaryValue* ProxyPrefsDictionary::CreatePacScript(
|
| + const std::string& pac_url) {
|
| + return CreateDictionary(ProxyPrefs::MODE_PAC_SCRIPT, pac_url, "", "");
|
| +}
|
| +
|
| +// static
|
| +DictionaryValue* ProxyPrefsDictionary::CreateFixedServers(
|
| + const std::string& proxy_server,
|
| + const std::string& bypass_list) {
|
| + return CreateDictionary(
|
| + ProxyPrefs::MODE_FIXED_SERVERS, "", proxy_server, bypass_list);
|
| +}
|
| +
|
| +// static
|
| +DictionaryValue* ProxyPrefsDictionary::CreateSystem() {
|
| + return CreateDictionary(ProxyPrefs::MODE_SYSTEM, "", "", "");
|
| +}
|
| +
|
| +// static
|
| +DictionaryValue* ProxyPrefsDictionary::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, kProxyModeNames[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;
|
| +}
|
|
|