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/proxy_cros_settings_provider.h" | 5 #include "chrome/browser/chromeos/proxy_cros_settings_provider.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 | 14 |
14 namespace chromeos { | 15 namespace chromeos { |
15 | 16 |
16 static const char kProxyPacUrl[] = "cros.session.proxy.pacurl"; | 17 static const char kProxyPacUrl[] = "cros.session.proxy.pacurl"; |
17 static const char kProxySingleHttp[] = "cros.session.proxy.singlehttp"; | 18 static const char kProxySingleHttp[] = "cros.session.proxy.singlehttp"; |
18 static const char kProxySingleHttpPort[] = "cros.session.proxy.singlehttpport"; | 19 static const char kProxySingleHttpPort[] = "cros.session.proxy.singlehttpport"; |
19 static const char kProxyHttpUrl[] = "cros.session.proxy.httpurl"; | 20 static const char kProxyHttpUrl[] = "cros.session.proxy.httpurl"; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 286 } |
286 | 287 |
287 bool ProxyCrosSettingsProvider::HandlesSetting(const std::string& path) { | 288 bool ProxyCrosSettingsProvider::HandlesSetting(const std::string& path) { |
288 return ::StartsWithASCII(path, "cros.session.proxy", true); | 289 return ::StartsWithASCII(path, "cros.session.proxy", true); |
289 } | 290 } |
290 | 291 |
291 //----------------- ProxyCrosSettingsProvider: private methods ----------------- | 292 //----------------- ProxyCrosSettingsProvider: private methods ----------------- |
292 | 293 |
293 chromeos::ProxyConfigServiceImpl* | 294 chromeos::ProxyConfigServiceImpl* |
294 ProxyCrosSettingsProvider::GetConfigService() const { | 295 ProxyCrosSettingsProvider::GetConfigService() const { |
295 Browser* browser = BrowserList::GetLastActive(); | 296 return g_browser_process->chromeos_proxy_config_service_impl(); |
296 // browser is NULL at OOBE/login stage. | |
297 Profile* profile = browser ? | |
298 browser->profile() : | |
299 ProfileManager::GetDefaultProfile(); | |
300 return profile->GetChromeOSProxyConfigServiceImpl(); | |
301 } | 297 } |
302 | 298 |
303 void ProxyCrosSettingsProvider::AppendPortIfValid( | 299 void ProxyCrosSettingsProvider::AppendPortIfValid( |
304 const char* port_cache_key, | 300 const char* port_cache_key, |
305 std::string* server_uri) { | 301 std::string* server_uri) { |
306 std::string port; | 302 std::string port; |
307 if (!server_uri->empty() && cache_.GetString(port_cache_key, &port) && | 303 if (!server_uri->empty() && cache_.GetString(port_cache_key, &port) && |
308 !port.empty()) { | 304 !port.empty()) { |
309 *server_uri += ":" + port; | 305 *server_uri += ":" + port; |
310 } | 306 } |
(...skipping 20 matching lines...) Expand all Loading... |
331 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : | 327 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : |
332 NULL; | 328 NULL; |
333 } | 329 } |
334 | 330 |
335 void ProxyCrosSettingsProvider::SetCache(const std::string& key, | 331 void ProxyCrosSettingsProvider::SetCache(const std::string& key, |
336 const Value* value) { | 332 const Value* value) { |
337 cache_.Set(key, value->DeepCopy()); | 333 cache_.Set(key, value->DeepCopy()); |
338 } | 334 } |
339 | 335 |
340 } // namespace chromeos | 336 } // namespace chromeos |
OLD | NEW |