| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 : PrefProxyConfigTrackerImpl(pref_service), | 385 : PrefProxyConfigTrackerImpl(pref_service), |
| 386 active_config_state_(ProxyPrefs::CONFIG_UNSET), | 386 active_config_state_(ProxyPrefs::CONFIG_UNSET), |
| 387 pointer_factory_(this) { | 387 pointer_factory_(this) { |
| 388 | 388 |
| 389 // Register for notifications of UseSharedProxies user preference. | 389 // Register for notifications of UseSharedProxies user preference. |
| 390 if (pref_service->FindPreference(prefs::kUseSharedProxies)) | 390 if (pref_service->FindPreference(prefs::kUseSharedProxies)) |
| 391 use_shared_proxies_.Init(prefs::kUseSharedProxies, pref_service, this); | 391 use_shared_proxies_.Init(prefs::kUseSharedProxies, pref_service, this); |
| 392 | 392 |
| 393 FetchProxyPolicy(); | 393 FetchProxyPolicy(); |
| 394 | 394 |
| 395 // Register for flimflam network notifications. | 395 // Register for shill network notifications. |
| 396 NetworkLibrary* network_lib = CrosLibrary::Get()->GetNetworkLibrary(); | 396 NetworkLibrary* network_lib = CrosLibrary::Get()->GetNetworkLibrary(); |
| 397 OnActiveNetworkChanged(network_lib, network_lib->active_network()); | 397 OnActiveNetworkChanged(network_lib, network_lib->active_network()); |
| 398 network_lib->AddNetworkManagerObserver(this); | 398 network_lib->AddNetworkManagerObserver(this); |
| 399 } | 399 } |
| 400 | 400 |
| 401 ProxyConfigServiceImpl::~ProxyConfigServiceImpl() { | 401 ProxyConfigServiceImpl::~ProxyConfigServiceImpl() { |
| 402 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); | 402 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); |
| 403 if (netlib) { | 403 if (netlib) { |
| 404 netlib->RemoveNetworkManagerObserver(this); | 404 netlib->RemoveNetworkManagerObserver(this); |
| 405 netlib->RemoveObserverForAllNetworks(this); | 405 netlib->RemoveObserverForAllNetworks(this); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 DetermineEffectiveConfig(network, true); | 593 DetermineEffectiveConfig(network, true); |
| 594 } | 594 } |
| 595 return; | 595 return; |
| 596 } | 596 } |
| 597 PrefProxyConfigTrackerImpl::Observe(type, source, details); | 597 PrefProxyConfigTrackerImpl::Observe(type, source, details); |
| 598 } | 598 } |
| 599 | 599 |
| 600 void ProxyConfigServiceImpl::OnUISetProxyConfig() { | 600 void ProxyConfigServiceImpl::OnUISetProxyConfig() { |
| 601 if (current_ui_network_.empty()) | 601 if (current_ui_network_.empty()) |
| 602 return; | 602 return; |
| 603 // Update config to flimflam. | 603 // Update config to shill. |
| 604 std::string value; | 604 std::string value; |
| 605 if (current_ui_config_.SerializeForNetwork(&value)) { | 605 if (current_ui_config_.SerializeForNetwork(&value)) { |
| 606 VLOG(1) << "Set proxy (mode=" << current_ui_config_.mode | 606 VLOG(1) << "Set proxy (mode=" << current_ui_config_.mode |
| 607 << ") for " << current_ui_network_; | 607 << ") for " << current_ui_network_; |
| 608 current_ui_config_.state = ProxyPrefs::CONFIG_SYSTEM; | 608 current_ui_config_.state = ProxyPrefs::CONFIG_SYSTEM; |
| 609 SetProxyConfigForNetwork(current_ui_network_, value, false); | 609 SetProxyConfigForNetwork(current_ui_network_, value, false); |
| 610 } | 610 } |
| 611 } | 611 } |
| 612 | 612 |
| 613 void ProxyConfigServiceImpl::OnActiveNetworkChanged(NetworkLibrary* network_lib, | 613 void ProxyConfigServiceImpl::OnActiveNetworkChanged(NetworkLibrary* network_lib, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 648 |
| 649 VLOG(1) << "New active network: path=" << active_network->service_path() | 649 VLOG(1) << "New active network: path=" << active_network->service_path() |
| 650 << ", name=" << active_network->name() | 650 << ", name=" << active_network->name() |
| 651 << ", profile=" << active_network->profile_type() | 651 << ", profile=" << active_network->profile_type() |
| 652 << "," << active_network->profile_path() | 652 << "," << active_network->profile_path() |
| 653 << ", proxy=" << active_network->proxy_config(); | 653 << ", proxy=" << active_network->proxy_config(); |
| 654 | 654 |
| 655 // Register observer for new network. | 655 // Register observer for new network. |
| 656 network_lib->AddNetworkObserver(active_network_, this); | 656 network_lib->AddNetworkObserver(active_network_, this); |
| 657 | 657 |
| 658 // If necessary, migrate config to flimflam. | 658 // If necessary, migrate config to shill. |
| 659 if (active_network->proxy_config().empty() && !device_config_.empty()) { | 659 if (active_network->proxy_config().empty() && !device_config_.empty()) { |
| 660 VLOG(1) << "Try migrating device config to " << active_network_; | 660 VLOG(1) << "Try migrating device config to " << active_network_; |
| 661 SetProxyConfigForNetwork(active_network_, device_config_, true); | 661 SetProxyConfigForNetwork(active_network_, device_config_, true); |
| 662 } else { | 662 } else { |
| 663 // Otherwise, determine and activate possibly new effective proxy config. | 663 // Otherwise, determine and activate possibly new effective proxy config. |
| 664 DetermineEffectiveConfig(active_network, true); | 664 DetermineEffectiveConfig(active_network, true); |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 | 667 |
| 668 void ProxyConfigServiceImpl::SetProxyConfigForNetwork( | 668 void ProxyConfigServiceImpl::SetProxyConfigForNetwork( |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 device_config_.clear(); | 838 device_config_.clear(); |
| 839 return; | 839 return; |
| 840 } | 840 } |
| 841 if (!active_network_.empty()) { | 841 if (!active_network_.empty()) { |
| 842 VLOG(1) << "Try migrating device config to " << active_network_; | 842 VLOG(1) << "Try migrating device config to " << active_network_; |
| 843 SetProxyConfigForNetwork(active_network_, device_config_, true); | 843 SetProxyConfigForNetwork(active_network_, device_config_, true); |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 | 846 |
| 847 } // namespace chromeos | 847 } // namespace chromeos |
| OLD | NEW |