OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/proxy_cros_settings_provider.h" | 5 #include "chrome/browser/chromeos/proxy_cros_settings_provider.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chromeos/cros_settings.h" | 9 #include "chrome/browser/chromeos/cros_settings.h" |
10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 std::string val; | 224 std::string val; |
225 if (list_value->GetString(x, &val)) { | 225 if (list_value->GetString(x, &val)) { |
226 bypass_rules.AddRuleFromString(val); | 226 bypass_rules.AddRuleFromString(val); |
227 } | 227 } |
228 } | 228 } |
229 config_service->UISetProxyConfigBypassRules(bypass_rules); | 229 config_service->UISetProxyConfigBypassRules(bypass_rules); |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 bool ProxyCrosSettingsProvider::Get(const std::string& path, | 234 const Value* ProxyCrosSettingsProvider::Get(const std::string& path) const { |
235 Value** out_value) const { | |
236 bool found = false; | 235 bool found = false; |
237 bool managed = false; | |
238 Value* data = NULL; | 236 Value* data = NULL; |
239 chromeos::ProxyConfigServiceImpl* config_service = GetConfigService(); | 237 chromeos::ProxyConfigServiceImpl* config_service = GetConfigService(); |
240 chromeos::ProxyConfigServiceImpl::ProxyConfig config; | 238 chromeos::ProxyConfigServiceImpl::ProxyConfig config; |
241 config_service->UIGetProxyConfig(&config); | 239 config_service->UIGetProxyConfig(&config); |
242 | 240 |
243 if (path == kProxyPacUrl) { | 241 if (path == kProxyPacUrl) { |
244 // Only show pacurl for pac-script mode. | 242 // Only show pacurl for pac-script mode. |
245 if (config.mode == | 243 if (config.mode == |
246 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT && | 244 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT && |
247 config.automatic_proxy.pac_url.is_valid()) { | 245 config.automatic_proxy.pac_url.is_valid()) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 found = true; | 294 found = true; |
297 } else if (path == kProxySocksPort) { | 295 } else if (path == kProxySocksPort) { |
298 data = CreateServerPortValue(config.socks_proxy); | 296 data = CreateServerPortValue(config.socks_proxy); |
299 found = true; | 297 found = true; |
300 } else if (path == kProxyIgnoreList) { | 298 } else if (path == kProxyIgnoreList) { |
301 ListValue* list = new ListValue(); | 299 ListValue* list = new ListValue(); |
302 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); | 300 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); |
303 for (size_t x = 0; x < bypass_rules.size(); x++) { | 301 for (size_t x = 0; x < bypass_rules.size(); x++) { |
304 list->Append(Value::CreateStringValue(bypass_rules[x]->ToString())); | 302 list->Append(Value::CreateStringValue(bypass_rules[x]->ToString())); |
305 } | 303 } |
306 *out_value = list; | 304 return list; |
307 return true; | |
308 } | 305 } |
309 if (found) { | 306 if (found) { |
310 DictionaryValue* dict = new DictionaryValue; | |
311 if (!data) | 307 if (!data) |
312 data = Value::CreateStringValue(""); | 308 data = Value::CreateStringValue(""); |
313 dict->Set("value", data); | 309 return data; |
314 dict->SetBoolean("managed", managed); | |
315 *out_value = dict; | |
316 return true; | |
317 } else { | |
318 *out_value = NULL; | |
319 return false; | |
320 } | 310 } |
| 311 return NULL; |
| 312 } |
| 313 |
| 314 // These settings are always fetched from the net manager which is the |
| 315 // definitive source for them. |
| 316 bool ProxyCrosSettingsProvider::GetTrusted(const std::string& path, |
| 317 const Callback& callback) const { |
| 318 return true; |
321 } | 319 } |
322 | 320 |
323 bool ProxyCrosSettingsProvider::HandlesSetting(const std::string& path) const { | 321 bool ProxyCrosSettingsProvider::HandlesSetting(const std::string& path) const { |
324 return ::StartsWithASCII(path, "cros.session.proxy", true); | 322 return ::StartsWithASCII(path, "cros.session.proxy", true); |
325 } | 323 } |
326 | 324 |
327 //----------------- ProxyCrosSettingsProvider: private methods ----------------- | 325 //----------------- ProxyCrosSettingsProvider: private methods ----------------- |
328 | 326 |
329 chromeos::ProxyConfigServiceImpl* | 327 chromeos::ProxyConfigServiceImpl* |
330 ProxyCrosSettingsProvider::GetConfigService() const { | 328 ProxyCrosSettingsProvider::GetConfigService() const { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 365 } |
368 | 366 |
369 Value* ProxyCrosSettingsProvider::CreateServerPortValue( | 367 Value* ProxyCrosSettingsProvider::CreateServerPortValue( |
370 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { | 368 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { |
371 return proxy.server.is_valid() ? | 369 return proxy.server.is_valid() ? |
372 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : | 370 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : |
373 NULL; | 371 NULL; |
374 } | 372 } |
375 | 373 |
376 } // namespace chromeos | 374 } // namespace chromeos |
OLD | NEW |