Chromium Code Reviews| 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 "chromeos/network/shill_property_handler.h" | 5 #include "chromeos/network/shill_property_handler.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/string_util.h" | |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
| 14 #include "chromeos/dbus/shill_device_client.h" | 15 #include "chromeos/dbus/shill_device_client.h" |
| 15 #include "chromeos/dbus/shill_ipconfig_client.h" | 16 #include "chromeos/dbus/shill_ipconfig_client.h" |
| 16 #include "chromeos/dbus/shill_manager_client.h" | 17 #include "chromeos/dbus/shill_manager_client.h" |
| 17 #include "chromeos/dbus/shill_profile_client.h" | 18 #include "chromeos/dbus/shill_profile_client.h" |
| 18 #include "chromeos/dbus/shill_service_client.h" | 19 #include "chromeos/dbus/shill_service_client.h" |
| 19 #include "chromeos/network/network_state.h" | 20 #include "chromeos/network/network_state.h" |
| 20 #include "components/device_event_log/device_event_log.h" | 21 #include "components/device_event_log/device_event_log.h" |
| 21 #include "dbus/object_path.h" | 22 #include "dbus/object_path.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 Handler handler_; | 98 Handler handler_; |
| 98 | 99 |
| 99 DISALLOW_COPY_AND_ASSIGN(ShillPropertyObserver); | 100 DISALLOW_COPY_AND_ASSIGN(ShillPropertyObserver); |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 //------------------------------------------------------------------------------ | 103 //------------------------------------------------------------------------------ |
| 103 // ShillPropertyHandler | 104 // ShillPropertyHandler |
| 104 | 105 |
| 105 ShillPropertyHandler::ShillPropertyHandler(Listener* listener) | 106 ShillPropertyHandler::ShillPropertyHandler(Listener* listener) |
| 106 : listener_(listener), | 107 : listener_(listener), |
| 107 shill_manager_(DBusThreadManager::Get()->GetShillManagerClient()) { | 108 shill_manager_(DBusThreadManager::Get()->GetShillManagerClient()) {} |
| 108 } | |
| 109 | 109 |
| 110 ShillPropertyHandler::~ShillPropertyHandler() { | 110 ShillPropertyHandler::~ShillPropertyHandler() { |
| 111 // Delete network service observers. | 111 // Delete network service observers. |
| 112 STLDeleteContainerPairSecondPointers(observed_networks_.begin(), | 112 STLDeleteContainerPairSecondPointers(observed_networks_.begin(), |
| 113 observed_networks_.end()); | 113 observed_networks_.end()); |
| 114 STLDeleteContainerPairSecondPointers(observed_devices_.begin(), | 114 STLDeleteContainerPairSecondPointers(observed_devices_.begin(), |
| 115 observed_devices_.end()); | 115 observed_devices_.end()); |
| 116 CHECK(shill_manager_ == DBusThreadManager::Get()->GetShillManagerClient()); | 116 CHECK(shill_manager_ == DBusThreadManager::Get()->GetShillManagerClient()); |
| 117 shill_manager_->RemovePropertyChangedObserver(this); | 117 shill_manager_->RemovePropertyChangedObserver(this); |
| 118 } | 118 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 146 bool ShillPropertyHandler::IsTechnologyUninitialized( | 146 bool ShillPropertyHandler::IsTechnologyUninitialized( |
| 147 const std::string& technology) const { | 147 const std::string& technology) const { |
| 148 return uninitialized_technologies_.count(technology) != 0; | 148 return uninitialized_technologies_.count(technology) != 0; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void ShillPropertyHandler::SetTechnologyEnabled( | 151 void ShillPropertyHandler::SetTechnologyEnabled( |
| 152 const std::string& technology, | 152 const std::string& technology, |
| 153 bool enabled, | 153 bool enabled, |
| 154 const network_handler::ErrorCallback& error_callback) { | 154 const network_handler::ErrorCallback& error_callback) { |
| 155 if (enabled) { | 155 if (enabled) { |
| 156 if (prohibited_technologies_.find(technology) != | |
| 157 prohibited_technologies_.end()) { | |
| 158 chromeos::network_handler::RunErrorCallback( | |
| 159 error_callback, "", "prohibited_technologies", | |
| 160 "Ignored: Attempt to enable prohibited network technology " + | |
| 161 technology); | |
| 162 return; | |
| 163 } | |
| 156 enabling_technologies_.insert(technology); | 164 enabling_technologies_.insert(technology); |
| 157 shill_manager_->EnableTechnology( | 165 shill_manager_->EnableTechnology( |
| 158 technology, base::Bind(&base::DoNothing), | 166 technology, base::Bind(&base::DoNothing), |
| 159 base::Bind(&ShillPropertyHandler::EnableTechnologyFailed, AsWeakPtr(), | 167 base::Bind(&ShillPropertyHandler::EnableTechnologyFailed, AsWeakPtr(), |
| 160 technology, error_callback)); | 168 technology, error_callback)); |
| 161 } else { | 169 } else { |
| 162 // Immediately clear locally from enabled and enabling lists. | 170 // Immediately clear locally from enabled and enabling lists. |
| 163 enabled_technologies_.erase(technology); | 171 enabled_technologies_.erase(technology); |
| 164 enabling_technologies_.erase(technology); | 172 enabling_technologies_.erase(technology); |
| 165 shill_manager_->DisableTechnology( | 173 shill_manager_->DisableTechnology( |
| 166 technology, base::Bind(&base::DoNothing), | 174 technology, base::Bind(&base::DoNothing), |
| 167 base::Bind(&network_handler::ShillErrorCallbackFunction, | 175 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 168 "SetTechnologyEnabled Failed", technology, error_callback)); | 176 "SetTechnologyEnabled Failed", technology, error_callback)); |
| 169 } | 177 } |
| 170 } | 178 } |
| 171 | 179 |
| 180 void ShillPropertyHandler::SetProhibitedTechnologies( | |
| 181 const std::vector<std::string>& prohibited_technologies, | |
| 182 const network_handler::ErrorCallback& error_callback) { | |
| 183 prohibited_technologies_.clear(); | |
| 184 for (const auto& technology : prohibited_technologies) | |
| 185 prohibited_technologies_.insert(technology); | |
|
stevenjb
2015/11/12 18:20:38
prohibited_technologies_.insert(prohibited_technol
fqj
2015/11/13 13:53:49
Done.
| |
| 186 | |
| 187 // Remove technologies from the other lists. | |
| 188 // And manually disable them. | |
| 189 for (const auto& technology : prohibited_technologies) { | |
| 190 enabling_technologies_.erase(technology); | |
| 191 enabled_technologies_.erase(technology); | |
| 192 shill_manager_->DisableTechnology( | |
| 193 technology, base::Bind(&base::DoNothing), | |
| 194 base::Bind(&network_handler::ShillErrorCallbackFunction, | |
| 195 "DisableTechnology Failed", technology, error_callback)); | |
| 196 } | |
| 197 | |
| 198 // Send updated prohibited technology list to shill. | |
| 199 const std::string prohibited_list = | |
| 200 base::JoinString(prohibited_technologies, ","); | |
| 201 base::StringValue value(prohibited_list); | |
| 202 shill_manager_->SetProperty( | |
| 203 "ProhibitedTechnologies", value, base::Bind(&base::DoNothing), | |
| 204 base::Bind(&network_handler::ShillErrorCallbackFunction, | |
| 205 "SetTechnologiesProhibited Failed", prohibited_list, | |
| 206 error_callback)); | |
| 207 } | |
| 208 | |
| 172 void ShillPropertyHandler::SetCheckPortalList( | 209 void ShillPropertyHandler::SetCheckPortalList( |
| 173 const std::string& check_portal_list) { | 210 const std::string& check_portal_list) { |
| 174 base::StringValue value(check_portal_list); | 211 base::StringValue value(check_portal_list); |
| 175 shill_manager_->SetProperty( | 212 shill_manager_->SetProperty( |
| 176 shill::kCheckPortalListProperty, value, base::Bind(&base::DoNothing), | 213 shill::kCheckPortalListProperty, value, base::Bind(&base::DoNothing), |
| 177 base::Bind(&network_handler::ShillErrorCallbackFunction, | 214 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 178 "SetCheckPortalList Failed", "Manager", | 215 "SetCheckPortalList Failed", "Manager", |
| 179 network_handler::ErrorCallback())); | 216 network_handler::ErrorCallback())); |
| 180 } | 217 } |
| 181 | 218 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 NET_LOG(EVENT) << "Failed to get IP Config properties: " << ip_config_path | 553 NET_LOG(EVENT) << "Failed to get IP Config properties: " << ip_config_path |
| 517 << ": " << call_status << ", For: " << path; | 554 << ": " << call_status << ", For: " << path; |
| 518 return; | 555 return; |
| 519 } | 556 } |
| 520 NET_LOG(EVENT) << "IP Config properties received: " << path; | 557 NET_LOG(EVENT) << "IP Config properties received: " << path; |
| 521 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); | 558 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); |
| 522 } | 559 } |
| 523 | 560 |
| 524 } // namespace internal | 561 } // namespace internal |
| 525 } // namespace chromeos | 562 } // namespace chromeos |
| OLD | NEW |