Misc clean up in browser_shutdown.cc.
[chromium-blink-merge.git] / components / proxy_config / proxy_config_dictionary.h
blob236a96beb4980860046892498d8f8df34b71be4f
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_
6 #define COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/proxy_config/proxy_config_export.h"
13 #include "components/proxy_config/proxy_prefs.h"
15 namespace base {
16 class DictionaryValue;
19 namespace net {
20 class ProxyServer;
23 // Factory and wrapper for proxy config dictionaries that are stored
24 // in the user preferences. The dictionary has the following structure:
25 // {
26 // mode: string,
27 // server: string,
28 // pac_url: string,
29 // bypass_list: string
30 // }
31 // See proxy_config_dictionary.cc for the structure of the respective strings.
32 class PROXY_CONFIG_EXPORT ProxyConfigDictionary {
33 public:
34 // Creates a deep copy of |dict| and leaves ownership to caller.
35 explicit ProxyConfigDictionary(const base::DictionaryValue* dict);
36 ~ProxyConfigDictionary();
38 bool GetMode(ProxyPrefs::ProxyMode* out) const;
39 bool GetPacUrl(std::string* out) const;
40 bool GetPacMandatory(bool* out) const;
41 bool GetProxyServer(std::string* out) const;
42 bool GetBypassList(std::string* out) const;
43 bool HasBypassList() const;
45 const base::DictionaryValue& GetDictionary() const;
47 static base::DictionaryValue* CreateDirect();
48 static base::DictionaryValue* CreateAutoDetect();
49 static base::DictionaryValue* CreatePacScript(const std::string& pac_url,
50 bool pac_mandatory);
51 static base::DictionaryValue* CreateFixedServers(
52 const std::string& proxy_server,
53 const std::string& bypass_list);
54 static base::DictionaryValue* CreateSystem();
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);
62 private:
63 static base::DictionaryValue* CreateDictionary(
64 ProxyPrefs::ProxyMode mode,
65 const std::string& pac_url,
66 bool pac_mandatory,
67 const std::string& proxy_server,
68 const std::string& bypass_list);
70 scoped_ptr<base::DictionaryValue> dict_;
72 DISALLOW_COPY_AND_ASSIGN(ProxyConfigDictionary);
75 #endif // COMPONENTS_PROXY_CONFIG_PROXY_CONFIG_DICTIONARY_H_