summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorers@chromium.org <ers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-27 20:58:26 +0000
committerers@chromium.org <ers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-27 20:58:26 +0000
commit6bb26a170b75285b9256ab8987fd26a8b57a6a6e (patch)
tree89281a91af5a6b62cb43c41bfef528ca9fab2172
parent6e21367f11a355ae580d8f2249a4e3742d950ceb (diff)
downloadchromium_src-6bb26a170b75285b9256ab8987fd26a8b57a6a6e.zip
chromium_src-6bb26a170b75285b9256ab8987fd26a8b57a6a6e.tar.gz
chromium_src-6bb26a170b75285b9256ab8987fd26a8b57a6a6e.tar.bz2
Several fixes to the UI for enabling SIM-locked modems.
- Clicking "Enable Mobile Data" from either the network dropdown menu or the internet settings page results in the SIM unlock dialog being posted if the SIM is locked. - If the Enable button on the settings page was pressed, and the SIM unlock dialog is cancel, the Enable button, which had been disabled (greyed out) when clicked, is re-enabled. - If the correct PIN (or PUK) is entered, and the SIM becomes unlocked, we now perform the actual device enable operation. Also changed the definitions of the PIN error messages, to match an about-to-be-committed change made on the flimflam side. BUG=chromium-os-partner:3538 TEST=Press enable on the settings page, bringing up unlock dialog. - Cancel the dialog. See that the Enable button is active. - Enter an incorrect PIN and see that it behaves as before, i.e., the dialog stays up and reports the new retries-allowed count. - Enter the correct PIN and see that the device becomes enabled, and the button changes to "Disable Mobile Data". Try all three of the above scenarios using the Enable choice in the network dropdown menu, with and without any Chrome tab displaying the settings page. Make sure the results are the same as they were when the Enable button on the settings page was used (except of course, the Enable button won't be displayed, so the part where you check that it's active after cancelling doesn't apply. R=stevenjb@chromium.org,nkostylev@chromium.org,zelidrag@chromium.org Review URL: http://codereview.chromium.org/7075015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87082 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/cros/network_library.cc6
-rw-r--r--chrome/browser/chromeos/cros/network_library.h4
-rw-r--r--chrome/browser/chromeos/status/network_menu.cc16
-rw-r--r--chrome/browser/chromeos/status/network_menu_button.cc16
-rw-r--r--chrome/browser/chromeos/status/network_menu_button.h3
-rw-r--r--chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc16
-rw-r--r--chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc29
-rw-r--r--content/common/notification_type.h6
8 files changed, 83 insertions, 13 deletions
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
index 92e1eb5..3010897 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -327,9 +327,9 @@ const char* kErrorAaaFailed = "aaa-failed";
// Flimflam error messages.
const char* kErrorPassphraseRequiredMsg = "Passphrase required";
-const char* kErrorIncorrectPinMsg = "org.chromium.flimflam.Device.IncorrectPin";
-const char* kErrorPinBlockedMsg = "org.chromium.flimflam.Device.PinBlocked";
-const char* kErrorPinRequiredMsg = "org.chromium.flimflam.Device.PinRequired";
+const char* kErrorIncorrectPinMsg = "org.chromium.flimflam.Error.IncorrectPin";
+const char* kErrorPinBlockedMsg = "org.chromium.flimflam.Error.PinBlocked";
+const char* kErrorPinRequiredMsg = "org.chromium.flimflam.Error.PinRequired";
const char* kUnknownString = "UNKNOWN";
diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h
index f4cadd8..d16c601 100644
--- a/chrome/browser/chromeos/cros/network_library.h
+++ b/chrome/browser/chromeos/cros/network_library.h
@@ -210,6 +210,10 @@ class NetworkDevice {
const std::string& model_id() const { return model_id_; }
const std::string& manufacturer() const { return manufacturer_; }
SIMLockState sim_lock_state() const { return sim_lock_state_; }
+ bool is_sim_locked() const {
+ return sim_lock_state_ == SIM_LOCKED_PIN ||
+ sim_lock_state_ == SIM_LOCKED_PUK;
+ }
const int sim_retries_left() const { return sim_retries_left_; }
SIMPinRequire sim_pin_required() const { return sim_pin_required_; }
const std::string& firmware_revision() const { return firmware_revision_; }
diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc
index e495737..340603a 100644
--- a/chrome/browser/chromeos/status/network_menu.cc
+++ b/chrome/browser/chromeos/status/network_menu.cc
@@ -472,16 +472,14 @@ void NetworkMenuModel::ActivatedAt(int index) {
} else if (flags & FLAG_TOGGLE_CELLULAR) {
const NetworkDevice* cellular = cros->FindCellularDevice();
if (!cellular) {
- LOG(ERROR) << "Not found cellular device, it should be available.";
+ LOG(ERROR) << "No cellular device found, it should be available.";
+ cros->EnableCellularNetworkDevice(!cros->cellular_enabled());
+ } else if (cellular->sim_lock_state() == SIM_UNLOCKED ||
+ cellular->sim_lock_state() == SIM_UNKNOWN) {
cros->EnableCellularNetworkDevice(!cros->cellular_enabled());
} else {
- if (cellular->sim_lock_state() == SIM_UNLOCKED ||
- cellular->sim_lock_state() == SIM_UNKNOWN) {
- cros->EnableCellularNetworkDevice(!cros->cellular_enabled());
- } else {
- SimDialogDelegate::ShowDialog(owner_->GetNativeWindow(),
- SimDialogDelegate::SIM_DIALOG_UNLOCK);
- }
+ SimDialogDelegate::ShowDialog(owner_->GetNativeWindow(),
+ SimDialogDelegate::SIM_DIALOG_UNLOCK);
}
} else if (flags & FLAG_TOGGLE_OFFLINE) {
cros->EnableOfflineMode(!cros->offline_mode());
@@ -817,7 +815,7 @@ void MainMenuModel::InitMenuItems(bool is_browser_mode,
const NetworkDevice* cellular = cros->FindCellularDevice();
bool is_locked = false;
if (!cellular) {
- LOG(ERROR) << "Not found cellular device, it should be available.";
+ LOG(ERROR) << "Didn't find cellular device.";
} else {
// If cellular is SIM locked then show "Enable" action.
is_locked = cellular->sim_lock_state() == SIM_LOCKED_PIN ||
diff --git a/chrome/browser/chromeos/status/network_menu_button.cc b/chrome/browser/chromeos/status/network_menu_button.cc
index d46f1de..202fe5c 100644
--- a/chrome/browser/chromeos/status/network_menu_button.cc
+++ b/chrome/browser/chromeos/status/network_menu_button.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
+#include "chrome/browser/chromeos/sim_dialog_delegate.h"
#include "chrome/browser/chromeos/status/status_area_host.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -105,6 +106,7 @@ NetworkMenuButton::NetworkMenuButton(StatusAreaHost* host)
left_badge_(NULL),
mobile_data_bubble_(NULL),
check_for_promo_(true),
+ was_sim_locked_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(animation_connecting_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
animation_connecting_.SetThrobDuration(kThrobDuration);
@@ -116,6 +118,7 @@ NetworkMenuButton::NetworkMenuButton(StatusAreaHost* host)
const NetworkDevice* cellular = network_library->FindCellularDevice();
if (cellular) {
cellular_device_path_ = cellular->device_path();
+ was_sim_locked_ = cellular->is_sim_locked();
network_library->AddNetworkDeviceObserver(cellular_device_path_, this);
}
}
@@ -158,6 +161,18 @@ void NetworkMenuButton::OnNetworkDeviceChanged(NetworkLibrary* cros,
const NetworkDevice* device) {
// Device status, such as SIMLock may have changed.
OnNetworkChanged(cros, cros->active_network());
+ const NetworkDevice* cellular = cros->FindCellularDevice();
+ if (cellular) {
+ // We make an assumption (which is valid for now) that the SIM
+ // unlock dialog is put up only when the user is trying to enable
+ // mobile data. So if the SIM is now unlocked, initiate the
+ // enable operation that the user originally requested.
+ if (was_sim_locked_ && !cellular->is_sim_locked() &&
+ !cros->cellular_enabled()) {
+ cros->EnableCellularNetworkDevice(true);
+ }
+ was_sim_locked_ = cellular->is_sim_locked();
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -411,6 +426,7 @@ void NetworkMenuButton::RefreshNetworkDeviceObserver(NetworkLibrary* cros) {
cros->RemoveNetworkDeviceObserver(cellular_device_path_, this);
}
if (!new_cellular_device_path.empty()) {
+ was_sim_locked_ = cellular->is_sim_locked();
cros->AddNetworkDeviceObserver(new_cellular_device_path, this);
}
cellular_device_path_ = new_cellular_device_path;
diff --git a/chrome/browser/chromeos/status/network_menu_button.h b/chrome/browser/chromeos/status/network_menu_button.h
index eb5e898..8cdfe00 100644
--- a/chrome/browser/chromeos/status/network_menu_button.h
+++ b/chrome/browser/chromeos/status/network_menu_button.h
@@ -142,6 +142,9 @@ class NetworkMenuButton : public StatusAreaButton,
// otherwise just ignore it for current session.
bool check_for_promo_;
+ // Cellular device SIM was locked when we last checked
+ bool was_sim_locked_;
+
// The throb animation that does the wifi connecting animation.
ui::ThrobAnimation animation_connecting_;
diff --git a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc
index 63b3465..b7bee2e 100644
--- a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc
@@ -198,6 +198,10 @@ class SimUnlockHandler : public WebUIMessageHandler,
// has been ended (either updated or cancelled).
void NotifyOnRequirePinChangeEnded(bool new_value);
+ // Notifies observers that the EnterPin or EnterPuk dialog has been
+ // completed (either cancelled or with entry of PIN/PUK).
+ void NotifyOnEnterPinEnded(bool cancelled);
+
// Checks whether SIM card is in PUK locked state and proceeds to PUK input.
void ProceedToPukInput();
@@ -381,6 +385,9 @@ void SimUnlockHandler::OnPinOperationCompleted(NetworkLibrary* cros,
// NO_PIN_RETRIES_LEFT step.
if (!(state_ == SIM_LOCKED_NO_PIN_TRIES_LEFT && error == PIN_ERROR_BLOCKED))
ProcessSimCardState(cellular);
+ if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_UNLOCK &&
+ state_ == SIM_ABSENT_NOT_LOCKED)
+ NotifyOnEnterPinEnded(false);
}
void SimUnlockHandler::CancelDialog() {
@@ -392,6 +399,8 @@ void SimUnlockHandler::CancelDialog() {
// changed and is not in process of changing at the moment.
NotifyOnRequirePinChangeEnded(
!(dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON));
+ } else if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_UNLOCK) {
+ NotifyOnEnterPinEnded(true);
}
}
@@ -433,6 +442,13 @@ void SimUnlockHandler::EnterCode(const std::string& code,
}
}
+void SimUnlockHandler::NotifyOnEnterPinEnded(bool cancelled) {
+ NotificationService::current()->Notify(
+ NotificationType::ENTER_PIN_ENDED,
+ NotificationService::AllSources(),
+ Details<bool>(&cancelled));
+}
+
void SimUnlockHandler::NotifyOnRequirePinChangeEnded(bool new_value) {
NotificationService::current()->Notify(
NotificationType::REQUIRE_PIN_SETTING_CHANGE_ENDED,
diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
index bead2c8..17ac85e 100644
--- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
@@ -54,6 +54,8 @@ InternetOptionsHandler::InternetOptionsHandler()
use_settings_ui_(false) {
registrar_.Add(this, NotificationType::REQUIRE_PIN_SETTING_CHANGE_ENDED,
NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::ENTER_PIN_ENDED,
+ NotificationService::AllSources());
chromeos::NetworkLibrary* netlib =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
netlib->AddNetworkManagerObserver(this);
@@ -378,7 +380,17 @@ void InternetOptionsHandler::DisableWifiCallback(const ListValue* args) {
void InternetOptionsHandler::EnableCellularCallback(const ListValue* args) {
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- cros->EnableCellularNetworkDevice(true);
+ const chromeos::NetworkDevice* cellular = cros->FindCellularDevice();
+ if (!cellular) {
+ LOG(ERROR) << "Didn't find cellular device, it should have been available.";
+ cros->EnableCellularNetworkDevice(true);
+ } else if (cellular->sim_lock_state() == chromeos::SIM_UNLOCKED ||
+ cellular->sim_lock_state() == chromeos::SIM_UNKNOWN) {
+ cros->EnableCellularNetworkDevice(true);
+ } else {
+ chromeos::SimDialogDelegate::ShowDialog(GetNativeWindow(),
+ chromeos::SimDialogDelegate::SIM_DIALOG_UNLOCK);
+ }
}
void InternetOptionsHandler::DisableCellularCallback(const ListValue* args) {
@@ -529,6 +541,21 @@ void InternetOptionsHandler::Observe(NotificationType type,
dictionary.SetBoolean("requirePin", require_pin);
web_ui_->CallJavascriptFunction(
"options.InternetOptions.updateSecurityTab", dictionary);
+ } else if (type == NotificationType::ENTER_PIN_ENDED) {
+ // We make an assumption (which is valid for now) that the SIM
+ // unlock dialog is put up only when the user is trying to enable
+ // mobile data.
+ bool cancelled = *Details<bool>(details).ptr();
+ if (cancelled) {
+ chromeos::NetworkLibrary* cros =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ DictionaryValue dictionary;
+ FillNetworkInfo(&dictionary, cros);
+ web_ui_->CallJavascriptFunction(
+ "options.InternetOptions.setupAttributes", dictionary);
+ }
+ // The case in which the correct PIN was entered and the SIM is
+ // now unlocked is handled in NetworkMenuButton.
}
}
diff --git a/content/common/notification_type.h b/content/common/notification_type.h
index 98d2ad0..b5b0b3d 100644
--- a/content/common/notification_type.h
+++ b/content/common/notification_type.h
@@ -1251,6 +1251,12 @@ class NotificationType {
// In either case notification is sent and details contain a bool
// that represents current value.
REQUIRE_PIN_SETTING_CHANGE_ENDED,
+
+ // Sent by SIM unlock dialog when it has finished the EnterPin or
+ // EnterPuk dialog, either because the user cancelled, or entered a
+ // PIN or PUK.
+ ENTER_PIN_ENDED,
+
#endif
// Sent before the repost form warning is brought up.