Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Unified Diff: chromeos/network/network_device_handler_impl.cc

Issue 2202693005: Don't set MAC address randomization when unsupported (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/network_device_handler_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_device_handler_impl.cc
diff --git a/chromeos/network/network_device_handler_impl.cc b/chromeos/network/network_device_handler_impl.cc
index d1b1d05d633d019fcac723fa0767606a5af9c7ad..068706915574b958a241ccab50a98c4521c2482f 100644
--- a/chromeos/network/network_device_handler_impl.cc
+++ b/chromeos/network/network_device_handler_impl.cc
@@ -434,7 +434,7 @@ void NetworkDeviceHandlerImpl::SetCellularAllowRoaming(
void NetworkDeviceHandlerImpl::SetMACAddressRandomizationEnabled(
const bool enabled) {
- mac_addr_randomization_ = enabled;
+ mac_addr_randomization_enabled_ = enabled;
ApplyMACAddressRandomizationToShill();
}
@@ -532,7 +532,8 @@ void NetworkDeviceHandlerImpl::DeviceListChanged() {
NetworkDeviceHandlerImpl::NetworkDeviceHandlerImpl()
: network_state_handler_(NULL),
cellular_allow_roaming_(false),
- mac_addr_randomization_(false) {}
+ mac_addr_randomization_supported_(true),
+ mac_addr_randomization_enabled_(false) {}
void NetworkDeviceHandlerImpl::Init(
NetworkStateHandler* network_state_handler) {
@@ -573,16 +574,28 @@ void NetworkDeviceHandlerImpl::ApplyCellularAllowRoamingToShill() {
}
void NetworkDeviceHandlerImpl::ApplyMACAddressRandomizationToShill() {
+ if (!mac_addr_randomization_supported_)
+ return;
+
const DeviceState* device_state =
GetWifiDeviceState(network_handler::ErrorCallback());
if (!device_state)
return;
- SetDevicePropertyInternal(device_state->path(),
- shill::kMACAddressRandomizationProperty,
- base::FundamentalValue(mac_addr_randomization_),
- base::Bind(&base::DoNothing),
- network_handler::ErrorCallback());
+ SetDevicePropertyInternal(
+ device_state->path(), shill::kMACAddressRandomizationProperty,
+ base::FundamentalValue(mac_addr_randomization_enabled_),
+ base::Bind(&base::DoNothing),
+ base::Bind(
+ &NetworkDeviceHandlerImpl::SetMACAddressRandomizationErrorCallback,
+ base::Unretained(this)));
stevenjb 2016/08/02 22:42:34 We need to use a weak ptr here, otherwise the erro
+}
+
+void NetworkDeviceHandlerImpl::SetMACAddressRandomizationErrorCallback(
+ const std::string& error_name,
+ std::unique_ptr<base::DictionaryValue> error_data) {
+ if (error_name == NetworkDeviceHandler::kErrorNotSupported)
+ mac_addr_randomization_supported_ = false;
}
const DeviceState* NetworkDeviceHandlerImpl::GetWifiDeviceState(
« no previous file with comments | « chromeos/network/network_device_handler_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698