Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: chromeos/network/proxy/ui_proxy_config.cc

Issue 2442313003: Move some proxy config code out of src/chrome (Closed)
Patch Set: Fix DEPS Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/chromeos/ui_proxy_config.h" 5 #include "chromeos/network/proxy/ui_proxy_config.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "components/proxy_config/proxy_config_dictionary.h" 9 #include "components/proxy_config/proxy_config_dictionary.h"
10 #include "net/proxy/proxy_config.h" 10 #include "net/proxy/proxy_config.h"
11 #include "url/url_constants.h" 11 #include "url/url_constants.h"
12 12
13 namespace { 13 namespace {
14 const char kSocksScheme[] = "socks"; 14 const char kSocksScheme[] = "socks";
15 } 15 }
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 UIProxyConfig::UIProxyConfig() 19 UIProxyConfig::UIProxyConfig()
20 : mode(MODE_DIRECT), 20 : mode(MODE_DIRECT),
21 state(ProxyPrefs::CONFIG_UNSET), 21 state(ProxyPrefs::CONFIG_UNSET),
22 user_modifiable(true) { 22 user_modifiable(true) {}
23 }
24 23
25 UIProxyConfig::~UIProxyConfig() { 24 UIProxyConfig::~UIProxyConfig() {}
26 }
27 25
28 void UIProxyConfig::SetPacUrl(const GURL& pac_url) { 26 void UIProxyConfig::SetPacUrl(const GURL& pac_url) {
29 mode = UIProxyConfig::MODE_PAC_SCRIPT; 27 mode = UIProxyConfig::MODE_PAC_SCRIPT;
30 automatic_proxy.pac_url = pac_url; 28 automatic_proxy.pac_url = pac_url;
31 } 29 }
32 30
33 void UIProxyConfig::SetSingleProxy(const net::ProxyServer& server) { 31 void UIProxyConfig::SetSingleProxy(const net::ProxyServer& server) {
34 mode = UIProxyConfig::MODE_SINGLE_PROXY; 32 mode = UIProxyConfig::MODE_SINGLE_PROXY;
35 single_proxy.server = server; 33 single_proxy.server = server;
36 } 34 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 if (rules.single_proxies.IsEmpty()) 73 if (rules.single_proxies.IsEmpty())
76 return false; 74 return false;
77 mode = MODE_SINGLE_PROXY; 75 mode = MODE_SINGLE_PROXY;
78 single_proxy.server = rules.single_proxies.Get(); 76 single_proxy.server = rules.single_proxies.Get();
79 bypass_rules = rules.bypass_rules; 77 bypass_rules = rules.bypass_rules;
80 return true; 78 return true;
81 case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME: 79 case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME:
82 // Make sure we have valid server for at least one of the protocols. 80 // Make sure we have valid server for at least one of the protocols.
83 if (rules.proxies_for_http.IsEmpty() && 81 if (rules.proxies_for_http.IsEmpty() &&
84 rules.proxies_for_https.IsEmpty() && 82 rules.proxies_for_https.IsEmpty() &&
85 rules.proxies_for_ftp.IsEmpty() && 83 rules.proxies_for_ftp.IsEmpty() && rules.fallback_proxies.IsEmpty()) {
86 rules.fallback_proxies.IsEmpty()) {
87 return false; 84 return false;
88 } 85 }
89 mode = MODE_PROXY_PER_SCHEME; 86 mode = MODE_PROXY_PER_SCHEME;
90 if (!rules.proxies_for_http.IsEmpty()) 87 if (!rules.proxies_for_http.IsEmpty())
91 http_proxy.server = rules.proxies_for_http.Get(); 88 http_proxy.server = rules.proxies_for_http.Get();
92 if (!rules.proxies_for_https.IsEmpty()) 89 if (!rules.proxies_for_https.IsEmpty())
93 https_proxy.server = rules.proxies_for_https.Get(); 90 https_proxy.server = rules.proxies_for_https.Get();
94 if (!rules.proxies_for_ftp.IsEmpty()) 91 if (!rules.proxies_for_ftp.IsEmpty())
95 ftp_proxy.server = rules.proxies_for_ftp.Get(); 92 ftp_proxy.server = rules.proxies_for_ftp.Get();
96 if (!rules.fallback_proxies.IsEmpty()) 93 if (!rules.fallback_proxies.IsEmpty())
(...skipping 16 matching lines...) Expand all
113 return ProxyConfigDictionary::CreateAutoDetect(); 110 return ProxyConfigDictionary::CreateAutoDetect();
114 } 111 }
115 case MODE_PAC_SCRIPT: { 112 case MODE_PAC_SCRIPT: {
116 return ProxyConfigDictionary::CreatePacScript( 113 return ProxyConfigDictionary::CreatePacScript(
117 automatic_proxy.pac_url.spec(), false); 114 automatic_proxy.pac_url.spec(), false);
118 } 115 }
119 case MODE_SINGLE_PROXY: { 116 case MODE_SINGLE_PROXY: {
120 std::string spec; 117 std::string spec;
121 if (single_proxy.server.is_valid()) 118 if (single_proxy.server.is_valid())
122 spec = single_proxy.server.ToURI(); 119 spec = single_proxy.server.ToURI();
123 return ProxyConfigDictionary::CreateFixedServers( 120 return ProxyConfigDictionary::CreateFixedServers(spec,
124 spec, bypass_rules.ToString()); 121 bypass_rules.ToString());
125 } 122 }
126 case MODE_PROXY_PER_SCHEME: { 123 case MODE_PROXY_PER_SCHEME: {
127 std::string spec; 124 std::string spec;
128 ProxyConfigDictionary::EncodeAndAppendProxyServer( 125 ProxyConfigDictionary::EncodeAndAppendProxyServer(
129 url::kHttpScheme, http_proxy.server, &spec); 126 url::kHttpScheme, http_proxy.server, &spec);
130 ProxyConfigDictionary::EncodeAndAppendProxyServer( 127 ProxyConfigDictionary::EncodeAndAppendProxyServer(
131 url::kHttpsScheme, https_proxy.server, &spec); 128 url::kHttpsScheme, https_proxy.server, &spec);
132 ProxyConfigDictionary::EncodeAndAppendProxyServer( 129 ProxyConfigDictionary::EncodeAndAppendProxyServer(
133 url::kFtpScheme, ftp_proxy.server, &spec); 130 url::kFtpScheme, ftp_proxy.server, &spec);
134 ProxyConfigDictionary::EncodeAndAppendProxyServer( 131 ProxyConfigDictionary::EncodeAndAppendProxyServer(
135 kSocksScheme, socks_proxy.server, &spec); 132 kSocksScheme, socks_proxy.server, &spec);
136 return ProxyConfigDictionary::CreateFixedServers( 133 return ProxyConfigDictionary::CreateFixedServers(spec,
137 spec, bypass_rules.ToString()); 134 bypass_rules.ToString());
138 } 135 }
139 default: 136 default:
140 break; 137 break;
141 } 138 }
142 NOTREACHED() << "Unrecognized proxy config mode for preference"; 139 NOTREACHED() << "Unrecognized proxy config mode for preference";
143 return NULL; 140 return NULL;
144 } 141 }
145 142
146 UIProxyConfig::ManualProxy* UIProxyConfig::MapSchemeToProxy( 143 UIProxyConfig::ManualProxy* UIProxyConfig::MapSchemeToProxy(
147 const std::string& scheme) { 144 const std::string& scheme) {
148 if (scheme == url::kHttpScheme) 145 if (scheme == url::kHttpScheme)
149 return &http_proxy; 146 return &http_proxy;
150 if (scheme == url::kHttpsScheme) 147 if (scheme == url::kHttpsScheme)
151 return &https_proxy; 148 return &https_proxy;
152 if (scheme == url::kFtpScheme) 149 if (scheme == url::kFtpScheme)
153 return &ftp_proxy; 150 return &ftp_proxy;
154 if (scheme == kSocksScheme) 151 if (scheme == kSocksScheme)
155 return &socks_proxy; 152 return &socks_proxy;
156 NOTREACHED() << "Invalid scheme: " << scheme; 153 NOTREACHED() << "Invalid scheme: " << scheme;
157 return NULL; 154 return NULL;
158 } 155 }
159 156
160 } // namespace chromeos 157 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/proxy/ui_proxy_config.h ('k') | chromeos/network/proxy/ui_proxy_config_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698