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

Unified Diff: chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc

Issue 7736014: [cros] Process proper notification in SIM dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: js focus fix Created 9 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 | « chrome/browser/resources/chromeos/sim_unlock.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc
diff --git a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc
index 3bbd744ce9f20bc59c2c021c0a9fee334fe74731..67ce7354ec162bd2ecd517cc7caf32294c75a972 100644
--- a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc
@@ -97,8 +97,8 @@ class SimUnlockHandler : public WebUIMessageHandler,
virtual void RegisterMessages() OVERRIDE;
// NetworkLibrary::NetworkDeviceObserver implementation.
- virtual void OnNetworkDeviceChanged(NetworkLibrary* cros,
- const NetworkDevice* device) OVERRIDE;
+ virtual void OnNetworkDeviceSimLockChanged(
+ NetworkLibrary* cros, const NetworkDevice* device) OVERRIDE;
// NetworkLibrary::PinOperationObserver implementation.
virtual void OnPinOperationCompleted(NetworkLibrary* cros,
@@ -213,6 +213,8 @@ class SimUnlockHandler : public WebUIMessageHandler,
const std::string& error_msg);
TabContents* tab_contents_;
+
+ // Dialog internal state.
SimUnlockState state_;
// Path of the Cellular device that we monitor property updates from.
@@ -224,6 +226,12 @@ class SimUnlockHandler : public WebUIMessageHandler,
// New PIN value for the case when we unblock SIM card or change PIN.
std::string new_pin_;
+ // True if there's a pending PIN operation.
+ // That means that SIM lock state change will be received 2 times:
+ // OnNetworkDeviceSimLockChanged and OnPinOperationCompleted.
+ // First one should be ignored.
+ bool pending_pin_operation_;
+
DISALLOW_COPY_AND_ASSIGN(SimUnlockHandler);
};
@@ -306,7 +314,8 @@ void SimUnlockUIHTMLSource::StartDataRequest(const std::string& path,
SimUnlockHandler::SimUnlockHandler()
: tab_contents_(NULL),
state_(SIM_UNLOCK_LOADING),
- dialog_mode_(SimDialogDelegate::SIM_DIALOG_UNLOCK) {
+ dialog_mode_(SimDialogDelegate::SIM_DIALOG_UNLOCK),
+ pending_pin_operation_(false) {
const chromeos::NetworkDevice* cellular = GetCellularDevice();
// One could just call us directly via chrome://sim-unlock.
if (cellular) {
@@ -348,17 +357,21 @@ void SimUnlockHandler::RegisterMessages() {
NewCallback(this, &SimUnlockHandler::HandleSimStatusInitialize));
}
-void SimUnlockHandler::OnNetworkDeviceChanged(NetworkLibrary* cros,
- const NetworkDevice* device) {
+void SimUnlockHandler::OnNetworkDeviceSimLockChanged(
+ NetworkLibrary* cros, const NetworkDevice* device) {
chromeos::SimLockState lock_state = device->sim_lock_state();
int retries_left = device->sim_retries_left();
- VLOG(1) << "OnNetworkDeviceChanged, lock: " << lock_state
+ VLOG(1) << "OnNetworkDeviceSimLockChanged, lock: " << lock_state
<< ", retries: " << retries_left;
- ProcessSimCardState(GetCellularDevice());
+ // There's a pending PIN operation.
+ // Wait for it to finish and refresh state then.
+ if (!pending_pin_operation_)
+ ProcessSimCardState(GetCellularDevice());
}
void SimUnlockHandler::OnPinOperationCompleted(NetworkLibrary* cros,
PinOperationError error) {
+ pending_pin_operation_ = false;
DCHECK(cros);
const NetworkDevice* cellular = cros->FindCellularDevice();
DCHECK(cellular);
@@ -408,6 +421,7 @@ void SimUnlockHandler::EnterCode(const std::string& code,
const NetworkDevice* cellular = GetCellularDevice();
chromeos::SimLockState lock_state = cellular->sim_lock_state();
+ pending_pin_operation_ = true;
switch (code_type) {
case CODE_PIN:
« no previous file with comments | « chrome/browser/resources/chromeos/sim_unlock.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698