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

Side by Side Diff: chrome/browser/chromeos/proxy_cros_settings_provider.cc

Issue 7867044: PART1: Initiated the SignedSettings refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments and issues. Created 9 years, 3 months 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 | Annotate | Revision Log
OLDNEW
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
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
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 bool ProxyCrosSettingsProvider::GetTrusted(
315 const std::string& path,
316 const base::Closure& callback) const {
317 // This will bounce the query to UserCrosSettingsProvider until
318 // ProxyConfigService can report this too.
319 // TODO(pastarmovj): Extend ProxyConfigService to support this kind of query.
320 return CrosSettings::Get()->GetTrusted(kAccountsPrefAllowGuest, callback);
Mattias Nissler (ping if slow) 2011/09/26 17:26:37 This is not correct either, since we might also be
pastarmovj 2011/09/29 15:15:03 Done.
321 } 321 }
322 322
323 bool ProxyCrosSettingsProvider::HandlesSetting(const std::string& path) const { 323 bool ProxyCrosSettingsProvider::HandlesSetting(const std::string& path) const {
324 return ::StartsWithASCII(path, "cros.session.proxy", true); 324 return ::StartsWithASCII(path, "cros.session.proxy", true);
325 } 325 }
326 326
327 //----------------- ProxyCrosSettingsProvider: private methods ----------------- 327 //----------------- ProxyCrosSettingsProvider: private methods -----------------
328 328
329 chromeos::ProxyConfigServiceImpl* 329 chromeos::ProxyConfigServiceImpl*
330 ProxyCrosSettingsProvider::GetConfigService() const { 330 ProxyCrosSettingsProvider::GetConfigService() const {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 367 }
368 368
369 Value* ProxyCrosSettingsProvider::CreateServerPortValue( 369 Value* ProxyCrosSettingsProvider::CreateServerPortValue(
370 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { 370 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const {
371 return proxy.server.is_valid() ? 371 return proxy.server.is_valid() ?
372 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : 372 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) :
373 NULL; 373 NULL;
374 } 374 }
375 375
376 } // namespace chromeos 376 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698