OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "chrome/browser/prefs/proxy_prefs.h" | |
11 #include "googleurl/src/gurl.h" | |
12 #include "net/proxy/proxy_bypass_rules.h" | |
13 #include "net/proxy/proxy_server.h" | |
14 | |
15 namespace base { | |
16 class DictionaryValue; | |
17 } | |
18 | |
19 namespace net { | |
20 class ProxyConfig; | |
21 } | |
22 | |
23 namespace chromeos { | |
24 | |
25 // In contrary to other platforms which simply use the systems' UI to allow | |
stevenjb
2013/05/15 17:44:14
nit: s/In contrary to/Contrary to (or 'In contrast
pneubeck (no reviews)
2013/05/15 20:24:48
Done.
| |
26 // users to configure proxies, we have to implement our own UI on the chromeos | |
27 // device. This requires extra and specific UI requirements that | |
28 // net::ProxyConfig does not suffice. So we create an augmented analog to | |
stevenjb
2013/05/15 17:44:14
nit: s/suffice/supply
pneubeck (no reviews)
2013/05/15 20:24:48
Done.
| |
29 // net::ProxyConfig here to include and handle these UI requirements, e.g. | |
30 // - state of configuration e.g. where it was picked up from - policy, | |
31 // extension, etc (refer to ProxyPrefs::ConfigState) | |
32 // - the read/write access of a proxy setting | |
33 // - may add more stuff later. | |
34 // This is then converted to the common net::ProxyConfig before being pushed | |
35 // to PrefProxyConfigTrackerImpl::OnProxyConfigChanged and then to the network | |
36 // stack. | |
37 struct UIProxyConfig { | |
stevenjb
2013/05/15 17:44:14
This is complex enough that a class might be bette
pneubeck (no reviews)
2013/05/15 20:24:48
Yes it's regularly copied.
I totally agree (also
stevenjb
2013/05/16 17:04:34
OK, that's fine, as long as we do follow up; the C
| |
38 // Specifies if proxy config is direct, auto-detect, using pac script, | |
39 // single-proxy, or proxy-per-scheme. | |
40 enum Mode { | |
41 MODE_DIRECT, | |
42 MODE_AUTO_DETECT, | |
43 MODE_PAC_SCRIPT, | |
44 MODE_SINGLE_PROXY, | |
45 MODE_PROXY_PER_SCHEME, | |
46 }; | |
47 | |
48 // Proxy setting for mode = direct or auto-detect or using pac script. | |
49 struct AutomaticProxy { | |
50 GURL pac_url; // Set if proxy is using pac script. | |
51 }; | |
52 | |
53 // Proxy setting for mode = single-proxy or proxy-per-scheme. | |
54 struct ManualProxy { | |
55 net::ProxyServer server; | |
56 }; | |
57 | |
58 UIProxyConfig(); | |
59 ~UIProxyConfig(); | |
60 | |
61 void SetPacUrl(const GURL& pac_url); | |
62 void SetSingleProxy(const net::ProxyServer& server); | |
63 | |
64 // |scheme| is one of "http", "https", "ftp" or "socks". | |
65 void SetProxyForScheme(const std::string& scheme, | |
66 const net::ProxyServer& server); | |
67 | |
68 // Only valid for MODE_SINGLE_PROXY or MODE_PROXY_PER_SCHEME. | |
69 void SetBypassRules(const net::ProxyBypassRules& rules); | |
70 | |
71 // Converts net::ProxyConfig to |this|. | |
72 bool FromNetProxyConfig(const net::ProxyConfig& net_config); | |
73 | |
74 // Converts |this| to Dictionary of ProxyConfigDictionary format (which | |
75 // is the same format used by prefs). | |
76 base::DictionaryValue* ToPrefProxyConfig(); | |
77 | |
78 // Map |scheme| (one of "http", "https", "ftp" or "socks") to the correct | |
79 // ManualProxy. Returns NULL if scheme is invalid. | |
80 ManualProxy* MapSchemeToProxy(const std::string& scheme); | |
81 | |
82 // We've migrated device settings to shill, so we only need to | |
83 // deserialize previously persisted device settings. | |
84 // Deserializes from signed setting on device as std::string into a | |
85 // protobuf and then into the config. | |
86 bool DeserializeForDevice(const std::string& input); | |
87 | |
88 // Serializes config into a ProxyConfigDictionary and then std::string | |
89 // persisted as string property in shill for a network. | |
90 bool SerializeForNetwork(std::string* output); | |
91 | |
92 // Encodes the proxy server as "<url-scheme>=<proxy-scheme>://<proxy>" | |
93 static void EncodeAndAppendProxyServer(const std::string& url_scheme, | |
94 const net::ProxyServer& server, | |
95 std::string* spec); | |
96 | |
97 Mode mode; | |
98 | |
99 ProxyPrefs::ConfigState state; | |
stevenjb
2013/05/15 17:44:14
Without the trailing _, these look like locals in
pneubeck (no reviews)
2013/05/15 20:24:48
I totally agree. So far this is only moved code wi
| |
100 | |
101 // True if user can modify proxy settings via UI. | |
102 // If proxy is managed by policy or extension or other_precde or is for | |
103 // shared network but kUseSharedProxies is turned off, it can't be modified | |
104 // by user. | |
105 bool user_modifiable; | |
106 | |
107 // Set if mode is MODE_DIRECT or MODE_AUTO_DETECT or MODE_PAC_SCRIPT. | |
108 AutomaticProxy automatic_proxy; | |
109 // Set if mode is MODE_SINGLE_PROXY. | |
110 ManualProxy single_proxy; | |
111 // Set if mode is MODE_PROXY_PER_SCHEME and has http proxy. | |
112 ManualProxy http_proxy; | |
113 // Set if mode is MODE_PROXY_PER_SCHEME and has https proxy. | |
114 ManualProxy https_proxy; | |
115 // Set if mode is MODE_PROXY_PER_SCHEME and has ftp proxy. | |
116 ManualProxy ftp_proxy; | |
117 // Set if mode is MODE_PROXY_PER_SCHEME and has socks proxy. | |
118 ManualProxy socks_proxy; | |
119 | |
120 // Exceptions for when not to use a proxy. | |
121 net::ProxyBypassRules bypass_rules; | |
122 }; | |
123 | |
124 } // namespace chromeos | |
125 | |
126 #endif // CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_H_ | |
OLD | NEW |