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

Unified Diff: extensions/browser/api/networking_private/networking_private_chromeos.cc

Issue 2303093003: MD Settings: Internet: Enable SIM unlock with no cellular network (Closed)
Patch Set: . Created 4 years, 3 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
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;

Powered by Google App Engine
This is Rietveld 408576698