| OLD | NEW |
| 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_config_service_impl.h" | 5 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 void ProxyConfigServiceImpl::RegisterPrefs(PrefService* pref_service) { | 579 void ProxyConfigServiceImpl::RegisterPrefs(PrefService* pref_service) { |
| 580 // Use shared proxies default to off. GetUseSharedProxies will return the | 580 // Use shared proxies default to off. GetUseSharedProxies will return the |
| 581 // correct value based on pre-login and login. | 581 // correct value based on pre-login and login. |
| 582 pref_service->RegisterBooleanPref(prefs::kUseSharedProxies, | 582 pref_service->RegisterBooleanPref(prefs::kUseSharedProxies, |
| 583 true, | 583 true, |
| 584 PrefService::UNSYNCABLE_PREF); | 584 PrefService::UNSYNCABLE_PREF); |
| 585 } | 585 } |
| 586 | 586 |
| 587 //------------------ ProxyConfigServiceImpl: private methods ------------------- | 587 //------------------ ProxyConfigServiceImpl: private methods ------------------- |
| 588 | 588 |
| 589 void ProxyConfigServiceImpl::Observe( | 589 void ProxyConfigServiceImpl::OnPreferenceChanged(PrefServiceBase* service, |
| 590 int type, | 590 const std::string& pref_name) { |
| 591 const content::NotificationSource& source, | 591 DCHECK(service == prefs()); |
| 592 const content::NotificationDetails& details) { | 592 VLOG(1) << "New use-shared-proxies = " << GetUseSharedProxies(); |
| 593 if (type == chrome::NOTIFICATION_PREF_CHANGED && | 593 |
| 594 *(content::Details<std::string>(details).ptr()) == | 594 if (pref_name == prefs::kUseSharedProxies) { |
| 595 prefs::kUseSharedProxies) { | 595 // Determine new proxy config which may have changed because of new |
| 596 if (content::Source<PrefService>(source).ptr() == prefs()) { | 596 // use-shared-proxies. If necessary, activate it. |
| 597 VLOG(1) << "New use-shared-proxies = " << GetUseSharedProxies(); | 597 Network* network = NULL; |
| 598 // Determine new proxy config which may have changed because of new | 598 if (!active_network_.empty()) { |
| 599 // use-shared-proxies. If necessary, activate it. | 599 network = CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath( |
| 600 Network* network = NULL; | 600 active_network_); |
| 601 if (!active_network_.empty()) { | 601 if (!network) |
| 602 network = CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath( | 602 LOG(WARNING) << "Can't find requested network " << active_network_; |
| 603 active_network_); | |
| 604 if (!network) | |
| 605 LOG(WARNING) << "Can't find requested network " << active_network_; | |
| 606 } | |
| 607 DetermineEffectiveConfig(network, true); | |
| 608 } | 603 } |
| 604 DetermineEffectiveConfig(network, true); |
| 609 return; | 605 return; |
| 610 } | 606 } |
| 611 PrefProxyConfigTrackerImpl::Observe(type, source, details); | 607 |
| 608 PrefProxyConfigTrackerImpl::OnPreferenceChanged(service, pref_name); |
| 612 } | 609 } |
| 613 | 610 |
| 614 void ProxyConfigServiceImpl::OnUISetProxyConfig() { | 611 void ProxyConfigServiceImpl::OnUISetProxyConfig() { |
| 615 if (current_ui_network_.empty()) | 612 if (current_ui_network_.empty()) |
| 616 return; | 613 return; |
| 617 // Update config to shill. | 614 // Update config to shill. |
| 618 std::string value; | 615 std::string value; |
| 619 if (current_ui_config_.SerializeForNetwork(&value)) { | 616 if (current_ui_config_.SerializeForNetwork(&value)) { |
| 620 VLOG(1) << "Set proxy (mode=" << current_ui_config_.mode | 617 VLOG(1) << "Set proxy (mode=" << current_ui_config_.mode |
| 621 << ") for " << current_ui_network_; | 618 << ") for " << current_ui_network_; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 device_config_.clear(); | 843 device_config_.clear(); |
| 847 return; | 844 return; |
| 848 } | 845 } |
| 849 if (!active_network_.empty()) { | 846 if (!active_network_.empty()) { |
| 850 VLOG(1) << "Try migrating device config to " << active_network_; | 847 VLOG(1) << "Try migrating device config to " << active_network_; |
| 851 SetProxyConfigForNetwork(active_network_, device_config_, true); | 848 SetProxyConfigForNetwork(active_network_, device_config_, true); |
| 852 } | 849 } |
| 853 } | 850 } |
| 854 | 851 |
| 855 } // namespace chromeos | 852 } // namespace chromeos |
| OLD | NEW |