Index: extensions/browser/api/networking_private/networking_private_chromeos.cc |
diff --git a/extensions/browser/api/networking_private/networking_private_chromeos.cc b/extensions/browser/api/networking_private/networking_private_chromeos.cc |
index b580cdae8b3d9e7e339aae226efff817cd516426..157cc7ec13d0ca4a0cbba06b485ad6cffece2a8a 100644 |
--- a/extensions/browser/api/networking_private/networking_private_chromeos.cc |
+++ b/extensions/browser/api/networking_private/networking_private_chromeos.cc |
@@ -199,6 +199,22 @@ base::DictionaryValue* GetThirdPartyVPNDictionary( |
return third_party_vpn; |
} |
+const chromeos::DeviceState* GetCellularDeviceState(const std::string& guid) { |
michaelpg
2016/09/06 21:10:38
chromeos::DeviceState is using'd at the top of the
stevenjb
2016/09/12 19:46:42
I remove the 'using'.
|
+ const chromeos::NetworkState* network_state = nullptr; |
+ if (!guid.empty()) |
+ network_state = GetStateHandler()->GetNetworkStateFromGuid(guid); |
+ const chromeos::DeviceState* device_state = nullptr; |
+ if (network_state) { |
+ device_state = |
+ GetStateHandler()->GetDeviceState(network_state->device_path()); |
+ } |
+ if (!device_state) { |
+ device_state = |
+ GetStateHandler()->GetDeviceStateByType(NetworkTypePattern::Cellular()); |
+ } |
+ return device_state; |
+} |
+ |
} // namespace |
//////////////////////////////////////////////////////////////////////////////// |
@@ -484,14 +500,7 @@ void NetworkingPrivateChromeOS::UnlockCellularSim( |
const std::string& puk, |
const VoidCallback& success_callback, |
const FailureCallback& failure_callback) { |
- const chromeos::NetworkState* network_state = |
- GetStateHandler()->GetNetworkStateFromGuid(guid); |
- if (!network_state) { |
- failure_callback.Run(networking_private::kErrorNetworkUnavailable); |
- return; |
- } |
- const chromeos::DeviceState* device_state = |
- GetStateHandler()->GetDeviceState(network_state->device_path()); |
+ const chromeos::DeviceState* device_state = GetCellularDeviceState(guid); |
if (!device_state) { |
failure_callback.Run(networking_private::kErrorNetworkUnavailable); |
return; |
@@ -522,14 +531,7 @@ void NetworkingPrivateChromeOS::SetCellularSimState( |
const std::string& new_pin, |
const VoidCallback& success_callback, |
const FailureCallback& failure_callback) { |
- const chromeos::NetworkState* network_state = |
- GetStateHandler()->GetNetworkStateFromGuid(guid); |
- if (!network_state) { |
- failure_callback.Run(networking_private::kErrorNetworkUnavailable); |
- return; |
- } |
- const chromeos::DeviceState* device_state = |
- GetStateHandler()->GetDeviceState(network_state->device_path()); |
+ const chromeos::DeviceState* device_state = GetCellularDeviceState(guid); |
if (!device_state) { |
failure_callback.Run(networking_private::kErrorNetworkUnavailable); |
return; |