Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_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/json/json_value_serializer.h" | 9 #include "base/json/json_value_serializer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 NOTREACHED(); | 464 NOTREACHED(); |
| 465 VLOG(1) << "Cannot set bypass rules for proxy mode [" | 465 VLOG(1) << "Cannot set bypass rules for proxy mode [" |
| 466 << current_ui_config_.mode << "]"; | 466 << current_ui_config_.mode << "]"; |
| 467 return false; | 467 return false; |
| 468 } | 468 } |
| 469 current_ui_config_.bypass_rules = bypass_rules; | 469 current_ui_config_.bypass_rules = bypass_rules; |
| 470 OnUISetProxyConfig(); | 470 OnUISetProxyConfig(); |
| 471 return true; | 471 return true; |
| 472 } | 472 } |
| 473 | 473 |
| 474 void ProxyConfigServiceImpl::AddNotificationCallback(base::Closure callback) { | |
| 475 std::vector<base::Closure>::iterator iter = callbacks_.begin(); | |
| 476 for (;iter != callbacks_.end(); ++iter) { | |
|
kuan
2011/11/10 14:27:25
s/;iter/; iter/
pastarmovj
2011/11/10 16:08:26
Done.
| |
| 477 if (callback.Equals(*iter)) { | |
| 478 return; | |
| 479 } | |
|
kuan
2011/11/10 14:27:25
don't need curly braces
pastarmovj
2011/11/10 16:08:26
Done.
| |
| 480 } | |
| 481 callbacks_.push_back(callback); | |
| 482 } | |
| 483 | |
| 484 void ProxyConfigServiceImpl::RemoveNotificationCallback( | |
| 485 base::Closure callback) { | |
| 486 std::vector<base::Closure>::iterator iter = callbacks_.begin(); | |
| 487 for (;iter != callbacks_.end(); ++iter) { | |
|
kuan
2011/11/10 14:27:25
s/;iter/; iter/
pastarmovj
2011/11/10 16:08:26
Done.
| |
| 488 if (callback.Equals(*iter)) { | |
| 489 callbacks_.erase(iter); | |
| 490 return; | |
| 491 } | |
| 492 } | |
| 493 } | |
| 494 | |
| 474 void ProxyConfigServiceImpl::OnProxyConfigChanged( | 495 void ProxyConfigServiceImpl::OnProxyConfigChanged( |
| 475 ProxyPrefs::ConfigState config_state, | 496 ProxyPrefs::ConfigState config_state, |
| 476 const net::ProxyConfig& config) { | 497 const net::ProxyConfig& config) { |
| 477 VLOG(1) << this << ": got prefs change: " << ConfigStateToString(config_state) | 498 VLOG(1) << this << ": got prefs change: " << ConfigStateToString(config_state) |
| 478 << ", mode=" << config.proxy_rules().type; | 499 << ", mode=" << config.proxy_rules().type; |
| 479 Network* network = NULL; | 500 Network* network = NULL; |
| 480 if (!active_network_.empty()) { | 501 if (!active_network_.empty()) { |
| 481 network = CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath( | 502 network = CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath( |
| 482 active_network_); | 503 active_network_); |
| 483 if (!network) | 504 if (!network) |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 } | 776 } |
| 756 | 777 |
| 757 void ProxyConfigServiceImpl::OnUISetCurrentNetwork(const Network* network) { | 778 void ProxyConfigServiceImpl::OnUISetCurrentNetwork(const Network* network) { |
| 758 DetermineEffectiveConfig(network, false); | 779 DetermineEffectiveConfig(network, false); |
| 759 VLOG(1) << this << ": current ui network: " | 780 VLOG(1) << this << ": current ui network: " |
| 760 << (network->name().empty() ? | 781 << (network->name().empty() ? |
| 761 current_ui_network_ : network->name()) | 782 current_ui_network_ : network->name()) |
| 762 << ", " << ModeToString(current_ui_config_.mode) | 783 << ", " << ModeToString(current_ui_config_.mode) |
| 763 << ", " << ConfigStateToString(current_ui_config_.state) | 784 << ", " << ConfigStateToString(current_ui_config_.state) |
| 764 << ", modifiable:" << current_ui_config_.user_modifiable; | 785 << ", modifiable:" << current_ui_config_.user_modifiable; |
| 786 // Notify whoever is interested in this change. | |
| 787 std::vector<base::Closure>::iterator iter = callbacks_.begin(); | |
| 788 while (iter != callbacks_.end()) { | |
| 789 if (iter->is_null()) { | |
| 790 iter = callbacks_.erase(iter); | |
| 791 } else { | |
| 792 iter->Run(); | |
| 793 iter++; | |
|
kuan
2011/11/10 14:27:25
pre-increment
pastarmovj
2011/11/10 16:08:26
Done.
| |
| 794 } | |
| 795 } | |
| 765 } | 796 } |
| 766 | 797 |
| 767 void ProxyConfigServiceImpl::ResetUICache() { | 798 void ProxyConfigServiceImpl::ResetUICache() { |
| 768 current_ui_network_.clear(); | 799 current_ui_network_.clear(); |
| 769 current_ui_config_ = ProxyConfig(); | 800 current_ui_config_ = ProxyConfig(); |
| 770 } | 801 } |
| 771 | 802 |
| 772 } // namespace chromeos | 803 } // namespace chromeos |
| OLD | NEW |