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

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

Issue 2446893008: NetworkHandler: Add ui_proxy_config_service (Closed)
Patch Set: Add NetworkHandler::ShutdownPrefServices 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_parser.h" 5 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 // We have to explicitly export this because the arraysize macro doesn't like 102 // We have to explicitly export this because the arraysize macro doesn't like
103 // extern arrays as their size is not known on compile time. 103 // extern arrays as their size is not known on compile time.
104 const size_t kProxySettingsCount = arraysize(kProxySettings); 104 const size_t kProxySettingsCount = arraysize(kProxySettings);
105 105
106 bool IsProxyPref(const std::string& path) { 106 bool IsProxyPref(const std::string& path) {
107 return base::StartsWith(path, kProxyPrefsPrefix, 107 return base::StartsWith(path, kProxyPrefsPrefix,
108 base::CompareCase::SENSITIVE); 108 base::CompareCase::SENSITIVE);
109 } 109 }
110 110
111 void SetProxyPrefValue(const std::string& path, 111 void SetProxyPrefValue(const std::string& network_guid,
112 const std::string& path,
112 const base::Value* in_value, 113 const base::Value* in_value,
113 UIProxyConfigService* config_service) { 114 UIProxyConfigService* config_service) {
114 if (!in_value) { 115 if (!in_value) {
115 NOTREACHED(); 116 NOTREACHED();
116 return; 117 return;
117 } 118 }
118 119
119 // Retrieve proxy config. 120 // Retrieve proxy config.
120 UIProxyConfig config; 121 UIProxyConfig config;
121 config_service->GetProxyConfig(&config); 122 config_service->GetProxyConfig(network_guid, &config);
122 123
123 if (path == kProxyPacUrl) { 124 if (path == kProxyPacUrl) {
124 std::string val; 125 std::string val;
125 if (in_value->GetAsString(&val)) { 126 if (in_value->GetAsString(&val)) {
126 GURL url(val); 127 GURL url(val);
127 if (url.is_valid()) 128 if (url.is_valid())
128 config.SetPacUrl(url); 129 config.SetPacUrl(url);
129 else 130 else
130 config.mode = UIProxyConfig::MODE_AUTO_DETECT; 131 config.mode = UIProxyConfig::MODE_AUTO_DETECT;
131 } 132 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 if (list_value->GetString(x, &val)) 269 if (list_value->GetString(x, &val))
269 bypass_rules.AddRuleFromString(val); 270 bypass_rules.AddRuleFromString(val);
270 } 271 }
271 config.SetBypassRules(bypass_rules); 272 config.SetBypassRules(bypass_rules);
272 } 273 }
273 } else { 274 } else {
274 LOG(WARNING) << "Unknown proxy settings path " << path; 275 LOG(WARNING) << "Unknown proxy settings path " << path;
275 return; 276 return;
276 } 277 }
277 278
278 config_service->SetProxyConfig(config); 279 config_service->SetProxyConfig(network_guid, config);
279 } 280 }
280 281
281 bool GetProxyPrefValue(const UIProxyConfigService& config_service, 282 bool GetProxyPrefValue(const std::string& network_guid,
282 const std::string& path, 283 const std::string& path,
284 UIProxyConfigService* config_service,
283 base::Value** out_value) { 285 base::Value** out_value) {
284 std::string controlled_by; 286 std::string controlled_by;
285 base::Value* data = NULL; 287 base::Value* data = NULL;
286 UIProxyConfig config; 288 UIProxyConfig config;
287 config_service.GetProxyConfig(&config); 289 config_service->GetProxyConfig(network_guid, &config);
288 290
289 if (path == kProxyPacUrl) { 291 if (path == kProxyPacUrl) {
290 // Only show pacurl for pac-script mode. 292 // Only show pacurl for pac-script mode.
291 if (config.mode == UIProxyConfig::MODE_PAC_SCRIPT && 293 if (config.mode == UIProxyConfig::MODE_PAC_SCRIPT &&
292 config.automatic_proxy.pac_url.is_valid()) { 294 config.automatic_proxy.pac_url.is_valid()) {
293 data = new base::StringValue(config.automatic_proxy.pac_url.spec()); 295 data = new base::StringValue(config.automatic_proxy.pac_url.spec());
294 } 296 }
295 } else if (path == kProxySingleHttp) { 297 } else if (path == kProxySingleHttp) {
296 data = CreateServerHostValue(config.single_proxy); 298 data = CreateServerHostValue(config.single_proxy);
297 } else if (path == kProxySingleHttpPort) { 299 } else if (path == kProxySingleHttpPort) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } else { 368 } else {
367 dict->SetBoolean("disabled", false); 369 dict->SetBoolean("disabled", false);
368 } 370 }
369 *out_value = dict; 371 *out_value = dict;
370 return true; 372 return true;
371 } 373 }
372 374
373 } // namespace proxy_cros_settings_parser 375 } // namespace proxy_cros_settings_parser
374 376
375 } // namespace chromeos 377 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698