EME test page application.
[chromium-blink-merge.git] / chrome / browser / chromeos / ui_proxy_config.h
blob08fa47fb09775fd38fcce6a8f2f3ee802b098888
1 // Copyright 2013 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 CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_H_
6 #define CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_H_
8 #include <string>
10 #include "chrome/browser/prefs/proxy_prefs.h"
11 #include "net/proxy/proxy_bypass_rules.h"
12 #include "net/proxy/proxy_server.h"
13 #include "url/gurl.h"
15 namespace base {
16 class DictionaryValue;
19 namespace net {
20 class ProxyConfig;
23 namespace chromeos {
25 // Contrary to other platforms which simply use the systems' UI to allow users
26 // to configure proxies, we have to implement our own UI on the chromeos device.
27 // This requires extra and specific UI requirements that net::ProxyConfig does
28 // not supply. So we create an augmented analog to net::ProxyConfig here to
29 // 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 {
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,
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.
53 // Proxy setting for mode = single-proxy or proxy-per-scheme.
54 struct ManualProxy {
55 net::ProxyServer server;
58 UIProxyConfig();
59 ~UIProxyConfig();
61 void SetPacUrl(const GURL& pac_url);
62 void SetSingleProxy(const net::ProxyServer& server);
64 // |scheme| is one of "http", "https", "ftp" or "socks".
65 void SetProxyForScheme(const std::string& scheme,
66 const net::ProxyServer& server);
68 // Only valid for MODE_SINGLE_PROXY or MODE_PROXY_PER_SCHEME.
69 void SetBypassRules(const net::ProxyBypassRules& rules);
71 // Converts net::ProxyConfig to |this|.
72 bool FromNetProxyConfig(const net::ProxyConfig& net_config);
74 // Converts |this| to Dictionary of ProxyConfigDictionary format (which
75 // is the same format used by prefs).
76 base::DictionaryValue* ToPrefProxyConfig() const;
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);
82 // Encodes the proxy server as "<url-scheme>=<proxy-scheme>://<proxy>"
83 static void EncodeAndAppendProxyServer(const std::string& url_scheme,
84 const net::ProxyServer& server,
85 std::string* spec);
87 Mode mode;
89 ProxyPrefs::ConfigState state;
91 // True if user can modify proxy settings via UI.
92 // If proxy is managed by policy or extension or other_precde or is for
93 // shared network but kUseSharedProxies is turned off, it can't be modified
94 // by user.
95 bool user_modifiable;
97 // Set if mode is MODE_DIRECT or MODE_AUTO_DETECT or MODE_PAC_SCRIPT.
98 AutomaticProxy automatic_proxy;
99 // Set if mode is MODE_SINGLE_PROXY.
100 ManualProxy single_proxy;
101 // Set if mode is MODE_PROXY_PER_SCHEME and has http proxy.
102 ManualProxy http_proxy;
103 // Set if mode is MODE_PROXY_PER_SCHEME and has https proxy.
104 ManualProxy https_proxy;
105 // Set if mode is MODE_PROXY_PER_SCHEME and has ftp proxy.
106 ManualProxy ftp_proxy;
107 // Set if mode is MODE_PROXY_PER_SCHEME and has socks proxy.
108 ManualProxy socks_proxy;
110 // Exceptions for when not to use a proxy.
111 net::ProxyBypassRules bypass_rules;
114 } // namespace chromeos
116 #endif // CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_H_