| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_ | 5 #ifndef COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_ |
| 6 #define COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_ | 6 #define COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "components/proxy_config/proxy_config_export.h" | 12 #include "components/proxy_config/proxy_config_export.h" |
| 13 #include "components/proxy_config/proxy_prefs.h" | 13 #include "components/proxy_config/proxy_prefs.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class DictionaryValue; | 16 class DictionaryValue; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace net { |
| 20 class ProxyServer; |
| 21 } |
| 22 |
| 19 // Factory and wrapper for proxy config dictionaries that are stored | 23 // Factory and wrapper for proxy config dictionaries that are stored |
| 20 // in the user preferences. The dictionary has the following structure: | 24 // in the user preferences. The dictionary has the following structure: |
| 21 // { | 25 // { |
| 22 // mode: string, | 26 // mode: string, |
| 23 // server: string, | 27 // server: string, |
| 24 // pac_url: string, | 28 // pac_url: string, |
| 25 // bypass_list: string | 29 // bypass_list: string |
| 26 // } | 30 // } |
| 27 // See proxy_config_dictionary.cc for the structure of the respective strings. | 31 // See proxy_config_dictionary.cc for the structure of the respective strings. |
| 28 class PROXY_CONFIG_EXPORT ProxyConfigDictionary { | 32 class PROXY_CONFIG_EXPORT ProxyConfigDictionary { |
| 29 public: | 33 public: |
| 30 // Creates a deep copy of |dict| and leaves ownership to caller. | 34 // Creates a deep copy of |dict| and leaves ownership to caller. |
| 31 explicit ProxyConfigDictionary(const base::DictionaryValue* dict); | 35 explicit ProxyConfigDictionary(const base::DictionaryValue* dict); |
| 32 ~ProxyConfigDictionary(); | 36 ~ProxyConfigDictionary(); |
| 33 | 37 |
| 34 bool GetMode(ProxyPrefs::ProxyMode* out) const; | 38 bool GetMode(ProxyPrefs::ProxyMode* out) const; |
| 35 bool GetPacUrl(std::string* out) const; | 39 bool GetPacUrl(std::string* out) const; |
| 36 bool GetPacMandatory(bool* out) const; | 40 bool GetPacMandatory(bool* out) const; |
| 37 bool GetProxyServer(std::string* out) const; | 41 bool GetProxyServer(std::string* out) const; |
| 38 bool GetBypassList(std::string* out) const; | 42 bool GetBypassList(std::string* out) const; |
| 39 bool HasBypassList() const; | 43 bool HasBypassList() const; |
| 40 | 44 |
| 41 const base::DictionaryValue& GetDictionary() const; | 45 const base::DictionaryValue& GetDictionary() const; |
| 42 | 46 |
| 43 static base::DictionaryValue* CreateDirect(); | 47 static base::DictionaryValue* CreateDirect(); |
| 44 static base::DictionaryValue* CreateAutoDetect(); | 48 static base::DictionaryValue* CreateAutoDetect(); |
| 45 static base::DictionaryValue* CreatePacScript(const std::string& pac_url, | 49 static base::DictionaryValue* CreatePacScript(const std::string& pac_url, |
| 46 bool pac_mandatory); | 50 bool pac_mandatory); |
| 47 static base::DictionaryValue* CreateFixedServers( | 51 static base::DictionaryValue* CreateFixedServers( |
| 48 const std::string& proxy_server, | 52 const std::string& proxy_server, |
| 49 const std::string& bypass_list); | 53 const std::string& bypass_list); |
| 50 static base::DictionaryValue* CreateSystem(); | 54 static base::DictionaryValue* CreateSystem(); |
| 55 |
| 56 // Encodes the proxy server as "<url-scheme>=<proxy-scheme>://<proxy>". |
| 57 // Used to generate the |proxy_server| arg for CreateFixedServers(). |
| 58 static void EncodeAndAppendProxyServer(const std::string& url_scheme, |
| 59 const net::ProxyServer& server, |
| 60 std::string* spec); |
| 61 |
| 51 private: | 62 private: |
| 52 static base::DictionaryValue* CreateDictionary( | 63 static base::DictionaryValue* CreateDictionary( |
| 53 ProxyPrefs::ProxyMode mode, | 64 ProxyPrefs::ProxyMode mode, |
| 54 const std::string& pac_url, | 65 const std::string& pac_url, |
| 55 bool pac_mandatory, | 66 bool pac_mandatory, |
| 56 const std::string& proxy_server, | 67 const std::string& proxy_server, |
| 57 const std::string& bypass_list); | 68 const std::string& bypass_list); |
| 58 | 69 |
| 59 scoped_ptr<base::DictionaryValue> dict_; | 70 scoped_ptr<base::DictionaryValue> dict_; |
| 60 | 71 |
| 61 DISALLOW_COPY_AND_ASSIGN(ProxyConfigDictionary); | 72 DISALLOW_COPY_AND_ASSIGN(ProxyConfigDictionary); |
| 62 }; | 73 }; |
| 63 | 74 |
| 64 #endif // COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_ | 75 #endif // COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_ |
| OLD | NEW |