diff options
author | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-23 02:24:10 +0000 |
---|---|---|
committer | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-23 02:24:10 +0000 |
commit | 3d823b16bfc15a4120b3cb6c047f846bebb4ea54 (patch) | |
tree | 8ffd7120d9b1f0d9434221eabcbabc149b58d946 | |
parent | b43ae0c19c1119424251128f2894753864877a17 (diff) | |
download | chromium_src-3d823b16bfc15a4120b3cb6c047f846bebb4ea54.zip chromium_src-3d823b16bfc15a4120b3cb6c047f846bebb4ea54.tar.gz chromium_src-3d823b16bfc15a4120b3cb6c047f846bebb4ea54.tar.bz2 |
Launch SIM unlock dialog from login UI if the SIM is locked.
If the cellular modem is locked, it appears as a disabled technology in the
login UI. A locked cellular device must be unlocked before the device can be
enabled, so the SIM unlock dialog should be shown.
BUG=167687
R=stevenjb@chromium.org
Review URL: https://codereview.chromium.org/23319003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219191 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 61 insertions, 24 deletions
diff --git a/ash/system/chromeos/network/network_connect.cc b/ash/system/chromeos/network/network_connect.cc index 433f9bd..0de9679 100644 --- a/ash/system/chromeos/network/network_connect.cc +++ b/ash/system/chromeos/network/network_connect.cc @@ -260,6 +260,57 @@ void ConnectToNetwork(const std::string& service_path, CallConnectToNetwork(service_path, check_error_state, owning_window); } +void SetTechnologyEnabled(const std::string& technology, bool enabled_state) { + std::string log_string = + base::StringPrintf("technology %s, target state: %s", + technology.c_str(), + (enabled_state ? "ENABLED" : "DISABLED")); + NET_LOG_USER("SetTechnologyEnabled", log_string); + NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); + bool enabled = handler->IsTechnologyEnabled(technology); + if (enabled_state == enabled) { + NET_LOG_USER("Technology already in target state.", log_string); + return; + } + if (enabled) { + // User requested to disable the technology. + handler->SetTechnologyEnabled( + technology, false, chromeos::network_handler::ErrorCallback()); + return; + } + // If we're dealing with a mobile network, then handle SIM lock here. + // SIM locking only applies to cellular, so the code below won't execute + // if |technology| has been explicitly set to WiMAX. + if (technology == NetworkStateHandler::kMatchTypeMobile || + technology == flimflam::kTypeCellular) { + const DeviceState* mobile = handler->GetDeviceStateByType(technology); + if (!mobile) { + NET_LOG_ERROR("SetTechnologyEnabled with no device", log_string); + return; + } + // The following only applies to cellular. + if (mobile->type() == flimflam::kTypeCellular) { + if (mobile->IsSimAbsent()) { + // If this is true, then we have a cellular device with no SIM inserted. + // TODO(armansito): Chrome should display a notification here, prompting + // the user to insert a SIM card and restart the device to enable + // cellular. See crbug.com/125171. + NET_LOG_USER("Cannot enable cellular device without SIM.", log_string); + return; + } + if (!mobile->sim_lock_type().empty()) { + // A SIM has been inserted, but it is locked. Let the user unlock it + // via the dialog. + ash::Shell::GetInstance()->system_tray_delegate()-> + ShowMobileSimDialog(); + return; + } + } + } + handler->SetTechnologyEnabled( + technology, true, chromeos::network_handler::ErrorCallback()); +} + void ActivateCellular(const std::string& service_path) { NET_LOG_USER("ActivateCellular", service_path); const NetworkState* cellular = diff --git a/ash/system/chromeos/network/network_connect.h b/ash/system/chromeos/network/network_connect.h index 3b40ec8..4940059 100644 --- a/ash/system/chromeos/network/network_connect.h +++ b/ash/system/chromeos/network/network_connect.h @@ -24,6 +24,12 @@ namespace network_connect { ASH_EXPORT void ConnectToNetwork(const std::string& service_path, gfx::NativeWindow owning_window); +// Enables or disables a network technology. If |technology| refers to cellular +// and the device cannot be enabled due to a SIM lock, this function will +// launch the SIM unlock dialog. +ASH_EXPORT void SetTechnologyEnabled(const std::string& technology, + bool enabled_state); + // Requests network activation and handles any errors and notifications. ASH_EXPORT void ActivateCellular(const std::string& service_path); diff --git a/ash/system/chromeos/network/network_state_list_detailed_view.cc b/ash/system/chromeos/network/network_state_list_detailed_view.cc index 64e6d3b..03a181e 100644 --- a/ash/system/chromeos/network/network_state_list_detailed_view.cc +++ b/ash/system/chromeos/network/network_state_list_detailed_view.cc @@ -856,25 +856,8 @@ void NetworkStateListDetailedView::ToggleMobile() { NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); bool enabled = handler->IsTechnologyEnabled(NetworkStateHandler::kMatchTypeMobile); - if (enabled) { - handler->SetTechnologyEnabled( - NetworkStateHandler::kMatchTypeMobile, false, - chromeos::network_handler::ErrorCallback()); - } else { - const DeviceState* mobile = - handler->GetDeviceStateByType(NetworkStateHandler::kMatchTypeMobile); - if (!mobile) { - LOG(ERROR) << "Mobile device not found."; - return; - } - if (!mobile->sim_lock_type().empty() || mobile->IsSimAbsent()) { - ash::Shell::GetInstance()->system_tray_delegate()->ShowMobileSimDialog(); - } else { - handler->SetTechnologyEnabled( - NetworkStateHandler::kMatchTypeMobile, true, - chromeos::network_handler::ErrorCallback()); - } - } + ash::network_connect::SetTechnologyEnabled( + NetworkStateHandler::kMatchTypeMobile, !enabled); } } // namespace tray diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc index ceca662..e4ebe740 100644 --- a/chrome/browser/chromeos/status/network_menu.cc +++ b/chrome/browser/chromeos/status/network_menu.cc @@ -18,6 +18,7 @@ #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/mobile_config.h" #include "chrome/browser/chromeos/options/network_config_view.h" +#include "chrome/browser/chromeos/sim_dialog_delegate.h" #include "chrome/browser/defaults.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/url_constants.h" @@ -61,8 +62,7 @@ bool ShouldHighlightNetwork(const NetworkState* network) { void ToggleTechnology(const std::string& technology) { NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); bool is_enabled = handler->IsTechnologyEnabled(technology); - handler->SetTechnologyEnabled(technology, !is_enabled, - network_handler::ErrorCallback()); + ash::network_connect::SetTechnologyEnabled(technology, !is_enabled); } } // namespace @@ -381,7 +381,6 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); // Populate our MenuItems with the current list of networks. - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); string16 label; // Ethernet @@ -563,8 +562,6 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { label = l10n_util::GetStringFUTF16(id, l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR)); gfx::ImageSkia icon; - if (is_locked) - icon = *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_SECURE_DARK); int flag = FLAG_TOGGLE_MOBILE; if (mobile_state == NetworkStateHandler::TECHNOLOGY_ENABLING) flag |= FLAG_DISABLED; |