OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cros_settings_provider_proxy.h" | 5 #include "chrome/browser/chromeos/cros_settings_provider_proxy.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
10 #include "chrome/browser/profile_manager.h" | 10 #include "chrome/browser/profile_manager.h" |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 | 13 |
| 14 static const char kProxyPacUrl[] = "cros.proxy.pacurl"; |
| 15 static const char kProxySingleHttp[] = "cros.proxy.singlehttp"; |
| 16 static const char kProxySingleHttpPort[] = "cros.proxy.singlehttpport"; |
| 17 static const char kProxyHttpUrl[] = "cros.proxy.httpurl"; |
| 18 static const char kProxyHttpPort[] = "cros.proxy.httpport"; |
| 19 static const char kProxyHttpsUrl[] = "cros.proxy.httpsurl"; |
| 20 static const char kProxyHttpsPort[] = "cros.proxy.httpsport"; |
| 21 static const char kProxyType[] = "cros.proxy.type"; |
| 22 static const char kProxySingle[] = "cros.proxy.single"; |
| 23 static const char kProxyFtpUrl[] = "cros.proxy.ftpurl"; |
| 24 static const char kProxyFtpPort[] = "cros.proxy.ftpport"; |
| 25 static const char kProxySocks[] = "cros.proxy.socks"; |
| 26 static const char kProxySocksPort[] = "cros.proxy.socksport"; |
| 27 static const char kProxyIgnoreList[] = "cros.proxy.ignorelist"; |
| 28 |
14 //------------------ CrosSettingsProviderProxy: public methods ----------------- | 29 //------------------ CrosSettingsProviderProxy: public methods ----------------- |
15 | 30 |
16 CrosSettingsProviderProxy::CrosSettingsProviderProxy() { } | 31 CrosSettingsProviderProxy::CrosSettingsProviderProxy() { } |
17 | 32 |
18 void CrosSettingsProviderProxy::DoSet(const std::string& path, | 33 void CrosSettingsProviderProxy::DoSet(const std::string& path, |
19 Value* in_value) { | 34 Value* in_value) { |
20 if (!in_value) { | 35 if (!in_value) { |
21 return; | 36 return; |
22 } | 37 } |
| 38 |
| 39 // Keep whatever user inputs so that we could use it later. |
| 40 SetCache(path, in_value); |
| 41 |
23 chromeos::ProxyConfigServiceImpl* config_service = GetConfigService(); | 42 chromeos::ProxyConfigServiceImpl* config_service = GetConfigService(); |
24 chromeos::ProxyConfigServiceImpl::ProxyConfig config; | 43 chromeos::ProxyConfigServiceImpl::ProxyConfig config; |
25 config_service->UIGetProxyConfig(&config); | 44 config_service->UIGetProxyConfig(&config); |
26 | 45 |
27 if (path == "cros.proxy.pacurl") { | 46 if (path == kProxyPacUrl) { |
28 std::string val; | 47 std::string val; |
29 if (in_value->GetAsString(&val)) { | 48 if (in_value->GetAsString(&val)) { |
30 GURL url(val); | 49 GURL url(val); |
31 config_service->UISetProxyConfigToPACScript(url); | 50 config_service->UISetProxyConfigToPACScript(url); |
32 } | 51 } |
33 } else if (path == "cros.proxy.singlehttp") { | 52 } else if (path == kProxySingleHttp) { |
34 std::string val; | 53 std::string val; |
35 if (in_value->GetAsString(&val)) { | 54 if (in_value->GetAsString(&val)) { |
36 std::string uri = val; | 55 std::string uri = val; |
37 AppendPortIfValid(config.single_proxy, &uri); | 56 AppendPortIfValid(kProxySingleHttpPort, &uri); |
38 config_service->UISetProxyConfigToSingleProxy( | 57 config_service->UISetProxyConfigToSingleProxy( |
39 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); | 58 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); |
40 } | 59 } |
41 } else if (path == "cros.proxy.singlehttpport") { | 60 } else if (path == kProxySingleHttpPort) { |
42 std::string val; | 61 std::string val; |
43 if (in_value->GetAsString(&val)) { | 62 if (in_value->GetAsString(&val)) { |
44 std::string uri; | 63 std::string uri; |
45 if (FormServerUriIfValid(config.single_proxy, val, &uri)) { | 64 FormServerUriIfValid(kProxySingleHttp, val, &uri); |
46 config_service->UISetProxyConfigToSingleProxy( | 65 config_service->UISetProxyConfigToSingleProxy( |
47 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); | 66 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); |
48 } | |
49 } | 67 } |
50 } else if (path == "cros.proxy.httpurl") { | 68 } else if (path == kProxyHttpUrl) { |
51 std::string val; | 69 std::string val; |
52 if (in_value->GetAsString(&val)) { | 70 if (in_value->GetAsString(&val)) { |
53 std::string uri = val; | 71 std::string uri = val; |
54 AppendPortIfValid(config.http_proxy, &uri); | 72 AppendPortIfValid(kProxyHttpPort, &uri); |
55 config_service->UISetProxyConfigToProxyPerScheme("http", | 73 config_service->UISetProxyConfigToProxyPerScheme("http", |
56 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); | 74 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); |
57 } | 75 } |
58 } else if (path == "cros.proxy.httpsurl") { | 76 } else if (path == kProxyHttpPort) { |
| 77 std::string val; |
| 78 if (in_value->GetAsString(&val)) { |
| 79 std::string uri; |
| 80 FormServerUriIfValid(kProxyHttpUrl, val, &uri); |
| 81 config_service->UISetProxyConfigToProxyPerScheme("http", |
| 82 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); |
| 83 } |
| 84 } else if (path == kProxyHttpsUrl) { |
59 std::string val; | 85 std::string val; |
60 if (in_value->GetAsString(&val)) { | 86 if (in_value->GetAsString(&val)) { |
61 std::string uri = val; | 87 std::string uri = val; |
62 AppendPortIfValid(config.https_proxy, &uri); | 88 AppendPortIfValid(kProxyHttpsPort, &uri); |
63 config_service->UISetProxyConfigToProxyPerScheme("https", | 89 config_service->UISetProxyConfigToProxyPerScheme("https", |
64 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTPS)); | 90 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTPS)); |
65 } | 91 } |
66 } else if (path == "cros.proxy.type") { | 92 } else if (path == kProxyHttpsPort) { |
| 93 std::string val; |
| 94 if (in_value->GetAsString(&val)) { |
| 95 std::string uri; |
| 96 FormServerUriIfValid(kProxyHttpsUrl, val, &uri); |
| 97 config_service->UISetProxyConfigToProxyPerScheme("https", |
| 98 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTPS)); |
| 99 } |
| 100 } else if (path == kProxyType) { |
67 int val; | 101 int val; |
68 if (in_value->GetAsInteger(&val)) { | 102 if (in_value->GetAsInteger(&val)) { |
69 if (val == 3) { | 103 if (val == 3) { |
70 if (config.automatic_proxy.pac_url.is_valid()) | 104 if (config.automatic_proxy.pac_url.is_valid()) |
71 config_service->UISetProxyConfigToPACScript( | 105 config_service->UISetProxyConfigToPACScript( |
72 config.automatic_proxy.pac_url); | 106 config.automatic_proxy.pac_url); |
73 else | 107 else |
74 config_service->UISetProxyConfigToAutoDetect(); | 108 config_service->UISetProxyConfigToAutoDetect(); |
75 } else if (val == 2) { | 109 } else if (val == 2) { |
76 if (config.single_proxy.server.is_valid()) { | 110 if (config.single_proxy.server.is_valid()) { |
(...skipping 23 matching lines...) Expand all Loading... |
100 } | 134 } |
101 if (!set_config) { | 135 if (!set_config) { |
102 config_service->UISetProxyConfigToProxyPerScheme("http", | 136 config_service->UISetProxyConfigToProxyPerScheme("http", |
103 net::ProxyServer()); | 137 net::ProxyServer()); |
104 } | 138 } |
105 } | 139 } |
106 } else { | 140 } else { |
107 config_service->UISetProxyConfigToDirect(); | 141 config_service->UISetProxyConfigToDirect(); |
108 } | 142 } |
109 } | 143 } |
110 } else if (path == "cros.proxy.single") { | 144 } else if (path == kProxySingle) { |
111 bool val; | 145 bool val; |
112 if (in_value->GetAsBoolean(&val)) { | 146 if (in_value->GetAsBoolean(&val)) { |
113 if (val) | 147 if (val) |
114 config_service->UISetProxyConfigToSingleProxy( | 148 config_service->UISetProxyConfigToSingleProxy( |
115 config.single_proxy.server); | 149 config.single_proxy.server); |
116 else | 150 else |
117 config_service->UISetProxyConfigToProxyPerScheme("http", | 151 config_service->UISetProxyConfigToProxyPerScheme("http", |
118 config.http_proxy.server); | 152 config.http_proxy.server); |
119 } | 153 } |
120 } else if (path == "cros.proxy.ftpurl") { | 154 } else if (path == kProxyFtpUrl) { |
121 std::string val; | 155 std::string val; |
122 if (in_value->GetAsString(&val)) { | 156 if (in_value->GetAsString(&val)) { |
123 std::string uri = val; | 157 std::string uri = val; |
124 AppendPortIfValid(config.ftp_proxy, &uri); | 158 AppendPortIfValid(kProxyFtpPort, &uri); |
125 config_service->UISetProxyConfigToProxyPerScheme("ftp", | 159 config_service->UISetProxyConfigToProxyPerScheme("ftp", |
126 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); | 160 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); |
127 } | 161 } |
128 } else if (path == "cros.proxy.socks") { | 162 } else if (path == kProxyFtpPort) { |
| 163 std::string val; |
| 164 if (in_value->GetAsString(&val)) { |
| 165 std::string uri; |
| 166 FormServerUriIfValid(kProxyFtpUrl, val, &uri); |
| 167 config_service->UISetProxyConfigToProxyPerScheme("ftp", |
| 168 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); |
| 169 } |
| 170 } else if (path == kProxySocks) { |
129 std::string val; | 171 std::string val; |
130 if (in_value->GetAsString(&val)) { | 172 if (in_value->GetAsString(&val)) { |
131 std::string uri = val; | 173 std::string uri = val; |
132 AppendPortIfValid(config.socks_proxy, &uri); | 174 AppendPortIfValid(kProxySocksPort, &uri); |
133 config_service->UISetProxyConfigToProxyPerScheme("socks", | 175 config_service->UISetProxyConfigToProxyPerScheme("socks", |
134 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_SOCKS4)); | 176 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_SOCKS4)); |
135 } | 177 } |
136 } else if (path == "cros.proxy.httpport") { | 178 } else if (path == kProxySocksPort) { |
137 std::string val; | 179 std::string val; |
138 if (in_value->GetAsString(&val)) { | 180 if (in_value->GetAsString(&val)) { |
139 std::string uri; | 181 std::string uri; |
140 if (FormServerUriIfValid(config.http_proxy, val, &uri)) { | 182 FormServerUriIfValid(kProxySocks, val, &uri); |
141 config_service->UISetProxyConfigToProxyPerScheme("http", | 183 config_service->UISetProxyConfigToProxyPerScheme("socks", |
142 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); | 184 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_SOCKS4)); |
143 } | |
144 } | 185 } |
145 } else if (path == "cros.proxy.httpsport") { | 186 } else if (path == kProxyIgnoreList) { |
146 std::string val; | |
147 if (in_value->GetAsString(&val)) { | |
148 std::string uri; | |
149 if (FormServerUriIfValid(config.https_proxy, val, &uri)) { | |
150 config_service->UISetProxyConfigToProxyPerScheme("https", | |
151 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTPS)); | |
152 } | |
153 } | |
154 } else if (path == "cros.proxy.ftpport") { | |
155 std::string val; | |
156 if (in_value->GetAsString(&val)) { | |
157 std::string uri; | |
158 if (FormServerUriIfValid(config.ftp_proxy, val, &uri)) { | |
159 config_service->UISetProxyConfigToProxyPerScheme("ftp", | |
160 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_HTTP)); | |
161 } | |
162 } | |
163 } else if (path == "cros.proxy.socksport") { | |
164 std::string val; | |
165 if (in_value->GetAsString(&val)) { | |
166 std::string uri; | |
167 if (FormServerUriIfValid(config.socks_proxy, val, &uri)) { | |
168 config_service->UISetProxyConfigToProxyPerScheme("socks", | |
169 net::ProxyServer::FromURI(uri, net::ProxyServer::SCHEME_SOCKS5)); | |
170 } | |
171 } | |
172 } else if (path == "cros.proxy.ignorelist") { | |
173 net::ProxyBypassRules bypass_rules; | 187 net::ProxyBypassRules bypass_rules; |
174 if (in_value->GetType() == Value::TYPE_LIST) { | 188 if (in_value->GetType() == Value::TYPE_LIST) { |
175 const ListValue* list_value = static_cast<const ListValue*>(in_value); | 189 const ListValue* list_value = static_cast<const ListValue*>(in_value); |
176 for (size_t x = 0; x < list_value->GetSize(); x++) { | 190 for (size_t x = 0; x < list_value->GetSize(); x++) { |
177 std::string val; | 191 std::string val; |
178 if (list_value->GetString(x, &val)) { | 192 if (list_value->GetString(x, &val)) { |
179 bypass_rules.AddRuleFromString(val); | 193 bypass_rules.AddRuleFromString(val); |
180 } | 194 } |
181 } | 195 } |
182 config_service->UISetProxyConfigBypassRules(bypass_rules); | 196 config_service->UISetProxyConfigBypassRules(bypass_rules); |
183 } | 197 } |
184 } | 198 } |
185 } | 199 } |
186 | 200 |
187 bool CrosSettingsProviderProxy::Get(const std::string& path, | 201 bool CrosSettingsProviderProxy::Get(const std::string& path, |
188 Value** out_value) const { | 202 Value** out_value) const { |
189 bool found = false; | 203 bool found = false; |
190 bool managed = false; | 204 bool managed = false; |
191 Value* data; | 205 Value* data; |
192 chromeos::ProxyConfigServiceImpl* config_service = GetConfigService(); | 206 chromeos::ProxyConfigServiceImpl* config_service = GetConfigService(); |
193 chromeos::ProxyConfigServiceImpl::ProxyConfig config; | 207 chromeos::ProxyConfigServiceImpl::ProxyConfig config; |
194 config_service->UIGetProxyConfig(&config); | 208 config_service->UIGetProxyConfig(&config); |
195 | 209 |
196 if (path == "cros.proxy.pacurl") { | 210 if (path == kProxyPacUrl) { |
197 if (config.automatic_proxy.pac_url.is_valid()) { | 211 if (config.automatic_proxy.pac_url.is_valid()) { |
198 data = Value::CreateStringValue(config.automatic_proxy.pac_url.spec()); | 212 data = Value::CreateStringValue(config.automatic_proxy.pac_url.spec()); |
199 found = true; | 213 found = true; |
200 } | 214 } |
201 } else if (path == "cros.proxy.singlehttp") { | 215 } else if (path == kProxySingleHttp) { |
202 found = (data = CreateServerHostValue(config.single_proxy)); | 216 found = (data = CreateServerHostValue(config.single_proxy)); |
203 } else if (path == "cros.proxy.singlehttpport") { | 217 } else if (path == kProxySingleHttpPort) { |
204 found = (data = CreateServerPortValue(config.single_proxy)); | 218 found = (data = CreateServerPortValue(config.single_proxy)); |
205 } else if (path == "cros.proxy.httpurl") { | 219 } else if (path == kProxyHttpUrl) { |
206 found = (data = CreateServerHostValue(config.http_proxy)); | 220 found = (data = CreateServerHostValue(config.http_proxy)); |
207 } else if (path == "cros.proxy.httpsurl") { | 221 } else if (path == kProxyHttpsUrl) { |
208 found = (data = CreateServerHostValue(config.https_proxy)); | 222 found = (data = CreateServerHostValue(config.https_proxy)); |
209 } else if (path == "cros.proxy.type") { | 223 } else if (path == kProxyType) { |
210 if (config.mode == | 224 if (config.mode == |
211 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_AUTO_DETECT || | 225 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_AUTO_DETECT || |
212 config.mode == | 226 config.mode == |
213 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT) { | 227 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT) { |
214 data = Value::CreateIntegerValue(3); | 228 data = Value::CreateIntegerValue(3); |
215 } else if (config.mode == | 229 } else if (config.mode == |
216 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY || | 230 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY || |
217 config.mode == | 231 config.mode == |
218 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PROXY_PER_SCHEME) { | 232 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PROXY_PER_SCHEME) { |
219 data = Value::CreateIntegerValue(2); | 233 data = Value::CreateIntegerValue(2); |
220 } else { | 234 } else { |
221 data = Value::CreateIntegerValue(1); | 235 data = Value::CreateIntegerValue(1); |
222 } | 236 } |
223 found = true; | 237 found = true; |
224 } else if (path == "cros.proxy.single") { | 238 } else if (path == kProxySingle) { |
225 data = Value::CreateBooleanValue(config.mode == | 239 data = Value::CreateBooleanValue(config.mode == |
226 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY); | 240 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_SINGLE_PROXY); |
227 found = true; | 241 found = true; |
228 } else if (path == "cros.proxy.ftpurl") { | 242 } else if (path == kProxyFtpUrl) { |
229 found = (data = CreateServerHostValue(config.ftp_proxy)); | 243 found = (data = CreateServerHostValue(config.ftp_proxy)); |
230 } else if (path == "cros.proxy.socks") { | 244 } else if (path == kProxySocks) { |
231 found = (data = CreateServerHostValue(config.socks_proxy)); | 245 found = (data = CreateServerHostValue(config.socks_proxy)); |
232 } else if (path == "cros.proxy.httpport") { | 246 } else if (path == kProxyHttpPort) { |
233 found = (data = CreateServerPortValue(config.http_proxy)); | 247 found = (data = CreateServerPortValue(config.http_proxy)); |
234 } else if (path == "cros.proxy.httpsport") { | 248 } else if (path == kProxyHttpsPort) { |
235 found = (data = CreateServerPortValue(config.https_proxy)); | 249 found = (data = CreateServerPortValue(config.https_proxy)); |
236 } else if (path == "cros.proxy.ftpport") { | 250 } else if (path == kProxyFtpPort) { |
237 found = (data = CreateServerPortValue(config.ftp_proxy)); | 251 found = (data = CreateServerPortValue(config.ftp_proxy)); |
238 } else if (path == "cros.proxy.socksport") { | 252 } else if (path == kProxySocksPort) { |
239 found = (data = CreateServerPortValue(config.socks_proxy)); | 253 found = (data = CreateServerPortValue(config.socks_proxy)); |
240 } else if (path == "cros.proxy.ignorelist") { | 254 } else if (path == kProxyIgnoreList) { |
241 ListValue* list = new ListValue(); | 255 ListValue* list = new ListValue(); |
242 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); | 256 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); |
243 for (size_t x = 0; x < bypass_rules.size(); x++) { | 257 for (size_t x = 0; x < bypass_rules.size(); x++) { |
244 list->Append(Value::CreateStringValue(bypass_rules[x]->ToString())); | 258 list->Append(Value::CreateStringValue(bypass_rules[x]->ToString())); |
245 } | 259 } |
246 *out_value = list; | 260 *out_value = list; |
247 return true; | 261 return true; |
248 } | 262 } |
249 if (found) { | 263 if (found) { |
250 DictionaryValue* dict = new DictionaryValue; | 264 DictionaryValue* dict = new DictionaryValue; |
(...skipping 17 matching lines...) Expand all Loading... |
268 CrosSettingsProviderProxy::GetConfigService() const { | 282 CrosSettingsProviderProxy::GetConfigService() const { |
269 Browser* browser = BrowserList::GetLastActive(); | 283 Browser* browser = BrowserList::GetLastActive(); |
270 // browser is NULL at OOBE/login stage. | 284 // browser is NULL at OOBE/login stage. |
271 Profile* profile = browser ? | 285 Profile* profile = browser ? |
272 browser->profile() : | 286 browser->profile() : |
273 ProfileManager::GetDefaultProfile(); | 287 ProfileManager::GetDefaultProfile(); |
274 return profile->GetChromeOSProxyConfigServiceImpl(); | 288 return profile->GetChromeOSProxyConfigServiceImpl(); |
275 } | 289 } |
276 | 290 |
277 void CrosSettingsProviderProxy::AppendPortIfValid( | 291 void CrosSettingsProviderProxy::AppendPortIfValid( |
278 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy, | 292 const char* port_cache_key, |
279 std::string* server_uri) { | 293 std::string* server_uri) { |
280 if (proxy.server.is_valid()) | 294 std::string port; |
281 *server_uri += ":" + proxy.server.host_port_pair().port(); | 295 if (!server_uri->empty() && cache_.GetString(port_cache_key, &port) && |
| 296 !port.empty()) { |
| 297 *server_uri += ":" + port; |
| 298 } |
282 } | 299 } |
283 | 300 |
284 bool CrosSettingsProviderProxy::FormServerUriIfValid( | 301 void CrosSettingsProviderProxy::FormServerUriIfValid( |
285 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy, | 302 const char* host_cache_key, |
286 const std::string& port_num, std::string* server_uri) { | 303 const std::string& port_num, std::string* server_uri) { |
287 if (!proxy.server.is_valid()) | 304 if (cache_.GetString(host_cache_key, server_uri) && !server_uri->empty() && |
288 return false; | 305 !port_num.empty()) |
289 *server_uri = proxy.server.host_port_pair().host() + ":" + port_num; | 306 *server_uri += ":" + port_num; |
290 return true; | |
291 } | 307 } |
292 | 308 |
293 Value* CrosSettingsProviderProxy::CreateServerHostValue( | 309 Value* CrosSettingsProviderProxy::CreateServerHostValue( |
294 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { | 310 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { |
295 return proxy.server.is_valid() ? | 311 return proxy.server.is_valid() ? |
296 Value::CreateStringValue(proxy.server.host_port_pair().host()) : | 312 Value::CreateStringValue(proxy.server.host_port_pair().host()) : |
297 NULL; | 313 NULL; |
298 } | 314 } |
299 | 315 |
300 Value* CrosSettingsProviderProxy::CreateServerPortValue( | 316 Value* CrosSettingsProviderProxy::CreateServerPortValue( |
301 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { | 317 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { |
302 return proxy.server.is_valid() ? | 318 return proxy.server.is_valid() ? |
303 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : | 319 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : |
304 NULL; | 320 NULL; |
305 } | 321 } |
306 | 322 |
| 323 void CrosSettingsProviderProxy::SetCache(const std::string& key, |
| 324 const Value* value) { |
| 325 cache_.Set(key, value->DeepCopy()); |
| 326 } |
| 327 |
307 } // namespace chromeos | 328 } // namespace chromeos |
OLD | NEW |